hexsha stringlengths 40 40 | size int64 5 2.72M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 976 | max_stars_repo_name stringlengths 5 113 | max_stars_repo_head_hexsha stringlengths 40 78 | 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:01:43 2022-03-31 23:59:48 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 00:06:24 2022-03-31 23:59:53 ⌀ | max_issues_repo_path stringlengths 3 976 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | 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 976 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | 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:19 2022-03-31 23:59:49 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 12:00:57 2022-03-31 23:59:49 ⌀ | content stringlengths 5 2.72M | avg_line_length float64 1.38 573k | max_line_length int64 2 1.01M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
642229486c25624fd2d51d88bd11f2eb5b20b94b | 1,727 | h | C | src/generator_packed_gemm_avx_avx512.h | abhisek-kundu/libxsmm | 6c8ca987e77e32253ad347a1357ce2687c448ada | [
"BSD-3-Clause"
] | 1 | 2021-05-23T21:25:05.000Z | 2021-05-23T21:25:05.000Z | src/generator_packed_gemm_avx_avx512.h | abhisek-kundu/libxsmm | 6c8ca987e77e32253ad347a1357ce2687c448ada | [
"BSD-3-Clause"
] | null | null | null | src/generator_packed_gemm_avx_avx512.h | abhisek-kundu/libxsmm | 6c8ca987e77e32253ad347a1357ce2687c448ada | [
"BSD-3-Clause"
] | 1 | 2021-04-08T16:12:18.000Z | 2021-04-08T16:12:18.000Z | /******************************************************************************
* Copyright (c) Intel Corporation - All rights reserved. *
* This file is part of the LIBXSMM library. *
* *
* For information on the license, see the LICENSE file. *
* Further information: https://github.com/hfp/libxsmm/ *
* SPDX-License-Identifier: BSD-3-Clause *
******************************************************************************/
/* Alexander Heinecke, Greg Henry, Timothy Costa (Intel Corp.)
******************************************************************************/
#ifndef GENERATOR_PACKED_GEMM_AVX_AVX512_H
#define GENERATOR_PACKED_GEMM_AVX_AVX512_H
#include "generator_common.h"
#define GARBAGE_PARAMETERS
LIBXSMM_API_INTERN
void libxsmm_generator_packed_gemm_avx_avx512_kernel( libxsmm_generated_code* io_generated_code,
const libxsmm_pgemm_descriptor* i_packed_pgemm_desc,
const char* i_arch
#ifdef GARBAGE_PARAMETERS
, unsigned int iunroll,
unsigned int junroll,
unsigned int loopi,
unsigned int loopj
#endif
);
#endif /*GENERATOR_PACKED_GEMM_AVX_AVX512_H*/
| 53.96875 | 108 | 0.389693 |
64246d994315c64e437f58c2229ed078a81f4b20 | 3,240 | h | C | src/core/parameter/hashfrag.h | Superjomn/SwiftSnails | ebf568c0b9dcd4f35474ee9212dda4914d140e56 | [
"Apache-2.0"
] | 58 | 2018-01-25T13:07:13.000Z | 2021-12-29T03:13:14.000Z | src/core/parameter/hashfrag.h | ChunweiYan/SwiftSnails | ebf568c0b9dcd4f35474ee9212dda4914d140e56 | [
"Apache-2.0"
] | 1 | 2017-07-18T05:51:50.000Z | 2017-07-18T05:51:50.000Z | src/core/parameter/hashfrag.h | Superjom/SwiftSnails | ebf568c0b9dcd4f35474ee9212dda4914d140e56 | [
"Apache-2.0"
] | 27 | 2015-04-20T02:18:44.000Z | 2017-11-18T02:27:40.000Z | #pragma once
#include "../../utils/all.h"
namespace swift_snails {
// get hash code
uint64_t hash_fn(uint64_t x) { return get_hash_code(x); }
/*
* Basic Hash Fragment
* without Replication, Fault Tolerance and Repair
*/
template <typename Key> class BasicHashFrag : public VirtualObject {
public:
typedef Key key_t;
// num_nodes: initial number of nodes
explicit BasicHashFrag() {
//_num_frags = global_config().get_config("frag_num").to_int32();
}
/*
* number of nodes should be setted by master
*/
void set_num_nodes(int x) {
CHECK_GT(x, 0);
_num_nodes = x;
}
// init nodes in the hash ring
// can be called only once
// and should be called by *Master Server*
// the worker nodes should not call it
void init() {
CHECK(num_nodes() > 0);
// num_nodes = global_config().register_config("init_node_num").to_int32();
_num_frags = global_config().get_config("frag_num").to_int32();
_map_table.reset(new index_t[num_frags()]);
// divide the fragments
int num_frag_each_node = int(num_frags() / num_nodes());
for (int i = 0; i < num_frags(); i++) {
// skip case: node_id=0 which is master's id
int id = index_t(i / num_frag_each_node) + 1;
if (id < 1)
id = 1;
if (id > num_nodes())
id = num_nodes();
_map_table[i] = id;
}
}
int to_node_id(const key_t &key) {
CHECK(_map_table) << "map_table has not been inited";
int frag_id = hash_fn(key) % num_frags();
int node_id = _map_table[frag_id];
return node_id;
}
void serialize(BinaryBuffer &bb) const {
bb << num_nodes();
bb << num_frags();
for (int i = 0; i < num_frags(); i++) {
bb << _map_table[i];
}
}
void deserialize(BinaryBuffer &bb) {
int num_nodes_, num_frags_;
bb >> num_nodes_;
bb >> num_frags_;
CHECK_GT(num_frags_, 0);
DLOG(INFO) << "deserialize hashfrag\tnum_nodes\t" << num_nodes_
<< "\tnum_frags\t" << num_frags_;
CHECK((_map_table && (num_frags_ == num_frags())) || (!_map_table));
_num_nodes = num_nodes_;
// init maptable
if (_num_frags == 0) {
CHECK(!_map_table);
_num_frags = num_frags_;
_map_table.reset(new index_t[num_frags()]);
}
// memory should not been inited
// the size of the map table will not be changed
for (int i = 0; i < num_frags(); i++) {
bb >> _map_table[i];
}
}
int num_nodes() const { return _num_nodes; }
int num_frags() const {
CHECK(_num_frags > 0) << "num_frags should be inited from config";
return _num_frags;
}
friend std::ostream &operator<<(std::ostream &os,
BasicHashFrag<key_t> &frag) {
os << "hash frag" << std::endl;
for (int i = 0; i < frag.num_frags(); i++) {
os << frag._map_table[i] << " ";
}
os << std::endl;
return os;
}
private:
int _num_nodes = 0;
int _num_frags = 0;
// record visit frequency
// std::map<int, NodeVisitFreq> visit_freqs;
// register config
std::unique_ptr<index_t[]> _map_table;
}; // class HashFrag
template <class Key> BasicHashFrag<Key> &global_hashfrag() {
static BasicHashFrag<Key> hash;
return hash;
}
}; // end namespace swift_snails
| 27.226891 | 79 | 0.617593 |
6426b57a9859a1aaba7babd309a586e5e78fa106 | 32,087 | c | C | ds/ds/src/common/dscommon/qtcommon.c | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | ds/ds/src/common/dscommon/qtcommon.c | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | ds/ds/src/common/dscommon/qtcommon.c | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z |
#include <NTDSpch.h>
#pragma hdrstop
#include <ntdsa.h>
#include <scache.h> // schema cache
#include <dbglobal.h> // The header for the directory database
#include <mdglobal.h> // MD global definition header
#include <mdlocal.h> // MD local definition header
#include <dsatools.h> // needed for output allocation
#include <objids.h> // Defines for selected atts
#include <dsjet.h>
#include <dbintrnl.h>
#include <dsevent.h>
#include <mdcodes.h>
#include <anchor.h>
#include <quota.h>
#include "debug.h" // standard debugging header
#define DEBSUB "QUOTA:" // define the subsystem for debugging
#include <fileno.h>
#define FILENO FILENO_QTCOMMON
// Quota table
//
JET_COLUMNID g_columnidQuotaNcdnt;
JET_COLUMNID g_columnidQuotaSid;
JET_COLUMNID g_columnidQuotaTombstoned;
JET_COLUMNID g_columnidQuotaTotal;
// Quota Rebuild Progress table
//
JET_COLUMNID g_columnidQuotaRebuildDNTLast;
JET_COLUMNID g_columnidQuotaRebuildDNTMax;
JET_COLUMNID g_columnidQuotaRebuildDone;
const ULONG g_ulQuotaRebuildBatchSize = 5000; // on async rebuild of Quota table, max. objects to process at a time
const ULONG g_cmsecQuotaRetryOnWriteConflict = 100; // on async rebuild of Quota table, time to sleep before retrying due to write-conflict
// update Quota count during Quota rebuild
//
JET_ERR ErrQuotaUpdateCountForRebuild_(
JET_SESID sesid,
JET_TABLEID tableidQuota,
JET_COLUMNID columnidCount,
const BOOL fCheckOnly )
{
JET_ERR err;
DWORD dwCount;
if ( fCheckOnly )
{
// QUOTA_UNDONE: it's a shame Jet doesn't currently
// support escrow columns on temp tables, so we
// have to increment the count manually
//
Call( JetPrepareUpdate( sesid, tableidQuota, JET_prepReplace ) );
Call( JetRetrieveColumn(
sesid,
tableidQuota,
columnidCount,
&dwCount,
sizeof(dwCount),
NULL, // pcbActual
JET_bitRetrieveCopy,
NULL ) ); // pretinfo
dwCount++;
Call( JetSetColumn(
sesid,
tableidQuota,
columnidCount,
&dwCount,
sizeof(dwCount),
NO_GRBIT,
NULL ) ); // psetinfo
Call( JetUpdate( sesid, tableidQuota, NULL, 0, NULL ) );
}
else
{
dwCount = 1;
Call( JetEscrowUpdate(
sesid,
tableidQuota,
columnidCount,
&dwCount,
sizeof(dwCount),
NULL, // pvOld
0, // cbOld
NULL, // pcbOldActual
NO_GRBIT ) );
}
HandleError:
return err;
}
// update quota for one object during Quota table rebuild
//
JET_ERR ErrQuotaAddObjectForRebuild_(
JET_SESID sesid,
JET_DBID dbid,
const DWORD dnt,
JET_TABLEID tableidQuota,
DWORD ncdnt,
PSID psidOwner,
const ULONG cbOwnerSid,
const BOOL fTombstoned,
JET_COLUMNID columnidQuotaNcdnt,
JET_COLUMNID columnidQuotaSid,
JET_COLUMNID columnidQuotaTombstoned,
JET_COLUMNID columnidQuotaTotal,
const BOOL fCheckOnly )
{
JET_ERR err;
BOOL fAdding = FALSE;
Call( JetMakeKey( sesid, tableidQuota, &ncdnt, sizeof(ncdnt), JET_bitNewKey ) );
Call( JetMakeKey( sesid, tableidQuota, psidOwner, cbOwnerSid, NO_GRBIT ) );
err = JetSeek( sesid, tableidQuota, JET_bitSeekEQ );
if ( JET_errRecordNotFound != err )
{
CheckErr( err );
// security principle already in Quota table,
// so just update counts
//
Call( ErrQuotaUpdateCountForRebuild_(
sesid,
tableidQuota,
columnidQuotaTotal,
fCheckOnly ) );
if ( fTombstoned )
{
Call( ErrQuotaUpdateCountForRebuild_(
sesid,
tableidQuota,
columnidQuotaTombstoned,
fCheckOnly ) );
}
}
else
{
JET_SETCOLUMN rgsetcol[2];
DWORD dwCount;
memset( rgsetcol, 0, sizeof(rgsetcol) );
rgsetcol[0].columnid = columnidQuotaNcdnt;
rgsetcol[0].pvData = &ncdnt;
rgsetcol[0].cbData = sizeof(ncdnt);
rgsetcol[1].columnid = columnidQuotaSid;
rgsetcol[1].pvData = psidOwner;
rgsetcol[1].cbData = cbOwnerSid;
// record not added yet, so add it
//
fAdding = TRUE;
Call( JetPrepareUpdate( sesid, tableidQuota, JET_prepInsert ) );
Call( JetSetColumns(
sesid,
tableidQuota,
rgsetcol,
sizeof(rgsetcol) / sizeof(rgsetcol[0]) ) );
if ( fCheckOnly )
{
// QUOTA_UNDONE: it's a shame Jet doesn't currently
// support escrow columns on temp tables, so we
// have to set the columns manually
//
dwCount = 1;
Call( JetSetColumn(
sesid,
tableidQuota,
columnidQuotaTotal,
&dwCount,
sizeof(dwCount),
NO_GRBIT,
NULL ) ); // psetinfo
dwCount = ( fTombstoned ? 1 : 0 );
Call( JetSetColumn(
sesid,
tableidQuota,
columnidQuotaTombstoned,
&dwCount,
sizeof(dwCount),
NO_GRBIT,
NULL ) ); // psetinfo
}
else if ( fTombstoned )
{
// tombstoned count is initialised by default to 0,
// so must set it to 1
//
dwCount = 1;
Call( JetSetColumn(
sesid,
tableidQuota,
columnidQuotaTombstoned,
&dwCount,
sizeof(dwCount),
NO_GRBIT,
NULL ) ); // psetinfo
}
// don't process KeyDuplicate errors because this
// may be during async rebuild of the Quota table
// and we are write-conflicting with some other
// session
//
err = JetUpdate( sesid, tableidQuota, NULL, 0, NULL );
if ( JET_errKeyDuplicate != err )
{
CheckErr( err );
}
}
if ( !fCheckOnly )
{
QuotaAudit_(
sesid,
dbid,
dnt,
ncdnt,
psidOwner,
cbOwnerSid,
TRUE, // fUpdatedTotal
fTombstoned,
TRUE, // fIncrementing
fAdding,
TRUE ); // fRebuild
}
HandleError:
return err;
}
// rebuild quota table
//
INT ErrQuotaRebuild_(
JET_SESID sesid,
JET_DBID dbid,
JET_TABLEID tableidQuota,
JET_TABLEID tableidQuotaRebuildProgress,
ULONG ulDNTLast,
JET_COLUMNID columnidQuotaNcdnt,
JET_COLUMNID columnidQuotaSid,
JET_COLUMNID columnidQuotaTombstoned,
JET_COLUMNID columnidQuotaTotal,
const BOOL fAsync,
const BOOL fCheckOnly )
{
JET_ERR err;
JET_TABLEID tableidObj = JET_tableidNil;
JET_TABLEID tableidSD = JET_tableidNil;
const ULONG iretcolDnt = 0;
const ULONG iretcolNcdnt = 1;
const ULONG iretcolObjFlag = 2;
const ULONG iretcolType = 3;
const ULONG iretcolTombstoned = 4;
const ULONG iretcolSD = 5;
const ULONG cretcol = 6;
JET_RETRIEVECOLUMN rgretcol[6];
BOOL fInTrx = FALSE;
DWORD dnt = ROOTTAG;
DWORD ncdnt;
BYTE bObjFlag;
DWORD insttype;
BOOL fTombstoned;
BYTE * rgbSD = NULL;
ULONG cbSD = 65536; // initial size of SD buffer
SDID sdid;
PSID psidOwner;
ULONG cbOwnerSid;
BOOL fUnused;
JET_TABLEID tableidRetrySD;
JET_COLUMNID columnidRetrySD;
ULONG cObjectsProcessed = 0;
CHAR fDone = FALSE;
ULONG ulMove = JET_MoveNext;
// allocate initial buffer for SD's
//
rgbSD = malloc( cbSD );
if ( NULL == rgbSD )
{
CheckErr( JET_errOutOfMemory );
}
// open cursor on objects table
//
Call( JetOpenTable(
sesid,
dbid,
SZDATATABLE,
NULL, // pvParameters
0, // cbParameters
NO_GRBIT,
&tableidObj ) );
Assert( JET_tableidNil != tableidObj );
// open cursor on SD table
//
Call( JetOpenTable(
sesid,
dbid,
SZSDTABLE,
NULL, // pvParameters
0, // cbParameters
NO_GRBIT,
&tableidSD ) );
Assert( JET_tableidNil != tableidSD );
// initialise retrieval structures
//
memset( rgretcol, 0, sizeof(rgretcol) );
rgretcol[iretcolDnt].columnid = dntid;
rgretcol[iretcolDnt].pvData = &dnt;
rgretcol[iretcolDnt].cbData = sizeof(dnt);
rgretcol[iretcolDnt].itagSequence = 1;
rgretcol[iretcolNcdnt].columnid = ncdntid;
rgretcol[iretcolNcdnt].pvData = &ncdnt;
rgretcol[iretcolNcdnt].cbData = sizeof(ncdnt);
rgretcol[iretcolNcdnt].itagSequence = 1;
rgretcol[iretcolObjFlag].columnid = objid;
rgretcol[iretcolObjFlag].pvData = &bObjFlag;
rgretcol[iretcolObjFlag].cbData = sizeof(bObjFlag);
rgretcol[iretcolObjFlag].itagSequence = 1;
rgretcol[iretcolType].columnid = insttypeid;
rgretcol[iretcolType].pvData = &insttype;
rgretcol[iretcolType].cbData = sizeof(insttype);
rgretcol[iretcolType].itagSequence = 1;
rgretcol[iretcolTombstoned].columnid = isdeletedid;
rgretcol[iretcolTombstoned].pvData = &fTombstoned;
rgretcol[iretcolTombstoned].cbData = sizeof(fTombstoned);
rgretcol[iretcolTombstoned].itagSequence = 1;
rgretcol[iretcolSD].columnid = ntsecdescid;
rgretcol[iretcolSD].pvData = rgbSD;
rgretcol[iretcolSD].cbData = cbSD;
rgretcol[iretcolSD].itagSequence = 1;
// switch to primary index and specify sequential scan on objects table
//
Call( JetSetCurrentIndex( sesid, tableidObj, NULL ) );
Call( JetSetTableSequential( sesid, tableidObj, NO_GRBIT ) );
Call( JetSetCurrentIndex( sesid, tableidSD, NULL ) );
Call( JetBeginTransaction( sesid ) );
fInTrx = TRUE;
// start scanning from where we last left off
//
Call( JetMakeKey( sesid, tableidObj, &ulDNTLast, sizeof(ulDNTLast), JET_bitNewKey ) );
err = JetSeek( sesid, tableidObj, JET_bitSeekGT );
for ( err = ( JET_errRecordNotFound != err ? err : JET_errNoCurrentRecord );
JET_errNoCurrentRecord != err && !eServiceShutdown;
err = JetMove( sesid, tableidObj, ulMove, NO_GRBIT ) )
{
// by default, on the next iteration, we'll move to the next record
//
ulMove = JET_MoveNext;
// validate error returned by record navigation
//
CheckErr( err );
// refresh in case buffer was reallocated
//
rgretcol[iretcolSD].pvData = rgbSD;
rgretcol[iretcolSD].cbData = cbSD;
// retrieve columns and be prepared to accept warnings
// (in case some attributes are NULL or the retrieval
// buffer wasn't big enough)
//
err = JetRetrieveColumns( sesid, tableidObj, rgretcol, cretcol );
if ( err < JET_errSuccess )
{
// error detected, force to error-handler
//
CheckErr( err );
}
else
{
// process any warnings individually
//
}
// DNT and ObjFlag should always be present
//
CheckErr( rgretcol[iretcolDnt].err );
CheckErr( rgretcol[iretcolObjFlag].err );
// if async rebuild, ensure we haven't exceeded
// the maximum DNT we should be processing and
// that this task hasn't already processed a lot
// of objects
//
if ( fAsync )
{
if ( dnt > gAnchor.ulQuotaRebuildDNTMax )
{
fDone = TRUE;
break;
}
else if ( cObjectsProcessed > g_ulQuotaRebuildBatchSize )
{
break;
}
}
// skip if not an object
//
if ( !bObjFlag )
{
continue;
}
// in all other cases NCDNT and InstanceType must be present
//
CheckErr( rgretcol[iretcolNcdnt].err );
CheckErr( rgretcol[iretcolType].err );
// skip if not tracking quota for this object
//
if ( !FQuotaTrackObject( insttype ) )
{
continue;
}
// see if object is flagged as tombstoned
//
if ( JET_wrnColumnNull == rgretcol[iretcolTombstoned].err )
{
fTombstoned = FALSE;
}
else
{
// only expected warnings is if column is NULL
//
CheckErr( rgretcol[iretcolTombstoned].err );
// this flag should only ever be TRUE or NULL
//
Assert( fTombstoned );
}
// SD may not have fit in our buffer
//
tableidRetrySD = JET_tableidNil;
if ( JET_wrnBufferTruncated == rgretcol[iretcolSD].err )
{
tableidRetrySD = tableidObj;
columnidRetrySD = ntsecdescid;
}
else
{
CheckErr( rgretcol[iretcolSD].err );
// see if SD is actually single-instanced
//
if ( sizeof(SDID) == rgretcol[iretcolSD].cbActual )
{
// retrieve the SD from the SD Table
//
Call( JetMakeKey( sesid, tableidSD, rgbSD, sizeof(SDID), JET_bitNewKey ) );
Call( JetSeek( sesid, tableidSD, JET_bitSeekEQ ) );
err = JetRetrieveColumn(
sesid,
tableidSD,
sdvalueid,
rgbSD,
cbSD,
&rgretcol[iretcolSD].cbActual,
NO_GRBIT,
NULL ); // pretinfo
if ( JET_wrnBufferTruncated == err )
{
tableidRetrySD = tableidSD,
columnidRetrySD = sdvalueid;
}
else
{
CheckErr( err );
// fall through below to process the retrieved SD
}
}
else
{
// fall through below to process the retrieved SD
}
}
// see if we need to retry SD retrieval because the
// original buffer was too small
//
if ( JET_tableidNil != tableidRetrySD )
{
// resize buffer, rounding up to the nearest 1k
//
cbSD = ( ( rgretcol[iretcolSD].cbActual + 1023 ) / 1024 ) * 1024;
rgretcol[iretcolSD].cbData = cbSD;
rgretcol[iretcolSD].pvData = realloc( rgbSD, cbSD );
if ( NULL == rgretcol[iretcolSD].pvData )
{
CheckErr( JET_errOutOfMemory );
}
rgbSD = rgretcol[iretcolSD].pvData;
// we've resized appropriately, so retrieve should
// now succeed without warnings
//
Call( JetRetrieveColumn(
sesid,
tableidRetrySD,
columnidRetrySD,
rgbSD,
cbSD,
NULL, // pcbActual
NO_GRBIT,
NULL ) ); // pretinfo
// process the retrieved SD below
//
}
// successfully retrieved the SD, so now
// extract the owner SID from it
//
if ( !IsValidSecurityDescriptor( (PSECURITY_DESCRIPTOR)rgbSD )
|| !GetSecurityDescriptorOwner( (PSID)rgbSD, &psidOwner, &fUnused ) )
{
err = GetLastError();
DPRINT2( 0, "Error extracting owner SID.\n", err, err );
LogUnhandledError( err );
goto HandleError;
}
else if ( NULL == psidOwner )
{
Assert( !"An SD is missing an owner SID." );
DPRINT( 0, "Error: owner SID was NULL.\n" );
err = ERROR_INVALID_SID;
LogUnhandledError( ERROR_INVALID_SID );
goto HandleError;
}
else
{
// since security descriptor is valid, sid should be valid
// (or am I just being naive?)
//
Assert( IsValidSid( psidOwner ) );
cbOwnerSid = GetLengthSid( psidOwner );
}
// if we're performing an async rebuild, write-lock the
// object to ensure no one else can modify the object from
// underneath us
//
if ( fAsync )
{
err = JetGetLock( sesid, tableidObj, JET_bitWriteLock );
if ( JET_errWriteConflict == err )
{
// someone else has the record locked, so need to
// rollback our transaction and wait for them to finish
//
Call( JetRollback( sesid, NO_GRBIT ) );
fInTrx = FALSE;
// give the other session time to complete its
// transaction
//
Sleep( g_cmsecQuotaRetryOnWriteConflict );
// start up another transaction in preparation
// to retry the object
//
Call( JetBeginTransaction( sesid ) );
fInTrx = TRUE;
// don't move to the next object (ie. retry this object)
//
ulMove = 0;
continue;
}
else
{
CheckErr( err );
}
}
// now go to the Quota table and update the quota record
// for this ncdnt+OwnerSID
//
err = ErrQuotaAddObjectForRebuild_(
sesid,
dbid,
dnt,
tableidQuota,
ncdnt,
psidOwner,
cbOwnerSid,
fTombstoned,
columnidQuotaNcdnt,
columnidQuotaSid,
columnidQuotaTombstoned,
columnidQuotaTotal,
fCheckOnly );
// if we had to add a new quota record and
// we're performing an async rebuild, it's possible
// someone beat us to it, in which case we need
// to abandon the transaction and try again
// NOTE: on insert, we actually get KeyDuplicate
// on a write-conflict
//
Assert( JET_errWriteConflict != err );
if ( JET_errKeyDuplicate == err && fAsync )
{
// someone else beat us to the quota record
// insertion, so need to wait for them to
// finish and then retry
//
Call( JetRollback( sesid, NO_GRBIT ) );
fInTrx = FALSE;
// give the other session time to complete its
// transaction
//
Sleep( g_cmsecQuotaRetryOnWriteConflict );
// don't move to the next object (ie. retry this object)
//
ulMove = 0;
}
else
{
// validate error returned from updating quota
// for the current object
//
CheckErr( err );
if ( JET_tableidNil != tableidQuotaRebuildProgress )
{
// upgrade rebuild progress for this object
//
Call( JetPrepareUpdate( sesid, tableidQuotaRebuildProgress, JET_prepReplace ) );
Call( JetSetColumn(
sesid,
tableidQuotaRebuildProgress,
g_columnidQuotaRebuildDNTLast,
&dnt,
sizeof(dnt),
NO_GRBIT,
NULL ) ); // &setinfo
Call( JetUpdate( sesid, tableidQuotaRebuildProgress, NULL, 0, NULL ) );
}
if ( fAsync )
{
// update progress in anchor so other sessions will
// start updating quota if they try to modify this object
// (though until we commit, they will write-conflict)
//
gAnchor.ulQuotaRebuildDNTLast = dnt;
}
// successfully updated, so commit
//
cObjectsProcessed++;
err = JetCommitTransaction( sesid, JET_bitCommitLazyFlush );
if ( JET_errSuccess != err )
{
if ( fAsync )
{
// revert gAnchor progress update (we don't have to
// actually reinstate the previous value, we just need
// to make sure it's less than the DNT of the current
// object (note that committing the transaction failed,
// so we're still in the transaction and still own
// the write-lock on the object)
//
DPRINT1( 0, "Rolling back gAnchor Quota rebuild progress due to CommitTransaction error %d\n", err );
gAnchor.ulQuotaRebuildDNTLast--;
}
LogUnhandledError( err );
goto HandleError;
}
fInTrx = FALSE;
}
Call( JetBeginTransaction( sesid ) );
fInTrx = TRUE;
}
// should always exit the loop above while still in a transaction
//
Assert( fInTrx );
// see if we reached the end of the objects table
//
if ( JET_errNoCurrentRecord == err && JET_MoveNext == ulMove )
{
fDone = TRUE;
}
if ( fDone )
{
if ( JET_tableidNil != tableidQuotaRebuildProgress )
{
// set fDone flag in Quota Rebuild Progress table
//
Call( JetPrepareUpdate( sesid, tableidQuotaRebuildProgress, JET_prepReplace ) );
Call( JetSetColumn(
sesid,
tableidQuotaRebuildProgress,
g_columnidQuotaRebuildDone,
&fDone,
sizeof(fDone),
NO_GRBIT,
NULL ) ); // &setinfo
Call( JetUpdate( sesid, tableidQuotaRebuildProgress, NULL, 0, NULL ) );
}
}
else
{
// didn't reach the end of the objects table, so
// the only other possibilities are that we
// retried to fetch the current record but it
// disappeared out from underneath us or we were
// forced to exit because we're shutting down or
// we already processed a lot of objects
//
Assert( ( fAsync && JET_errNoCurrentRecord == err && 0 == ulMove )
|| eServiceShutdown
|| ( fAsync && cObjectsProcessed > g_ulQuotaRebuildBatchSize ) );
}
Call( JetCommitTransaction( sesid, JET_bitCommitLazyFlush ) );
fInTrx = FALSE;
if ( fDone && fAsync )
{
// set flag in anchor to indicate Quota table
// is ready to be used
//
gAnchor.fQuotaTableReady = TRUE;
// generate an event indicating that the Quota table
// has been successfully rebuilt
//
LogEvent(
DS_EVENT_CAT_INTERNAL_PROCESSING,
DS_EVENT_SEV_ALWAYS,
DIRLOG_ASYNC_QUOTA_REBUILD_COMPLETED,
NULL,
NULL,
NULL );
}
HandleError:
if ( fInTrx )
{
// if still in transaction, then we must have already hit an error,
// so nothing we can do but assert if rollback fails
//
const JET_ERR errT = JetRollback( sesid, NO_GRBIT );
Assert( JET_errSuccess == errT );
Assert( JET_errSuccess != err );
}
if ( JET_tableidNil != tableidSD )
{
err = JetCloseTableWithErrUnhandled( sesid, tableidSD, err );
}
if ( JET_tableidNil != tableidObj )
{
err = JetCloseTableWithErrUnhandled( sesid, tableidObj, err );
}
if ( NULL != rgbSD )
{
free( rgbSD );
}
return err;
}
//
// EXTERNAL FUNCTIONS
//
// verify the integrity of the Quota table by rebuilding it
// in a temp. table then verifying that the two tables match
// exactly
//
INT ErrQuotaIntegrityCheck(
JET_SESID sesid,
JET_DBID dbid,
ULONG * pcCorruptions )
{
JET_ERR err;
JET_TABLEID tableidQuota = JET_tableidNil;
JET_TABLEID tableidObj = JET_tableidNil;
JET_TABLEID tableidSD = JET_tableidNil;
JET_TABLEID tableidQuotaTemp = JET_tableidNil;
BOOL fQuotaTableHitEOF = FALSE;
BOOL fTempTableHitEOF = FALSE;
const ULONG iretcolNcdnt = 0;
const ULONG iretcolSid = 1;
const ULONG iretcolTombstoned = 2;
const ULONG iretcolTotal = 3;
JET_RETRIEVECOLUMN rgretcolQuota[4];
JET_RETRIEVECOLUMN rgretcolQuotaTemp[4];
DWORD ncdnt;
BYTE rgbSid[255];
ULONG cTombstoned;
ULONG cTotal;
DWORD ncdntTemp;
BYTE rgbSidTemp[255];
ULONG cTombstonedTemp;
ULONG cTotalTemp;
JET_COLUMNID rgcolumnidQuotaTemp[4];
JET_COLUMNDEF rgcolumndefQuotaTemp[4] = {
{ sizeof( JET_COLUMNDEF ), 0, JET_coltypLong, 0, 0, 0, 0, 0, JET_bitColumnTTKey }, // ncdnt
{ sizeof( JET_COLUMNDEF ), 0, JET_coltypBinary, 0, 0, 0, 0, 0, JET_bitColumnTTKey }, // owner sid
{ sizeof( JET_COLUMNDEF ), 0, JET_coltypLong, 0, 0, 0, 0, 0, NO_GRBIT }, // tombstoned count
{ sizeof( JET_COLUMNDEF ), 0, JET_coltypLong, 0, 0, 0, 0, 0, NO_GRBIT } }; // total count
// initialise count of corruptions encountered
//
*pcCorruptions = 0;
// open necessary cursors
//
Call( JetOpenTable(
sesid,
dbid,
g_szQuotaTable,
NULL,
0,
JET_bitTableDenyRead, // ensure no one else could be accessing the table while we're checking it
&tableidQuota ) );
Assert( JET_tableidNil != tableidQuota );
Call( JetOpenTable(
sesid,
dbid,
SZDATATABLE,
NULL,
0,
NO_GRBIT,
&tableidObj ) );
Assert( JET_tableidNil != tableidObj );
Call( JetOpenTable(
sesid,
dbid,
SZSDTABLE,
NULL,
0,
NO_GRBIT,
&tableidSD ) );
Assert( JET_tableidNil != tableidSD );
// we'll be seeking and updating this table constantly, which
// will cause Jet to materialise the sort to a full-fledged
// temp. table pretty quickly, so may as well just force
// materialisation right off the bat
//
Call( JetOpenTempTable(
sesid,
rgcolumndefQuotaTemp,
sizeof(rgcolumndefQuotaTemp) / sizeof(rgcolumndefQuotaTemp[0]),
JET_bitTTForceMaterialization,
&tableidQuotaTemp,
rgcolumnidQuotaTemp ) );
Assert( JET_tableidNil != tableidQuotaTemp );
// build copy of the Quota table in a temp table
//
Call( ErrQuotaRebuild_(
sesid,
dbid,
tableidQuotaTemp,
JET_tableidNil,
ROOTTAG,
rgcolumnidQuotaTemp[iretcolNcdnt],
rgcolumnidQuotaTemp[iretcolSid],
rgcolumnidQuotaTemp[iretcolTombstoned],
rgcolumnidQuotaTemp[iretcolTotal],
FALSE, // fAsync
TRUE ) ); // fCheckOnly
// now compare the temp table
// to the existing table to verify they
// are identical
//
memset( rgretcolQuota, 0, sizeof(rgretcolQuota) );
memset( rgretcolQuotaTemp, 0, sizeof(rgretcolQuotaTemp) );
rgretcolQuota[iretcolNcdnt].columnid = g_columnidQuotaNcdnt;
rgretcolQuota[iretcolNcdnt].pvData = &ncdnt;
rgretcolQuota[iretcolNcdnt].cbData = sizeof(ncdnt);
rgretcolQuota[iretcolNcdnt].itagSequence = 1;
rgretcolQuota[iretcolSid].columnid = g_columnidQuotaSid;
rgretcolQuota[iretcolSid].pvData = rgbSid;
rgretcolQuota[iretcolSid].cbData = sizeof(rgbSid);
rgretcolQuota[iretcolSid].itagSequence = 1;
rgretcolQuota[iretcolTombstoned].columnid = g_columnidQuotaTombstoned;
rgretcolQuota[iretcolTombstoned].pvData = &cTombstoned;
rgretcolQuota[iretcolTombstoned].cbData = sizeof(cTombstoned);
rgretcolQuota[iretcolTombstoned].itagSequence = 1;
rgretcolQuota[iretcolTotal].columnid = g_columnidQuotaTotal;
rgretcolQuota[iretcolTotal].pvData = &cTotal;
rgretcolQuota[iretcolTotal].cbData = sizeof(cTotal);
rgretcolQuota[iretcolTotal].itagSequence = 1;
rgretcolQuotaTemp[iretcolNcdnt].columnid = rgcolumnidQuotaTemp[iretcolNcdnt];
rgretcolQuotaTemp[iretcolNcdnt].pvData = &ncdntTemp;
rgretcolQuotaTemp[iretcolNcdnt].cbData = sizeof(ncdntTemp);
rgretcolQuotaTemp[iretcolNcdnt].itagSequence = 1;
rgretcolQuotaTemp[iretcolSid].columnid = rgcolumnidQuotaTemp[iretcolSid];
rgretcolQuotaTemp[iretcolSid].pvData = rgbSidTemp;
rgretcolQuotaTemp[iretcolSid].cbData = sizeof(rgbSidTemp);
rgretcolQuotaTemp[iretcolSid].itagSequence = 1;
rgretcolQuotaTemp[iretcolTombstoned].columnid = rgcolumnidQuotaTemp[iretcolTombstoned];
rgretcolQuotaTemp[iretcolTombstoned].pvData = &cTombstonedTemp;
rgretcolQuotaTemp[iretcolTombstoned].cbData = sizeof(cTombstonedTemp);
rgretcolQuotaTemp[iretcolTombstoned].itagSequence = 1;
rgretcolQuotaTemp[iretcolTotal].columnid = rgcolumnidQuotaTemp[iretcolTotal];
rgretcolQuotaTemp[iretcolTotal].pvData = &cTotalTemp;
rgretcolQuotaTemp[iretcolTotal].cbData = sizeof(cTotalTemp);
rgretcolQuotaTemp[iretcolTotal].itagSequence = 1;
// unfortunately, temp tables don't currently support
// JetSetTableSequential
//
Call( JetSetTableSequential( sesid, tableidQuota, NO_GRBIT ) );
// initialise both cursors
//
err = JetMove( sesid, tableidQuota, JET_MoveFirst, NO_GRBIT );
if ( JET_errNoCurrentRecord == err )
{
fQuotaTableHitEOF = TRUE;
}
else
{
CheckErr( err );
}
err = JetMove( sesid, tableidQuotaTemp, JET_MoveFirst, NO_GRBIT );
if ( JET_errNoCurrentRecord == err )
{
fTempTableHitEOF = TRUE;
}
else
{
CheckErr( err );
}
for ( ; ; )
{
// these flags indicate whether the cursors should be moved on the
// next iteration of the loop (note that the only time you wouldn't
// want to move one of the cursors is if corruption was hit and
// we're now trying to re-sync the cursors to the same record)
//
BOOL fSkipQuotaCursor = FALSE;
BOOL fSkipTempCursor = FALSE;
// must filter out records in the Quota table
// without any more object references
//
while ( !fQuotaTableHitEOF )
{
// retrieve the current record for real cursor
//
Call( JetRetrieveColumns(
sesid,
tableidQuota,
rgretcolQuota,
sizeof(rgretcolQuota) / sizeof(rgretcolQuota[0]) ) );
if ( 0 != cTotal )
{
break;
}
else
{
// records with no more object references may
// not have gotten deleted by Jet yet, so
// just ignore such records and move to the next
//
err = JetMove( sesid, tableidQuota, JET_MoveNext, NO_GRBIT );
if ( JET_errNoCurrentRecord == err )
{
fQuotaTableHitEOF = TRUE;
}
else
{
CheckErr( err );
}
}
}
if ( fQuotaTableHitEOF && fTempTableHitEOF )
{
// hit end of both cursors at the same time,
// so everything is fine - just exit the loop
//
break;
}
else if ( !fQuotaTableHitEOF && !fTempTableHitEOF )
{
// both cursors are on a valid record, continue
// on to retrieve the record from the temp
// table and compare it against the record from
// the Quota table
}
else
{
// hit end of one cursor, but not the other,
// so something is amiss - just force failure
//
CheckErr( JET_errNoCurrentRecord );
}
// retrieve the current record for the temp cursor
//
Call( JetRetrieveColumns(
sesid,
tableidQuotaTemp,
rgretcolQuotaTemp,
sizeof(rgretcolQuotaTemp) / sizeof(rgretcolQuotaTemp[0]) ) );
// verify they are identical
//
if ( ncdnt != ncdntTemp )
{
DPRINT2( 0, "Mismatched ncdnt: %d - %d\n", ncdnt, ncdntTemp );
Assert( !"Mismatched ncdnt." );
(*pcCorruptions)++;
if ( ncdnt > ncdntTemp )
{
// key of current record in Quota table is greater than
// key of current record in temp table, so just move the
// temp table cursor to try and get the cursors to sync up
// to the same key again
//
fSkipQuotaCursor = TRUE;
}
else
{
// key of current record in Quota table is less than
// key of current record in temp table, so just move the
// Quota table cursor to try and get the cursors to sync up
// to the same key again
//
fSkipTempCursor = TRUE;
}
}
else if ( !EqualSid( (PSID)rgbSid, (PSID)rgbSidTemp ) )
{
const ULONG cbSid = rgretcolQuota[iretcolSid].cbActual;
const ULONG cbSidTemp = rgretcolQuotaTemp[iretcolSid].cbActual;
const INT db = cbSid - cbSidTemp;
INT cmp = memcmp( rgbSid, rgbSidTemp, db < 0 ? cbSid : cbSidTemp );
if ( 0 == cmp )
{
// can't be equal
//
Assert( 0 != db );
cmp = db;
}
DPRINT2( 0, "Mismatched owner SID for ncdnt %d (0x%x).\n", ncdnt, ncdnt );
Assert( !"Mismatched owner SID." );
(*pcCorruptions)++;
if ( cmp > 0 )
{
// key of current record in Quota table is greater than
// key of current record in temp table, so just move the
// temp table cursor to try and get the cursors to sync up
// to the same key again
//
fSkipQuotaCursor = TRUE;
}
else
{
// key of current record in Quota table is less than
// key of current record in temp table, so just move the
// Quota table cursor to try and get the cursors to sync up
// to the same key again
//
fSkipTempCursor = TRUE;
}
}
else if ( cTotal != cTotalTemp )
{
DPRINT4( 0, "Mismatched quota total count for ncdnt %d (0x%x): %d - %d\n", ncdnt, ncdnt, cTotal, cTotalTemp );
Assert( !"Mismatched quota total count." );
(*pcCorruptions)++;
}
else if ( cTombstoned != cTombstonedTemp )
{
DPRINT4( 0, "Mismatched quota tombstoned count for ncdnt %d (0x%x): %d - %d\n", ncdnt, ncdnt, cTombstoned, cTombstonedTemp );
Assert( !"Mismatched quota tombstoned count." );
(*pcCorruptions)++;
}
// navigate both cursors to the next record,
// tracking whether either hits EOF
//
Assert( !fSkipQuotaCursor || *pcCorruptions > 0 );
if ( !fSkipQuotaCursor )
{
err = JetMove( sesid, tableidQuota, JET_MoveNext, NO_GRBIT );
if ( JET_errNoCurrentRecord == err )
{
fQuotaTableHitEOF = TRUE;
}
else
{
CheckErr( err );
}
}
Assert( !fSkipTempCursor || *pcCorruptions > 0 );
if ( !fSkipTempCursor )
{
err = JetMove( sesid, tableidQuotaTemp, JET_MoveNext, NO_GRBIT );
if ( JET_errNoCurrentRecord == err )
{
fTempTableHitEOF = TRUE;
}
else
{
CheckErr( err );
}
}
}
if ( *pcCorruptions > 0 )
{
DPRINT1( 0, "CORRUPTION detected in Quota table. There were a total of %d problems.\n", *pcCorruptions );
Assert( !"CORRUPTION detected in Quota table." );
}
err = JET_errSuccess;
HandleError:
if ( JET_tableidNil != tableidQuotaTemp )
{
err = JetCloseTableWithErrUnhandled( sesid, tableidQuotaTemp, err );
}
if ( JET_tableidNil != tableidSD )
{
err = JetCloseTableWithErrUnhandled( sesid, tableidSD, err );
}
if ( JET_tableidNil != tableidObj )
{
err = JetCloseTableWithErrUnhandled( sesid, tableidObj, err );
}
if ( JET_tableidNil != tableidQuota )
{
err = JetCloseTableWithErrUnhandled( sesid, tableidQuota, err );
}
return err;
}
| 26.474422 | 142 | 0.643407 |
64289d902d325f58061cb2bbe19c73ca6d9bc88e | 2,568 | c | C | src/kdf/hkdf/generic.c | ucodev/libpsec | 41f070c94e73a84c8553af92ac12635f9e7cef3d | [
"Apache-2.0"
] | null | null | null | src/kdf/hkdf/generic.c | ucodev/libpsec | 41f070c94e73a84c8553af92ac12635f9e7cef3d | [
"Apache-2.0"
] | null | null | null | src/kdf/hkdf/generic.c | ucodev/libpsec | 41f070c94e73a84c8553af92ac12635f9e7cef3d | [
"Apache-2.0"
] | null | null | null | /*
* @file generic.c
* @brief PSEC Library
* HMAC-based Extract-and-Expand Key Derivation Function interface
*
* Date: 09-09-2014
*
* Copyright 2014 Pedro A. Hortas (pah@ucodev.org)
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "hash.h"
#include "mac.h"
#include "tc.h"
unsigned char *hkdf_expand(
unsigned char *out,
unsigned char *(*hmac) (
unsigned char *out,
const unsigned char *key,
size_t key_len,
const unsigned char *msg,
size_t msg_len
),
size_t hash_len,
const unsigned char *ikm,
size_t ikm_len,
const unsigned char *salt,
size_t salt_len,
const unsigned char *info,
size_t info_len,
size_t out_len)
{
unsigned int i = 0;
float nf = ((float) out_len / (float) hash_len);
unsigned int n = ((nf - ((float) ((unsigned int) nf))) > 0) ? ((unsigned int) nf) + 1 : ((unsigned int) nf);
unsigned char prk[HASH_DIGEST_SIZE_MAX];
unsigned char t[hash_len + info_len + 1];
unsigned char o_tmp[n * hash_len];
/* Validate */
if (out_len > (255 * hash_len)) {
errno = EINVAL;
return NULL;
}
/* Extract */
if (!hmac(prk, salt, salt_len, ikm, ikm_len))
return NULL;
/* Expand */
if (info_len)
tc_memcpy(t, info, info_len);
t[info_len] = 0x01;
if (!hmac(o_tmp, prk, hash_len, t, info_len + 1))
return NULL;
for (i = 2; i <= n; i ++) {
tc_memcpy(t, &o_tmp[(i - 2) * hash_len], hash_len);
if (info_len)
tc_memcpy(&t[hash_len], info, info_len);
t[hash_len + info_len] = (unsigned char) i;
if (!hmac(&o_tmp[(i - 1) * hash_len], prk, hash_len, t, sizeof(t)))
return NULL;
}
/* Allocate */
if (!out) {
if (!(out = malloc(out_len)))
return NULL;
}
/* Deliver */
tc_memcpy(out, o_tmp, out_len);
/* All good */
return out;
}
| 24 | 109 | 0.672118 |
64291cc0668f797fae28016439b8ac6199488929 | 902 | h | C | rdpfuzz-winafl/cmake-3.16.0/Source/cmJsonObjects.h | fengjixuchui/rdpfuzz | 4561b6fbf73ada553ce78ad44918fd0930ee4e85 | [
"Apache-2.0"
] | 107 | 2021-08-28T20:08:42.000Z | 2022-03-22T08:02:16.000Z | rdpfuzz-winafl/cmake-3.16.0/Source/cmJsonObjects.h | fengjixuchui/rdpfuzz | 4561b6fbf73ada553ce78ad44918fd0930ee4e85 | [
"Apache-2.0"
] | null | null | null | rdpfuzz-winafl/cmake-3.16.0/Source/cmJsonObjects.h | fengjixuchui/rdpfuzz | 4561b6fbf73ada553ce78ad44918fd0930ee4e85 | [
"Apache-2.0"
] | 16 | 2021-08-30T06:57:36.000Z | 2022-03-22T08:05:52.000Z | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmJsonObjects_h
#define cmJsonObjects_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
#include "cm_jsoncpp_value.h"
class cmake;
class cmGlobalGenerator;
extern void cmGetCMakeInputs(const cmGlobalGenerator* gg,
const std::string& sourceDir,
const std::string& buildDir,
std::vector<std::string>* internalFiles,
std::vector<std::string>* explicitFiles,
std::vector<std::string>* tmpFiles);
extern Json::Value cmDumpCodeModel(const cmake* cm);
extern Json::Value cmDumpCTestInfo(const cmake* cm);
extern Json::Value cmDumpCMakeInputs(const cmake* cm);
#endif
| 32.214286 | 77 | 0.648559 |
64292cc5a0b7378ef18a280f286da93a51dcfb2f | 134 | h | C | ZelGameEngine/include/zel_math.h | NVriezen/ZelGameEngine | f54c7438a4fe9938ef15e25a35b8c325e6ac7d1c | [
"Apache-2.0"
] | 1 | 2021-06-04T11:15:54.000Z | 2021-06-04T11:15:54.000Z | ZelGameEngine/include/zel_math.h | NVriezen/ZelGameEngine | f54c7438a4fe9938ef15e25a35b8c325e6ac7d1c | [
"Apache-2.0"
] | null | null | null | ZelGameEngine/include/zel_math.h | NVriezen/ZelGameEngine | f54c7438a4fe9938ef15e25a35b8c325e6ac7d1c | [
"Apache-2.0"
] | null | null | null | #pragma once
//replace glm
#include <glm/glm/glm.hpp>
#include <glm/glm/gtc/matrix_transform.hpp>
#include <glm/glm/gtc/type_ptr.hpp>
| 22.333333 | 43 | 0.753731 |
642b45a0ed831a3fdb9a0a8517caf10cb880906b | 1,020 | c | C | tools-src/gnu/glibc/timezone/test-tz.c | enfoTek/tomato.linksys.e2000.nvram-mod | 2ce3a5217def49d6df7348522e2bfda702b56029 | [
"FSFAP"
] | 80 | 2015-01-02T10:14:04.000Z | 2021-06-07T06:29:49.000Z | tools-src/gnu/glibc/timezone/test-tz.c | unforgiven512/tomato | 96f09fab4929c6ddde5c9113f1b2476ad37133c4 | [
"FSFAP"
] | 9 | 2015-05-14T11:03:12.000Z | 2018-01-04T07:12:58.000Z | tools-src/gnu/glibc/timezone/test-tz.c | unforgiven512/tomato | 96f09fab4929c6ddde5c9113f1b2476ad37133c4 | [
"FSFAP"
] | 69 | 2015-01-02T10:45:56.000Z | 2021-09-06T07:52:13.000Z | #include <stdlib.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
struct {
const char * env;
time_t expected;
} tests[] = {
{"MST", 832935315},
{"", 832910115},
{":UTC", 832910115},
{"UTC", 832910115},
{"UTC0", 832910115}
};
int
main (int argc, char ** argv)
{
int errors = 0;
struct tm tm;
time_t t;
unsigned int i;
memset (&tm, 0, sizeof (tm));
tm.tm_isdst = 0;
tm.tm_year = 96; /* years since 1900 */
tm.tm_mon = 4;
tm.tm_mday = 24;
tm.tm_hour = 3;
tm.tm_min = 55;
tm.tm_sec = 15;
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
{
setenv ("TZ", tests[i].env, 1);
t = mktime (&tm);
if (t != tests[i].expected)
{
printf ("%s: flunked test %u (expected %lu, got %lu)\n",
argv[0], i, (long) tests[i].expected, (long) t);
++errors;
}
}
if (errors == 0)
{
puts ("No errors.");
return EXIT_SUCCESS;
}
else
{
printf ("%d errors.\n", errors);
return EXIT_FAILURE;
}
}
| 17.894737 | 59 | 0.526471 |
642d20275c4b68bf6efb9c0ca5d56a7f9932b316 | 434 | h | C | src/uct/rocm/copy/rocm_copy_md.h | ironMann/ucx | 4bb5c6892c7958a64378c5137e279e8250261a56 | [
"BSD-3-Clause"
] | 13 | 2020-05-12T02:12:32.000Z | 2021-07-18T07:04:56.000Z | src/uct/rocm/copy/rocm_copy_md.h | ironMann/ucx | 4bb5c6892c7958a64378c5137e279e8250261a56 | [
"BSD-3-Clause"
] | 48 | 2019-03-22T09:41:47.000Z | 2022-03-31T18:54:57.000Z | src/uct/rocm/copy/rocm_copy_md.h | ironMann/ucx | 4bb5c6892c7958a64378c5137e279e8250261a56 | [
"BSD-3-Clause"
] | 33 | 2020-05-12T02:12:34.000Z | 2021-12-22T03:09:16.000Z | /*
* Copyright (C) Advanced Micro Devices, Inc. 2019. ALL RIGHTS RESERVED.
* See file LICENSE for terms.
*/
#ifndef UCT_ROCM_COPY_MD_H
#define UCT_ROCM_COPY_MD_H
#include <uct/base/uct_md.h>
extern uct_component_t uct_rocm_copy_component;
typedef struct uct_rocm_copy_md {
struct uct_md super;
} uct_rocm_copy_md_t;
typedef struct uct_rocm_copy_md_config {
uct_md_config_t super;
} uct_rocm_copy_md_config_t;
#endif
| 18.869565 | 72 | 0.781106 |
642f1691e55712b346f1a3575d498d422ba273cd | 7,294 | h | C | dev/Code/Framework/AzCore/AzCore/Module/ModuleManager.h | horvay/lumberyardtutor | 63b0681a7ed2a98d651b699984de92951721353e | [
"AML"
] | 5 | 2018-08-17T21:05:55.000Z | 2021-04-17T10:48:26.000Z | dev/Code/Framework/AzCore/AzCore/Module/ModuleManager.h | horvay/lumberyardtutor | 63b0681a7ed2a98d651b699984de92951721353e | [
"AML"
] | null | null | null | dev/Code/Framework/AzCore/AzCore/Module/ModuleManager.h | horvay/lumberyardtutor | 63b0681a7ed2a98d651b699984de92951721353e | [
"AML"
] | 5 | 2017-12-05T16:36:00.000Z | 2021-04-27T06:33:54.000Z | /*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/EntityBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Module/ModuleManagerBus.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/smart_ptr/weak_ptr.h>
namespace AZ
{
namespace Internal
{
/**
* Internal bus for the ModuleManager to communicate with itself.
*/
class ModuleManagerInternalRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
/**
* Event for shared pointers' deleters to call to unload the module.
* This is an ebus event (instead of a raw access) in case a module shared pointer outlives the ModuleManager.
*/
virtual void ClearModuleReferences(const AZ::OSString& normalizedModulePath) = 0;
};
using ModuleManagerInternalRequestBus = AZ::EBus<ModuleManagerInternalRequests>;
}
/**
* ModuleEntity is an Entity that carries a module class id along with it.
* This we do so that when the System Entity Editor saves out an entity,
* when it's loaded from the stream, we can use that id to associate the
* entity with the appropriate module.
*/
class ModuleEntity
: public Entity
{
friend class ModuleManager;
public:
AZ_CLASS_ALLOCATOR(ModuleEntity, SystemAllocator, 0)
AZ_RTTI(ModuleEntity, "{C5950488-35E0-4B55-B664-29A691A6482F}", Entity);
static void Reflect(ReflectContext* context);
ModuleEntity() = default;
ModuleEntity(const AZ::Uuid& moduleClassId, const char* name = nullptr)
: Entity(name)
, m_moduleClassId(moduleClassId)
{ }
// The typeof of the module class associated with this module,
// so it can be associated with the correct module after loading
AZ::Uuid m_moduleClassId;
protected:
// Allow manual setting of state
void SetState(Entity::State state);
};
/**
* Contains a static or dynamic AZ::Module.
*/
struct ModuleDataImpl
: public ModuleData
{
AZ_CLASS_ALLOCATOR(ModuleDataImpl, SystemAllocator, 0);
ModuleDataImpl() = default;
~ModuleDataImpl() override;
// no copy/move allowed
ModuleDataImpl(const ModuleDataImpl&) = delete;
ModuleDataImpl& operator=(const ModuleDataImpl&) = delete;
ModuleDataImpl(ModuleDataImpl&& rhs) = delete;
ModuleDataImpl& operator=(ModuleDataImpl&&) = delete;
////////////////////////////////////////////////////////////////////////
// IModuleData
DynamicModuleHandle* GetDynamicModuleHandle() const override { return m_dynamicHandle.get(); }
Module* GetModule() const override { return m_module; }
Entity* GetEntity() const override { return m_moduleEntity.get(); }
const char* GetDebugName() const override;
////////////////////////////////////////////////////////////////////////
/// Deals with loading and unloading the AZ::Module's DLL.
/// This is null when the AZ::Module comes from a static LIB.
AZStd::unique_ptr<DynamicModuleHandle> m_dynamicHandle;
/// Handle to the module class within the module
Module* m_module = nullptr;
//! Entity that holds this module's provided system components
AZStd::unique_ptr<ModuleEntity> m_moduleEntity;
//! The last step this module completed
ModuleInitializationSteps m_lastCompletedStep = ModuleInitializationSteps::None;
};
/*!
* Handles reloading modules and their dependents at runtime
*/
class ModuleManager
: protected ModuleManagerRequestBus::Handler
, protected EntityBus::Handler
, protected Internal::ModuleManagerInternalRequestBus::Handler
{
public:
static void Reflect(ReflectContext* context);
ModuleManager();
~ModuleManager() override;
// Destroy and unload all modules
void UnloadModules();
// To be called by the Component Application when it deserializes an entity
void AddModuleEntity(ModuleEntity* moduleEntity);
protected:
////////////////////////////////////////////////////////////////////////
// ModuleManagerRequestBus
void EnumerateModules(EnumerateModulesCallback perModuleCallback) override;
LoadModuleOutcome LoadDynamicModule(const char* modulePath, ModuleInitializationSteps lastStepToPerform, bool maintainReference) override;
LoadModulesResult LoadDynamicModules(const ModuleDescriptorList& modules, ModuleInitializationSteps lastStepToPerform, bool maintainReferences) override;
LoadModulesResult LoadStaticModules(CreateStaticModulesCallback staticModulesCb, ModuleInitializationSteps lastStepToPerform) override;
bool IsModuleLoaded(const char* modulePath) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// ModuleManagerInternalRequestBus
void ClearModuleReferences(const AZ::OSString& normalizedModulePath) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// EntityBus
void OnEntityActivated(const AZ::EntityId& entityId) override;
////////////////////////////////////////////////////////////////////////
// Helper function for initializing module entities
void ActivateEntities(const AZStd::vector<AZStd::shared_ptr<ModuleDataImpl>>& modulesToInit, bool doDependencySort);
// Helper function to preprocess the module names to handle any special processing
static AZ::OSString PreProcessModule(const AZ::OSString& moduleName);
/// The modules we own
AZStd::vector<AZStd::shared_ptr<ModuleDataImpl>> m_ownedModules;
using UnownedModulesMap = AZStd::unordered_map<AZ::OSString, AZStd::weak_ptr<ModuleDataImpl>>;
/// The modules we don't own
/// Is multimap to handle CRC collisions
UnownedModulesMap m_notOwnedModules;
};
} // namespace AZ
| 41.443182 | 161 | 0.612558 |
64310c0fa2ba449405bd44719c3f11b530799543 | 1,485 | c | C | Chapter5/Exercise5-4/exercise5-4.c | P-Miranda/c-programming-language | af189b3e2b1f0243dfc54154110d85ab6ea9c38e | [
"MIT"
] | null | null | null | Chapter5/Exercise5-4/exercise5-4.c | P-Miranda/c-programming-language | af189b3e2b1f0243dfc54154110d85ab6ea9c38e | [
"MIT"
] | null | null | null | Chapter5/Exercise5-4/exercise5-4.c | P-Miranda/c-programming-language | af189b3e2b1f0243dfc54154110d85ab6ea9c38e | [
"MIT"
] | null | null | null | #include <stdio.h>
#define STR_LEN 100 /* max string length */
/* Write the function `strend(s,t)`, which returns 1 if the string `t` occurs at
* the end of the string `s`, and zero otherwhise. */
int strend(char *s, char *t);
void strcat_(char *s, char *t);
int main(){
char t[] = "This is string t";
char s[STR_LEN] = "I'm string s!";
char s_small[] = "small string";
/* s != t and s >= t */
printf("s: %s\n", s);
printf("t: %s\n", t);
printf("strend(s,t): %d\n", strend(s,t));
/* s ends in t */
strcat_(s, t);
printf("strcat(): %s\n", s);
printf("strend(s,t): %d\n", strend(s,t));
/* s < t */
printf("strend(s_small,t): %d\n", strend(s_small,t));
return 0;
}
/* strend: check for t at the end of s*/
int strend(char *s, char *t){
char *s_aux = s, *t_aux = t;
/* go to s end */
while(*s_aux)
s_aux++;
/* go to t end */
while(*t_aux)
t_aux++;
/* check if s >= t */
if((t_aux - t) > (s_aux - s)){
printf("error: len(s) < len(t)\n");
return 0;
}
/* compare from end to start */
while(t_aux >= t){
if(*t_aux != *s_aux)
return 0;
t_aux--;
s_aux--;
}
return 1;
}
/* strcat: concatenate t into s */
void strcat_(char *s, char *t){
/* go to s end */
while(*s != '\0')
s++;
/* copy t after s */
while(*s++ = *t++)
;
/* terminate string */
*s = '\0';
return;
}
| 20.625 | 81 | 0.486195 |
6431406686e0b359ee3a2b52e093f7d464fcbf4a | 312 | h | C | src/emu/sound/multipcm.h | Zoltan45/Mame-mkp119 | d219a3549eafb4215727c974e09e43b28d058328 | [
"CC0-1.0"
] | null | null | null | src/emu/sound/multipcm.h | Zoltan45/Mame-mkp119 | d219a3549eafb4215727c974e09e43b28d058328 | [
"CC0-1.0"
] | null | null | null | src/emu/sound/multipcm.h | Zoltan45/Mame-mkp119 | d219a3549eafb4215727c974e09e43b28d058328 | [
"CC0-1.0"
] | null | null | null | #ifndef __MultiPCM_H__
#define __MultiPCM_H__
struct MultiPCM_interface
{
int region;
};
WRITE8_HANDLER( MultiPCM_reg_0_w );
READ8_HANDLER( MultiPCM_reg_0_r);
WRITE8_HANDLER( MultiPCM_reg_1_w );
READ8_HANDLER( MultiPCM_reg_1_r);
void multipcm_set_bank(int which, UINT32 leftoffs, UINT32 rightoffs);
#endif
| 17.333333 | 69 | 0.814103 |
6432a54daab36a7ce19128102e9e9c30c5d060a0 | 5,442 | h | C | neo/d3xp/physics/Physics_Monster.h | vic3t3chn0/OpenKrown | 201c8fb6895cb0439e39c984d2fbc2c2eaf185b4 | [
"MIT"
] | 1 | 2018-11-07T22:44:23.000Z | 2018-11-07T22:44:23.000Z | neo/d3xp/physics/Physics_Monster.h | vic3t3chn0/OpenKrown | 201c8fb6895cb0439e39c984d2fbc2c2eaf185b4 | [
"MIT"
] | null | null | null | neo/d3xp/physics/Physics_Monster.h | vic3t3chn0/OpenKrown | 201c8fb6895cb0439e39c984d2fbc2c2eaf185b4 | [
"MIT"
] | null | null | null | /*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code 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.
Doom 3 BFG Edition Source Code 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 Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __PHYSICS_MONSTER_H__
#define __PHYSICS_MONSTER_H__
/*
===================================================================================
Monster physics
Simulates the motion of a monster through the environment. The monster motion
is typically driven by animations.
===================================================================================
*/
typedef enum
{
MM_OK,
MM_SLIDING,
MM_BLOCKED,
MM_STEPPED,
MM_FALLING
} monsterMoveResult_t;
typedef struct monsterPState_s
{
int atRest;
bool onGround;
idVec3 origin;
idVec3 velocity;
idVec3 localOrigin;
idVec3 pushVelocity;
} monsterPState_t;
class idPhysics_Monster : public idPhysics_Actor
{
public:
CLASS_PROTOTYPE( idPhysics_Monster );
idPhysics_Monster();
void Save( idSaveGame* savefile ) const;
void Restore( idRestoreGame* savefile );
// maximum step up the monster can take, default 18 units
void SetMaxStepHeight( const float newMaxStepHeight );
float GetMaxStepHeight() const;
// minimum cosine of floor angle to be able to stand on the floor
void SetMinFloorCosine( const float newMinFloorCosine );
// set delta for next move
void SetDelta( const idVec3& d );
// returns true if monster is standing on the ground
bool OnGround() const;
// returns the movement result
monsterMoveResult_t GetMoveResult() const;
// overrides any velocity for pure delta movement
void ForceDeltaMove( bool force );
// whether velocity should be affected by gravity
void UseFlyMove( bool force );
// don't use delta movement
void UseVelocityMove( bool force );
// get entity blocking the move
idEntity* GetSlideMoveEntity() const;
// enable/disable activation by impact
void EnableImpact();
void DisableImpact();
public: // common physics interface
bool Evaluate( int timeStepMSec, int endTimeMSec );
void UpdateTime( int endTimeMSec );
int GetTime() const;
void GetImpactInfo( const int id, const idVec3& point, impactInfo_t* info ) const;
void ApplyImpulse( const int id, const idVec3& point, const idVec3& impulse );
void Activate();
void PutToRest();
bool IsAtRest() const;
int GetRestStartTime() const;
void SaveState();
void RestoreState();
void SetOrigin( const idVec3& newOrigin, int id = -1 );
void SetAxis( const idMat3& newAxis, int id = -1 );
void Translate( const idVec3& translation, int id = -1 );
void Rotate( const idRotation& rotation, int id = -1 );
void SetLinearVelocity( const idVec3& newLinearVelocity, int id = 0 );
const idVec3& GetLinearVelocity( int id = 0 ) const;
void SetPushed( int deltaTime );
const idVec3& GetPushedLinearVelocity( const int id = 0 ) const;
void SetMaster( idEntity* master, const bool orientated = true );
void WriteToSnapshot( idBitMsg& msg ) const;
void ReadFromSnapshot( const idBitMsg& msg );
private:
// monster physics state
monsterPState_t current;
monsterPState_t saved;
// client interpolation state
monsterPState_t previous;
monsterPState_t next;
// properties
float maxStepHeight; // maximum step height
float minFloorCosine; // minimum cosine of floor angle
idVec3 delta; // delta for next move
bool forceDeltaMove;
bool fly;
bool useVelocityMove;
bool noImpact; // if true do not activate when another object collides
// results of last evaluate
monsterMoveResult_t moveResult;
idEntity* blockingEntity;
private:
void CheckGround( monsterPState_t& state );
monsterMoveResult_t SlideMove( idVec3& start, idVec3& velocity, const idVec3& delta );
monsterMoveResult_t StepMove( idVec3& start, idVec3& velocity, const idVec3& delta );
void Rest();
};
#endif /* !__PHYSICS_MONSTER_H__ */
| 34.0125 | 366 | 0.68688 |
6432bdf4d533c262c7e8e4c763e92da47e27bec4 | 301 | h | C | MenuBarHostPlugin/MenuBarHostPlugin/PluginProtocol.h | RabbitMC/PluginStatusBarMenu | 3883b206a494b1c98b056f984572132e74953cc5 | [
"MIT"
] | null | null | null | MenuBarHostPlugin/MenuBarHostPlugin/PluginProtocol.h | RabbitMC/PluginStatusBarMenu | 3883b206a494b1c98b056f984572132e74953cc5 | [
"MIT"
] | 1 | 2020-03-19T06:32:01.000Z | 2020-03-19T06:32:01.000Z | MenuBarHostPlugin/MenuBarHostPlugin/PluginProtocol.h | RabbitMC/PluginStatusBarMenu | 3883b206a494b1c98b056f984572132e74953cc5 | [
"MIT"
] | null | null | null | //
// PluginProtocol.h
// MenuBarHostPlugin
//
// Created by Miralem Cebic on 25.07.17.
// Copyright © 2017 Miralem Cebic. All rights reserved.
//
#ifndef PluginProtocol_h
#define PluginProtocol_h
@protocol PluginProtocol <NSObject>
- (NSMenuItem *)menuItem;
@end
#endif /* PluginProtocol_h */
| 17.705882 | 56 | 0.727575 |
6433afc30f658430312996759eb19d5f00e43e10 | 295 | c | C | lib/libstuff/geom/rect_contains_p.c | aksr/wmii | 56b3a14f57e8150d74c2c5e6012e7a8eda3c17d9 | [
"MIT"
] | 78 | 2016-11-23T07:45:27.000Z | 2022-03-19T21:00:52.000Z | lib/libstuff/geom/rect_contains_p.c | aksr/wmii | 56b3a14f57e8150d74c2c5e6012e7a8eda3c17d9 | [
"MIT"
] | 4 | 2015-06-28T19:20:59.000Z | 2020-07-15T05:27:56.000Z | lib/libstuff/geom/rect_contains_p.c | aksr/wmii | 56b3a14f57e8150d74c2c5e6012e7a8eda3c17d9 | [
"MIT"
] | 16 | 2018-01-09T06:01:19.000Z | 2022-03-15T22:11:57.000Z | /* Copyright ©2006-2010 Kris Maglione <maglione.k at Gmail>
* See LICENSE file for license details.
*/
#include <stuff/geom.h>
bool
rect_contains_p(Rectangle r, Rectangle r2) {
return r2.min.x >= r.min.x
&& r2.max.x <= r.max.x
&& r2.min.y >= r.min.y
&& r2.max.y <= r.max.y;
}
| 22.692308 | 59 | 0.620339 |
6434a8a33585a0cb59e929aa6898df5dc5beef56 | 717 | h | C | Projector/Projector/User Interface/PlanViewMobileGridTableViewCellCollectionViewLayout.h | planningcenter/projector | 5fc2b3baa752331e505228503fb4e6e82cdd0e0d | [
"MIT"
] | 9 | 2018-02-13T18:33:43.000Z | 2020-03-08T15:31:48.000Z | Projector/Projector/User Interface/PlanViewMobileGridTableViewCellCollectionViewLayout.h | planningcenter/projector | 5fc2b3baa752331e505228503fb4e6e82cdd0e0d | [
"MIT"
] | 2 | 2018-04-30T10:28:56.000Z | 2019-02-23T16:31:10.000Z | Projector/Projector/User Interface/PlanViewMobileGridTableViewCellCollectionViewLayout.h | planningcenter/projector | 5fc2b3baa752331e505228503fb4e6e82cdd0e0d | [
"MIT"
] | 11 | 2018-02-17T12:39:27.000Z | 2021-03-10T09:07:41.000Z | /*!
* PlanViewMobileGridTableViewCellCollectionViewLayout.h
* Projector
*
*
* Created by Skylar Schipper on 12/4/14
*/
#ifndef Projector_PlanViewMobileGridTableViewCellCollectionViewLayout_h
#define Projector_PlanViewMobileGridTableViewCellCollectionViewLayout_h
@import UIKit;
#import "PlanViewGridCollectionViewLayout.h"
@interface PlanViewMobileGridTableViewCellCollectionViewLayout : UICollectionViewLayout
- (void)selectionChanged;
- (void)invalidateLayoutCache;
@end
@protocol PlanViewMobileGridTableViewCellCollectionViewLayoutDelegate <PlanViewGridCollectionViewLayoutDelegate>
- (BOOL)isPlanIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView;
@end
#endif
| 23.129032 | 112 | 0.849372 |
6434faee88cb4fe3996992dfabd926d3403a0d93 | 2,260 | h | C | utils/containers/lists/concurrent_list_neighbor.h | florianthonig/entangled | ffdbcc9aabdcf47fefb7cdd3b80154ab2f1f3393 | [
"Apache-2.0"
] | null | null | null | utils/containers/lists/concurrent_list_neighbor.h | florianthonig/entangled | ffdbcc9aabdcf47fefb7cdd3b80154ab2f1f3393 | [
"Apache-2.0"
] | null | null | null | utils/containers/lists/concurrent_list_neighbor.h | florianthonig/entangled | ffdbcc9aabdcf47fefb7cdd3b80154ab2f1f3393 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2018 IOTA Stiftung
* https://github.com/iotaledger/entangled
*
* Refer to the LICENSE file for licensing information
*/
#ifndef __UTILS_CONTAINERS_LISTS_CONCURRENT_LIST_NEIGHBOR_H__
#define __UTILS_CONTAINERS_LISTS_CONCURRENT_LIST_NEIGHBOR_H__
#include "gossip/neighbor.h"
#include "utils/containers/lists/concurrent_list.h.inc"
#ifdef __cplusplus
extern "C" {
#endif
DECLARE_CL(neighbor_t);
typedef concurrent_list_neighbor_t neighbors_list_t;
/**
* neighbor_t comparator for list operations
*
* @param lhs Left hand side neighbor_t
* @param rhs Right hand side neighbor_t
*
* @return true if equal, false otherwise
*/
bool neighbor_cmp(neighbor_t const *const lhs, neighbor_t const *const rhs);
/**
* Add a neighbor to a list
*
* @param neighbors The neighbors list
* @param neighbor The neighbor
*
* @return true if the neighbor was added, false otherwise
*/
bool neighbor_add(neighbors_list_t *const neighbors, neighbor_t const neighbor);
/**
* Remove a neighbor from a list
*
* @param neighbors The neighbors list
* @pram neighbor The neighbor
*
* @return true if the neighbor was removed, false otherwise
*/
bool neighbor_remove(neighbors_list_t *const neighbors,
neighbor_t const neighbor);
/**
* Find a neigbor matching given endpoint
*
* @param neighbors The neighbors list
* @param endpoint The endpoint
*
* @return a pointer to the neigbor if found, NULL otherwise
*/
neighbor_t *neighbor_find_by_endpoint(neighbors_list_t *const neighbors,
endpoint_t const *const endpoint);
/**
* Find a neigbor matching given endpoint values
*
* @param neighbors The neighbors list
* @param ip The endpoint ip
* @param port The endpoint port
* @param protocol The endpoint protocol
*
* @return a pointer to the neigbor if found, NULL otherwise
*/
neighbor_t *neighbor_find_by_endpoint_values(neighbors_list_t *const neighbors,
char const *const ip,
uint16_t const port,
protocol_type_t const protocol);
#ifdef __cplusplus
}
#endif
#endif // __UTILS_CONTAINERS_LISTS_CONCURRENT_LIST_NEIGHBOR_H__
| 26.904762 | 80 | 0.703097 |
643525423bf9dd348c4e8bb0ed775784af5c99a4 | 2,339 | c | C | tools/cbmc/proofs/SkipNameField/SkipNameField_harness.c | ictk-solution-dev/amazon-freertos | cc76512292ddfb70bba3030dbcb740ef3c6ead8b | [
"MIT"
] | 2 | 2020-06-23T08:05:58.000Z | 2020-06-24T01:25:51.000Z | tools/cbmc/proofs/SkipNameField/SkipNameField_harness.c | LibreWireless/amazon-freertos-uno | 2ddb5c0ac906e4ab5340062641776f44e0f1d67d | [
"MIT"
] | 2 | 2022-03-29T05:16:50.000Z | 2022-03-29T05:16:50.000Z | tools/cbmc/proofs/SkipNameField/SkipNameField_harness.c | ictk-solution-dev/amazon-freertos | cc76512292ddfb70bba3030dbcb740ef3c6ead8b | [
"MIT"
] | null | null | null | /* Standard includes. */
#include <stdint.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "list.h"
#include "semphr.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_UDP_IP.h"
#include "FreeRTOS_DNS.h"
#include "NetworkBufferManagement.h"
#include "NetworkInterface.h"
#include "IPTraceMacroDefaults.h"
#include "cbmc.h"
uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen );
void harness() {
// Choose arbitrary buffer of size at most NETWORK_BUFFER_SIZE
uint8_t my_buffer[NETWORK_BUFFER_SIZE];
size_t my_buffer_offset;
uint8_t *buffer = my_buffer + my_buffer_offset;
size_t buffer_size = NETWORK_BUFFER_SIZE - my_buffer_offset;
__CPROVER_assume(my_buffer_offset <= NETWORK_BUFFER_SIZE);
// Choose arbitrary pointer into buffer
size_t buffer_offset;
uint8_t *pucByte = buffer + buffer_offset;
__CPROVER_assume(buffer_offset <= NETWORK_BUFFER_SIZE);
// Choose arbitrary value for space remaining in the buffer
size_t xSourceLen;
////////////////////////////////////////////////////////////////
// Specification and proof of prvSkipNameField
// CBMC pointer model (this is obviously true)
__CPROVER_assume(NETWORK_BUFFER_SIZE < CBMC_MAX_OBJECT_SIZE);
// Preconditions
// pointer is valid pointer into buffer
__CPROVER_assume(xSourceLen == 0 ||
(buffer <= pucByte && pucByte < buffer + buffer_size));
// length is valid value for space remaining in the buffer
__CPROVER_assume(pucByte + xSourceLen <= buffer + buffer_size);
// CBMC loop unwinding: bound depend on xSourceLen
__CPROVER_assume(xSourceLen <= NETWORK_BUFFER_SIZE);
SAVE_OLDVAL(pucByte, uint8_t *);
SAVE_OLDVAL(xSourceLen, size_t);
// function return value is either NULL or the updated value of pucByte
uint8_t *rc = prvSkipNameField(pucByte, xSourceLen);
// Postconditions
// pucByte can be advanced one position past the end of the buffer
__CPROVER_assert((rc == 0) ||
(rc - OLDVAL(pucByte) >= 1 &&
rc - OLDVAL(pucByte) <= OLDVAL(xSourceLen) &&
pucByte == OLDVAL(pucByte) &&
buffer <= rc && rc <= buffer + buffer_size),
"updated pucByte");
}
| 30.776316 | 74 | 0.689183 |
64363a58a2494f56cd7315c236ae0d704a66a115 | 666 | h | C | src/bringup/bin/netsvc/board-info.h | Prajwal-Koirala/fuchsia | ca7ae6c143cd4c10bad9aa1869ffcc24c3e4b795 | [
"BSD-2-Clause"
] | 4 | 2020-02-23T09:02:06.000Z | 2022-01-08T17:06:28.000Z | src/bringup/bin/netsvc/board-info.h | PlugFox/fuchsia | 39afe5230d41628b3c736a6e384393df954968c8 | [
"BSD-2-Clause"
] | 2 | 2021-09-19T21:55:09.000Z | 2021-12-19T03:34:53.000Z | src/bringup/bin/netsvc/board-info.h | PlugFox/fuchsia | 39afe5230d41628b3c736a6e384393df954968c8 | [
"BSD-2-Clause"
] | 1 | 2021-08-23T11:33:57.000Z | 2021-08-23T11:33:57.000Z | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_BRINGUP_BIN_NETSVC_BOARD_INFO_H_
#define SRC_BRINGUP_BIN_NETSVC_BOARD_INFO_H_
#include <fidl/fuchsia.sysinfo/cpp/wire.h>
#include <unistd.h>
bool CheckBoardName(fidl::UnownedClientEnd<fuchsia_sysinfo::SysInfo> sysinfo, const char* name,
size_t length);
bool ReadBoardInfo(fidl::UnownedClientEnd<fuchsia_sysinfo::SysInfo> sysinfo, void* data,
off_t offset, size_t* length);
size_t BoardInfoSize();
#endif // SRC_BRINGUP_BIN_NETSVC_BOARD_INFO_H_
| 33.3 | 95 | 0.756757 |
6436770f3f7cecb88361763581ac162f8eb04758 | 267 | h | C | source/DeathShroud.h | Doomspear/MyUltima | e171a3e73624c4ca2292a073a250878758f3a837 | [
"MIT"
] | null | null | null | source/DeathShroud.h | Doomspear/MyUltima | e171a3e73624c4ca2292a073a250878758f3a837 | [
"MIT"
] | null | null | null | source/DeathShroud.h | Doomspear/MyUltima | e171a3e73624c4ca2292a073a250878758f3a837 | [
"MIT"
] | null | null | null | #pragma once
#include "item.h"
typedef class CDeathShroud : public CItem
{
public:
void Init();
void Progress();
void Render();
void Release();
public:
CDeathShroud(void);
CDeathShroud(CObj* pOwner);
virtual ~CDeathShroud(void);
}DEATHSHROUD, *PDEATHSHROUD;
| 15.705882 | 41 | 0.726592 |
643761ed721c9c963b2d4034fe390be0fcde8b24 | 3,656 | h | C | include/cat_buffer.h | dixyes-bot/libcat | fe441647c43f8439bd493aa4c129082e9331276d | [
"Apache-2.0"
] | null | null | null | include/cat_buffer.h | dixyes-bot/libcat | fe441647c43f8439bd493aa4c129082e9331276d | [
"Apache-2.0"
] | null | null | null | include/cat_buffer.h | dixyes-bot/libcat | fe441647c43f8439bd493aa4c129082e9331276d | [
"Apache-2.0"
] | null | null | null | /*
+--------------------------------------------------------------------------+
| libcat |
+--------------------------------------------------------------------------+
| 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. See accompanying LICENSE file. |
+--------------------------------------------------------------------------+
| Author: Twosee <twosee@php.net> |
+--------------------------------------------------------------------------+
*/
#ifndef CAT_BUFFER_H
#define CAT_BUFFER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cat.h"
#define CAT_BUFFER_DEFAULT_SIZE 8192
typedef struct cat_buffer_s {
/* public readonly */
char *value;
size_t size;
size_t length;
} cat_buffer_t;
typedef char *(*cat_buffer_alloc_function_t)(size_t size);
typedef char *(*cat_buffer_realloc_function_t)(char *old_value, size_t old_length, size_t new_size);
typedef void (*cat_buffer_update_function_t)(char *value, size_t new_length);
typedef void (*cat_buffer_free_function_t)(char *value);
typedef struct cat_buffer_allocator_s {
cat_buffer_alloc_function_t alloc_function;
cat_buffer_realloc_function_t realloc_function;
cat_buffer_update_function_t update_function;
cat_buffer_free_function_t free_function;
} cat_buffer_allocator_t;
extern CAT_API cat_buffer_allocator_t cat_buffer_allocator;
CAT_API cat_bool_t cat_buffer_module_init(void);
CAT_API cat_bool_t cat_buffer_register_allocator(const cat_buffer_allocator_t *allocator);
CAT_API size_t cat_buffer_align_size(size_t size, size_t alignment);
CAT_API void cat_buffer_init(cat_buffer_t *buffer);
CAT_API cat_bool_t cat_buffer_alloc(cat_buffer_t *buffer, size_t size);
CAT_API cat_bool_t cat_buffer_create(cat_buffer_t *buffer, size_t size);
CAT_API cat_bool_t cat_buffer_realloc(cat_buffer_t *buffer, size_t new_size);
CAT_API cat_bool_t cat_buffer_extend(cat_buffer_t *buffer, size_t recommend_size);
CAT_API cat_bool_t cat_buffer_malloc_trim(cat_buffer_t *buffer);
CAT_API cat_bool_t cat_buffer_write(cat_buffer_t *buffer, size_t offset, const char *ptr, size_t length);
CAT_API cat_bool_t cat_buffer_append(cat_buffer_t *buffer, const char *ptr, size_t length);
CAT_API void cat_buffer_truncate(cat_buffer_t *buffer, size_t start, size_t length);
CAT_API void cat_buffer_clear(cat_buffer_t *buffer);
CAT_API char *cat_buffer_fetch(cat_buffer_t *buffer);
CAT_API cat_bool_t cat_buffer_dup(cat_buffer_t *buffer, cat_buffer_t *new_buffer);
CAT_API void cat_buffer_close(cat_buffer_t *buffer);
CAT_API char *cat_buffer_get_value(const cat_buffer_t *buffer);
CAT_API size_t cat_buffer_get_size(const cat_buffer_t *buffer);
CAT_API size_t cat_buffer_get_length(const cat_buffer_t *buffer);
CAT_API cat_bool_t cat_buffer_make_pair(cat_buffer_t *rbuffer, size_t rsize, cat_buffer_t *wbuffer, size_t wsize);
CAT_API void cat_buffer_dump(cat_buffer_t *buffer);
#ifdef __cplusplus
}
#endif
#endif /* CAT_BUFFER_H */
| 45.135802 | 114 | 0.68791 |
6437ca607de05c0d7c470e3b35c1e6695d8d6a10 | 3,958 | h | C | sdk/xpcom/include/xpcom/nsValueArray.h | rogerdahl/vbox-remote-keyboard | 526a9597ccff145becf921b907a93d886cd1a5c9 | [
"MIT"
] | 521 | 2019-03-29T15:44:08.000Z | 2022-03-22T09:46:19.000Z | sdk/xpcom/include/xpcom/nsValueArray.h | rogerdahl/vbox-remote-keyboard | 526a9597ccff145becf921b907a93d886cd1a5c9 | [
"MIT"
] | 30 | 2019-06-04T17:00:49.000Z | 2021-09-08T20:44:19.000Z | sdk/xpcom/include/xpcom/nsValueArray.h | rogerdahl/vbox-remote-keyboard | 526a9597ccff145becf921b907a93d886cd1a5c9 | [
"MIT"
] | 99 | 2019-03-29T16:04:13.000Z | 2022-03-28T16:59:34.000Z | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is nsValueArray.h/nsValueArray.cpp code, released
* Dec 28, 2001.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Garrett Arch Blythe, 20-December-2001
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsValueArray_h___
#define nsValueArray_h___
//
// nsValueArray.h
//
// Implement an array class to store unsigned integer values.
// The maximum value must be known up front. Once known, the
// smallest memory representation will be attempted; i.e. if the
// maximum value was 1275, then 2 bytes (uint16) would represent each value
// in the array instead of 4 bytes (uint32).
//
#include "nscore.h"
typedef PRUint32 nsValueArrayCount;
typedef PRUint32 nsValueArrayIndex;
typedef PRUint32 nsValueArrayValue;
#define NSVALUEARRAY_INVALID ((nsValueArrayValue)-1)
class NS_COM nsValueArray {
public:
nsValueArray(nsValueArrayValue aMaxValue,
nsValueArrayCount aInitialCapacity = 0);
~nsValueArray();
//
// Assignment.
//
public:
nsValueArray& operator=(const nsValueArray& other);
//
// Array size information.
// Ability to add more values without growing is Capacity - Count.
//
public:
inline nsValueArrayCount Count() const {
return mCount;
}
inline nsValueArrayCount Capacity() const {
return mCapacity;
}
void Compact();
// Removes all elements from this array
inline void Clear() {
mCount = 0;
}
//
// Array access.
//
public:
nsValueArrayValue ValueAt(nsValueArrayIndex aIndex) const;
inline nsValueArrayValue operator[](nsValueArrayIndex aIndex) const {
return ValueAt(aIndex);
}
nsValueArrayIndex IndexOf(nsValueArrayValue aPossibleValue) const;
inline PRBool AppendValue(nsValueArrayValue aValue) {
return InsertValueAt(aValue, Count());
}
inline PRBool RemoveValue(nsValueArrayValue aValue) {
return RemoveValueAt(IndexOf(aValue));
}
PRBool InsertValueAt(nsValueArrayValue aValue, nsValueArrayIndex aIndex);
PRBool RemoveValueAt(nsValueArrayIndex aIndex);
//
// Data members.
//
private:
nsValueArrayCount mCount;
nsValueArrayCount mCapacity;
PRUint8* mValueArray;
PRUint8 mBytesPerValue;
};
#endif /* nsValueArray_h___ */
| 31.412698 | 78 | 0.708691 |
6437dabbc9270fde325576e244d97703b0ae230a | 250 | h | C | src/Common.h | huangkaibo/chatroom-p2p | 3b00a2135b11479f8c976211d33d95f2acad895c | [
"Apache-2.0"
] | null | null | null | src/Common.h | huangkaibo/chatroom-p2p | 3b00a2135b11479f8c976211d33d95f2acad895c | [
"Apache-2.0"
] | null | null | null | src/Common.h | huangkaibo/chatroom-p2p | 3b00a2135b11479f8c976211d33d95f2acad895c | [
"Apache-2.0"
] | null | null | null | #ifndef COMMON_H
#define COMMON_H
#include"Node.h"
class Common {
private:
static Node server;
public:
static Node getServer_Node();
static unsigned short getAvailablePort();
static bool compare_node(Node node1, Node node2);
};
#endif COMMON_H
| 16.666667 | 50 | 0.768 |
6437ddbd7842e099eead7d49a0aade24fcbc88ec | 10,234 | h | C | drivers/net/fjes/fjes_trace.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | drivers/net/fjes/fjes_trace.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 1 | 2021-01-27T01:29:47.000Z | 2021-01-27T01:29:47.000Z | drivers/net/fjes/fjes_trace.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | /* SPDX-License-Identifier: GPL-2.0-only */
/*
* FUJITSU Extended Socket Network Device driver
* Copyright (c) 2015-2016 FUJITSU LIMITED
*/
#if !defined(FJES_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define FJES_TRACE_H_
#include <linux/types.h>
#include <linux/tracepoint.h>
#undef TRACE_SYSTEM
#define TRACE_SYSTEM fjes
/* tracepoints for fjes_hw.c */
TRACE_EVENT(fjes_hw_issue_request_command,
TP_PROTO(union REG_CR *cr, union REG_CS *cs, int timeout,
enum fjes_dev_command_response_e ret),
TP_ARGS(cr, cs, timeout, ret),
TP_STRUCT__entry(
__field(u16, cr_req)
__field(u8, cr_error)
__field(u16, cr_err_info)
__field(u8, cr_req_start)
__field(u16, cs_req)
__field(u8, cs_busy)
__field(u8, cs_complete)
__field(int, timeout)
__field(int, ret)
),
TP_fast_assign(
__entry->cr_req = cr->bits.req_code;
__entry->cr_error = cr->bits.error;
__entry->cr_err_info = cr->bits.err_info;
__entry->cr_req_start = cr->bits.req_start;
__entry->cs_req = cs->bits.req_code;
__entry->cs_busy = cs->bits.busy;
__entry->cs_complete = cs->bits.complete;
__entry->timeout = timeout;
__entry->ret = ret;
),
TP_printk("CR=[req=%04x, error=%u, err_info=%04x, req_start=%u], CS=[req=%04x, busy=%u, complete=%u], timeout=%d, ret=%d",
__entry->cr_req, __entry->cr_error, __entry->cr_err_info,
__entry->cr_req_start, __entry->cs_req, __entry->cs_busy,
__entry->cs_complete, __entry->timeout, __entry->ret)
);
TRACE_EVENT(fjes_hw_request_info,
TP_PROTO(struct fjes_hw *hw, union fjes_device_command_res *res_buf),
TP_ARGS(hw, res_buf),
TP_STRUCT__entry(
__field(int, length)
__field(int, code)
__dynamic_array(u8, zone, hw->max_epid)
__dynamic_array(u8, status, hw->max_epid)
),
TP_fast_assign(
int x;
__entry->length = res_buf->info.length;
__entry->code = res_buf->info.code;
for (x = 0; x < hw->max_epid; x++) {
*((u8 *)__get_dynamic_array(zone) + x) =
res_buf->info.info[x].zone;
*((u8 *)__get_dynamic_array(status) + x) =
res_buf->info.info[x].es_status;
}
),
TP_printk("res_buf=[length=%d, code=%d, es_zones=%s, es_status=%s]",
__entry->length, __entry->code,
__print_array(__get_dynamic_array(zone),
__get_dynamic_array_len(zone) / sizeof(u8),
sizeof(u8)),
__print_array(__get_dynamic_array(status),
__get_dynamic_array_len(status) / sizeof(u8),
sizeof(u8)))
);
TRACE_EVENT(fjes_hw_request_info_err,
TP_PROTO(char *err),
TP_ARGS(err),
TP_STRUCT__entry(
__string(err, err)
),
TP_fast_assign(
__assign_str(err, err);
),
TP_printk("%s", __get_str(err))
);
TRACE_EVENT(fjes_hw_register_buff_addr_req,
TP_PROTO(union fjes_device_command_req *req_buf,
struct ep_share_mem_info *buf_pair),
TP_ARGS(req_buf, buf_pair),
TP_STRUCT__entry(
__field(int, length)
__field(int, epid)
__field(u64, tx)
__field(size_t, tx_size)
__field(u64, rx)
__field(size_t, rx_size)
),
TP_fast_assign(
void *tx, *rx;
tx = (void *)buf_pair->tx.buffer;
rx = (void *)buf_pair->rx.buffer;
__entry->length = req_buf->share_buffer.length;
__entry->epid = req_buf->share_buffer.epid;
__entry->tx_size = buf_pair->tx.size;
__entry->rx_size = buf_pair->rx.size;
__entry->tx = page_to_phys(vmalloc_to_page(tx)) +
offset_in_page(tx);
__entry->rx = page_to_phys(vmalloc_to_page(rx)) +
offset_in_page(rx);
),
TP_printk("req_buf=[length=%d, epid=%d], TX=[phy=0x%016llx, size=%zu], RX=[phy=0x%016llx, size=%zu]",
__entry->length, __entry->epid, __entry->tx, __entry->tx_size,
__entry->rx, __entry->rx_size)
);
TRACE_EVENT(fjes_hw_register_buff_addr,
TP_PROTO(union fjes_device_command_res *res_buf, int timeout),
TP_ARGS(res_buf, timeout),
TP_STRUCT__entry(
__field(int, length)
__field(int, code)
__field(int, timeout)
),
TP_fast_assign(
__entry->length = res_buf->share_buffer.length;
__entry->code = res_buf->share_buffer.code;
__entry->timeout = timeout;
),
TP_printk("res_buf=[length=%d, code=%d], timeout=%d",
__entry->length, __entry->code, __entry->timeout)
);
TRACE_EVENT(fjes_hw_register_buff_addr_err,
TP_PROTO(char *err),
TP_ARGS(err),
TP_STRUCT__entry(
__string(err, err)
),
TP_fast_assign(
__assign_str(err, err);
),
TP_printk("%s", __get_str(err))
);
TRACE_EVENT(fjes_hw_unregister_buff_addr_req,
TP_PROTO(union fjes_device_command_req *req_buf),
TP_ARGS(req_buf),
TP_STRUCT__entry(
__field(int, length)
__field(int, epid)
),
TP_fast_assign(
__entry->length = req_buf->unshare_buffer.length;
__entry->epid = req_buf->unshare_buffer.epid;
),
TP_printk("req_buf=[length=%d, epid=%d]",
__entry->length, __entry->epid)
);
TRACE_EVENT(fjes_hw_unregister_buff_addr,
TP_PROTO(union fjes_device_command_res *res_buf, int timeout),
TP_ARGS(res_buf, timeout),
TP_STRUCT__entry(
__field(int, length)
__field(int, code)
__field(int, timeout)
),
TP_fast_assign(
__entry->length = res_buf->unshare_buffer.length;
__entry->code = res_buf->unshare_buffer.code;
__entry->timeout = timeout;
),
TP_printk("res_buf=[length=%d, code=%d], timeout=%d",
__entry->length, __entry->code, __entry->timeout)
);
TRACE_EVENT(fjes_hw_unregister_buff_addr_err,
TP_PROTO(char *err),
TP_ARGS(err),
TP_STRUCT__entry(
__string(err, err)
),
TP_fast_assign(
__assign_str(err, err);
),
TP_printk("%s", __get_str(err))
);
TRACE_EVENT(fjes_hw_start_debug_req,
TP_PROTO(union fjes_device_command_req *req_buf),
TP_ARGS(req_buf),
TP_STRUCT__entry(
__field(int, length)
__field(int, mode)
__field(phys_addr_t, buffer)
),
TP_fast_assign(
__entry->length = req_buf->start_trace.length;
__entry->mode = req_buf->start_trace.mode;
__entry->buffer = req_buf->start_trace.buffer[0];
),
TP_printk("req_buf=[length=%d, mode=%d, buffer=%pap]",
__entry->length, __entry->mode, &__entry->buffer)
);
TRACE_EVENT(fjes_hw_start_debug,
TP_PROTO(union fjes_device_command_res *res_buf),
TP_ARGS(res_buf),
TP_STRUCT__entry(
__field(int, length)
__field(int, code)
),
TP_fast_assign(
__entry->length = res_buf->start_trace.length;
__entry->code = res_buf->start_trace.code;
),
TP_printk("res_buf=[length=%d, code=%d]", __entry->length, __entry->code)
);
TRACE_EVENT(fjes_hw_start_debug_err,
TP_PROTO(char *err),
TP_ARGS(err),
TP_STRUCT__entry(
__string(err, err)
),
TP_fast_assign(
__assign_str(err, err);
),
TP_printk("%s", __get_str(err))
);
TRACE_EVENT(fjes_hw_stop_debug,
TP_PROTO(union fjes_device_command_res *res_buf),
TP_ARGS(res_buf),
TP_STRUCT__entry(
__field(int, length)
__field(int, code)
),
TP_fast_assign(
__entry->length = res_buf->stop_trace.length;
__entry->code = res_buf->stop_trace.code;
),
TP_printk("res_buf=[length=%d, code=%d]", __entry->length, __entry->code)
);
TRACE_EVENT(fjes_hw_stop_debug_err,
TP_PROTO(char *err),
TP_ARGS(err),
TP_STRUCT__entry(
__string(err, err)
),
TP_fast_assign(
__assign_str(err, err);
),
TP_printk("%s", __get_str(err))
);
/* tracepoints for fjes_main.c */
TRACE_EVENT(fjes_txrx_stop_req_irq_pre,
TP_PROTO(struct fjes_hw *hw, int src_epid,
enum ep_partner_status status),
TP_ARGS(hw, src_epid, status),
TP_STRUCT__entry(
__field(int, src_epid)
__field(enum ep_partner_status, status)
__field(u8, ep_status)
__field(unsigned long, txrx_stop_req_bit)
__field(u16, rx_status)
),
TP_fast_assign(
__entry->src_epid = src_epid;
__entry->status = status;
__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
__entry->rx_status =
hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
),
TP_printk("epid=%d, partner_status=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
__entry->src_epid, __entry->status, __entry->ep_status,
__entry->txrx_stop_req_bit, __entry->rx_status)
);
TRACE_EVENT(fjes_txrx_stop_req_irq_post,
TP_PROTO(struct fjes_hw *hw, int src_epid),
TP_ARGS(hw, src_epid),
TP_STRUCT__entry(
__field(int, src_epid)
__field(u8, ep_status)
__field(unsigned long, txrx_stop_req_bit)
__field(u16, rx_status)
),
TP_fast_assign(
__entry->src_epid = src_epid;
__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
__entry->rx_status = hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
),
TP_printk("epid=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
__entry->src_epid, __entry->ep_status,
__entry->txrx_stop_req_bit, __entry->rx_status)
);
TRACE_EVENT(fjes_stop_req_irq_pre,
TP_PROTO(struct fjes_hw *hw, int src_epid,
enum ep_partner_status status),
TP_ARGS(hw, src_epid, status),
TP_STRUCT__entry(
__field(int, src_epid)
__field(enum ep_partner_status, status)
__field(u8, ep_status)
__field(unsigned long, txrx_stop_req_bit)
__field(u16, rx_status)
),
TP_fast_assign(
__entry->src_epid = src_epid;
__entry->status = status;
__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
__entry->rx_status =
hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
),
TP_printk("epid=%d, partner_status=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
__entry->src_epid, __entry->status, __entry->ep_status,
__entry->txrx_stop_req_bit, __entry->rx_status)
);
TRACE_EVENT(fjes_stop_req_irq_post,
TP_PROTO(struct fjes_hw *hw, int src_epid),
TP_ARGS(hw, src_epid),
TP_STRUCT__entry(
__field(int, src_epid)
__field(u8, ep_status)
__field(unsigned long, txrx_stop_req_bit)
__field(u16, rx_status)
),
TP_fast_assign(
__entry->src_epid = src_epid;
__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
__entry->rx_status =
hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
),
TP_printk("epid=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
__entry->src_epid, __entry->ep_status,
__entry->txrx_stop_req_bit, __entry->rx_status)
);
#endif /* FJES_TRACE_H_ */
#undef TRACE_INCLUDE_PATH
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_PATH ../../../drivers/net/fjes
#define TRACE_INCLUDE_FILE fjes_trace
/* This part must be outside protection */
#include <trace/define_trace.h>
| 27.961749 | 123 | 0.729627 |
6438da1615b950d202f632d5a005cd1bb78a052f | 1,111 | h | C | aos/events/event_loop_event.h | Ewpratten/frc_971_mirror | 3a8a0c4359f284d29547962c2b4c43d290d8065c | [
"BSD-2-Clause"
] | null | null | null | aos/events/event_loop_event.h | Ewpratten/frc_971_mirror | 3a8a0c4359f284d29547962c2b4c43d290d8065c | [
"BSD-2-Clause"
] | null | null | null | aos/events/event_loop_event.h | Ewpratten/frc_971_mirror | 3a8a0c4359f284d29547962c2b4c43d290d8065c | [
"BSD-2-Clause"
] | null | null | null | #ifndef AOS_EVENTS_EVENT_LOOP_EVENT_H
#define AOS_EVENTS_EVENT_LOOP_EVENT_H
#include "aos/time/time.h"
#include "glog/logging.h"
namespace aos {
// Common interface to track when callbacks and timers should have happened.
class EventLoopEvent {
public:
virtual ~EventLoopEvent() {}
bool valid() const { return event_time_ != monotonic_clock::max_time; }
void Invalidate() { event_time_ = monotonic_clock::max_time; }
monotonic_clock::time_point event_time() const {
DCHECK(valid());
return event_time_;
}
virtual void HandleEvent() = 0;
void set_event_time(monotonic_clock::time_point event_time) {
event_time_ = event_time;
}
private:
monotonic_clock::time_point event_time_ = monotonic_clock::max_time;
};
// Adapter class to implement EventLoopEvent by calling HandleEvent on T.
template <typename T>
class EventHandler final : public EventLoopEvent {
public:
EventHandler(T *t) : t_(t) {}
~EventHandler() = default;
void HandleEvent() override { t_->HandleEvent(); }
private:
T *const t_;
};
} // namespace aos
#endif // AOS_EVENTS_EVENT_LOOP_EVENT_H
| 23.638298 | 76 | 0.737174 |
643ac55b42b439ccfb2c097e815653f8adb0c73a | 347 | h | C | core/tests/123-searching-quickly/blacklist_cpp.h | hecto932/OJplus | 1876a498f1a449e05f6a00340e7141ae3f5a50bf | [
"MIT"
] | 2 | 2015-11-19T19:24:42.000Z | 2018-08-14T09:46:54.000Z | shield/blacklist_cpp.h | hecto932/TEG | ad80c3a707dafbc4a39dd7ea79da42988ed332c6 | [
"MIT",
"Unlicense"
] | null | null | null | shield/blacklist_cpp.h | hecto932/TEG | ad80c3a707dafbc4a39dd7ea79da42988ed332c6 | [
"MIT",
"Unlicense"
] | 1 | 2018-11-17T05:10:59.000Z | 2018-11-17T05:10:59.000Z | /*
*****************************************
SI DESEA AGREGAR UNA NUEVA DESCRIPCCION
SOLO COLOQUELA DEBAJO DE LAS LINEAS "#define"
** HAY FUNCIONES EN C QUE EN C++ NO FUNCIONAN
*/
#define fork errorNo1 //Fork is not allowed
#define clone errorNo2 //Clone is not allowed
#define sleep errorNo3 //Sleep is not allowed
| 31.545455 | 50 | 0.599424 |
643afda3a7ac7a2c64ba813dd15b5dce1eb4650e | 3,653 | c | C | ast-8.6.2/err_drama.c | astro-datalab/dlapps | 18a338a887af19d195b5c1eeed6c0a9e38686125 | [
"BSD-3-Clause"
] | 1 | 2020-08-17T21:26:16.000Z | 2020-08-17T21:26:16.000Z | ast-8.6.2/err_drama.c | noaodatalab/dlapps | 33e8fc6161448f2052369b1fbe2765e854c1ac52 | [
"BSD-3-Clause"
] | null | null | null | ast-8.6.2/err_drama.c | noaodatalab/dlapps | 33e8fc6161448f2052369b1fbe2765e854c1ac52 | [
"BSD-3-Clause"
] | null | null | null | /*
* Name:
* err_ems.c
* Purpose:
* Implement the "err" module for the DRAMA ERS error system.
* Description:
* This file implements an alternative "err" module for the AST
* library. It is used to deliver error messages through the
* DRAMA ERS error message system rather than by the default mechanism.
* Copyright:
* Copyright (C) 2008 Science and Technology Facilities Council.
* Copyright (C) 1997-2006 Council for the Central Laboratory of the
* Research Councils
* Licence:
* This program 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.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
* Authors:
* DSB: David S. Berry (UCLan)
* TIMJ: Tim Jenness (JAC, Hawaii)
* RFWS: R.F. Warren-Smith (STARLINK)
* {enter_new_authors_here}
* History:
* 6-NOV-1996 (DSB):
* Original version.
* 16-SEP-2008 (TIMJ):
* Use modern EMS interface
* 13-NOV-2008 (TIMJ):
* Modify for DRAMA
* {enter_changes_here}
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
/* Module Macros. */
/* ============== */
/* Define the astCLASS macro (even although this is not a class
implementation). This indicates to header files that they should
make "protected" symbols available. */
#define astCLASS
/* Include files. */
/* ============== */
/* Interface definitions. */
/* ---------------------- */
#include "err.h" /* Interface to this module */
/* Need to define these for DRAMA. Otherwise we have to include drama.h
in the distribution as well */
#if HAVE_STDARG_H
# define DSTDARG_OK
#endif
#define ERS_STANDALONE
#include "Ers.h" /* Interface to the Ers system */
/* Function implementations. */
/* ========================= */
void astPutErr_( int status, const char *message ) {
/*
*+
* Name:
* astPutErr
* Purpose:
* Deliver an error message.
* Type:
* Protected function.
* Synopsis:
* #include "err.h"
* void astPutErr( int status, const char *message )
* Description:
* This function delivers an error message and (optionally) an
* accompanying status value to the user. It may be re-implemented
* in order to deliver error messages in different ways, according
* to the environment in which the AST library is being used.
* Parameters:
* status
* The error status value.
* message
* A pointer to a null-terminated character string containing
* the error message to be delivered. This should not contain
* newline characters.
* Notes:
* - This function is documented as "protected" but, in fact, is
* publicly accessible so that it may be re-implemented as
* required.
*-
*/
/* Local Variables: */
StatusType local_status; /* Local status value */
/* Make a copy of the status value supplied. Then invoke ems_rep_c to
report the error message through EMS and to associate the error
status with it. Ignore any returned status value. */
local_status = status;
ErsRep( 0, &local_status, "%s", message );
}
| 29.699187 | 74 | 0.655352 |
643d96e2d29a9f889dd3f87875a8147d8cefe7ca | 5,233 | h | C | sonos_pi3_crossover/src/caps-0.9.26/basics.h | kirkden/sonos_pi3_refresh | cfa997f3a26bd7738eef7b685a9c1e037c53ed7e | [
"MIT"
] | 1 | 2021-03-24T15:14:50.000Z | 2021-03-24T15:14:50.000Z | sonos_pi3_crossover/src/caps-0.9.26/basics.h | kirkden/sonos_pi3_refresh | cfa997f3a26bd7738eef7b685a9c1e037c53ed7e | [
"MIT"
] | null | null | null | sonos_pi3_crossover/src/caps-0.9.26/basics.h | kirkden/sonos_pi3_refresh | cfa997f3a26bd7738eef7b685a9c1e037c53ed7e | [
"MIT"
] | null | null | null | /*
basics.h
Copyright 2004-12 Tim Goetze <tim@quitte.de>
http://quitte.de/dsp/
Common constants, typedefs, utility functions
and simplified LADSPA #defines.
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA or point your web browser to http://www.gnu.org.
*/
#ifndef BASICS_H
#define BASICS_H
#define _GNU_SOURCE 1
#define _USE_GNU 1
/* unlocking some standard math calls. */
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#define _ISOC99_SOURCE 1
#define _ISOC9X_SOURCE 1
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <assert.h>
#include <stdio.h>
#include "ladspa.h"
typedef __int8_t int8;
typedef __uint8_t uint8;
typedef __int16_t int16;
typedef __uint16_t uint16;
typedef __int32_t int32;
typedef __uint32_t uint32;
typedef __int64_t int64;
typedef __uint64_t uint64;
#define MIN_GAIN 1e-6 /* -120 dB */
/* smallest non-denormal 32 bit IEEE float is 1.18e-38 */
#define NOISE_FLOOR 1e-20 /* -400 dB */
#define HARD_RT LADSPA_PROPERTY_HARD_RT_CAPABLE
/* some LADSPA_DEFINES_THAT_COME_WITH_LOTS_OF_CHARACTERS */
#define INPUT LADSPA_PORT_INPUT
#define OUTPUT LADSPA_PORT_OUTPUT
#define CONTROL LADSPA_PORT_CONTROL
#define AUDIO LADSPA_PORT_AUDIO
#define AUDIO_IN AUDIO|INPUT
#define AUDIO_OUT AUDIO|OUTPUT
#define CTRL_IN CONTROL|INPUT
#define CTRL_OUT CONTROL|OUTPUT
/* extending LADSPA_PORT_* */
#define LADSPA_PORT_GROUP (AUDIO<<1) /* 16 */
#define GROUP LADSPA_PORT_GROUP
/* more LADSPA_DEFINES_THAT_REALLY_COME_WITH_LOTS_OF_CHARACTERS */
#define BOUNDED (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE)
#define INTEGER LADSPA_HINT_INTEGER
#define LOG LADSPA_HINT_LOGARITHMIC
#define TOGGLE LADSPA_HINT_TOGGLED
#define DEFAULT_0 LADSPA_HINT_DEFAULT_0
#define DEFAULT_1 LADSPA_HINT_DEFAULT_1
#define DEFAULT_100 LADSPA_HINT_DEFAULT_100
#define DEFAULT_440 LADSPA_HINT_DEFAULT_440
#define DEFAULT_MIN LADSPA_HINT_DEFAULT_MINIMUM
#define DEFAULT_LOW LADSPA_HINT_DEFAULT_LOW
#define DEFAULT_MID LADSPA_HINT_DEFAULT_MIDDLE
#define DEFAULT_HIGH LADSPA_HINT_DEFAULT_HIGH
#define DEFAULT_MAX LADSPA_HINT_DEFAULT_MAXIMUM
/* //////////////////////////////////////////////////////////////////////// */
typedef struct {
const char * name;
LADSPA_PortDescriptor descriptor;
LADSPA_PortRangeHint range;
const char * meta;
} PortInfo;
typedef LADSPA_Data sample_t;
typedef unsigned int uint;
typedef unsigned long ulong;
/* prototype that takes a sample and yields a sample */
typedef sample_t (*clip_func_t) (sample_t);
#ifndef max
template <class X, class Y> X min (X x, Y y) { return x < (X)y ? x : (X)y; }
template <class X, class Y> X max (X x, Y y) { return x > (X)y ? x : (X)y; }
#endif /* ! max */
template <class T>
T clamp (T value, T lower, T upper)
{
if (value < lower) return lower;
if (value > upper) return upper;
return value;
}
static inline float frandom() { return (float) random() / (float) RAND_MAX; }
/* NB: also true if 0 */
inline bool
is_denormal (float & f)
{
int32 i = *((int32 *) &f);
return ((i & 0x7f800000) == 0);
}
/* not used, check validity before using */
inline bool
is_denormal (double & f)
{
int64 i = *((int64 *) &f);
return ((i & 0x7fe0000000000000ll) == 0);
}
/* lovely algorithm from
http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2Float
*/
inline uint
next_power_of_2 (uint n)
{
assert (n <= 0x40000000);
--n;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
return ++n;
}
inline double db2lin (double db) { return pow(10, .05*db); }
inline double lin2db (double lin) { return 20*log10(lin); }
#if defined(__i386__) || defined(__amd64__)
#define TRAP asm ("int $3;")
#else
#define TRAP
#endif
/* //////////////////////////////////////////////////////////////////////// */
#define CAPS "C* "
class Plugin
{
public:
float fs, over_fs; /* sample rate and 1/fs */
float adding_gain; /* for run_adding() */
int first_run; /* 1st block after activate(), do no parameter smoothing */
sample_t normal; /* renormal constant */
sample_t ** ports;
LADSPA_PortRangeHint * ranges; /* for getport() below */
public:
/* get port value, mapping inf or nan to 0 */
inline sample_t getport_unclamped (int i)
{
sample_t v = *ports[i];
return (isinf (v) || isnan(v)) ? 0 : v;
}
/* get port value and clamp to port range */
inline sample_t getport (int i)
{
LADSPA_PortRangeHint & r = ranges[i];
sample_t v = getport_unclamped (i);
return clamp (v, r.LowerBound, r.UpperBound);
}
};
#endif /* BASICS_H */
| 25.402913 | 78 | 0.699408 |
643dad6851871e123d917c07b26bfe7b50b77ba4 | 5,710 | h | C | gateway/afm/data/internal/BluetoothData.h | milligan22963/radar | d4b053509d1e65b385e9337f3eab7dfc4aae412a | [
"MIT"
] | null | null | null | gateway/afm/data/internal/BluetoothData.h | milligan22963/radar | d4b053509d1e65b385e9337f3eab7dfc4aae412a | [
"MIT"
] | null | null | null | gateway/afm/data/internal/BluetoothData.h | milligan22963/radar | d4b053509d1e65b385e9337f3eab7dfc4aae412a | [
"MIT"
] | null | null | null | /*--------------------------------------
BluetoothPacket
Company: AFM Software
Copyright: 2018
--------------------------------------*/
#ifndef _H_BLUETOOTHPACKET
#define _H_BLUETOOTHPACKET
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "DataPacket.h"
/**
* @brief top level namespace for afm library assets
*/
namespace afm
{
/**
* @brief secondary level namespace for data library assets
*/
namespace data
{
static const uint8_t sm_manufacturerSpecific = 0xFF;
// example data over the air
// things typically are length type value
// "rawData":"
// 043e2a020103001c2a0750a0001e0201041aff4c0002150005000100001000800000805f9b013100107167c3a1"
// 04 = b00000100 (HCI_EventPacket)
// 3e = event code (HCI_LEMetaEvent)
// 2a = length of 42
struct __attribute__((packed)) LEAdvertisingPacket
{
uint8_t packetType;
uint8_t eventType;
uint8_t packetLength;
void *pPacketData;
};
// after length we will have all sorts of goodness
// 02 01 03 00 1c2a0750a000 1e0201041aff4c0002150005000100001000800000805f9b013100107167c3a1
// 02 - report type
// 01 - number of reports
// 03 report #1 type
// 00 address type
// address 1c2a0750a00 (lsB to msB)
/**
* The structure defining a bluetooth address
* which is the same as a mac address i.e. 6 uint_8's
*/
static const int sm_bdAddressLength = 6;
struct __attribute__((packed)) BLUETOOTH_ADDRESS
{
uint8_t address[sm_bdAddressLength];
};
/**
* Structure defining an LE advertising report as received as an event
*/
struct __attribute__((packed)) LE_ADVERTISING_DATA_REPORT
{
uint8_t reportType; // type for this report.
uint8_t addressType;
BLUETOOTH_ADDRESS address;
uint8_t payloadLength; // length of data payload (not including RSSI)
uint8_t payload[0];
// RSSI is takced on the end of the packet one beyond the payload length
int8_t getRSSI()
{
return payload[payloadLength]; // last byte is RSSI
}
};
// 1e 02 01 04 1a ff 4c00 02150005000100001000800000805f9b013100107167c3a1
// 1e - payload length - in above structure
// 02 - flags
// 01 - flags 1
// 04 - flags 2
// 1a - length
// ff - manufacturer specific type
// 4c00 - company id
struct __attribute__((packed)) LE_ReportData
{
uint8_t flags[3]; // 3 flags
uint8_t length;
uint8_t manufacturerType;
uint8_t companyId[2];
uint8_t beaconData[0];
};
// 02 15 0005000100001000800000805f9b0131 0010 7167 c3 a1
// 02 - beacon type 0 must be 2
// 15 - beacon type 1 must be 15
// 0005000100001000800000805f9b0131 - uuid
// 0010 major id
// 7167 minor id
// c3 power setting at 1M from a fruit
// a1 - rssi
/**
* Structure defining an LE advertising report as received as an event
*/
struct __attribute__((packed)) LE_ADVERTISING_DATA_PACKET
{
uint8_t eventType;
uint8_t numberReports; // reports can be from 1 to 25
LE_ADVERTISING_DATA_REPORT reports[0];
};
/**
* Structure defining the advertising stucture header
*/
struct __attribute__((packed)) LE_ADVERTISING_DATA_STRUCTURE_HEADER
{
uint8_t length; // length of the combined type and data fields
uint8_t type;
};
/**
* Structure defining an advertising data structure
*/
struct __attribute__((packed)) LE_ADVERTISING_DATA_STRUCTURE : public LE_ADVERTISING_DATA_STRUCTURE_HEADER
{
uint8_t data[0];
};
/**
* Structure defining a manufacturing-specific advertising structure
*/
struct __attribute__((packed)) LE_ADVERTISING_DATA_MANUFACTURE_SPECIFIC : public LE_ADVERTISING_DATA_STRUCTURE_HEADER
{
uint8_t companyId[2];
uint8_t data[0];
};
/*
* Apple beacon format
*
* From apples guide on beacons
*
* This structure contains only those included in the manufacturing-specific data
*/
struct __attribute__((packed)) LEBeaconData
{
uint8_t beaconType[2];
uint8_t uuid[16];
uint16_t major;
union opt_t
{
uint16_t minor; // apple
uint8_t data[2]; // 2 data bytes (Cypress humidity = data[0], temperature = data[1]
} opt;
int8_t power;
};
// pre-declaration for shared ptr definition
class BluetoothDataPacket;
using BluetoothDataPacketSPtr = std::shared_ptr<BluetoothDataPacket>;
/**
* @class BluetoothDataPacket
*
* @brief concrete implementation for Data packets
*/
class BluetoothDataPacket : public DataPacket
{
public:
/**
* @brief default constructor
*/
BluetoothDataPacket();
/**
* @brief default descructor
*/
virtual ~BluetoothDataPacket();
/**
* @copydoc IDataPacket::FromRaw
*/
virtual bool FromRaw(const RawData &rawData) override;
private:
std::string ConvertRawToString(const RawData &rawData);
std::string ConvertBDAddress(BLUETOOTH_ADDRESS *pAddress);
BluetoothDataPacketSPtr ProcessReport(LE_ADVERTISING_DATA_REPORT *pReport);
std::string ConvertCypressTemperature(uint8_t value);
std::string ConvertCypressHumitidy(uint8_t value);
};
}
}
#endif | 28.128079 | 119 | 0.617513 |
643eefbfb16bf8197b09dd3ed9370f1a0e00d1de | 2,928 | c | C | Firmware_Projects_uVision5/Projects/S2E_App/src/retarget.c | ai22ai22/W7500x-Serial-to-Ethernet-device | 1874fa5b1ae067407c3187d7a103a5a03e286c32 | [
"Apache-2.0"
] | 3 | 2016-05-25T15:07:16.000Z | 2020-07-03T16:52:12.000Z | Firmware_Projects_uVision5/Projects/S2E_App/src/retarget.c | hermeszhang/W7500x-Serial-to-Ethernet-device | 1874fa5b1ae067407c3187d7a103a5a03e286c32 | [
"Apache-2.0"
] | null | null | null | Firmware_Projects_uVision5/Projects/S2E_App/src/retarget.c | hermeszhang/W7500x-Serial-to-Ethernet-device | 1874fa5b1ae067407c3187d7a103a5a03e286c32 | [
"Apache-2.0"
] | 9 | 2016-07-12T08:26:34.000Z | 2020-10-16T00:45:19.000Z | /**
******************************************************************************
* @file retarget.c
* @author IOP Team
* @version V1.0.0
* @date 01-May-2015
* @brief Using for printf function
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, WIZnet SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2015 WIZnet Co.,Ltd.</center></h2>
******************************************************************************
*/
#include <stdio.h>
#include "W7500x_uart.h"
//#include "common.h"
//#include "uart_cb.h" // << UART selector
// Replaced the defines for UART Selector to Callback functions.
#define USING_UART2
#if defined (USING_UART0)
#define UART_SEND_BYTE(ch) UartPutc(UART0,ch)
#define UART_RECV_BYTE() UartGetc(UART0)
#elif defined (USING_UART1)
#define UART_SEND_BYTE(ch) UartPutc(UART1,ch)
#define UART_RECV_BYTE() UartGetc(UART1)
#elif defined (USING_UART2)
#define UART_SEND_BYTE(ch) S_UartPutc(ch)
#define UART_RECV_BYTE() S_UartGetc()
#endif
#if defined ( __CC_ARM )
/******************************************************************************/
/* Retarget functions for ARM DS-5 Professional / Keil MDK */
/******************************************************************************/
#include <time.h>
#include <rt_misc.h>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f) {
return (UART_SEND_BYTE(ch));
}
int fgetc(FILE *f) {
return (UART_SEND_BYTE(UART_RECV_BYTE()));
}
int ferror(FILE *f) {
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch) {
UART_SEND_BYTE(ch);
}
void _sys_exit(int return_code) {
label: goto label; /* endless loop */
}
#elif defined (__GNUC__)
/******************************************************************************/
/* Retarget functions for GNU Tools for ARM Embedded Processors */
/******************************************************************************/
#include <sys/stat.h>
__attribute__ ((used)) int _write (int fd, char *ptr, int len)
{
size_t i;
for (i=0; i<len;i++) {
UART_SEND_BYTE(ptr[i]); // call character output function
}
return len;
}
#else //using TOOLCHAIN_IAR
int putchar(int ch)
{
return (UART_SEND_BYTE(ch));
}
int getchar(void)
{
return (UART_SEND_BYTE(UART_RECV_BYTE()));
}
#endif
| 28.153846 | 80 | 0.555669 |
643f54c12004ef2efea79fbc46cc6b203f4edcfe | 396 | h | C | include/lspe/lspe.h | ZYMelaii/LSP-Engine | 675ce5340152e23d9f23c857c99027cd733ef575 | [
"MIT"
] | 1 | 2021-09-23T09:25:32.000Z | 2021-09-23T09:25:32.000Z | include/lspe/lspe.h | ZYMelaii/LSP-Engine | 675ce5340152e23d9f23c857c99027cd733ef575 | [
"MIT"
] | null | null | null | include/lspe/lspe.h | ZYMelaii/LSP-Engine | 675ce5340152e23d9f23c857c99027cd733ef575 | [
"MIT"
] | null | null | null | #ifndef LSPE_H
#define LSPE_H
#include "../lspe/base/base.h"
#include "../lspe/base/vec.h"
#include "../lspe/base/mat.h"
#include "../lspe/bbox.h"
#include "../lspe/abt.h"
#include "../lspe/broadphase.h"
#include "../lspe/shape.h"
#include "../lspe/body.h"
#include "../lspe/fixture.h"
#include "../lspe/contact.h"
#include "../lspe/collision.h"
#include "../lspe/world.h"
#endif /* LSPE_H */
| 20.842105 | 31 | 0.643939 |
644aa7150825b7d9a4dd7565add1941f22c5421a | 4,732 | h | C | Snowplow/Internal/Configurations/SPSubjectConfiguration.h | glukhanyk/snowplow-objc-tracker | ed0bb8302d1cd191d9f9a9bb08c3615f1469f6f4 | [
"Apache-2.0"
] | null | null | null | Snowplow/Internal/Configurations/SPSubjectConfiguration.h | glukhanyk/snowplow-objc-tracker | ed0bb8302d1cd191d9f9a9bb08c3615f1469f6f4 | [
"Apache-2.0"
] | null | null | null | Snowplow/Internal/Configurations/SPSubjectConfiguration.h | glukhanyk/snowplow-objc-tracker | ed0bb8302d1cd191d9f9a9bb08c3615f1469f6f4 | [
"Apache-2.0"
] | null | null | null | //
// SPSubjectConfiguration.h
// Snowplow
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
//
// This program is licensed to you under the Apache License Version 2.0,
// and you may not use this file except in compliance with the Apache License
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
// http://www.apache.org/licenses/LICENSE-2.0.
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the Apache License Version 2.0 is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the Apache License Version 2.0 for the specific
// language governing permissions and limitations there under.
//
// Authors: Alex Benini
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
// License: Apache License Version 2.0
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import "SPConfiguration.h"
NS_ASSUME_NONNULL_BEGIN
@interface SPSize : NSObject <NSCoding>
@property (readonly) NSInteger width;
@property (readonly) NSInteger height;
- initWithWidth:(NSInteger)width height:(NSInteger)height;
@end
NS_SWIFT_NAME(SubjectConfigurationProtocol)
@protocol SPSubjectConfigurationProtocol
/**
* The custom UserID.
*/
@property (nullable) NSString *userId;
/**
* The network UserID.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
@property (nullable) NSString *networkUserId;
/**
* The domain UserID.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
@property (nullable) NSString *domainUserId;
/**
* The user-agent.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
@property (nullable) NSString *useragent;
/**
* The IP address.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
@property (nullable) NSString *ipAddress;
/**
* The current timezone.
*/
@property (nullable) NSString *timezone;
/**
* The language set in the device.
*/
@property (nullable) NSString *language;
/**
* The screen resolution.
*/
@property (nullable) SPSize *screenResolution;
/**
* The screen viewport.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
@property (nullable) SPSize *screenViewPort;
/**
* The color depth.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
@property (nullable) NSNumber *colorDepth;
@end
/**
* This class represents the configuration of the subject.
* The SubjectConfiguration can be used to setup the tracker with the basic information about the
* user and the app which will be attached on all the events as contexts.
* The contexts to track can be enabled in the `TrackerConfiguration` class.
*/
NS_SWIFT_NAME(SubjectConfiguration)
@interface SPSubjectConfiguration : SPConfiguration <SPSubjectConfigurationProtocol>
/**
* The custom UserID.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, userId)
/**
* The network UserID.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, networkUserId)
/**
* The domain UserID.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, domainUserId)
/**
* The user-agent.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, useragent)
/**
* The IP address.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, ipAddress)
/**
* The current timezone.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, timezone)
/**
* The language set in the device.
*/
SP_BUILDER_DECLARE_NULLABLE(NSString *, language)
/**
* The screen resolution.
*/
SP_BUILDER_DECLARE_NULLABLE(SPSize *, screenResolution)
/**
* The screen viewport.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
SP_BUILDER_DECLARE_NULLABLE(SPSize *, screenViewPort)
/**
* The color depth.
* Note: It's not generated by the tracker, it needs to be filled by the developer when instrumenting the tracker.
*/
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, colorDepth)
@end
NS_ASSUME_NONNULL_END
| 31.131579 | 114 | 0.75 |
644acd28cff7c3b546cc4ab38fcc0d5abc662822 | 5,696 | c | C | src/cwb/utils/barlib.c | cran/RcppCWB | aa4440b068dcc16fc378af23d3d63c2683a2e366 | [
"BSD-3-Clause"
] | null | null | null | src/cwb/utils/barlib.c | cran/RcppCWB | aa4440b068dcc16fc378af23d3d63c2683a2e366 | [
"BSD-3-Clause"
] | 58 | 2018-03-11T11:14:26.000Z | 2022-03-28T21:19:21.000Z | src/cwb/utils/barlib.c | cran/RcppCWB | aa4440b068dcc16fc378af23d3d63c2683a2e366 | [
"BSD-3-Clause"
] | 4 | 2018-07-11T23:15:55.000Z | 2021-02-02T16:33:32.000Z | /*
* IMS Open Corpus Workbench (CWB)
* Copyright (C) 1993-2006 by IMS, University of Stuttgart
* Copyright (C) 2007- by the respective contributers (see file AUTHORS)
*
* 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, 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 (in the file "COPYING", or available via
* WWW at http://www.gnu.org/copyleft/gpl.html).
*/
#include "barlib.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
/**
* @file
*
* This file contains the methods for the BARdesc class.
*
* @see BARdesc
*/
/**
* Creates a BAR whose matrix size is N-by-M, with beam width W.
*
* @param N First dimension size for the new matrix (see BARdesc).
* @param M Second dimension size for the new matrix (see BARdesc).
* @param W Beam width size for the new matrix (see BARdesc).
* @return The new BARdesc object.
*/
BARdesc
BAR_new(int N, int M, int W)
{
BARdesc BAR;
int i;
int size, vsize;
BAR = (BARdesc) malloc(sizeof(struct _BARdesc));
assert(BAR);
BAR->x_size = N;
BAR->y_size = M;
BAR->d_size = N + M;
BAR->beam_width = W;
vsize = BAR->d_size;
size = vsize * W;
/* allocate data space */
BAR->data = (int *) malloc(size * sizeof(int));
assert(BAR->data);
BAR->data_size = size;
/* allocate and init access vectors */
BAR->d_block_start_x = (int *) malloc(vsize * sizeof(int));
assert(BAR->d_block_start_x);
for (i = 0; i < BAR->d_size; i++) {
BAR->d_block_start_x[i] = -1;
}
BAR->d_block_data = (int **) malloc(vsize * sizeof(int *));
assert(BAR->d_block_data);
for (i = 0; i < BAR->d_size; i++) {
BAR->d_block_data[i] = BAR->data + (i * W);
}
BAR->vector_size = vsize;
return(BAR);
}
/**
* Changes the size of a BAR (erasing the contents of the BAR).
*
* This function must never be passed a NULL object.
*
* @see BARdesc
*
* @param BAR The BAR to resize.
* @param N First dimension of the new size of matrix (see BARdesc).
* @param M Second dimension of the new size of matrix (see BARdesc).
* @param W Beam width of the new size of matrix (see BARdesc).
*/
void
BAR_reinit(BARdesc BAR, int N, int M, int W)
{
int i;
int size, vsize;
assert(BAR);
BAR->x_size = N;
BAR->y_size = M;
BAR->d_size = N + M;
BAR->beam_width = W;
vsize = BAR-> d_size;
size = vsize * W;
/* reallocate data space if necessary */
if (size > BAR->data_size) {
assert(BAR->data = (int *) realloc(BAR->data, size * sizeof(int)));
BAR->data_size = size;
}
/* reallocate access vectors if necessary */
if (vsize > BAR->vector_size) {
assert(BAR->d_block_start_x = (int *) realloc(BAR->d_block_start_x, vsize * sizeof(int)));
assert(BAR->d_block_data = (int **) realloc(BAR->d_block_data, vsize * sizeof(int *)));
BAR -> vector_size = vsize;
}
/* init access vectors */
for (i = 0; i < BAR->d_size; i++) {
BAR->d_block_data[i] = BAR->data + i*W;
}
for (i = 0; i < BAR->d_size; i++) {
BAR->d_block_start_x[i] = -1;
}
}
/**
* Destroys a BARdesc object.
*
* @param BAR Descriptor of the BAR to destroy.
*/
void
BAR_delete(BARdesc BAR)
{
assert(BAR);
free(BAR->data);
free(BAR->d_block_start_x);
free(BAR->d_block_data);
free(BAR);
}
/**
* Sets an element of a BAR.
*
* Usage:
*
* BAR_write(BAR, x, y, i);
*
* sets A(x,y) = i.
*
* - if (x,y) is outside matrix or beam range, the function call is ignored.
* - if d_(x+y) hasn't been accessed before, the block_start_x value is set to x.
*
* @param BAR BAR descriptor: the matrix we want to write to.
@param x matrix x coordinate of the cell we want to write in.
* @param y matrix y coordinate of the cell we want to write in.
* @param i value to set it to
*
*/
void
BAR_write(BARdesc BAR, int x, int y, int i)
{
int *p, *p1;
if (((unsigned)x < BAR->x_size) && ((unsigned)y < BAR->y_size)) { /* fast bounds check */
int d = x + y;
if (BAR->d_block_start_x[d] < 0) {
/* uninitialised diagonal */
BAR->d_block_start_x[d] = x;
/* initialise diagonal with zeroes */
p1 = BAR->d_block_data[d] + BAR->beam_width;
for (p = BAR->d_block_data[d]; p < p1; p++) *p = 0;
BAR->d_block_data[d][0] = i;
}
else {
/* set value if within beam range */
int dx = x - BAR->d_block_start_x[d];
if ((unsigned)dx < BAR->beam_width) {
BAR->d_block_data[d][dx] = i;
}
}
}
}
/**
* Reads a single integer value from the specified cell of the matrix in a BAR.
*
* Usage:
*
* i = A(x,y)
*
* is expressed as
*
* i = BAR_read(BAR, x, y);
*
* @param BAR BAR descriptor: the matrix we want to read from.
* @param x matrix x coordinate of the value we want.
* @param y matrix y coordinate of the value we want.
* @return the value of A(x,y); if (x,y) is
* outside the matrix or beam range, the function returns 0.
*/
int
BAR_read(BARdesc BAR, int x, int y)
{
if (((unsigned)x < BAR->x_size) && ((unsigned)y < BAR->y_size)) {
int d = x + y;
int x_start = BAR->d_block_start_x[d];
if ((x_start >= 0) && ((unsigned)(x - x_start) < BAR->beam_width)) {
return BAR->d_block_data[d][x - x_start];
}
else {
return 0;
}
}
else {
return 0;
}
}
| 26.12844 | 94 | 0.613413 |
644b327ed318247d9d8a8b253d85c0fb037cdee7 | 1,064 | h | C | BaseEvnTool/Classes/CaseyAbsoluteLayout/CyFrame.h | sunyong445/BaseEvnTool | 46fc71e44e013d7ed1820d94a5b1a0c3a778678a | [
"MIT"
] | 1 | 2018-12-14T03:37:42.000Z | 2018-12-14T03:37:42.000Z | BaseEvnTool/Classes/CaseyAbsoluteLayout/CyFrame.h | sunyong445/BaseEvnTool | 46fc71e44e013d7ed1820d94a5b1a0c3a778678a | [
"MIT"
] | null | null | null | BaseEvnTool/Classes/CaseyAbsoluteLayout/CyFrame.h | sunyong445/BaseEvnTool | 46fc71e44e013d7ed1820d94a5b1a0c3a778678a | [
"MIT"
] | null | null | null | //
// CyFrame.h
// CaseyAbsoluteLayout
//
// Created by Casey on 06/12/2018.
// Copyright © 2018 Casey. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CyFrame : NSObject
@property (nonatomic, weak)UIView *view;
@property (nonatomic, assign)CGFloat left;
@property (nonatomic, assign)CGFloat right;
@property (nonatomic, assign)CGFloat top;
@property (nonatomic, assign)CGFloat bottom;
@property (nonatomic, assign)CGFloat height;
@property (nonatomic, assign)CGFloat width;
@property (nonatomic, assign)CGFloat centerX;
@property (nonatomic, assign)CGFloat centerY;
/*
使用equalSuperView相关方法,注意,只会superview frame的当前状态做关联
不会因superview的Frame变化而变化,这个是绝对布局,可以认为是一次性行为。
所以当出现和你预想的不一样,检查superview的Frame是否发生了变化
*/
- (void)leftEqualSuperViewL;
- (void)rightEqualSuperViewR;
- (void)topEqualSuperViewT;
- (void)bottomEqualSuperViewB;
- (void)centerEqualSuperViewC;
- (void)centerXEqualSuperViewCx;
- (void)centerYEqualSuperViewCy;
- (void)cleanAllStatus;
@end
NS_ASSUME_NONNULL_END
| 20.862745 | 50 | 0.779135 |
644bac23c799758fe58bc3e87c795ec36e71c4e9 | 326 | h | C | Surf/AccessibilityHelper.h | alirawashdeh/surf | 8eb0bc1d663543ec1b104cd1b1ea3c87b0e85cde | [
"MIT"
] | 1 | 2021-05-15T15:37:09.000Z | 2021-05-15T15:37:09.000Z | Surf/AccessibilityHelper.h | alirawashdeh/surf | 8eb0bc1d663543ec1b104cd1b1ea3c87b0e85cde | [
"MIT"
] | null | null | null | Surf/AccessibilityHelper.h | alirawashdeh/surf | 8eb0bc1d663543ec1b104cd1b1ea3c87b0e85cde | [
"MIT"
] | null | null | null | //
// SendKeys.h
// Surf
//
// Created by Ali Rawashdeh on 30/12/2020.
//
#import <Foundation/Foundation.h>
@interface AccessibilityHelper : NSObject
+ (void)returnBackspaceAndCharacterToCursor:(NSString *) emoji label:(NSString*)label;
+ (void)highlightPrevious;
+ (void)rightArrow;
+ (NSRect)getCursorPosition;
@end
| 17.157895 | 86 | 0.730061 |
644cdcd6a8aae90f67235c3d2360bbc092df37a2 | 182 | c | C | src/state.c | OllieDay/liborvibo | 2d11d289c22d2e29ae2ccfb192750f791a233105 | [
"BSD-3-Clause"
] | null | null | null | src/state.c | OllieDay/liborvibo | 2d11d289c22d2e29ae2ccfb192750f791a233105 | [
"BSD-3-Clause"
] | null | null | null | src/state.c | OllieDay/liborvibo | 2d11d289c22d2e29ae2ccfb192750f791a233105 | [
"BSD-3-Clause"
] | null | null | null | #include "state.h"
const char *
orvibo_state_string(const enum orvibo_state state) {
return state == ORVIBO_STATE_UNKNOWN ? "unknown" : state == ORVIBO_STATE_OFF ? "off" : "on";
}
| 26 | 93 | 0.71978 |
644ef9a8ce9b41b826bcb1dc68399ca91b56aa0d | 1,137 | h | C | JLKit/Classes/JLController/Controller+Extension/UIViewController+BarButtonItem_JL.h | jlancer/JLKit | d5f4ff93bb79d2c3f32f7f08ce3955575f1cff7b | [
"MIT"
] | 1 | 2021-08-19T05:52:53.000Z | 2021-08-19T05:52:53.000Z | JLKit/Classes/JLController/Controller+Extension/UIViewController+BarButtonItem_JL.h | jlancer/JLKit | d5f4ff93bb79d2c3f32f7f08ce3955575f1cff7b | [
"MIT"
] | null | null | null | JLKit/Classes/JLController/Controller+Extension/UIViewController+BarButtonItem_JL.h | jlancer/JLKit | d5f4ff93bb79d2c3f32f7f08ce3955575f1cff7b | [
"MIT"
] | 1 | 2019-11-07T01:56:52.000Z | 2019-11-07T01:56:52.000Z | //
// UIViewController+BarButtonItem_JL.h
// JLKit
//
// Created by wangjian on 2019/11/4.
// Copyright © 2019 wangjian. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIViewController (BarButtonItem_JL)
// 增加图片类型导航按钮(左)
- (void)jl_addLeftBarButton:(UIImage *)image action:(void(^)(void))action;
// 增加图片类型导航按钮(右)
- (void)jl_addRightBarButton:(UIImage *)image action:(void(^)(void))action;
// 增加文本类型导航按钮(左)
- (void)jl_addLeftBarTextButton:(NSAttributedString *)text action:(void(^)(void))action;
// 增加文本类型导航按钮(右)
- (void)jl_addRightBarTextButton:(NSAttributedString *)text action:(void(^)(void))action;
// 增加自定义类型导航按钮(左)
- (void)jl_addLeftBarCustomView:(UIView *)customeView action:(void(^)(void))action;
// 增加自定义类型导航按钮(右)
- (void)jl_addRightBarCustomView:(UIView *)customeView action:(void(^)(void))action;
// 移除左侧导航按钮
- (void)jl_removeLeftBarButtons;
// 移除右侧导航按钮
- (void)jl_removeRightBarButtons;
// 增加UIBarButtonItem(Base)
- (void)jl_addBarButton:(BOOL)isLeft object:(id)object size:(CGSize)size margin:(UIEdgeInsets)margin action:(void(^)(void))action;
@end
NS_ASSUME_NONNULL_END
| 25.266667 | 130 | 0.744943 |
644f4b43e0bf0124d34f8ed34f64f51f34bf35dd | 8,623 | h | C | CheatESP.h | DevilZ46/ProjektX | 85be423cf08d42935c42396774fec35b7c5d1625 | [
"MIT"
] | 1 | 2022-01-16T09:42:07.000Z | 2022-01-16T09:42:07.000Z | CheatESP.h | leeza007/ProjectX | 1b6037caaee8ced38991bdb81ad065b46936a859 | [
"MIT"
] | null | null | null | CheatESP.h | leeza007/ProjectX | 1b6037caaee8ced38991bdb81ad065b46936a859 | [
"MIT"
] | 3 | 2021-02-23T04:44:39.000Z | 2021-04-14T05:57:23.000Z | #pragma once
namespace CheatESP
{
void DrawPlayer(cActor* pActor, bool bIsBot, bool bIsHenchMan, bool bIsHenchManNEW, bool bIsHenchManGang1, bool bIsHenchManGang2, bool bIsHenchManGang3);
void DrawMarker(cActor* pActor, const char* sMarkerName);
void DrawMarkerFromTier(cActor* pActor, const char* sMarkerName, BYTE bTier);
bool GetDrawPos(cActor* pActor, RECT& vDrawPos, Vector4 vColor);
bool GetPlayerName(cActor* pActor, char* sPlayerName);
}
void CheatESP::DrawPlayer(cActor* pActor, bool bIsBot, bool bIsHenchMan, bool bIsHenchManNEW, bool bIsHenchManGang1, bool bIsHenchManGang2, bool bIsHenchManGang3)
{
if (!pActor) return;
if (!pActor->SceneComponent) return;
if (!pActor->PlayerState) return;
if (!pActor->PlayerMesh) return;
if (!pActor->PlayerMesh->StaticMesh) return;
if (!Settings::Menu::ESP_OnTeam && Settings::Local::LocalTeam != 0)
if (Settings::Local::LocalTeam == pActor->PlayerState->TeamIndex)
return;
Vector4 DrawColor;
if (Settings::Menu::ESP_CheckKO && pActor->IsDBNO())
DrawColor = Settings::Menu::ESPKnockedDownColor;
else if (Settings::Menu::ESP_CheckVisible && EngineHelper::Internal::LineOfSightTo(pActor))
DrawColor = Settings::Menu::ESPVisibleColor;
else if (bIsBot)
DrawColor = Settings::Menu::ESPBotColor;
else if (Settings::Menu::MARK_Shark)
DrawColor = Settings::Menu::SharkColor;
else if (Settings::Menu::MARK_Llama)
DrawColor = Settings::Menu::LlamaColor;
else if (bIsHenchMan || bIsHenchManNEW || bIsHenchManGang1 || bIsHenchManGang2 || bIsHenchManGang3)
DrawColor = Settings::Menu::ESPHenchManColor;
else
DrawColor = Settings::Menu::ESPColor;
RECT rDraw;
if (!GetDrawPos(pActor, rDraw, DrawColor)) // We draw bones in here.
return;
// 2D Box
if (Settings::Menu::ESP_UseBox)
{
if (Settings::Menu::ESP_FillBox)
RenderHelper::Box(Vector2(rDraw.left, rDraw.top), Vector2(rDraw.right, rDraw.bottom), Settings::Menu::ESP_Thickness, DrawColor.ToColor(.15f), DrawColor);
else
RenderHelper::Box(Vector2(rDraw.left, rDraw.top), Vector2(rDraw.right, rDraw.bottom), Settings::Menu::ESP_Thickness, DrawColor);
}
// Only when we have a valid local pawn.
if (Settings::Local::bIsValid)
{
const float YOffset = 2;
bool bHasDrawText = false;
char sDrawText[1024];
// Name & Distance
if (Settings::Menu::ESP_Username && Settings::Menu::ESP_Distance)
{
char sName[255];
if (GetPlayerName(pActor, sName))
{
sprintf(sDrawText, _xor("[%.0fM] %s\0").c_str(), Settings::Local::Camera.Location.Distance(pActor->SceneComponent->RelativeLocation), sName);
bHasDrawText = true;
}
else
{
sprintf(sDrawText, _xor("[%.0fM]\0").c_str(), Settings::Local::Camera.Location.Distance(pActor->SceneComponent->RelativeLocation));
bHasDrawText = true;
}
}
else if (Settings::Menu::ESP_Distance)
{
bHasDrawText = true;
sprintf(sDrawText, _xor("[%.0fM]\0").c_str(), Settings::Local::Camera.Location.Distance(pActor->SceneComponent->RelativeLocation));
}
else if (Settings::Menu::ESP_Username)
{
char sName[255];
if (GetPlayerName(pActor, sName))
{
sprintf(sDrawText, _xor("%s\0").c_str(), sName);
bHasDrawText = true;
}
}
if (bHasDrawText)
{
if (Settings::Menu::ESP_FillText)
RenderHelper::Text(RenderHelper::pFonts[1], Vector2(rDraw.left + (rDraw.right / 2), rDraw.top - (Settings::Menu::ESP_FontSize + YOffset)), sDrawText, DrawColor, Settings::Menu::TextFillColor, Settings::Menu::ESP_FontSize, true);
else
RenderHelper::Text(RenderHelper::pFonts[1], Vector2(rDraw.left + (rDraw.right / 2), rDraw.top - (Settings::Menu::ESP_FontSize + YOffset)), sDrawText, DrawColor, Settings::Menu::ESP_FontSize, true);
}
}
}
void CheatESP::DrawMarker(cActor* pActor, const char* sMarkerName)
{
if (!pActor) return;
if (!pActor->SceneComponent) return;
float fDistance = Settings::Local::Camera.Location.Distance(pActor->SceneComponent->RelativeLocation);
float fRadius = (fDistance > 50) ? 3.0f : 5.5f;
if (fDistance > Settings::Menu::MARK_MaxDistance || fDistance < 10.0f)
return;
Vector3 vScreenPos;
if (!EngineHelper::Internal::WorldToScreen(pActor->SceneComponent->RelativeLocation, &vScreenPos))
return;
char sBuffer[256];
if (Settings::Menu::ESP_Distance)
sprintf(sBuffer, _xor("[%.0fM] %s\0").c_str(), fDistance, sMarkerName);
else
sprintf(sBuffer, _xor("%s\0").c_str(), sMarkerName);
RenderHelper::Cirlce(vScreenPos.ToVec2(), Settings::Menu::ESP_Thickness, fRadius, Settings::Menu::MarkerColor);
vScreenPos.y += (fRadius + 3.0f);
if (Settings::Menu::ESP_FillText)
RenderHelper::Text(RenderHelper::pFonts[1], vScreenPos.ToVec2(), sBuffer, Settings::Menu::MarkerColor, Settings::Menu::TextFillColor, Settings::Menu::ESP_FontSize, true);
else
RenderHelper::Text(RenderHelper::pFonts[1], vScreenPos.ToVec2(), sBuffer, Settings::Menu::MarkerColor, Settings::Menu::ESP_FontSize, true);
}
void CheatESP::DrawMarkerFromTier(cActor* pActor, const char* sMarkerName, BYTE bTier)
{
if (!pActor) return;
if (!pActor->SceneComponent) return;
float fDistance = Settings::Local::Camera.Location.Distance(pActor->SceneComponent->RelativeLocation);
float fRadius = (fDistance > 50) ? 3.0f : 5.5f;
if (fDistance > Settings::Menu::MARK_MaxDistance)
return;
Vector3 vScreenPos;
if (!EngineHelper::Internal::WorldToScreen(pActor->SceneComponent->RelativeLocation, &vScreenPos))
return;
char sBuffer[256];
if (Settings::Menu::ESP_Distance)
sprintf(sBuffer, _xor("[%.0fM] %s\0").c_str(), fDistance, sMarkerName);
else
sprintf(sBuffer, _xor("%s\0").c_str(), sMarkerName);
RenderHelper::Cirlce(vScreenPos.ToVec2(), Settings::Menu::ESP_Thickness, fRadius, EngineHelper::Toggle::TierToColor(bTier));
vScreenPos.y += (fRadius + 3.0f);
if (Settings::Menu::ESP_FillText)
RenderHelper::Text(RenderHelper::pFonts[1], vScreenPos.ToVec2(), sBuffer, EngineHelper::Toggle::TierToColor(bTier), Settings::Menu::TextFillColor, Settings::Menu::ESP_FontSize, true);
else
RenderHelper::Text(RenderHelper::pFonts[1], vScreenPos.ToVec2(), sBuffer, EngineHelper::Toggle::TierToColor(bTier), Settings::Menu::ESP_FontSize, true);
}
bool CheatESP::GetDrawPos(cActor* pActor, RECT& vDrawPos, Vector4 vColor)
{
if (!pActor) return false;
if (!pActor->SceneComponent) return false;
if (!pActor->PlayerMesh) return false;
if (!pActor->PlayerMesh->StaticMesh) return false;
Vector3 vPos[100];
std::vector<int32_t> nBoneIDS = { 66 ,65 ,36 ,2 ,9 ,62,10,38,11,39,67,74,73,80,68,75,71,78,72,79 };
std::vector<std::vector<int32_t>> nBonePairs = {
{99, 1},
{1, 3},
{2, 4},
{2, 5},
{4, 6},
{5, 7},
{6, 8},
{7, 9},
{3, 10},
{3, 11},
{10, 12},
{11, 13},
{12, 14},
{13, 15},
{14, 16},
{15, 17},
{16, 18},
{17, 19}
};
size_t nIndex = 0;
float minX = FLT_MAX;
float maxX = -FLT_MAX;
float minY = FLT_MAX;
float maxY = -FLT_MAX;
for (auto ID : nBoneIDS)
{
bool bResult = false;
if (ID == 66)
{
Vector3 vWorldPos;
if (EngineHelper::Internal::GetBoneWorld(pActor, 66, &vWorldPos))
{
EngineHelper::Internal::WorldToScreen(vWorldPos, &vPos[99]);
vWorldPos.z += 15.5f;
bResult = EngineHelper::Internal::WorldToScreen(vWorldPos, &vPos[nIndex]);
}
}
else
{
nIndex++;
bResult = EngineHelper::Internal::GetBoneScreen(pActor, ID, &vPos[nIndex]);
}
if (bResult)
{
minX = min(vPos[nIndex].x, minX);
maxX = max(vPos[nIndex].x, maxX);
minY = min(vPos[nIndex].y, minY);
maxY = max(vPos[nIndex].y, maxY);
}
}
RECT rResult;
rResult.top = minY;
rResult.bottom = maxY - minY;
rResult.left = minX;
rResult.right = maxX - minX;
vDrawPos = rResult;
// Draw Bones..
if (Settings::Menu::ESP_Bones)
for (auto Pair : nBonePairs)
RenderHelper::Line(vPos[Pair.at(0)].ToVec2(), vPos[Pair.at(1)].ToVec2(), Settings::Menu::ESP_Thickness, vColor);
return true;
}
bool CheatESP::GetPlayerName(cActor* pActor, char* sPlayerName)
{
if (!pActor) return false;
if (!pActor->PlayerState)return false;
if (!Hook_ProcessEvent::Details::bIsHooked) return false;
FString Buffer;
SpoofCall(Hook_ProcessEvent::HkProcessEvent, (PVOID)pActor->PlayerState, (PVOID)Settings::BaseOffsets::GetPlayerName, (PVOID)&Buffer, (PVOID)0);
if (!Buffer.c_str())
return false;
wcstombs(sPlayerName, Buffer.c_str(), sizeof(sPlayerName));
EngineHelper::UObjects::FreeObjName((uintptr_t)Buffer.c_str());
return true;
}
| 33.293436 | 233 | 0.686652 |
644f59b8801820f2781cb109edeb106d8167a3e3 | 5,411 | c | C | misc/win32/env.c | ystk/debian-apr | fae1ea607d107c123364385b0b05b41f07be516e | [
"Apache-2.0"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | misc/win32/env.c | ystk/debian-apr | fae1ea607d107c123364385b0b05b41f07be516e | [
"Apache-2.0"
] | 2,917 | 2015-01-12T16:17:49.000Z | 2022-03-31T11:57:47.000Z | misc/win32/env.c | ystk/debian-apr | fae1ea607d107c123364385b0b05b41f07be516e | [
"Apache-2.0"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | /* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "apr.h"
#include "apr_arch_misc.h"
#include "apr_arch_utf8.h"
#include "apr_env.h"
#include "apr_errno.h"
#include "apr_pools.h"
#include "apr_strings.h"
#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE)
static apr_status_t widen_envvar_name (apr_wchar_t *buffer,
apr_size_t bufflen,
const char *envvar)
{
apr_size_t inchars;
apr_status_t status;
inchars = strlen(envvar) + 1;
status = apr_conv_utf8_to_ucs2(envvar, &inchars, buffer, &bufflen);
if (status == APR_INCOMPLETE)
status = APR_ENAMETOOLONG;
return status;
}
#endif
APR_DECLARE(apr_status_t) apr_env_get(char **value,
const char *envvar,
apr_pool_t *pool)
{
#if defined(_WIN32_WCE)
return APR_ENOTIMPL;
#else
char *val = NULL;
DWORD size;
#if APR_HAS_UNICODE_FS
IF_WIN_OS_IS_UNICODE
{
apr_wchar_t wenvvar[APR_PATH_MAX];
apr_size_t inchars, outchars;
apr_wchar_t *wvalue, dummy;
apr_status_t status;
status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar);
if (status)
return status;
SetLastError(0);
size = GetEnvironmentVariableW(wenvvar, &dummy, 0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
/* The environment variable doesn't exist. */
return APR_ENOENT;
if (size == 0) {
/* The environment value exists, but is zero-length. */
*value = apr_pstrdup(pool, "");
return APR_SUCCESS;
}
wvalue = apr_palloc(pool, size * sizeof(*wvalue));
size = GetEnvironmentVariableW(wenvvar, wvalue, size);
inchars = wcslen(wvalue) + 1;
outchars = 3 * inchars; /* Enough for any UTF-8 representation */
val = apr_palloc(pool, outchars);
status = apr_conv_ucs2_to_utf8(wvalue, &inchars, val, &outchars);
if (status)
return status;
}
#endif
#if APR_HAS_ANSI_FS
ELSE_WIN_OS_IS_ANSI
{
char dummy;
SetLastError(0);
size = GetEnvironmentVariableA(envvar, &dummy, 0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
/* The environment variable doesn't exist. */
return APR_ENOENT;
if (size == 0) {
/* The environment value exists, but is zero-length. */
*value = apr_pstrdup(pool, "");
return APR_SUCCESS;
}
val = apr_palloc(pool, size);
size = GetEnvironmentVariableA(envvar, val, size);
if (size == 0)
/* Mid-air collision?. Somebody must've changed the env. var. */
return APR_INCOMPLETE;
}
#endif
*value = val;
return APR_SUCCESS;
#endif
}
APR_DECLARE(apr_status_t) apr_env_set(const char *envvar,
const char *value,
apr_pool_t *pool)
{
#if defined(_WIN32_WCE)
return APR_ENOTIMPL;
#else
#if APR_HAS_UNICODE_FS
IF_WIN_OS_IS_UNICODE
{
apr_wchar_t wenvvar[APR_PATH_MAX];
apr_wchar_t *wvalue;
apr_size_t inchars, outchars;
apr_status_t status;
status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar);
if (status)
return status;
outchars = inchars = strlen(value) + 1;
wvalue = apr_palloc(pool, outchars * sizeof(*wvalue));
status = apr_conv_utf8_to_ucs2(value, &inchars, wvalue, &outchars);
if (status)
return status;
if (!SetEnvironmentVariableW(wenvvar, wvalue))
return apr_get_os_error();
}
#endif
#if APR_HAS_ANSI_FS
ELSE_WIN_OS_IS_ANSI
{
if (!SetEnvironmentVariableA(envvar, value))
return apr_get_os_error();
}
#endif
return APR_SUCCESS;
#endif
}
APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool)
{
#if defined(_WIN32_WCE)
return APR_ENOTIMPL;
#else
#if APR_HAS_UNICODE_FS
IF_WIN_OS_IS_UNICODE
{
apr_wchar_t wenvvar[APR_PATH_MAX];
apr_status_t status;
status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar);
if (status)
return status;
if (!SetEnvironmentVariableW(wenvvar, NULL))
return apr_get_os_error();
}
#endif
#if APR_HAS_ANSI_FS
ELSE_WIN_OS_IS_ANSI
{
if (!SetEnvironmentVariableA(envvar, NULL))
return apr_get_os_error();
}
#endif
return APR_SUCCESS;
#endif
}
| 28.036269 | 78 | 0.625208 |
64501de67c7637dd62aabeaee078391ef2e00e23 | 1,481 | h | C | components/net/lwip/port/netif/ethernetif.h | cazure/rt-thread | 1bdde743433d331740766c895ff867df6268df20 | [
"Apache-2.0"
] | 2 | 2022-03-04T02:47:55.000Z | 2022-03-04T05:55:31.000Z | components/net/lwip/port/netif/ethernetif.h | cazure/rt-thread | 1bdde743433d331740766c895ff867df6268df20 | [
"Apache-2.0"
] | 1 | 2018-12-20T00:02:50.000Z | 2018-12-20T00:02:50.000Z | components/net/lwip/port/netif/ethernetif.h | cazure/rt-thread | 1bdde743433d331740766c895ff867df6268df20 | [
"Apache-2.0"
] | 1 | 2022-01-25T02:14:32.000Z | 2022-01-25T02:14:32.000Z | /*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-02-22 xiangxistu integrate v1.4.1 v2.0.3 and v2.1.2 porting layer
*/
#ifndef __NETIF_ETHERNETIF_H__
#define __NETIF_ETHERNETIF_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "lwip/netif.h"
#include <rtthread.h>
#define NIOCTL_GADDR 0x01
#ifndef RT_LWIP_ETH_MTU
#define ETHERNET_MTU 1500
#else
#define ETHERNET_MTU RT_LWIP_ETH_MTU
#endif
/* eth flag with auto_linkup or phy_linkup */
#define ETHIF_LINK_AUTOUP 0x0000
#define ETHIF_LINK_PHYUP 0x0100
struct eth_device
{
/* inherit from rt_device */
struct rt_device parent;
/* network interface for lwip */
struct netif *netif;
rt_uint16_t flags;
rt_uint8_t link_changed;
rt_uint8_t link_status;
rt_uint8_t rx_notice;
/* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev);
rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
};
int eth_system_device_init(void);
void eth_device_deinit(struct eth_device *dev);
rt_err_t eth_device_ready(struct eth_device* dev);
rt_err_t eth_device_init(struct eth_device * dev, const char *name);
rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
#ifdef __cplusplus
}
#endif
#endif /* __NETIF_ETHERNETIF_H__ */
| 23.887097 | 95 | 0.728562 |
64511c4a52001c574bbd76cb4174d51fc1364ba3 | 10,045 | c | C | arch/x86/kernel/cpu/sgx/virt.c | Server2356/Sun-Kernel | 63cc54a6948ba572388f829c1fd641ffde0803d8 | [
"MIT"
] | 3 | 2022-03-11T06:46:44.000Z | 2022-03-14T18:04:48.000Z | kernel/arch/x86/kernel/cpu/sgx/virt.c | SFIP/SFIP | e428a425d2d0e287f23d49f3dd583617ebd2e4a3 | [
"Zlib"
] | 1 | 2021-01-27T01:29:47.000Z | 2021-01-27T01:29:47.000Z | kernel/arch/x86/kernel/cpu/sgx/virt.c | SFIP/SFIP | e428a425d2d0e287f23d49f3dd583617ebd2e4a3 | [
"Zlib"
] | null | null | null | // SPDX-License-Identifier: GPL-2.0
/*
* Device driver to expose SGX enclave memory to KVM guests.
*
* Copyright(c) 2021 Intel Corporation.
*/
#include <linux/miscdevice.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/sched/mm.h>
#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/xarray.h>
#include <asm/sgx.h>
#include <uapi/asm/sgx.h>
#include "encls.h"
#include "sgx.h"
struct sgx_vepc {
struct xarray page_array;
struct mutex lock;
};
/*
* Temporary SECS pages that cannot be EREMOVE'd due to having child in other
* virtual EPC instances, and the lock to protect it.
*/
static struct mutex zombie_secs_pages_lock;
static struct list_head zombie_secs_pages;
static int __sgx_vepc_fault(struct sgx_vepc *vepc,
struct vm_area_struct *vma, unsigned long addr)
{
struct sgx_epc_page *epc_page;
unsigned long index, pfn;
int ret;
WARN_ON(!mutex_is_locked(&vepc->lock));
/* Calculate index of EPC page in virtual EPC's page_array */
index = vma->vm_pgoff + PFN_DOWN(addr - vma->vm_start);
epc_page = xa_load(&vepc->page_array, index);
if (epc_page)
return 0;
epc_page = sgx_alloc_epc_page(vepc, false);
if (IS_ERR(epc_page))
return PTR_ERR(epc_page);
ret = xa_err(xa_store(&vepc->page_array, index, epc_page, GFP_KERNEL));
if (ret)
goto err_free;
pfn = PFN_DOWN(sgx_get_epc_phys_addr(epc_page));
ret = vmf_insert_pfn(vma, addr, pfn);
if (ret != VM_FAULT_NOPAGE) {
ret = -EFAULT;
goto err_delete;
}
return 0;
err_delete:
xa_erase(&vepc->page_array, index);
err_free:
sgx_free_epc_page(epc_page);
return ret;
}
static vm_fault_t sgx_vepc_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct sgx_vepc *vepc = vma->vm_private_data;
int ret;
mutex_lock(&vepc->lock);
ret = __sgx_vepc_fault(vepc, vma, vmf->address);
mutex_unlock(&vepc->lock);
if (!ret)
return VM_FAULT_NOPAGE;
if (ret == -EBUSY && (vmf->flags & FAULT_FLAG_ALLOW_RETRY)) {
mmap_read_unlock(vma->vm_mm);
return VM_FAULT_RETRY;
}
return VM_FAULT_SIGBUS;
}
static const struct vm_operations_struct sgx_vepc_vm_ops = {
.fault = sgx_vepc_fault,
};
static int sgx_vepc_mmap(struct file *file, struct vm_area_struct *vma)
{
struct sgx_vepc *vepc = file->private_data;
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
vma->vm_ops = &sgx_vepc_vm_ops;
/* Don't copy VMA in fork() */
vma->vm_flags |= VM_PFNMAP | VM_IO | VM_DONTDUMP | VM_DONTCOPY;
vma->vm_private_data = vepc;
return 0;
}
static int sgx_vepc_free_page(struct sgx_epc_page *epc_page)
{
int ret;
/*
* Take a previously guest-owned EPC page and return it to the
* general EPC page pool.
*
* Guests can not be trusted to have left this page in a good
* state, so run EREMOVE on the page unconditionally. In the
* case that a guest properly EREMOVE'd this page, a superfluous
* EREMOVE is harmless.
*/
ret = __eremove(sgx_get_epc_virt_addr(epc_page));
if (ret) {
/*
* Only SGX_CHILD_PRESENT is expected, which is because of
* EREMOVE'ing an SECS still with child, in which case it can
* be handled by EREMOVE'ing the SECS again after all pages in
* virtual EPC have been EREMOVE'd. See comments in below in
* sgx_vepc_release().
*
* The user of virtual EPC (KVM) needs to guarantee there's no
* logical processor is still running in the enclave in guest,
* otherwise EREMOVE will get SGX_ENCLAVE_ACT which cannot be
* handled here.
*/
WARN_ONCE(ret != SGX_CHILD_PRESENT, EREMOVE_ERROR_MESSAGE,
ret, ret);
return ret;
}
sgx_free_epc_page(epc_page);
return 0;
}
static int sgx_vepc_release(struct inode *inode, struct file *file)
{
struct sgx_vepc *vepc = file->private_data;
struct sgx_epc_page *epc_page, *tmp, *entry;
unsigned long index;
LIST_HEAD(secs_pages);
xa_for_each(&vepc->page_array, index, entry) {
/*
* Remove all normal, child pages. sgx_vepc_free_page()
* will fail if EREMOVE fails, but this is OK and expected on
* SECS pages. Those can only be EREMOVE'd *after* all their
* child pages. Retries below will clean them up.
*/
if (sgx_vepc_free_page(entry))
continue;
xa_erase(&vepc->page_array, index);
}
/*
* Retry EREMOVE'ing pages. This will clean up any SECS pages that
* only had children in this 'epc' area.
*/
xa_for_each(&vepc->page_array, index, entry) {
epc_page = entry;
/*
* An EREMOVE failure here means that the SECS page still
* has children. But, since all children in this 'sgx_vepc'
* have been removed, the SECS page must have a child on
* another instance.
*/
if (sgx_vepc_free_page(epc_page))
list_add_tail(&epc_page->list, &secs_pages);
xa_erase(&vepc->page_array, index);
}
/*
* SECS pages are "pinned" by child pages, and "unpinned" once all
* children have been EREMOVE'd. A child page in this instance
* may have pinned an SECS page encountered in an earlier release(),
* creating a zombie. Since some children were EREMOVE'd above,
* try to EREMOVE all zombies in the hopes that one was unpinned.
*/
mutex_lock(&zombie_secs_pages_lock);
list_for_each_entry_safe(epc_page, tmp, &zombie_secs_pages, list) {
/*
* Speculatively remove the page from the list of zombies,
* if the page is successfully EREMOVE'd it will be added to
* the list of free pages. If EREMOVE fails, throw the page
* on the local list, which will be spliced on at the end.
*/
list_del(&epc_page->list);
if (sgx_vepc_free_page(epc_page))
list_add_tail(&epc_page->list, &secs_pages);
}
if (!list_empty(&secs_pages))
list_splice_tail(&secs_pages, &zombie_secs_pages);
mutex_unlock(&zombie_secs_pages_lock);
xa_destroy(&vepc->page_array);
kfree(vepc);
return 0;
}
static int sgx_vepc_open(struct inode *inode, struct file *file)
{
struct sgx_vepc *vepc;
vepc = kzalloc(sizeof(struct sgx_vepc), GFP_KERNEL);
if (!vepc)
return -ENOMEM;
mutex_init(&vepc->lock);
xa_init(&vepc->page_array);
file->private_data = vepc;
return 0;
}
static const struct file_operations sgx_vepc_fops = {
.owner = THIS_MODULE,
.open = sgx_vepc_open,
.release = sgx_vepc_release,
.mmap = sgx_vepc_mmap,
};
static struct miscdevice sgx_vepc_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "sgx_vepc",
.nodename = "sgx_vepc",
.fops = &sgx_vepc_fops,
};
int __init sgx_vepc_init(void)
{
/* SGX virtualization requires KVM to work */
if (!cpu_feature_enabled(X86_FEATURE_VMX))
return -ENODEV;
INIT_LIST_HEAD(&zombie_secs_pages);
mutex_init(&zombie_secs_pages_lock);
return misc_register(&sgx_vepc_dev);
}
/**
* sgx_virt_ecreate() - Run ECREATE on behalf of guest
* @pageinfo: Pointer to PAGEINFO structure
* @secs: Userspace pointer to SECS page
* @trapnr: trap number injected to guest in case of ECREATE error
*
* Run ECREATE on behalf of guest after KVM traps ECREATE for the purpose
* of enforcing policies of guest's enclaves, and return the trap number
* which should be injected to guest in case of any ECREATE error.
*
* Return:
* - 0: ECREATE was successful.
* - <0: on error.
*/
int sgx_virt_ecreate(struct sgx_pageinfo *pageinfo, void __user *secs,
int *trapnr)
{
int ret;
/*
* @secs is an untrusted, userspace-provided address. It comes from
* KVM and is assumed to be a valid pointer which points somewhere in
* userspace. This can fault and call SGX or other fault handlers when
* userspace mapping @secs doesn't exist.
*
* Add a WARN() to make sure @secs is already valid userspace pointer
* from caller (KVM), who should already have handled invalid pointer
* case (for instance, made by malicious guest). All other checks,
* such as alignment of @secs, are deferred to ENCLS itself.
*/
if (WARN_ON_ONCE(!access_ok(secs, PAGE_SIZE)))
return -EINVAL;
__uaccess_begin();
ret = __ecreate(pageinfo, (void *)secs);
__uaccess_end();
if (encls_faulted(ret)) {
*trapnr = ENCLS_TRAPNR(ret);
return -EFAULT;
}
/* ECREATE doesn't return an error code, it faults or succeeds. */
WARN_ON_ONCE(ret);
return 0;
}
EXPORT_SYMBOL_GPL(sgx_virt_ecreate);
static int __sgx_virt_einit(void __user *sigstruct, void __user *token,
void __user *secs)
{
int ret;
/*
* Make sure all userspace pointers from caller (KVM) are valid.
* All other checks deferred to ENCLS itself. Also see comment
* for @secs in sgx_virt_ecreate().
*/
#define SGX_EINITTOKEN_SIZE 304
if (WARN_ON_ONCE(!access_ok(sigstruct, sizeof(struct sgx_sigstruct)) ||
!access_ok(token, SGX_EINITTOKEN_SIZE) ||
!access_ok(secs, PAGE_SIZE)))
return -EINVAL;
__uaccess_begin();
ret = __einit((void *)sigstruct, (void *)token, (void *)secs);
__uaccess_end();
return ret;
}
/**
* sgx_virt_einit() - Run EINIT on behalf of guest
* @sigstruct: Userspace pointer to SIGSTRUCT structure
* @token: Userspace pointer to EINITTOKEN structure
* @secs: Userspace pointer to SECS page
* @lepubkeyhash: Pointer to guest's *virtual* SGX_LEPUBKEYHASH MSR values
* @trapnr: trap number injected to guest in case of EINIT error
*
* Run EINIT on behalf of guest after KVM traps EINIT. If SGX_LC is available
* in host, SGX driver may rewrite the hardware values at wish, therefore KVM
* needs to update hardware values to guest's virtual MSR values in order to
* ensure EINIT is executed with expected hardware values.
*
* Return:
* - 0: EINIT was successful.
* - <0: on error.
*/
int sgx_virt_einit(void __user *sigstruct, void __user *token,
void __user *secs, u64 *lepubkeyhash, int *trapnr)
{
int ret;
if (!cpu_feature_enabled(X86_FEATURE_SGX_LC)) {
ret = __sgx_virt_einit(sigstruct, token, secs);
} else {
preempt_disable();
sgx_update_lepubkeyhash(lepubkeyhash);
ret = __sgx_virt_einit(sigstruct, token, secs);
preempt_enable();
}
/* Propagate up the error from the WARN_ON_ONCE in __sgx_virt_einit() */
if (ret == -EINVAL)
return ret;
if (encls_faulted(ret)) {
*trapnr = ENCLS_TRAPNR(ret);
return -EFAULT;
}
return ret;
}
EXPORT_SYMBOL_GPL(sgx_virt_einit);
| 26.574074 | 77 | 0.717073 |
6451e8baa9af9ad89570cf9aee24893fa8504663 | 622 | h | C | YahooSDKDemo/YOContactViewController.h | Vaibhav8080-2/yos-social-objc | b94cc3bbde61f568dc3726bb00d47ef137cc3656 | [
"Unlicense"
] | null | null | null | YahooSDKDemo/YOContactViewController.h | Vaibhav8080-2/yos-social-objc | b94cc3bbde61f568dc3726bb00d47ef137cc3656 | [
"Unlicense"
] | null | null | null | YahooSDKDemo/YOContactViewController.h | Vaibhav8080-2/yos-social-objc | b94cc3bbde61f568dc3726bb00d47ef137cc3656 | [
"Unlicense"
] | null | null | null | //
// YOViewController.h
// YahooSDKDemo
//
// Created by Michael Ho on 8/5/14.
// Copyright 2014 Yahoo Inc.
//
// The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license.
//
#import <UIKit/UIKit.h>
@interface YOContactViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UINavigationBar *topNavigationBar;
@property (strong, nonatomic) NSArray *contactList;
- (void)loadContactList:(NSArray *)contactList;
- (void)skipToProfile;
@end
| 27.043478 | 113 | 0.763666 |
6451f9e37a5252b75bddda9f5de409e8e2569031 | 7,106 | h | C | symengine/polys/uintpoly_flint.h | shifan3/symengine | d9539af520c4b121aff780d27ba22cced9983ece | [
"MIT"
] | 2 | 2020-11-06T12:45:03.000Z | 2022-03-18T18:00:15.000Z | symengine/polys/uintpoly_flint.h | QNjeason/symengine | 7b39028f5d642f4c81e4e4a0cf918326d12d13d6 | [
"MIT"
] | null | null | null | symengine/polys/uintpoly_flint.h | QNjeason/symengine | 7b39028f5d642f4c81e4e4a0cf918326d12d13d6 | [
"MIT"
] | null | null | null | /**
* \file uintpoly_flint.h
* Class for Polynomial: UIntPolyFlint
**/
#ifndef SYMENGINE_UINTPOLY_FLINT_H
#define SYMENGINE_UINTPOLY_FLINT_H
#include <symengine/polys/upolybase.h>
#ifdef HAVE_SYMENGINE_FLINT
#include <symengine/flint_wrapper.h>
using fzp_t = SymEngine::fmpz_poly_wrapper;
using fqp_t = SymEngine::fmpq_poly_wrapper;
namespace SymEngine
{
template <typename Container, template <typename X, typename Y> class BaseType,
typename Poly>
class UFlintPoly : public BaseType<Container, Poly>
{
public:
using Cf = typename BaseType<Container, Poly>::coef_type;
UFlintPoly(const RCP<const Basic> &var, Container &&dict)
: BaseType<Container, Poly>(var, std::move(dict))
{
}
int compare(const Basic &o) const
{
SYMENGINE_ASSERT(is_a<Poly>(o))
const Poly &s = down_cast<const Poly &>(o);
if (this->get_poly().degree() != s.get_poly().degree())
return (this->get_poly().degree() < s.get_poly().degree()) ? -1 : 1;
int cmp = this->get_var()->compare(*s.get_var());
if (cmp != 0)
return cmp;
for (unsigned int i = 0; i < this->get_poly().length(); ++i) {
if (this->get_poly().get_coeff(i) != s.get_poly().get_coeff(i))
return (this->get_poly().get_coeff(i)
< s.get_poly().get_coeff(i))
? -1
: 1;
}
return 0;
}
static Container container_from_dict(const RCP<const Basic> &var,
std::map<unsigned, Cf> &&d)
{
Container f;
for (auto const &p : d) {
if (p.second != 0) {
typename Container::internal_coef_type r(get_mp_t(p.second));
f.set_coeff(p.first, r);
}
}
return std::move(f);
}
static RCP<const Poly> from_vec(const RCP<const Basic> &var,
const std::vector<Cf> &v)
{
// TODO improve this (we already know the degree)
Container f;
for (unsigned int i = 0; i < v.size(); i++) {
if (v[i] != 0) {
typename Container::internal_coef_type r(get_mp_t(v[i]));
f.set_coeff(i, r);
}
}
return make_rcp<const Poly>(var, std::move(f));
}
template <typename FromPoly>
static enable_if_t<is_a_UPoly<FromPoly>::value, RCP<const Poly>>
from_poly(const FromPoly &p)
{
Container f;
for (auto it = p.begin(); it != p.end(); ++it) {
typename Container::internal_coef_type r(get_mp_t(it->second));
f.set_coeff(it->first, r);
}
return Poly::from_container(p.get_var(), std::move(f));
}
Cf eval(const Cf &x) const
{
typename Container::internal_coef_type r(get_mp_t(x));
return to_mp_class(this->get_poly().eval(r));
}
Cf get_coeff(unsigned int x) const
{
return to_mp_class(this->get_poly().get_coeff(x));
}
// can't return by reference
Cf get_coeff_ref(unsigned int x) const
{
return to_mp_class(this->get_poly().get_coeff(x));
}
typedef ContainerForIter<Poly, Cf> iterator;
typedef ContainerRevIter<Poly, Cf> r_iterator;
iterator begin() const
{
return iterator(this->template rcp_from_this_cast<Poly>(), 0);
}
iterator end() const
{
return iterator(this->template rcp_from_this_cast<Poly>(), size());
}
r_iterator obegin() const
{
return r_iterator(this->template rcp_from_this_cast<Poly>(),
(long)size() - 1);
}
r_iterator oend() const
{
return r_iterator(this->template rcp_from_this_cast<Poly>(), -1);
}
int size() const
{
return numeric_cast<int>(this->get_poly().length());
}
};
class UIntPolyFlint : public UFlintPoly<fzp_t, UIntPolyBase, UIntPolyFlint>
{
public:
IMPLEMENT_TYPEID(SYMENGINE_UINTPOLYFLINT)
//! Constructor of UIntPolyFlint class
UIntPolyFlint(const RCP<const Basic> &var, fzp_t &&dict);
//! \return size of the hash
hash_t __hash__() const;
}; // UIntPolyFlint
class URatPolyFlint : public UFlintPoly<fqp_t, URatPolyBase, URatPolyFlint>
{
public:
IMPLEMENT_TYPEID(SYMENGINE_URATPOLYFLINT)
//! Constructor of URatPolyFlint class
URatPolyFlint(const RCP<const Basic> &var, fqp_t &&dict);
//! \return size of the hash
hash_t __hash__() const;
}; // URatPolyFlint
template <typename Container, template <typename X, typename Y> class BaseType,
typename Poly>
std::vector<std::pair<RCP<const Poly>, long>>
factors(const UFlintPoly<Container, BaseType, Poly> &a)
{
auto fac_wrapper = a.get_poly().factors();
auto &fac = fac_wrapper.get_fmpz_poly_factor_t();
std::vector<std::pair<RCP<const Poly>, long>> S;
if (fac->c != 1_z)
S.push_back(std::make_pair(
make_rcp<const Poly>(a.get_var(), numeric_cast<int>(fac->c)), 1));
SYMENGINE_ASSERT(fac->p != NULL and fac->exp != NULL)
for (long i = 0; i < fac->num; i++) {
fzp_t z;
z.swap_fmpz_poly_t(fac->p[i]);
S.push_back(std::make_pair(
make_rcp<const Poly>(a.get_var(), std::move(z)), fac->exp[i]));
}
return S;
}
template <typename Container, template <typename X, typename Y> class BaseType,
typename Poly>
RCP<const Poly> gcd_upoly(const UFlintPoly<Container, BaseType, Poly> &a,
const Poly &b)
{
if (!(a.get_var()->__eq__(*b.get_var())))
throw SymEngineException("Error: variables must agree.");
return make_rcp<const Poly>(a.get_var(), a.get_poly().gcd(b.get_poly()));
}
template <typename Container, template <typename X, typename Y> class BaseType,
typename Poly>
RCP<const Poly> lcm_upoly(const UFlintPoly<Container, BaseType, Poly> &a,
const Poly &b)
{
if (!(a.get_var()->__eq__(*b.get_var())))
throw SymEngineException("Error: variables must agree.");
return make_rcp<const Poly>(a.get_var(), a.get_poly().lcm(b.get_poly()));
}
template <typename Container, template <typename X, typename Y> class BaseType,
typename Poly>
RCP<const Poly> pow_upoly(const UFlintPoly<Container, BaseType, Poly> &a,
unsigned int p)
{
return make_rcp<const Poly>(a.get_var(), a.get_poly().pow(p));
}
template <typename Container, template <typename X, typename Y> class BaseType,
typename Poly>
bool divides_upoly(const UFlintPoly<Container, BaseType, Poly> &a,
const Poly &b, const Ptr<RCP<const Poly>> &res)
{
if (!(a.get_var()->__eq__(*b.get_var())))
throw SymEngineException("Error: variables must agree.");
typename Poly::container_type q, r;
b.get_poly().divrem(q, r, a.get_poly());
if (r == 0) {
*res = make_rcp<Poly>(a.get_var(), std::move(q));
return true;
} else {
return false;
}
}
}
#endif // HAVE_SYMENGINE_FLINT
#endif // SYMENGINE_UINTPOLY_FLINT_H
| 31.303965 | 80 | 0.602589 |
64536d4451fbf0e65a2f12cab1e44649b845b2d1 | 15,407 | h | C | src/gromacs/mdspan/mdspan.h | alexxy/gromacs | 5a5b1be159beabc9ddd53eb22e3142bcb86d3aaa | [
"BSD-2-Clause"
] | null | null | null | src/gromacs/mdspan/mdspan.h | alexxy/gromacs | 5a5b1be159beabc9ddd53eb22e3142bcb86d3aaa | [
"BSD-2-Clause"
] | null | null | null | src/gromacs/mdspan/mdspan.h | alexxy/gromacs | 5a5b1be159beabc9ddd53eb22e3142bcb86d3aaa | [
"BSD-2-Clause"
] | null | null | null | /*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright 2018- The GROMACS Authors
* and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
* Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* https://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at https://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out https://www.gromacs.org.
*/
/*
* This file is a modified version of original work of Sandia Corporation.
* In the spirit of the original code, this particular file can be distributed
* on the terms of Sandia Corporation.
*/
/*
* Kokkos v. 2.0
* Copyright (2014) Sandia Corporation
*
* Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
* the U.S. Government retains certain rights in this software.
*
* Kokkos is licensed under 3-clause BSD terms of use:
*
* 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 Corporation nor the names of the
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE
* 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.
*
* Questions? Contact Christian R. Trott (crtrott@sandia.gov)
*/
/*! \libinternal \file
* \brief Declares gmx::mdspan
*
* \author Christian Trott <crtrott@sandia.gov>
* \author Ronan Keryell <ronan.keryell@xilinx.com>
* \author Carter Edwards <hedwards@nvidia.com>
* \author David Hollman <dshollm@sandia.gov>
* \author Christian Blau <cblau@gwdg.de>
* \inlibraryapi
* \ingroup mdspan
*/
#ifndef MDSPAN_MDSPAN_H
#define MDSPAN_MDSPAN_H
#include <array>
#include <type_traits>
#include "accessor_policy.h"
#include "extents.h"
#include "layouts.h"
namespace gmx
{
/*! \libinternal \brief Multidimensional array indexing and memory access with flexible mapping and access model.
*
* \tparam ElementType Type of elemnt to be viewed
* \tparam Extents The dimensions of the multidimenisonal array to view.
* \tparam LayoutPolicy Describes is the memory layout of the multidimensional array; right by default.
* \tparam AccessorPolicy Describes memory access model.
*/
template<class ElementType, class Extents, class LayoutPolicy = layout_right, class AccessorPolicy = accessor_basic<ElementType>>
class basic_mdspan
{
public:
//! Expose type used to define the extents of the data.
using extents_type = Extents;
//! Expose type used to define the layout of the data.
using layout_type = LayoutPolicy;
//! Expose type used to define the memory access model of the data.
using accessor_type = AccessorPolicy;
//! Expose type used to map multidimensional indices to one-dimensioal indices.
using mapping_type = typename layout_type::template mapping<extents_type>;
//! Exposes the type of stored element.
using element_type = typename accessor_type::element_type;
//! Expose the underlying type of the stored elements.
using value_type = std::remove_cv_t<element_type>;
//! Expose the type used for indexing.
using index_type = ptrdiff_t;
//! Expose type for index differences.
using difference_type = ptrdiff_t;
//! Expose underlying pointer to data type.
using pointer = typename accessor_type::pointer;
//! Expose reference to data type.
using reference = typename accessor_type::reference;
//! Trivial constructor
constexpr basic_mdspan() noexcept : acc_(), map_(), ptr_() {}
//! Move constructor
constexpr basic_mdspan(basic_mdspan&& other) noexcept = default;
//! copy constructor
constexpr basic_mdspan(const basic_mdspan& other) noexcept = default;
//! Copy assignment
basic_mdspan& operator=(const basic_mdspan& other) noexcept = default;
//! Move assignment
basic_mdspan& operator=(basic_mdspan&& other) noexcept = default;
//! Copy constructor
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor>
constexpr basic_mdspan(
const basic_mdspan<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor>& rhs) noexcept
:
acc_(rhs.acc_), map_(rhs.map_), ptr_(rhs.ptr_)
{
}
//! Copy assignment constructor
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor>
basic_mdspan&
operator=(const basic_mdspan<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor>& rhs) noexcept
{
acc_ = rhs.acc_;
map_ = rhs.map_;
ptr_ = rhs.ptr_;
return *this;
}
/*!\brief Construct mdspan by setting the dynamic extents and pointer to data.
* \param[in] ptr Pointer to data to be accessed by this span
* \param[in] DynamicExtents
* \tparam IndexType index type to describe dynamic extents
*/
template<class... IndexType>
explicit constexpr basic_mdspan(pointer ptr, IndexType... DynamicExtents) noexcept :
acc_(accessor_type()), map_(extents_type(DynamicExtents...)), ptr_(ptr)
{
}
/*! \brief Construct from array describing dynamic extents.
* \param[in] ptr Pointer to data to be accessed by this span
* \param[in] dynamic_extents Array the size of dynamic extents.
*/
constexpr basic_mdspan(pointer ptr,
const std::array<ptrdiff_t, extents_type::rank_dynamic()>& dynamic_extents) :
acc_(accessor_type()), map_(extents_type(dynamic_extents)), ptr_(ptr)
{
}
/*! \brief Construct from pointer and mapping.
* \param[in] ptr Pointer to data to be accessed by this span
* \param[in] m Mapping from multidimenisonal indices to one-dimensional offset.
*/
constexpr basic_mdspan(pointer ptr, const mapping_type& m) noexcept :
acc_(accessor_type()), map_(m), ptr_(ptr)
{
}
/*! \brief Construct with pointer, mapping and accessor.
* \param[in] ptr Pointer to data to be accessed by this span
* \param[in] m Mapping from multidimenisonal indices to one-dimensional offset.
* \param[in] a Accessor implementing memory access model.
*/
constexpr basic_mdspan(pointer ptr, const mapping_type& m, const accessor_type& a) noexcept :
acc_(a), map_(m), ptr_(ptr)
{
}
/*! \brief Construct mdspan from multidimensional arrays implemented with mdspan
*
* Requires the container to have a view_type describing the mdspan, which is
* accessible through an asView() call
*
* This allows functions to declare mdspans as arguments, but take e.g. multidimensional
* arrays implicitly during the function call
* \tparam U container type
* \param[in] other mdspan-implementing container
*/
template<typename U, typename = std::enable_if_t<std::is_same_v<typename std::remove_reference_t<U>::view_type::element_type, ElementType>>>
constexpr basic_mdspan(U&& other) : basic_mdspan(other.asView())
{
}
/*! \brief Construct mdspan of const Elements from multidimensional arrays implemented with mdspan
*
* Requires the container to have a const_view_type describing the mdspan, which is
* accessible through an asConstView() call
*
* This allows functions to declare mdspans as arguments, but take e.g. multidimensional
* arrays implicitly during the function call
* \tparam U container type
* \param[in] other mdspan-implementing container
*/
template<typename U, typename = std::enable_if_t<std::is_same_v<typename std::remove_reference_t<U>::const_view_type::element_type, ElementType>>>
constexpr basic_mdspan(const U& other) : basic_mdspan(other.asConstView())
{
}
/*! \brief Brace operator to access multidimensional array element.
* \param[in] indices The multidimensional indices of the object.
* Requires rank() == sizeof...(IndexType). Slicing is implemented via sub_span.
* \returns reference to element at indices.
*/
template<class... IndexType>
constexpr std::enable_if_t<sizeof...(IndexType) == extents_type::rank(), reference>
operator()(IndexType... indices) const noexcept
{
return acc_.access(ptr_, map_(indices...));
}
/*! \brief Canonical bracket operator for one-dimensional arrays.
* Allows mdspan to act like array in one-dimension.
* Enabled only when rank==1.
* \param[in] i one-dimensional index
* \returns reference to element stored at position i
*/
template<class IndexType>
constexpr std::enable_if_t<std::is_integral_v<IndexType> && extents_type::rank() == 1, reference>
operator[](const IndexType& i) const noexcept
{
return acc_.access(ptr_, map_(i));
}
/*! \brief Bracket operator for multi-dimensional arrays.
*
* \note Prefer operator() for better compile-time and run-time performance
*
* Slices two- and higher-dimensional arrays along a given slice by
* returning a new basic_mdspan that drops the first extent and indexes
* the remaining extents
*
* \note Currently only implemented for layout_right
* \note For layout_right this implementation has significant
* performance benefits over implementing a more general slicing
* operator with a strided layout
* \note Enabled only when rank() > 1
*
* \tparam IndexType integral tyoe for the index that enables indexing
* with, e.g., int or size_t
* \param[in] index one-dimensional index of the slice to be indexed
*
* \returns basic_mdspan that is sliced at the given index
*/
template<class IndexType,
typename sliced_mdspan_type = basic_mdspan<element_type, decltype(extents_type().sliced_extents()), LayoutPolicy, AccessorPolicy>>
constexpr std::enable_if_t<std::is_integral_v<IndexType> && (extents_type::rank() > 1)
&& std::is_same_v<LayoutPolicy, layout_right>,
sliced_mdspan_type>
operator[](const IndexType index) const noexcept
{
return sliced_mdspan_type(ptr_ + index * stride(0), extents().sliced_extents());
}
//! Report the rank.
static constexpr int rank() noexcept { return extents_type::rank(); }
//! Report the dynamic rank.
static constexpr int rank_dynamic() noexcept { return extents_type::rank_dynamic(); }
/*! \brief Return the static extent.
* \param[in] k dimension to query for static extent
* \returns static extent along specified dimension
*/
constexpr index_type static_extent(size_t k) const noexcept
{
return map_.extents().static_extent(k);
}
/*! \brief Return the extent.
* \param[in] k dimension to query for extent
* \returns extent along specified dimension
*/
constexpr index_type extent(int k) const noexcept { return map_.extents().extent(k); }
//! Return all extents
constexpr const extents_type& extents() const noexcept { return map_.extents(); }
//! Report if mappings for this basic_span is always unique.
static constexpr bool is_always_unique() noexcept { return mapping_type::is_always_unique(); }
//! Report if mapping for this basic_span is always strided
static constexpr bool is_always_strided() noexcept { return mapping_type::is_always_strided(); }
//! Report if mapping for this basic_span is always is_contiguous
static constexpr bool is_always_contiguous() noexcept
{
return mapping_type::is_always_contiguous();
}
//! Report if the currently applied map is unique
constexpr bool is_unique() const noexcept { return map_.is_unique(); }
//! Report if the currently applied map is strided
constexpr bool is_strided() const noexcept { return map_.is_strided(); }
//! Report if the currently applied map is contiguous
constexpr bool is_contiguous() const noexcept { return map_.is_contiguous(); }
//! Report stride along a specific rank.
constexpr index_type stride(size_t r) const noexcept { return map_.stride(r); }
//! Return the currently applied mapping.
constexpr mapping_type mapping() const noexcept { return map_; }
//! Return the memory access model.
constexpr accessor_type accessor() const noexcept { return acc_; }
//! Return pointer to underlying data
constexpr pointer data() const noexcept { return ptr_; }
private:
//! The memory access model
accessor_type acc_;
//! The transformation from multidimenisonal index to memory offset.
mapping_type map_;
//! Memory location handle
pointer ptr_;
};
//! basic_mdspan with wrapped indices, basic_accessor policiy and right-aligned memory layout.
template<class T, ptrdiff_t... Indices>
using mdspan = basic_mdspan<T, extents<Indices...>, layout_right, accessor_basic<T>>;
} // namespace gmx
#endif /* end of include guard: MDSPAN_MDSPAN_H */
| 45.314706 | 150 | 0.709223 |
64543f589394eedbbc0b816d4c233201f172ef03 | 646 | h | C | src/multiset.h | DiracLee/dtl | 8077b8c9c51da3e748e421b4bee96c78402d131e | [
"MIT"
] | 1 | 2021-01-06T05:02:11.000Z | 2021-01-06T05:02:11.000Z | src/multiset.h | DiracLee/dtl | 8077b8c9c51da3e748e421b4bee96c78402d131e | [
"MIT"
] | null | null | null | src/multiset.h | DiracLee/dtl | 8077b8c9c51da3e748e421b4bee96c78402d131e | [
"MIT"
] | null | null | null | #ifndef DTL_MULTISET_H_
#define DTL_MULTISET_H_
#include <algorithm>
#include <memory>
#include "rb_tree.h"
namespace dtl {
template <typename Key, typename Compare = ::std::less<Key>,
typename Alloc = ::std::allocator<Key> >
class Multiset {
public:
using key_type = Key;
using value_type = Key;
using key_compare = Compare;
using value_compare = Compare;
using iterator = typename rep_type::const_iterator;
private:
using rep_type = dtl::RBTree<key_type, value_type, ::std::identity<value_type>,
key_compare, Alloc>;
rep_type t;
};
} // namespace dtl
#endif // DTL_MULTISET_H_ | 20.83871 | 81 | 0.679567 |
64545e6a90976698535b9148c69489cc49ea65fa | 574 | h | C | Statistics.h | johanvdp/FoocusStacker | 5a8c61fa389d9843bcd7b261580931eea9274506 | [
"Unlicense"
] | 1 | 2020-12-04T13:48:39.000Z | 2020-12-04T13:48:39.000Z | Statistics.h | johanvdp/FoocusStacker | 5a8c61fa389d9843bcd7b261580931eea9274506 | [
"Unlicense"
] | null | null | null | Statistics.h | johanvdp/FoocusStacker | 5a8c61fa389d9843bcd7b261580931eea9274506 | [
"Unlicense"
] | null | null | null | // The author disclaims copyright to this source code.
#ifndef STATISTICS_H
#define STATISTICS_H
#include <Arduino.h>
#include "Component.h"
#include "Debug.h"
class Statistics: public Component {
public:
Statistics();
virtual ~Statistics();
void setup();
void add(float sample);
float getAverage();
float getMinimum();
float getMaximum();
private:
void recalculate();
static const int NUMBER_OF_SAMPLES = 100;
float samples[NUMBER_OF_SAMPLES];
int index = 0;
boolean needRecalculation = true;
float average;
float minimum;
float maximum;
};
#endif
| 15.513514 | 54 | 0.735192 |
6455393a464b64ef155c54c8d5a8a3800e9443df | 1,846 | c | C | firmware/CommonCode/DataHistory.c | tzurolo/LightingUPS | 8a5418d28191ce0a7a5a39886fd27455ec238eaa | [
"MIT"
] | null | null | null | firmware/CommonCode/DataHistory.c | tzurolo/LightingUPS | 8a5418d28191ce0a7a5a39886fd27455ec238eaa | [
"MIT"
] | null | null | null | firmware/CommonCode/DataHistory.c | tzurolo/LightingUPS | 8a5418d28191ce0a7a5a39886fd27455ec238eaa | [
"MIT"
] | 1 | 2020-10-28T05:46:04.000Z | 2020-10-28T05:46:04.000Z | //
// Data History
//
#include "DataHistory.h"
void DataHistory_insertValue (
const uint16_t value,
DataHistory_t* dataHistory)
{
// put data in buffer
dataHistory->dataBuffer[dataHistory->tail] = value;
// advance tail
if (dataHistory->tail >= (dataHistory->capacity - 1)) {
// wrap around
dataHistory->tail = 0;
} else {
++dataHistory->tail;
}
// increment length
if (dataHistory->length < dataHistory->capacity) {
++dataHistory->length;
}
}
uint16_t DataHistory_getLatest (
const DataHistory_t* dataHistory)
{
uint16_t latest = 0;
if (dataHistory->length > 0) {
uint8_t dataIndex = ((dataHistory->tail == 0)
? dataHistory->capacity
: dataHistory->tail) - 1;
latest = dataHistory->dataBuffer[dataIndex];
}
return latest;
}
void DataHistory_getStatistics (
const DataHistory_t* dataHistory,
const uint8_t numSamples,
uint16_t* min,
uint16_t* max,
uint16_t* avg)
{
*min = 65535;
*max = 0;
*avg = 0;
if (dataHistory->length > 0) {
uint32_t sum = 0;
uint8_t dataIndex = ((dataHistory->tail == 0)
? dataHistory->capacity
: dataHistory->tail) - 1;
for (int i = 0; i < numSamples; ++i) {
const uint16_t sample = dataHistory->dataBuffer[dataIndex];
if (sample < *min) {
*min = sample;
}
if (sample > *max) {
*max = sample;
}
sum += sample;
dataIndex = (
(dataIndex == 0)
? dataHistory->capacity
: dataIndex) - 1;
}
*avg = (uint16_t)(sum / numSamples);
}
}
| 23.666667 | 72 | 0.511376 |
64565d86240b651788aa56916bc309a8f5f787fa | 11,389 | h | C | include/lib/smbios_tables.h | dhendrix/mosys | 8baa261c5a7335ed9e089eb70564654c82305a9f | [
"BSD-3-Clause"
] | null | null | null | include/lib/smbios_tables.h | dhendrix/mosys | 8baa261c5a7335ed9e089eb70564654c82305a9f | [
"BSD-3-Clause"
] | null | null | null | include/lib/smbios_tables.h | dhendrix/mosys | 8baa261c5a7335ed9e089eb70564654c82305a9f | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MOSYS_LIB_SMBIOS_TABLES_H__
#define MOSYS_LIB_SMBIOS_TABLES_H__
#include <inttypes.h>
#define SMBIOS_LEGACY_ENTRY_BASE 0xf0000
#define SMBIOS_LEGACY_ENTRY_LEN 0x10000
#define SMBIOS_ENTRY_MAGIC "_SM_"
/* Entry */
struct smbios_entry {
uint8_t anchor_string[4];
uint8_t entry_cksum;
uint8_t entry_length;
uint8_t major_ver;
uint8_t minor_ver;
uint16_t max_size;
uint8_t entry_rev;
uint8_t format_area[5];
uint8_t inter_anchor_string[5];
uint8_t inter_anchor_cksum;
uint16_t table_length;
uint32_t table_address;
uint16_t table_entry_count;
uint8_t bcd_revision;
} __attribute__ ((packed));
/* Header */
struct smbios_header {
uint8_t type;
uint8_t length;
uint16_t handle;
} __attribute__ ((packed));
/* Type 0 - BIOS information */
struct smbios_table_bios {
uint8_t vendor;
uint8_t version;
uint16_t start_address;
uint8_t release_date;
uint8_t rom_size_64k_blocks;
uint32_t characteristics;
uint8_t unused[4]; /* unused bytes */
uint8_t extension[2]; /* v2.4+ */
uint8_t major_ver; /* v2.4+ */
uint8_t minor_ver; /* v2.4+ */
uint8_t ec_major_ver; /* v2.4+ */
uint8_t ec_minor_ver; /* v2.4+ */
} __attribute__ ((packed));
/* Type 1 - system information */
struct smbios_table_system {
uint8_t manufacturer;
uint8_t name;
uint8_t version;
uint8_t serial_number;
uint8_t uuid[16];
uint8_t wakeup_type;
uint8_t sku_number; /* v2.4+ */
uint8_t family; /* v2.4+ */
} __attribute__ ((packed));
/* Type 15 - event log */
struct smbios_table_log {
uint16_t length;
uint16_t header_start;
uint16_t data_start;
uint8_t method;
uint8_t status;
uint32_t change_token;
union {
struct {
uint16_t index;
uint16_t data;
} io;
uint32_t mem;
uint16_t gpnv;
} address;
uint8_t header_format;
uint8_t descriptor_num;
uint8_t descriptor_len;
uint8_t descriptor[0]; /* variable length data */
} __attribute__ ((packed));
/* Event log Type 1 header */
struct smbios_log_header_type1 {
uint8_t oem[5]; /* oem customization */
uint8_t metw; /* multiple event time window */
uint8_t meci; /* multiple event count increment */
uint8_t reset_addr; /* pre-boot event log reset CMOS address */
uint8_t reset_index; /* pre-boot event log reset CMOS bit index */
uint8_t cksum_start; /* CMOS checksum starting offset */
uint8_t cksum_count; /* CMOS checksum byte count */
uint8_t cksum_offset; /* CMOS checksum offset */
uint8_t reserved[3]; /* future expansion */
uint8_t revision; /* header revision (=1) */
} __attribute__ ((packed));
/* Event log entry */
struct smbios_log_entry {
uint8_t type; /* entry type */
uint8_t length; /* data length */
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t data[0]; /* variable length data */
} __attribute__ ((packed));
/* the possible values for smbios_log_entry.type */
enum smbios_log_entry_type {
SMBIOS_EVENT_TYPE_RESERVED = 0x00, /* Reserved */
SMBIOS_EVENT_TYPE_SBE = 0x01, /* single-bit ECC error */
SMBIOS_EVENT_TYPE_MBE = 0x02, /* multi-bit ECC error */
SMBIOS_EVENT_TYPE_PARITY = 0x03, /* memory parity error */
SMBIOS_EVENT_TYPE_BUSTMOUT = 0x04, /* bus timeout */
SMBIOS_EVENT_TYPE_IOCHECK = 0x05, /* IO channel check */
SMBIOS_EVENT_TYPE_SOFTNMI = 0x06, /* software NMI */
SMBIOS_EVENT_TYPE_POSTMEM = 0x07, /* POST memory resize */
SMBIOS_EVENT_TYPE_POSTERR = 0x08, /* POST error */
SMBIOS_EVENT_TYPE_PCIPERR = 0x09, /* PCI parity error */
SMBIOS_EVENT_TYPE_PCISERR = 0x0a, /* PCI system error */
SMBIOS_EVENT_TYPE_CPUFAIL = 0x0b, /* CPU failure */
SMBIOS_EVENT_TYPE_EISAFSTO = 0x0c, /* EISA FailSafe Timer timeout */
SMBIOS_EVENT_TYPE_CORRDIS = 0x0d, /* correctable memory log disabled */
SMBIOS_EVENT_TYPE_LOGDIS = 0x0e, /* specific event type log disabled */
SMBIOS_EVENT_TYPE_LIMIT = 0x10, /* system limit exceeded (e.g. temp) */
SMBIOS_EVENT_TYPE_WDT = 0x11, /* async HW timer (WDT) timeout */
SMBIOS_EVENT_TYPE_SYSINFO = 0x12, /* system config information */
SMBIOS_EVENT_TYPE_HDINFO = 0x13, /* hard disk information */
SMBIOS_EVENT_TYPE_RECONFIG = 0x14, /* system reconfigured */
SMBIOS_EVENT_TYPE_UCCPUERR = 0x15, /* uncorrectable CPU-complex error */
SMBIOS_EVENT_TYPE_LOGCLEAR = 0x16, /* log area reset/cleared */
SMBIOS_EVENT_TYPE_BOOT = 0x17, /* system boot */
SMBIOS_EVENT_TYPE_OEM = 0x80, /* OEM-specific event */
SMBIOS_EVENT_TYPE_ENDLOG = 0xff /* end of log */
};
/* the possible values for log access method */
enum smbios_log_method_type {
SMBIOS_LOG_METHOD_TYPE_IO8 = 0, /* 8-bit indexed I/O */
SMBIOS_LOG_METHOD_TYPE_IO8X2 = 1, /* 2x8-bit indexed I/O */
SMBIOS_LOG_METHOD_TYPE_IO16 = 2, /* 16-bit indexed I/O */
SMBIOS_LOG_METHOD_TYPE_MEM = 3, /* 32-bit physical memory */
SMBIOS_LOG_METHOD_TYPE_GPNV = 4, /* general purpose non-volatile */
};
/* Type 16 - physical memory array */
struct smbios_table_memory_array {
uint8_t location; /* enumerated */
uint8_t use; /* enumerated */
uint8_t error_correction; /* enumerated */
uint32_t capacity; /* in KB */
uint16_t memory_error_handle; /* error information */
uint16_t num_devices; /* number of slots */
} __attribute__ ((packed));
/* memory array location */
enum smbios_memory_array_location {
SMBIOS_MEMORY_ARRAY_LOC_OTHER = 0x01,
SMBIOS_MEMORY_ARRAY_LOC_UNKNOWN = 0x02,
SMBIOS_MEMORY_ARRAY_LOC_BOARD = 0x03,
SMBIOS_MEMORY_ARRAY_LOC_ISA_CARD = 0x04,
SMBIOS_MEMORY_ARRAY_LOC_EISA_CARD = 0x05,
SMBIOS_MEMORY_ARRAY_LOC_PCI_CARD = 0x06,
SMBIOS_MEMORY_ARRAY_LOC_MCA_CARD = 0x07,
SMBIOS_MEMORY_ARRAY_LOC_PCMCIA_CARD = 0x08,
SMBIOS_MEMORY_ARRAY_LOC_OTHER_CARD = 0x09,
SMBIOS_MEMORY_ARRAY_LOC_NUBUS = 0x0a,
SMBIOS_MEMORY_ARRAY_LOC_PC98_C20 = 0xa0,
SMBIOS_MEMORY_ARRAY_LOC_PC98_C24 = 0xa1,
SMBIOS_MEMORY_ARRAY_LOC_PC98_E = 0xa2,
SMBIOS_MEMORY_ARRAY_LOC_PC98_LBUS = 0xa3,
};
/* memory array use */
enum smbios_memory_array_use {
SMBIOS_MEMORY_ARRAY_USE_OTHER = 0x01,
SMBIOS_MEMORY_ARRAY_USE_UNKNOWN = 0x02,
SMBIOS_MEMORY_ARRAY_USE_SYSTEM = 0x03,
SMBIOS_MEMORY_ARRAY_USE_VIDEO = 0x04,
SMBIOS_MEMORY_ARRAY_USE_FLASH = 0x05,
SMBIOS_MEMORY_ARRAY_USE_NVRAM = 0x06,
SMBIOS_MEMORY_ARRAY_USE_CACHE = 0x07,
};
/* memory array error correction */
enum smbios_memory_array_ecc {
SMBIOS_MEMORY_ARRAY_ECC_OTHER = 0x01,
SMBIOS_MEMORY_ARRAY_ECC_UNKNOWN = 0x02,
SMBIOS_MEMORY_ARRAY_ECC_NONE = 0x03,
SMBIOS_MEMORY_ARRAY_ECC_PARITY = 0x04,
SMBIOS_MEMORY_ARRAY_ECC_SBE = 0x05,
SMBIOS_MEMORY_ARRAY_ECC_MBE = 0x06,
SMBIOS_MEMORY_ARRAY_ECC_CRC = 0x07,
};
/* Type 17 - memory device */
struct smbios_table_memory_device {
uint16_t memory_array_handle;
uint16_t memory_error_handle;
uint16_t total_width; /* in bits, including ECC */
uint16_t data_width; /* in bits, no ECC */
uint16_t size; /* bit 15: 0=MB 1=KB */
uint8_t form_factor; /* enumerated, 9=DIMM */
uint8_t device_set; /* dimm group */
uint8_t locator; /* string */
uint8_t bank_locator; /* string */
uint8_t type; /* memory type enum */
uint16_t type_detail; /* memory type detail bitmask */
uint16_t speed; /* in MHz */
uint8_t manufacturer; /* string */
uint8_t serial_number; /* string */
uint8_t asset_tag; /* string */
uint8_t part_number; /* string */
} __attribute__ ((packed));
/* memory device types */
enum smbios_memory_type {
SMBIOS_MEMORY_TYPE_OTHER = 0x01,
SMBIOS_MEMORY_TYPE_UNKNOWN = 0x02,
SMBIOS_MEMORY_TYPE_DRAM = 0x03,
SMBIOS_MEMORY_TYPE_EDRAM = 0x04,
SMBIOS_MEMORY_TYPE_VRAM = 0x05,
SMBIOS_MEMORY_TYPE_SRAM = 0x06,
SMBIOS_MEMORY_TYPE_RAM = 0x07,
SMBIOS_MEMORY_TYPE_ROM = 0x08,
SMBIOS_MEMORY_TYPE_FLASH = 0x09,
SMBIOS_MEMORY_TYPE_EEPROM = 0x0a,
SMBIOS_MEMORY_TYPE_FEPROM = 0x0b,
SMBIOS_MEMORY_TYPE_EPROM = 0x0c,
SMBIOS_MEMORY_TYPE_CDRAM = 0x0d,
SMBIOS_MEMORY_TYPE_3DRAM = 0x0e,
SMBIOS_MEMORY_TYPE_SDRAM = 0x0f,
SMBIOS_MEMORY_TYPE_SGRAM = 0x10,
SMBIOS_MEMORY_TYPE_RDRAM = 0x11,
SMBIOS_MEMORY_TYPE_DDR = 0x12,
SMBIOS_MEMORY_TYPE_DDR2 = 0x13,
SMBIOS_MEMORY_TYPE_DDR2_FBDIMM = 0x14,
SMBIOS_MEMORY_TYPE_DDR3 = 0x18,
};
/* memory device type details (bitmask) */
enum smbios_memory_type_detail {
SMBIOS_MEMORY_TYPE_DETAIL_OTHER = 0x0001,
SMBIOS_MEMORY_TYPE_DETAIL_UNKNOWN = 0x0002,
SMBIOS_MEMORY_TYPE_DETAIL_FAST_PAGED = 0x0004,
SMBIOS_MEMORY_TYPE_DETAIL_STATIC_COL = 0x0008,
SMBIOS_MEMORY_TYPE_DETAIL_PSEUDO_STATIC = 0x0010,
SMBIOS_MEMORY_TYPE_DETAIL_RAMBUS = 0x0020,
SMBIOS_MEMORY_TYPE_DETAIL_SYNCHRONOUS = 0x0040,
SMBIOS_MEMORY_TYPE_DETAIL_CMOS = 0x0080,
SMBIOS_MEMORY_TYPE_DETAIL_EDO = 0x0100,
SMBIOS_MEMORY_TYPE_DETAIL_WINDOW_DRAM = 0x0200,
SMBIOS_MEMORY_TYPE_DETAIL_CACHE_DRAM = 0x0400,
SMBIOS_MEMORY_TYPE_DETAIL_NON_VOLATILE = 0x0800,
};
/* Type 32 - System Boot Information */
struct smbios_table_system_boot {
uint8_t reserved[6]; /* Should be all zeros */
uint8_t boot_status[0]; /* Variable boot status */
} __attribute__ ((packed));
/* The system boot number may be exposed in the type 32 table. It is identified
* by the Vendor/OEM identifier 128. This is Google specific. */
#define BOOT_STATUS_BOOT_NUMBER 128
struct smbios_system_boot_number {
uint8_t identifier;
uint32_t boot_number;
} __attribute__((packed));
/* The length and number of strings defined here is not a limitation of SMBIOS.
* These numbers were deemed good enough during development. */
#define SMBIOS_MAX_STRINGS 10
#define SMBIOS_MAX_STRING_LENGTH 64
/* One structure to rule them all */
struct smbios_table {
struct smbios_header header;
union {
struct smbios_table_bios bios;
struct smbios_table_system system;
struct smbios_table_log log;
struct smbios_table_memory_array mem_array;
struct smbios_table_memory_device mem_device;
struct smbios_table_system_boot system_boot;
uint8_t data[1024];
} data;
char string[SMBIOS_MAX_STRINGS][SMBIOS_MAX_STRING_LENGTH];
};
#endif /* MOSYS_LIB_SMBIOS_TABLES_H__ */
| 34.935583 | 79 | 0.761173 |
645908c6017e0395fa8f3303afa8bff5a6014c14 | 2,462 | h | C | uart_example/main.h | Azure-Sphere-DevX/AzureSphereDevX.examples | fff28f6c40845b24e9a062de7e301a4306a6e73e | [
"MIT"
] | 4 | 2021-12-16T05:02:28.000Z | 2022-01-24T22:53:01.000Z | uart_example/main.h | Azure-Sphere-DevX/AzureSphereDevX.examples | fff28f6c40845b24e9a062de7e301a4306a6e73e | [
"MIT"
] | 2 | 2021-09-21T05:44:26.000Z | 2022-01-05T22:49:22.000Z | uart_example/main.h | Azure-Sphere-DevX/AzureSphereDevX.examples | fff28f6c40845b24e9a062de7e301a4306a6e73e | [
"MIT"
] | 6 | 2021-09-15T13:16:08.000Z | 2022-02-07T09:09:04.000Z | #pragma once
#include "hw/azure_sphere_learning_path.h" // Hardware definition
#include "app_exit_codes.h"
#include "dx_uart.h"
#include "dx_gpio.h"
#include "dx_terminate.h"
#include "dx_timer.h"
#include "dx_utilities.h"
#include <applibs/log.h>
// Forward declarations
static void ButtonPressCheckHandler(EventLoopTimer *eventLoopTimer);
static void uart_rx_handler1(DX_UART_BINDING *uartBinding);
/****************************************************************************************
* GPIO Peripherals
****************************************************************************************/
static DX_GPIO_BINDING buttonA = {
.pin = BUTTON_A, .name = "buttonA", .direction = DX_INPUT, .detect = DX_GPIO_DETECT_LOW};
static DX_GPIO_BINDING buttonB = {
.pin = BUTTON_B, .name = "buttonB", .direction = DX_INPUT, .detect = DX_GPIO_DETECT_LOW};
// All GPIOs added to gpio_bindings will be opened in InitPeripheralsAndHandlers
DX_GPIO_BINDING *gpio_bindings[] = {&buttonA, &buttonB};
/****************************************************************************************
* UART Peripherals
****************************************************************************************/
static DX_UART_BINDING loopBackClick1 = {.uart = UART_CLICK1,
.name = "uart click1",
.handler = uart_rx_handler1,
.uartConfig.baudRate = 115200,
.uartConfig.dataBits = UART_DataBits_Eight,
.uartConfig.parity = UART_Parity_None,
.uartConfig.stopBits = UART_StopBits_One,
.uartConfig.flowControl = UART_FlowControl_None};
// All UARTSs added to uart_bindings will be opened in InitPeripheralsAndHandlers
DX_UART_BINDING *uart_bindings[] = {&loopBackClick1};
/****************************************************************************************
* Timer Bindings
****************************************************************************************/
static DX_TIMER_BINDING buttonPressCheckTimer = {
.period = {0, ONE_MS}, .name = "buttonPressCheckTimer", .handler = ButtonPressCheckHandler};
// All timers referenced in timer_bindings with be opened in the InitPeripheralsAndHandlers function
DX_TIMER_BINDING *timer_bindings[] = {&buttonPressCheckTimer};
| 47.346154 | 100 | 0.517059 |
ea770ae4b9c457b1f6e47213baa71f2518fc74d9 | 200 | h | C | digitalCurrency/Common/CALayer+color.h | xunibidev/ZTuoExchange_IOS | 6cacf26ac2938fc4731141afd5a15b1f8cb1d6cd | [
"Apache-2.0"
] | 13 | 2019-08-04T14:09:52.000Z | 2019-11-12T02:57:04.000Z | digitalCurrency/Common/CALayer+color.h | Theo1016/ZTuoExchange_ios | 6cacf26ac2938fc4731141afd5a15b1f8cb1d6cd | [
"Apache-2.0"
] | null | null | null | digitalCurrency/Common/CALayer+color.h | Theo1016/ZTuoExchange_ios | 6cacf26ac2938fc4731141afd5a15b1f8cb1d6cd | [
"Apache-2.0"
] | 40 | 2020-08-07T08:27:33.000Z | 2022-03-11T04:45:47.000Z | //
// CALayer+color.h
// horizonLoan
//
// Created by sunliang on 2017/9/27.
// Copyright © 2017年 ztuo. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@interface CALayer (color)
@end
| 15.384615 | 48 | 0.68 |
ea781a20315b49106f5180e3c399a3d0a85c8417 | 1,446 | h | C | DataFormats/RecoCandidate/interface/RecoEcalCandidate.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | DataFormats/RecoCandidate/interface/RecoEcalCandidate.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | DataFormats/RecoCandidate/interface/RecoEcalCandidate.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | #ifndef RecoCandidate_RecoEcalCandidate_h
#define RecoCandidate_RecoEcalCandidate_h
/** \class reco::RecoEcalCandidate
*
* Reco Candidates with a Super Cluster component
*
* \author Luca Lista, INFN
*
*
*/
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
namespace reco {
class RecoEcalCandidate : public RecoCandidate {
public:
/// default constructor
RecoEcalCandidate() : RecoCandidate() { }
/// constructor from values
RecoEcalCandidate( Charge q , const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
int pdgId = 0, int status = 0 ) :
RecoCandidate( q, p4, vtx, pdgId, status ) { }
/// constructor from values
RecoEcalCandidate( Charge q , const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
int pdgId = 0, int status = 0 ) :
RecoCandidate( q, p4, vtx, pdgId, status ) { }
/// destructor
virtual ~RecoEcalCandidate();
/// returns a clone of the candidate
virtual RecoEcalCandidate * clone() const;
/// set reference to superCluster
void setSuperCluster( const reco::SuperClusterRef & r ) { superCluster_ = r; }
/// reference to a superCluster
virtual reco::SuperClusterRef superCluster() const;
private:
/// check overlap with another candidate
virtual bool overlap( const Candidate & ) const;
/// reference to a superCluster
reco::SuperClusterRef superCluster_;
};
}
#endif
| 31.434783 | 102 | 0.679806 |
ea782212ec4adc134a40353677561ab4199be648 | 721 | h | C | components/cookie_config/cookie_store_util.h | xzhan96/chromium.src | 1bd0cf3997f947746c0fc5406a2466e7b5f6159e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2021-01-07T18:51:03.000Z | 2021-01-07T18:51:03.000Z | components/cookie_config/cookie_store_util.h | emilio/chromium.src | 1bd0cf3997f947746c0fc5406a2466e7b5f6159e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | components/cookie_config/cookie_store_util.h | emilio/chromium.src | 1bd0cf3997f947746c0fc5406a2466e7b5f6159e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2014 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 COMPONENTS_COOKIE_CONFIG_COOKIE_STORE_UTIL_H_
#define COMPONENTS_COOKIE_CONFIG_COOKIE_STORE_UTIL_H_
namespace net {
class CookieCryptoDelegate;
} // namespace net
namespace cookie_config {
// Factory method for returning a CookieCryptoDelegate if one is appropriate for
// this platform. The object returned is a LazyInstance. Ownership is not
// transferred.
net::CookieCryptoDelegate* GetCookieCryptoDelegate();
void SetEnableCookieCrypto(bool enable);
} // namespace cookie_config
#endif // COMPONENTS_COOKIE_CONFIG_COOKIE_STORE_UTIL_H_
| 32.772727 | 80 | 0.814147 |
ea7a37658b88a3c114fdb35ef34d75ccdc373ec0 | 8,078 | c | C | NoC264_3x3/software/Parser_Node/slicehdr.c | bargei/NoC264 | e82ab974e0c1d07391be8950024c1f3ac6a8c290 | [
"MIT"
] | 4 | 2017-06-25T06:32:30.000Z | 2021-12-04T23:40:53.000Z | NoC264_3x3/software/Parser_Node/slicehdr.c | bargei/NoC264 | e82ab974e0c1d07391be8950024c1f3ac6a8c290 | [
"MIT"
] | 1 | 2017-10-20T03:03:14.000Z | 2017-10-20T03:03:14.000Z | NoC264_3x3/software/Parser_Node/slicehdr.c | bargei/NoC264 | e82ab974e0c1d07391be8950024c1f3ac6a8c290 | [
"MIT"
] | 3 | 2017-10-20T02:06:26.000Z | 2021-05-30T06:15:02.000Z | #include "common.h"
#include "input.h"
#include "nal.h"
#include "cavlc.h"
#include "params.h"
#include "slicehdr.h"
static void skip_ref_pic_list_reordering() {
int reordering_of_pic_nums_idc;
int abs_diff_pic_num;
int long_term_pic_num;
fprintf(stderr,"Warning: I do not support reference picture list reordering.\n"
" Watch out for decoding errors!\n");
do {
reordering_of_pic_nums_idc=get_unsigned_exp_golomb();
if(reordering_of_pic_nums_idc==0 || reordering_of_pic_nums_idc==1)
abs_diff_pic_num=get_unsigned_exp_golomb()+1;
else if(reordering_of_pic_nums_idc==2)
long_term_pic_num=get_unsigned_exp_golomb();
} while(reordering_of_pic_nums_idc!=3);
}
static void skip_adaptive_ref_pic_marking() {
int memory_management_control_operation;
int difference_of_pic_nums;
int long_term_pic_num;
int long_term_frame_idx;
int max_long_term_frame_idx;
fprintf(stderr,"Warning: I do not support adaptive reference picture marking.\n"
" Watch out for decoding errors!\n");
do {
memory_management_control_operation=get_unsigned_exp_golomb();
if(memory_management_control_operation==1 || memory_management_control_operation==3)
difference_of_pic_nums=get_unsigned_exp_golomb()+1;
if(memory_management_control_operation==2)
long_term_pic_num=get_unsigned_exp_golomb();
if(memory_management_control_operation==3 || memory_management_control_operation==6)
long_term_frame_idx=get_unsigned_exp_golomb();
if(memory_management_control_operation==4)
max_long_term_frame_idx=get_unsigned_exp_golomb()-1;
} while(memory_management_control_operation!=0);
}
void decode_slice_header(slice_header *sh,
seq_parameter_set *sps,
pic_parameter_set *pps,
nal_unit *nalu) {
memset((void*)sh,0,sizeof(slice_header));
sh->first_mb_in_slice =get_unsigned_exp_golomb();
sh->slice_type =get_unsigned_exp_golomb()%5;
sh->pic_parameter_set_id =get_unsigned_exp_golomb();
sh->frame_num =input_get_bits(sps->log2_max_frame_num);
if(!sps->frame_mbs_only_flag) {
sh->field_pic_flag =input_get_one_bit();
if(sh->field_pic_flag)
sh->bottom_field_flag =input_get_one_bit();
}
sh->MbaffFrameFlag=(sps->mb_adaptive_frame_field_flag && !sh->field_pic_flag);
sh->PicHeightInMbs=sps->FrameHeightInMbs/(1+sh->field_pic_flag);
sh->PicHeightInSamples=(sh->PicHeightInMbs)<<4;
sh->PicSizeInMbs=sps->PicWidthInMbs*sh->PicHeightInMbs;
if(nalu->nal_unit_type==5)
sh->idr_pic_id =get_unsigned_exp_golomb();
if(sps->pic_order_cnt_type==0) {
sh->pic_order_cnt_lsb =input_get_bits(sps->log2_max_pic_order_cnt_lsb);
if(pps->pic_order_present_flag && !sh->field_pic_flag)
sh->delta_pic_order_cnt_bottom =get_signed_exp_golomb();
}
if(sps->pic_order_cnt_type==1 && !sps->delta_pic_order_always_zero_flag) {
sh->delta_pic_order_cnt[0] =get_signed_exp_golomb();
if(pps->pic_order_present_flag && !sh->field_pic_flag)
sh->delta_pic_order_cnt[1] =get_signed_exp_golomb();
}
if(pps->redundant_pic_cnt_present_flag)
sh->redundant_pic_cnt =get_unsigned_exp_golomb();
if(sh->slice_type==B_SLICE)
sh->direct_spatial_mv_pred_flag =input_get_one_bit();
if(sh->slice_type==P_SLICE || sh->slice_type==B_SLICE || sh->slice_type==SP_SLICE) {
sh->num_ref_idx_active_override_flag =input_get_one_bit();
if(sh->num_ref_idx_active_override_flag) {
sh->num_ref_idx_l0_active =get_unsigned_exp_golomb()+1;
if(sh->slice_type==B_SLICE)
sh->num_ref_idx_l1_active =get_unsigned_exp_golomb()+1;
}
}
// ref_pic_list_reordering()
if(sh->slice_type!=I_SLICE && sh->slice_type!=SI_SLICE) {
sh->ref_pic_list_reordering_flag_l0 =input_get_one_bit();
if(sh->ref_pic_list_reordering_flag_l0)
skip_ref_pic_list_reordering();
}
if(sh->slice_type==B_SLICE) {
sh->ref_pic_list_reordering_flag_l1 =input_get_one_bit();
if(sh->ref_pic_list_reordering_flag_l1)
skip_ref_pic_list_reordering();
}
if((pps->weighted_pred_flag && (sh->slice_type==P_SLICE || sh->slice_type==SP_SLICE)) ||
(pps->weighted_bipred_idc==1 && sh->slice_type==B_SLICE)) {
fprintf(stderr,"sorry, I _really_ do not support weighted prediction!\n");
exit(1);
}
if(nalu->nal_ref_idc!=0) {
// dec_ref_pic_marking()
if(nalu->nal_unit_type==5) {
sh->no_output_of_prior_pics_flag =input_get_one_bit();
sh->long_term_reference_flag =input_get_one_bit();
} else {
sh->adaptive_ref_pic_marking_mode_flag =input_get_one_bit();
if(sh->adaptive_ref_pic_marking_mode_flag)
skip_adaptive_ref_pic_marking();
}
}
if(pps->entropy_coding_mode_flag && sh->slice_type!=I_SLICE && sh->slice_type!=SI_SLICE)
sh->cabac_init_idc =get_unsigned_exp_golomb();
sh->slice_qp_delta =get_signed_exp_golomb();
sh->SliceQPy=pps->pic_init_qp+sh->slice_qp_delta;
if(sh->slice_type==SP_SLICE || sh->slice_type==SI_SLICE) {
if(sh->slice_type==SP_SLICE)
sh->sp_for_switch_flag =input_get_one_bit();
sh->slice_qs_delta =get_signed_exp_golomb();
}
if(pps->deblocking_filter_control_present_flag) {
sh->disable_deblocking_filter_idc =get_unsigned_exp_golomb();
if(sh->disable_deblocking_filter_idc!=1) {
sh->slice_alpha_c0_offset_div2 =get_signed_exp_golomb();
sh->slice_beta_offset_div2 =get_signed_exp_golomb();
}
}
if(pps->num_slice_groups>1 && pps->slice_group_map_type>=3 && pps->slice_group_map_type<=5)
sh->slice_group_change_cycle =get_unsigned_exp_golomb();
}
char *_str_slice_type(int type) {
switch(type) {
case P_SLICE: case P_SLICE+5: return "P-Slice";
case B_SLICE: case B_SLICE+5: return "B-Slice";
case I_SLICE: case I_SLICE+5: return "I-Slice";
case SP_SLICE: case SP_SLICE+5: return "SP-Slice";
case SI_SLICE: case SI_SLICE+5: return "SI-Slice";
}
return "Illegal Slice";
}
///////////////////////////////////////////////////////////////////////////////
#ifdef BUILD_TESTS
int _test_slicehdr(int argc, char *argv[]) {
nal_unit unit;
seq_parameter_set sps;
pic_parameter_set pps;
slice_header sh;
int count;
if(!input_open("../streams/nemo_simple.264")) return 1;
for(count=1; get_next_nal_unit(&unit); ++count)
switch(unit.nal_unit_type) {
case 7: decode_seq_parameter_set(&sps); break;
case 8: decode_pic_parameter_set(&pps); break;
case 1: case 5:
decode_slice_header(&sh,&sps,&pps,&unit);
printf("%s at unit #%d (frame_num=%d)\n",
_str_slice_type(sh.slice_type),count,sh.frame_num);
printf(" RefID=0x%08X first_mb_in_slice=%d field_pic=%d\n",
sh.pic_parameter_set_id,sh.first_mb_in_slice,sh.field_pic_flag);
printf(" MbaffFrameFlag=%d PicSizeInSamples=%dx%d\n",
sh.MbaffFrameFlag,sps.PicWidthInSamples,sh.PicHeightInSamples);
printf(" idr_pic_id=0x%04X pic_order_cnt_lsb=%d redundant_pic_cnt=%d\n",
sh.idr_pic_id,sh.pic_order_cnt_lsb,sh.redundant_pic_cnt);
printf(" direct_spatial_mv_pred=%d num_ref_idx_active_override=%d\n",
sh.direct_spatial_mv_pred_flag,sh.num_ref_idx_active_override_flag);
printf(" ref_pic_list_reordering=%d/%d adaptive_ref_pic_marking=%d\n",
sh.ref_pic_list_reordering_flag_l0,sh.ref_pic_list_reordering_flag_l1,
sh.adaptive_ref_pic_marking_mode_flag);
printf(" slice_qp_delta=%d slice_qs_delta=%d\n",
sh.slice_qp_delta,sh.slice_qs_delta);
break;
}
input_close();
return 0;
}
#endif
| 43.197861 | 94 | 0.67492 |
ea7a8af692f5d702e89a9b39cb3af310d344455e | 3,285 | c | C | src/serve/http.c | ef4203/serve | c2ab5172ee22629253d2d3424937bc8a556147e8 | [
"MIT"
] | 2 | 2019-08-27T15:51:47.000Z | 2019-08-27T15:51:55.000Z | src/serve/http.c | ef4203/serve | c2ab5172ee22629253d2d3424937bc8a556147e8 | [
"MIT"
] | null | null | null | src/serve/http.c | ef4203/serve | c2ab5172ee22629253d2d3424937bc8a556147e8 | [
"MIT"
] | null | null | null | // SPDX-License-Identifier: MIT
/* Provides functions for working with the HTTP standard. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <stdex/string.h>
#include <stdex/int.h>
#include <serve/http.h>
HTTPMETHOD __parse_http_method(const char *__request)
{
if (strprefix("GET", __request))
return GET;
if (strprefix("HEAD", __request))
return HEAD;
if (strprefix("POST", __request))
return POST;
if (strprefix("PUT", __request))
return PUT;
if (strprefix("DELETE", __request))
return DELETE;
if (strprefix("TRACE", __request))
return TRACE;
if (strprefix("CONNECT", __request))
return CONNECT;
fprintf(stderr, "Could not understand HTTP method");
// TODO: Figure something out here
return GET;
}
char *__status_code_str(const int __http_status_code)
{
switch (__http_status_code)
{
case 200:
return "OK";
break;
case 404:
return "Not Found";
break;
default:
return "Not Found";
break;
}
}
/* Parse the HTTP request from the raw request data. */
HTTPREQ http_parse_request(char *__request)
{
HTTPREQ request;
request.method = __parse_http_method(__request);
memset(request.url, 0, sizeof(request.url));
memset(request.body, 0, sizeof(request.body));
char *requestPtr = __request;
while (*++requestPtr != ' ')
;
int i = 0;
while (*++requestPtr != ' ' && i < sizeof(request.url))
{
request.url[i] = *requestPtr;
i++;
}
return request;
}
/* Handle the given URL with a specified FUNC. */
void http_handle(const char *__url, const char *(*__func)())
{
char *func_buff = (char *)malloc(2048 * sizeof(char));
func_buff = __func();
free(func_buff);
}
/* Send a HTTP formated response on the given SOCKET. */
void send_http_response(const int __socket, const int __http_status_code, char **__body)
{
char *status_code = itostr(__http_status_code);
char *base_header = strnew();
strapp(&base_header, "HTTP/1.1 ");
strapp(&base_header, status_code);
strapp(&base_header, " ");
strapp(&base_header, __status_code_str(__http_status_code));
strapp(&base_header, "\n");
char *body_len = itostr(strlen(*__body));
char *content_len_header = strnew();
strapp(&content_len_header, "Content-length: ");
strapp(&content_len_header, body_len);
strapp(&content_len_header, "\n");
write(__socket, base_header, strlen(base_header));
write(__socket, content_len_header, strlen(content_len_header));
write(__socket, "Content-Type: text/html\n\n", 25);
write(__socket, *__body, strlen(*__body));
free(base_header);
free(content_len_header);
}
void serve_files(const int __socket, const char *__path)
{
char buf[128];
char *result = strnew();
FILE *fp;
if ((fp = fopen(__path, "r")) == NULL)
{
strapp(&result, "404: Not Found");
send_http_response(__socket, 404, &result);
}
else
{
while (fgets(buf, 128, fp) != NULL)
{
strapp(&result, buf);
}
send_http_response(__socket, 200, &result);
fclose(fp);
}
free(result);
}
| 24.699248 | 88 | 0.627702 |
ea7de1f300da1dd55b1ad8d27745ed1d99771ab3 | 632 | h | C | dibi.h | sunfoxcz/dibi-cpp | fdd91f75fd01f167ded1472908ec18be2279b082 | [
"MIT"
] | 1 | 2019-03-23T18:22:15.000Z | 2019-03-23T18:22:15.000Z | dibi.h | sunfoxcz/dibi-cpp | fdd91f75fd01f167ded1472908ec18be2279b082 | [
"MIT"
] | null | null | null | dibi.h | sunfoxcz/dibi-cpp | fdd91f75fd01f167ded1472908ec18be2279b082 | [
"MIT"
] | null | null | null | #ifndef DIBI_H
#define DIBI_H
#include "dibiDefine.h"
#include "dibiDriver.h"
class dibi
{
public:
static map<string,dibiDriver *> registry;
static dibiDriver *conn;
static string sql;
public:
static dibiDriver* connect(dibiConfig_t);
static dibiDriver* connect(dibiConfig_t, string);
static bool isConnected();
static dibiDriver* getConnection();
static dibiDriver* getConnection(string);
static void activate(string);
static int64 insertId();
static int64 affectedRows();
static dibiResult* nativeQuery(string);
};
#endif
| 23.407407 | 57 | 0.655063 |
ea835c52cb8328e3094e9db9afa03485222a2c71 | 530 | h | C | swift/Project/Pods/BDXBridgeKitToB/BDXBridgeKitToB/Classes/Methods/System/BDXBridgeCheckPermissionMethod.h | jfsong1122/iostest | d9cf8156d8a0b6fa4a8aa383d40ac5ff9ba2a7d9 | [
"MIT"
] | null | null | null | swift/Project/Pods/BDXBridgeKitToB/BDXBridgeKitToB/Classes/Methods/System/BDXBridgeCheckPermissionMethod.h | jfsong1122/iostest | d9cf8156d8a0b6fa4a8aa383d40ac5ff9ba2a7d9 | [
"MIT"
] | null | null | null | swift/Project/Pods/BDXBridgeKitToB/BDXBridgeKitToB/Classes/Methods/System/BDXBridgeCheckPermissionMethod.h | jfsong1122/iostest | d9cf8156d8a0b6fa4a8aa383d40ac5ff9ba2a7d9 | [
"MIT"
] | null | null | null | //
// BDXBridgeCheckPermissionMethod.h
// BDXBridgeKit
//
// Created by Lizhen Hu on 2020/8/6.
//
#import "BDXBridgeMethod.h"
NS_ASSUME_NONNULL_BEGIN
@interface BDXBridgeCheckPermissionMethod : BDXBridgeMethod
@end
@interface BDXBridgeCheckPermissionMethodParamModel : BDXBridgeModel
@property (nonatomic, assign) BDXBridgePermissionType permission;
@end
@interface BDXBridgeCheckPermissionMethodResultModel : BDXBridgeModel
@property (nonatomic, assign) BDXBridgePermissionStatus status;
@end
NS_ASSUME_NONNULL_END
| 18.275862 | 69 | 0.818868 |
ea83a0a40cb6eca62ea09ff2246329ed5541cd7b | 11,154 | c | C | test/location_test.c | tizenorg/framework.api.location-manager | 924a071a70171da7d2512199f777020a55ae9056 | [
"Apache-2.0"
] | null | null | null | test/location_test.c | tizenorg/framework.api.location-manager | 924a071a70171da7d2512199f777020a55ae9056 | [
"Apache-2.0"
] | null | null | null | test/location_test.c | tizenorg/framework.api.location-manager | 924a071a70171da7d2512199f777020a55ae9056 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2011 Samsung Electronics Co., Ltd 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <locations.h>
location_manager_h manager;
void zone_event_cb(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp,
void *user_data)
{
if (state == LOCATIONS_BOUNDARY_IN) {
printf("Entering zone\n");
} else // state == LOCATIONS_BOUNDARY_OUT
{
printf("Leaving zone\n");
}
printf("Latitude: %lf, longitude: %lf, altitude: %lf\n", latitude, longitude, altitude);
printf("Time: %s\n", ctime(×tamp));
}
static bool satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use,
void *user_data)
{
printf("[Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation, prn,
snr, is_in_use);
return true;
}
static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use,
void *user_data)
{
printf("[Last Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation,
prn, snr, is_in_use);
return true;
}
static void _state_change_cb(location_service_state_e state, void *user_data)
{
fprintf(stderr, "--------------------------state change %d---------\n", state);
location_manager_h lm = (location_manager_h) user_data;
if (state == LOCATIONS_SERVICE_ENABLED) {
int ret;
double altitude;
double latitude;
double longitude;
time_t timestamp;
ret = location_manager_get_position(lm, &altitude, &latitude, &longitude, ×tamp);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : location_manager_get_position ---> %d \n", ret);
} else {
printf("[%ld] alt: %g, lat %g, long %g\n", timestamp, altitude, latitude, longitude);
}
location_accuracy_level_e level;
double horizontal;
double vertical;
ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : location_manager_get_accuracy ---> %d \n", ret);
} else {
printf("Level : %d, horizontal: %g, vertical %g\n", level, horizontal, vertical);
}
char *nmea;
ret = gps_status_get_nmea(lm, &nmea);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : gps_status_get_nmea ---> %d \n", ret);
} else {
printf("NMEA : %s\n", nmea);
free(nmea);
}
int num_of_view, num_of_active;
ret = gps_status_get_satellite(lm, &num_of_active, &num_of_view, ×tamp);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : gps_status_get_satellite_count_in_view ---> %d \n", ret);
} else {
printf("[%ld] Satellite number of active : %d, in view : %d\n", timestamp, num_of_active, num_of_view);
}
ret = gps_status_foreach_satellites_in_view(lm, satellites_foreach_cb, user_data);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : gps_status_foreach_satellites_in_view ---> %d \n", ret);
}
}
}
static bool __poly_coords_cb(location_coords_s coords, void *user_data)
{
printf("location_bounds_foreach_rect_coords(latitude : %lf, longitude: %lf) \n", coords.latitude, coords.longitude);
return TRUE;
}
static bool __location_bounds_cb(location_bounds_h bounds, void *user_data)
{
if (bounds == NULL)
printf("bounds ==NULL\n");
else {
location_bounds_type_e type;
location_bounds_get_type(bounds, &type);
if (type == LOCATION_BOUNDS_CIRCLE) {
location_coords_s center;
double radius;
location_bounds_get_circle_coords(bounds, ¢er, &radius);
printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center.latitude,
center.longitude, radius);
} else if (type == LOCATION_BOUNDS_RECT) {
location_coords_s left_top;
location_coords_s right_bottom;
location_bounds_get_rect_coords(bounds, &left_top, &right_bottom);
printf("location_bounds_get_rect_coords(left_top : %lf, %lf - right_bottom : %lf, %lf) \n",
left_top.latitude, left_top.longitude, right_bottom.latitude, right_bottom.longitude);
} else if (type == LOCATION_BOUNDS_POLYGON) {
location_bounds_foreach_polygon_coords(bounds, __poly_coords_cb, NULL);
}
}
return TRUE;
}
void location_bounds_test()
{
int ret;
location_coords_s center;
center.latitude = 37.258;
center.longitude = 127.056;
double radius = 30;
location_bounds_h bounds_circle;
ret = location_bounds_create_circle(center, radius, &bounds_circle);
if (ret != LOCATION_BOUNDS_ERROR_NONE) {
printf("location_bounds_create_circle() failed\n");
} else
printf("Bounds(circle) has been created successfully.\n");
ret = location_manager_add_boundary(manager, bounds_circle);
if (ret != LOCATIONS_ERROR_NONE) {
printf("Setting boundary failed\n");
} else
printf("Boundary set\n");
location_coords_s center2;
double radius2;
ret = location_bounds_get_circle_coords(bounds_circle, ¢er2, &radius2);
if (ret != LOCATIONS_ERROR_NONE) {
printf("location_bounds_get_circle_coords() failed\n");
} else
printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center2.latitude,
center2.longitude, radius2);
//Add the rect bounds
location_coords_s left_top;
left_top.latitude = 30;
left_top.longitude = 30;
location_coords_s right_bottom;
right_bottom.latitude = 10;
right_bottom.longitude = 50;
location_bounds_h bounds_rect;
ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
if (ret != LOCATION_BOUNDS_ERROR_NONE) {
printf("location_bounds_create_rect() failed\n");
} else
printf("Bounds(rect) has been created successfully.\n");
ret = location_manager_add_boundary(manager, bounds_rect);
if (ret != LOCATIONS_ERROR_NONE) {
printf("Setting boundary failed\n");
} else
printf("Boundary set\n");
location_coords_s left_top2;
location_coords_s right_bottom2;
ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, &right_bottom2);
if (ret != LOCATIONS_ERROR_NONE) {
printf("location_bounds_get_rect_coords() failed\n");
} else
printf("location_bounds_get_rect_coords(left_top : %lf, %lf - right_bottom : %lf, %lf) \n", left_top2.latitude,
left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude);
//Add the polygon bounds
int poly_size = 3;
location_coords_s coord_list[poly_size];
coord_list[0].latitude = 10;
coord_list[0].longitude = 10;
coord_list[1].latitude = 20;
coord_list[1].longitude = 20;
coord_list[2].latitude = 30;
coord_list[2].longitude = 30;
location_bounds_h bounds_poly;
ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
if (ret != LOCATION_BOUNDS_ERROR_NONE) {
printf("location_bounds_create_polygon() failed\n");
} else
printf("Bounds(polygon) has been created successfully.\n");
ret = location_manager_add_boundary(manager, bounds_poly);
if (ret != LOCATIONS_ERROR_NONE) {
printf("Setting boundary failed\n");
} else
printf("Boundary set\n");
ret = location_bounds_foreach_polygon_coords(bounds_poly, __poly_coords_cb, NULL);
if (ret != LOCATIONS_ERROR_NONE) {
printf("location_bounds_get_rect_coords() failed\n");
}
location_coords_s test_coords;
test_coords.latitude = 12;
test_coords.longitude = 12;
if (location_bounds_contains_coordinates(bounds_poly, test_coords))
printf("location_bounds_contains_coordinates() retrun TRUE \n");
else
printf("location_bounds_contains_coordinates() retrun FALSE \n");
//print current bounds
ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager);
if (ret != LOCATIONS_ERROR_NONE) {
printf("location_manager_foreach_boundary() failed\n");
}
}
void location_get_last_information_test()
{
int ret;
double altitude, latitude, longitude;
double climb, direction, speed;
double horizontal, vertical;
location_accuracy_level_e level;
time_t timestamp;
int num_of_inview, num_of_active;
ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, ×tamp);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : location_manager_get_last_position ---> %d \n", ret);
} else {
printf("[%ld] alt: %g, lat: %g, long: %g\n", timestamp, altitude, latitude, longitude);
}
ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, ×tamp);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : location_manager_get_last_velocity ---> %d \n", ret);
} else {
printf("climb: %f, direction: %f, speed: %f\n", climb, direction, speed);
}
ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : location_manager_get_last_accuracy ---> %d \n", ret);
} else {
printf("Level : %d, horizontal: %g, vertical : %g\n", level, horizontal, vertical);
}
ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, ×tamp);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : gps_status_get_last_satellite_count_in_view ---> %d \n", ret);
} else {
printf("[%ld] Satellite number of active : %d, in view : %d\n", timestamp, num_of_active, num_of_inview);
}
ret = gps_status_foreach_last_satellites_in_view(manager, last_satellites_foreach_cb, NULL);
if (ret != LOCATIONS_ERROR_NONE) {
printf(" Fail : gps_status_foreach_last_satellites_in_view ---> %d \n", ret);
}
}
int location_test()
{
int ret;
ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager);
printf("create : %d\n", ret);
location_bounds_test();
location_get_last_information_test();
//set zone changed callback
ret = location_manager_set_zone_changed_cb(manager, zone_event_cb, (void *)manager);
printf("set zone callback : %d\n", ret);
ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager);
printf("set state callback : %d\n", ret);
ret = location_manager_start(manager);
printf("start : %d\n", ret);
return 1;
}
static GMainLoop *g_mainloop = NULL;
static gboolean exit_program(gpointer data)
{
if (manager == NULL) {
printf("manager == NULL \n");
} else {
int ret = location_manager_stop(manager);
printf("stop : %d\n", ret);
ret = location_manager_destroy(manager);
printf("destroy : %d\n", ret);
}
g_main_loop_quit(g_mainloop);
printf("Quit g_main_loop\n");
return FALSE;
}
int main(int argc, char **argv)
{
g_setenv("PKG_NAME", "com.samsung.location-test", 1);
g_mainloop = g_main_loop_new(NULL, 0);
location_test();
g_timeout_add_seconds(90, exit_program, NULL);
g_main_loop_run(g_mainloop);
return 0;
}
| 32.902655 | 127 | 0.7279 |
ea862e0cc3e2eec286e1a83d78e8cec09cefe236 | 456 | h | C | arduino/opencr_develop/opencr_fw_template/opencr_fw_arduino/src/arduino/variants/OpenCR/bsp/opencr/bsp.h | yemiaobing/opencr | 8700d276f60cb72db4f1ed85deff26a5f96ce7b6 | [
"Apache-2.0"
] | 3 | 2019-12-06T08:28:21.000Z | 2021-05-28T22:56:22.000Z | arduino/opencr_develop/opencr_fw_template/opencr_fw_arduino/src/arduino/variants/OpenCR/bsp/opencr/bsp.h | yemiaobing/opencr | 8700d276f60cb72db4f1ed85deff26a5f96ce7b6 | [
"Apache-2.0"
] | null | null | null | arduino/opencr_develop/opencr_fw_template/opencr_fw_arduino/src/arduino/variants/OpenCR/bsp/opencr/bsp.h | yemiaobing/opencr | 8700d276f60cb72db4f1ed85deff26a5f96ce7b6 | [
"Apache-2.0"
] | 1 | 2019-02-03T04:49:15.000Z | 2019-02-03T04:49:15.000Z | /*
* bsp.h
*
* boart support package
*
* Created on: 2017. 3. 16.
* Author: Baram
*/
#ifndef BSP_H
#define BSP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "def.h"
#include "stm32f746xx.h"
#include "stm32f7xx_hal.h"
#include "system_clock.h"
#define USE_USB_FS
void bsp_init();
void bsp_deinit();
void bsp_mpu_config(void);
#ifdef __cplusplus
}
#endif
#endif
| 10.857143 | 29 | 0.60307 |
ea8b05f0bcc338c2683e93cba5fcf01469a5b324 | 242 | h | C | VASRefreshControl-Example/VASRefreshControl-Example/ViewController.h | spbvasilenko/VASPullToRefresh | 6ed439eda07dfcbf079d538c4844b40123823303 | [
"Unlicense",
"MIT"
] | 28 | 2015-07-06T06:23:19.000Z | 2016-06-06T08:14:21.000Z | VASRefreshControl-Example/VASRefreshControl-Example/ViewController.h | spbvasilenko/VASPullToRefresh | 6ed439eda07dfcbf079d538c4844b40123823303 | [
"Unlicense",
"MIT"
] | null | null | null | VASRefreshControl-Example/VASRefreshControl-Example/ViewController.h | spbvasilenko/VASPullToRefresh | 6ed439eda07dfcbf079d538c4844b40123823303 | [
"Unlicense",
"MIT"
] | 8 | 2015-07-07T06:16:25.000Z | 2015-12-26T15:07:34.000Z | //
// ViewController.h
// VASRefreshControl-Example
//
// Created by Igor Vasilenko on 05/07/15.
// Copyright (c) 2015 Igor Vasilenko. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
| 15.125 | 59 | 0.710744 |
ea8c080a5cd5cfca85e2229c0b5639fb1760f727 | 783 | h | C | VIBE/Normal/ProductDetail/View/ProductDetailHeaderTableViewCell.h | julyutopia/Vibe-Handmade | a7b245d62f1a948536252d2e3ccee8aca7fe64ee | [
"MIT"
] | null | null | null | VIBE/Normal/ProductDetail/View/ProductDetailHeaderTableViewCell.h | julyutopia/Vibe-Handmade | a7b245d62f1a948536252d2e3ccee8aca7fe64ee | [
"MIT"
] | null | null | null | VIBE/Normal/ProductDetail/View/ProductDetailHeaderTableViewCell.h | julyutopia/Vibe-Handmade | a7b245d62f1a948536252d2e3ccee8aca7fe64ee | [
"MIT"
] | null | null | null | //
// ProductDetailHeaderTableViewCell.h
// VIBE
//
// Created by Li Haii on 16/10/20.
// Copyright © 2016年 LiHaii. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JGInfiniteScrollView.h"
#import "VibeProductModal.h"
@interface ProductDetailHeaderTableViewCell : UITableViewCell<JGInfiniteScrollViewDelegate>
{
float _width;
float _height;
UIView * _headerBackView;
NSMutableArray * _bannerImgsArray;
JGInfiniteScrollView * _autoScrollView;
UIView * _avatarBackView;
UIImageView * _avatarImgView;
UILabel * _productNameLabel;
}
-(void)setProductDetailHeaderCellWithModal:(VibeProductModal *)modal;
@end
| 23.727273 | 91 | 0.625798 |
ea8c14e06cf18ccf1c9ebac6db72f96daab366f9 | 1,107 | c | C | src/impl/ui/textbox_fps.c | Potent-Code/vektor | 1680f6d8d3a8c0e7ba4b3b38db874b5113459a7b | [
"0BSD"
] | null | null | null | src/impl/ui/textbox_fps.c | Potent-Code/vektor | 1680f6d8d3a8c0e7ba4b3b38db874b5113459a7b | [
"0BSD"
] | null | null | null | src/impl/ui/textbox_fps.c | Potent-Code/vektor | 1680f6d8d3a8c0e7ba4b3b38db874b5113459a7b | [
"0BSD"
] | null | null | null | #include <ui/textbox_fps.h>
textbox_fps textbox_fps_new();
void textbox_fps_update(void* pfps);
textbox_fps textbox_fps_new()
{
textbox_fps new = calloc(1, sizeof(*new));
scenegraph_node_init(get_scene_data(new));
new->scene_data.node_object = new;
new->scene_data.node_type = sg_geometry_2d;
new->scene_data.update = &textbox_fps_update;
new->tb = textbox_new(((float)window_width/2.0)-(12.0*(float)default_font->w) - 1.0, ((float)window_height/2.0)-(float)default_font->h - 1.0, 12, 1, 13);
// link the textbox scenegraph node to this scenegraph node
scenegraph_addchild(get_scene_data(new), get_scene_data(new->tb));
new->last_update = SDL_GetTicks();
return new;
}
void textbox_fps_update(void *pfps)
{
textbox_fps fps = pfps;
uint32_t elapsed;
char fps_msg[256];
// update frames per second counter
fps->framecount++;
if((elapsed = (SDL_GetTicks() - fps->last_update)) > 1000)
{
snprintf(fps_msg, 255, "%.0f fps", (float)fps->framecount / ((float)elapsed / 1000.));
textbox_set_text(fps->tb, fps_msg);
fps->last_update = SDL_GetTicks();
fps->framecount = 0;
}
}
| 25.159091 | 154 | 0.71635 |
ea8cf067b14626f058e8abd987d3682fa063a8ad | 1,403 | h | C | src/extension_constants.h | backwardn/timescaledb | b1eeb56c12c699c336245bb75dc1a843b19f949b | [
"Apache-2.0"
] | 1 | 2020-09-17T10:21:21.000Z | 2020-09-17T10:21:21.000Z | src/extension_constants.h | backwardn/timescaledb | b1eeb56c12c699c336245bb75dc1a843b19f949b | [
"Apache-2.0"
] | null | null | null | src/extension_constants.h | backwardn/timescaledb | b1eeb56c12c699c336245bb75dc1a843b19f949b | [
"Apache-2.0"
] | null | null | null | /*
* This file and its contents are licensed under the Apache License 2.0.
* Please see the included NOTICE for copyright information and
* LICENSE-APACHE for a copy of the license.
*/
#ifndef TIMESCALEDB_EXTENSION_CONSTANTS_H
#define TIMESCALEDB_EXTENSION_CONSTANTS_H
/* No function definitions here, only potentially globally available defines as this is used by the
* loader*/
#define EXTENSION_NAME "timescaledb"
#define EXTENSION_FDW_NAME "timescaledb_fdw"
#define TSL_LIBRARY_NAME "timescaledb-tsl"
#define TS_LIBDIR "$libdir/"
#define EXTENSION_SO TS_LIBDIR "" EXTENSION_NAME
#define MAX_VERSION_LEN (NAMEDATALEN + 1)
#define MAX_SO_NAME_LEN \
(8 + NAMEDATALEN + 1 + MAX_VERSION_LEN) /* "$libdir/"+extname+"-"+version \
* */
#define CATALOG_SCHEMA_NAME "_timescaledb_catalog"
#define INTERNAL_SCHEMA_NAME "_timescaledb_internal"
#define CACHE_SCHEMA_NAME "_timescaledb_cache"
#define CONFIG_SCHEMA_NAME "_timescaledb_config"
#define RENDEZVOUS_BGW_LOADER_API_VERSION "timescaledb.bgw_loader_api_version"
static const char *const timescaledb_schema_names[] = {
CATALOG_SCHEMA_NAME, INTERNAL_SCHEMA_NAME, CACHE_SCHEMA_NAME, CONFIG_SCHEMA_NAME
};
#define NUM_TIMESCALEDB_SCHEMAS (sizeof(timescaledb_schema_names) / sizeof(char *))
#endif /* TIMESCALEDB_EXTENSION_CONSTANTS_H */
| 40.085714 | 100 | 0.747684 |
ea8d4b0c03c5c1bcb9284590da6d2ea908e14d70 | 1,125 | c | C | week2/day11/ex03/ft_list_size.c | kyyninen/42-c-basecamp | d8441bb424867b94c47de96e51a8df10697d677b | [
"Unlicense"
] | 2 | 2021-06-17T08:03:09.000Z | 2021-06-17T08:03:53.000Z | week2/day11/ex03/ft_list_size.c | kyyninen/42-c-basecamp | d8441bb424867b94c47de96e51a8df10697d677b | [
"Unlicense"
] | null | null | null | week2/day11/ex03/ft_list_size.c | kyyninen/42-c-basecamp | d8441bb424867b94c47de96e51a8df10697d677b | [
"Unlicense"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_size.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpolonen <tpolonen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/08 14:18:22 by tpolonen #+# #+# */
/* Updated: 2021/06/08 21:00:03 by tpolonen ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_list.h"
int ft_list_size(t_list *begin_list)
{
t_list *seek;
int size;
if (!begin_list)
return (0);
seek = begin_list->next;
size = 1;
while (seek != 0)
{
size++;
seek = seek->next;
}
return (size);
}
| 36.290323 | 80 | 0.219556 |
ea8db440cc3292ec3416e033b823aba2540c3a57 | 3,510 | h | C | dockerfiles/gaas_tutorial_2/GAAS/software/SLAM/ygz_slam_ros/Thirdparty/PCL/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/metrics.h | hddxds/scripts_from_gi | afb8977c001b860335f9062464e600d9115ea56e | [
"Apache-2.0"
] | 2 | 2019-04-10T14:04:52.000Z | 2019-05-29T03:41:58.000Z | software/SLAM/ygz_slam_ros/Thirdparty/PCL/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/metrics.h | glider54321/GAAS | 5c3b8c684e72fdf7f62c5731a260021e741069e7 | [
"BSD-3-Clause"
] | null | null | null | software/SLAM/ygz_slam_ros/Thirdparty/PCL/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/metrics.h | glider54321/GAAS | 5c3b8c684e72fdf7f62c5731a260021e741069e7 | [
"BSD-3-Clause"
] | 1 | 2021-12-20T06:54:41.000Z | 2021-12-20T06:54:41.000Z | /*
* metrics.h
*
* Created on: Jun 22, 2011
* Author: aitor
*/
#ifndef REC_FRAMEWORK_METRICS_H_
#define REC_FRAMEWORK_METRICS_H_
#include <cmath>
#include <cstdlib>
namespace Metrics
{
using ::std::abs;
template<typename T>
struct Accumulator
{
typedef T Type;
};
template<>
struct Accumulator<unsigned char>
{
typedef float Type;
};
template<>
struct Accumulator<unsigned short>
{
typedef float Type;
};
template<>
struct Accumulator<unsigned int>
{
typedef float Type;
};
template<>
struct Accumulator<char>
{
typedef float Type;
};
template<>
struct Accumulator<short>
{
typedef float Type;
};
template<>
struct Accumulator<int>
{
typedef float Type;
};
template<class T>
struct HistIntersectionUnionDistance
{
typedef T ElementType;
typedef typename Accumulator<T>::Type ResultType;
/**
* Compute a distance between two vectors using (1 - (1 + sum(min(a_i,b_i))) / (1 + sum(max(a_i, b_i))) )
*
* This distance is not a valid kdtree distance, it's not dimensionwise additive
* and ignores worst_dist parameter.
*/
template<typename Iterator1, typename Iterator2>
ResultType
operator() (Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
{
(void)worst_dist;
ResultType result = ResultType ();
ResultType min0, min1, min2, min3;
ResultType max0, max1, max2, max3;
Iterator1 last = a + size;
Iterator1 lastgroup = last - 3;
ResultType sum_min, sum_max;
sum_min = 0;
sum_max = 0;
while (a < lastgroup)
{
min0 = (a[0] < b[0] ? a[0] : b[0]);
max0 = (a[0] > b[0] ? a[0] : b[0]);
min1 = (a[1] < b[1] ? a[1] : b[1]);
max1 = (a[1] > b[1] ? a[1] : b[1]);
min2 = (a[2] < b[2] ? a[2] : b[2]);
max2 = (a[2] > b[2] ? a[2] : b[2]);
min3 = (a[3] < b[3] ? a[3] : b[3]);
max3 = (a[3] > b[3] ? a[3] : b[3]);
sum_min += min0 + min1 + min2 + min3;
sum_max += max0 + max1 + max2 + max3;
a += 4;
b += 4;
/*if (worst_dist>0 && result>worst_dist) {
return result;
}*/
}
while (a < last)
{
min0 = *a < *b ? *a : *b;
max0 = *a > *b ? *a : *b;
sum_min += min0;
sum_max += max0;
a++;
b++;
//std::cout << a << " " << last << std::endl;
}
result = static_cast<ResultType> (1.0 - ((1 + sum_min) / (1 + sum_max)));
return result;
}
/* This distance functor is not dimension-wise additive, which
* makes it an invalid kd-tree distance, not implementing the accum_dist method */
/**
* Partial distance, used by the kd-tree.
*/
template<typename U, typename V>
inline ResultType
accum_dist (const U& a, const V& b, int) const
{
//printf("New code being used, accum_dist\n");
ResultType min0;
ResultType max0;
min0 = (a < b ? a : b) + 1.0;
max0 = (a > b ? a : b) + 1.0;
return (1 - (min0 / max0));
//return (a+b-2*(a<b?a:b));
}
};
}
#endif /* REC_FRAMEWORK_METRICS_H_ */
| 25.434783 | 112 | 0.492877 |
ea9006df463d748e6632153a46e4fb07871ee5dc | 5,507 | c | C | object.c | tleino/tfmud | b85c683fc5e173968770553a3d44aa5ce1b36f06 | [
"0BSD"
] | null | null | null | object.c | tleino/tfmud | b85c683fc5e173968770553a3d44aa5ce1b36f06 | [
"0BSD"
] | null | null | null | object.c | tleino/tfmud | b85c683fc5e173968770553a3d44aa5ce1b36f06 | [
"0BSD"
] | null | null | null | /*
* ISC License
*
* Copyright (c) 2021, Tommi Leino <namhas@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "object.h"
#include "room.h"
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <inttypes.h>
#include <stdio.h>
#include <fnmatch.h>
static void object_add_child(
struct object *,
struct object *);
static void object_remove_child(
struct object *,
struct object *);
static void object_add(
struct object *);
static void object_remove(
struct object *);
static ObjType parse_type(
const char *);
static char *parse_key(
const char *,
ObjType *);
static size_t hash_key(
const char *);
#define OBJ_HASH_SZ 8192
static struct object *_head;
static struct object *_hash[OBJ_HASH_SZ];
static size_t _max_id[MAX_OBJ_TYPE];
#ifndef ARRLEN
#define ARRLEN(_x) sizeof((_x)) / sizeof((_x)[0])
#endif
void
set_title(struct object *obj, const char *str)
{
if (obj->title != NULL)
free(obj->title);
obj->title = strdup(str);
}
const char *
title(struct object *obj)
{
return obj->title;
}
static size_t
hash_key(const char *key)
{
size_t k;
for (k = 0; *key != '\0'; key++)
k = *key + (k << 6) + (k << 16) - k;
k %= OBJ_HASH_SZ;
return k;
}
static ObjType
parse_type(const char *type)
{
static const char *types[MAX_OBJ_TYPE] = {
"player", "room", "item"
};
ObjType i;
for (i = 0; i < MAX_OBJ_TYPE; i++)
if (strcmp(types[i], type) == 0)
return i;
return i;
}
static char *
parse_key(const char *key, ObjType *type)
{
char cl[16 + 1];
static char id[16 + 1];
size_t i;
assert(key != NULL);
i = strcspn(key, "/");
assert(key[i] != '\0');
/*
* Truncate to sizeof(cl)-1
*/
strncpy(cl, key, i > sizeof(cl)-1 ? sizeof(cl)-1 : i);
cl[i > sizeof(cl)-1 ? sizeof(cl)-1 : i] = '\0';
*type = parse_type(cl);
strlcpy(id, &key[i+1], sizeof(id));
return id;
}
#include <stdio.h>
struct object *
object_find(const char *key)
{
struct object *np;
size_t k;
k = hash_key(key);
np = _hash[k];
while (np != NULL) {
if (strcmp(np->key, key) != 0)
np = np->next_hash;
else
break;
}
if (np == NULL) {
/* FIXME: Always return object */
if ((np = object_create(key)) == NULL)
return NULL;
np->next_hash = _hash[k];
_hash[k] = np;
}
return np;
}
size_t
max_object_id(ObjType type)
{
return _max_id[type];
}
struct object *
object_create(const char *key)
{
struct object *obj;
const char *id;
printf("Create object: %s\n", key);
if ((obj = calloc(1, sizeof(*obj))) == NULL)
return NULL;
if ((obj->key = strdup(key)) == NULL) {
free(obj);
return NULL;
}
id = parse_key(key, &obj->type);
if (_max_id[obj->type] < (size_t) atoll(id))
_max_id[obj->type] = (size_t) atoll(id);
if (obj->type == OBJ_TYPE_ROOM)
room_create(obj, id);
object_add(obj);
return obj;
}
void
object_save_all(FILE *fp, const char *pattern)
{
struct object *obj;
obj = NULL;
while ((obj = object_next(obj)) != NULL) {
if (fnmatch(pattern, obj->key, 0) == FNM_NOMATCH)
continue;
printf("Saving %s\n", obj->key);
if (obj->type == OBJ_TYPE_ROOM)
room_save(ROOM(obj), fp);
}
}
void
object_free(struct object *obj)
{
object_remove(obj);
free(obj->key);
free(obj);
}
void
object_reparent(struct object *obj, struct object *parent)
{
if (obj->parent != NULL)
object_remove_child(obj->parent, obj);
if (parent != NULL)
object_add_child(parent, obj);
}
struct object *
object_next_child(struct object *obj, struct object *prev)
{
if (prev == NULL)
return obj->first_child;
else
return prev->next;
}
struct object *
object_next(struct object *prev)
{
if (prev == NULL)
return _head;
else
return prev->next_all;
}
static void
object_add(struct object *obj)
{
obj->next_all = _head;
_head = obj;
}
static void
object_remove(struct object *obj)
{
struct object *np, *prev = NULL;
for (np = _head; np != NULL; prev = np, np = np->next_all)
if (np == obj) {
if (obj->parent != NULL)
object_remove_child(obj->parent, obj);
if (prev != NULL)
prev->next_all = np->next_all;
else if (np == _head)
_head = np->next_all;
break;
}
}
static void
object_remove_child(struct object *obj, struct object *child)
{
struct object *np, *prev = NULL;
for (np = obj->first_child; np != NULL; prev = np, np = np->next)
if (np == child) {
if (prev != NULL)
prev->next = np->next;
else if (np == obj->first_child)
obj->first_child = np->next;
np->parent = NULL;
break;
}
}
static void
object_add_child(struct object *obj, struct object *child)
{
if (child->parent == NULL) {
child->next = obj->first_child;
child->parent = obj;
obj->first_child = child;
}
}
| 19.597865 | 75 | 0.63846 |
ea902af3b2ccdb92e03c6c065a60769029855bff | 3,185 | h | C | lib/EMP/emp-tool/io/net_io_channel.h | zpleefly/libscapi | 27d7d964d645ed111c2cc9870087971cf13e24f4 | [
"MIT"
] | null | null | null | lib/EMP/emp-tool/io/net_io_channel.h | zpleefly/libscapi | 27d7d964d645ed111c2cc9870087971cf13e24f4 | [
"MIT"
] | 2 | 2021-03-20T05:38:48.000Z | 2021-03-31T20:14:11.000Z | lib/EMP/emp-tool/io/net_io_channel.h | zpleefly/libscapi | 27d7d964d645ed111c2cc9870087971cf13e24f4 | [
"MIT"
] | null | null | null | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <string>
#include "io_channel.h"
using namespace std;
#ifndef NETWORK_IO_CHANNEL
#define NETWORK_IO_CHANNEL
/** @addtogroup IO
@{
*/
class NetIO: public IOChannel<NetIO> { public:
bool is_server;
int mysocket = -1;
int consocket = -1;
FILE * stream = nullptr;
char * buffer = nullptr;
bool has_sent = false;
string addr;
int port;
#ifdef COUNT_IO
uint64_t counter = 0;
#endif
NetIO(const char * address, int port, bool quiet = false) {
this->port = port;
is_server = (address == nullptr);
if (address == nullptr) {
struct sockaddr_in dest;
struct sockaddr_in serv;
socklen_t socksize = sizeof(struct sockaddr_in);
memset(&serv, 0, sizeof(serv));
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = htonl(INADDR_ANY); /* set our address to any interface */
serv.sin_port = htons(port); /* set the server port number */
mysocket = socket(AF_INET, SOCK_STREAM, 0);
int reuse = 1;
setsockopt(mysocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse));
bind(mysocket, (struct sockaddr *)&serv, sizeof(struct sockaddr));
listen(mysocket, 1);
consocket = accept(mysocket, (struct sockaddr *)&dest, &socksize);
}
else {
addr = string(address);
struct sockaddr_in dest;
consocket = socket(AF_INET, SOCK_STREAM, 0);
memset(&dest, 0, sizeof(dest));
dest.sin_family = AF_INET;
dest.sin_addr.s_addr = inet_addr(address);
dest.sin_port = htons(port);
while(connect(consocket, (struct sockaddr *)&dest, sizeof(struct sockaddr)) == -1) {
usleep(1000);
}
}
// set_nodelay();
if(!quiet)
cout << "connected"<<endl;
stream = fdopen(consocket, "wb+");
buffer = new char[NETWORK_BUFFER_SIZE];
memset(buffer, 0, NETWORK_BUFFER_SIZE);
setvbuf(stream, buffer, _IOFBF, NETWORK_BUFFER_SIZE);
}
~NetIO(){
fflush(stream);
close(consocket);
delete[] buffer;
}
void sync() {
int tmp = 0;
if(is_server) {
send_data(&tmp, 1);
recv_data(&tmp, 1);
}else{
recv_data(&tmp, 1);
send_data(&tmp, 1);
flush();
}
}
void set_nodelay(){
const int one=1;
setsockopt(consocket,IPPROTO_TCP,TCP_NODELAY,&one,sizeof(one));
}
void set_delay(){
const int zero = 0;
setsockopt(consocket,IPPROTO_TCP,TCP_NODELAY,&zero,sizeof(zero));
}
void flush() {
fflush(stream);
}
void send_data_impl(const void * data, int len) {
#ifdef COUNT_IO
counter +=len;
#endif
int sent = 0;
while(sent < len) {
int res = fwrite(sent+(char*)data, 1, len-sent, stream);
if (res >= 0)
sent+=res;
else
fprintf(stderr,"error: net_send_data %d\n", res);
}
has_sent = true;
}
void recv_data_impl(void * data, int len) {
if(has_sent)
fflush(stream);
has_sent = false;
int sent = 0;
while(sent < len) {
int res = fread(sent+(char*)data, 1, len-sent, stream);
if (res >= 0)
sent+=res;
else
fprintf(stderr,"error: net_send_data %d\n", res);
}
}
};
/**@}*/
#endif//NETWORK_IO_CHANNEL
| 23.768657 | 87 | 0.655573 |
ea910d51cc2595ddb701b5a95e08134e602eeece | 649 | h | C | inc/prf_read_data.h | patinnc/oppat | 5113cb46b5810d421a4e87903c8afe4f46605ae7 | [
"MIT"
] | 24 | 2019-03-30T17:58:58.000Z | 2022-03-30T06:25:28.000Z | inc/prf_read_data.h | epickrram/oppat | b83602d2c1582487b0cb16af444db3f478f09e73 | [
"MIT"
] | null | null | null | inc/prf_read_data.h | epickrram/oppat | b83602d2c1582487b0cb16af444db3f478f09e73 | [
"MIT"
] | 2 | 2019-05-14T11:49:01.000Z | 2022-03-01T10:44:50.000Z | /* Copyright (c) 2018 Patrick Fay
*
* License http://opensource.org/licenses/mit-license.php MIT License
*/
#pragma once
#include "rd_json.h"
#ifdef EXTERN_STR
#undef EXTERN_STR
#endif
#ifdef PRF_RD_DATA_CPP
#define EXTERN_STR
#else
#define EXTERN_STR extern
#endif
EXTERN_STR int prf_read_data_bin(std::string flnm, int verbose, prf_obj_str &prf_obj, double tm_beg, file_list_str &file_list);
EXTERN_STR size_t prf_sample_to_string(int idx, std::string &ostr, prf_obj_str &prf_obj);
EXTERN_STR int prf_parse_text(std::string flnm, prf_obj_str &prf_obj, double tm_beg_in, int verbose, std::vector <evt_str> &evt_tbl2);
| 28.217391 | 135 | 0.756549 |
ea938821b40c72903d6a8df77d364216e1bbade8 | 6,109 | h | C | aws-cpp-sdk-forecast/include/aws/forecast/model/Filter.h | grujicbr/aws-sdk-cpp | bdd43c178042f09c6739645e3f6cd17822a7c35c | [
"Apache-2.0"
] | 1 | 2020-03-11T05:36:20.000Z | 2020-03-11T05:36:20.000Z | aws-cpp-sdk-forecast/include/aws/forecast/model/Filter.h | novaquark/aws-sdk-cpp | a0969508545bec9ae2864c9e1e2bb9aff109f90c | [
"Apache-2.0"
] | null | null | null | aws-cpp-sdk-forecast/include/aws/forecast/model/Filter.h | novaquark/aws-sdk-cpp | a0969508545bec9ae2864c9e1e2bb9aff109f90c | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2010-2017 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.
*/
#pragma once
#include <aws/forecast/ForecastService_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/forecast/model/FilterConditionString.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace ForecastService
{
namespace Model
{
/**
* <p>Describes a filter for choosing a subset of objects. Each filter consists of
* a condition and a match statement. The condition is either <code>IS</code> or
* <code>IS_NOT</code>, which specifies whether to include or exclude the objects
* that match the statement, respectively. The match statement consists of a key
* and a value.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/forecast-2018-06-26/Filter">AWS API
* Reference</a></p>
*/
class AWS_FORECASTSERVICE_API Filter
{
public:
Filter();
Filter(Aws::Utils::Json::JsonView jsonValue);
Filter& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>The name of the parameter to filter on.</p>
*/
inline const Aws::String& GetKey() const{ return m_key; }
/**
* <p>The name of the parameter to filter on.</p>
*/
inline bool KeyHasBeenSet() const { return m_keyHasBeenSet; }
/**
* <p>The name of the parameter to filter on.</p>
*/
inline void SetKey(const Aws::String& value) { m_keyHasBeenSet = true; m_key = value; }
/**
* <p>The name of the parameter to filter on.</p>
*/
inline void SetKey(Aws::String&& value) { m_keyHasBeenSet = true; m_key = std::move(value); }
/**
* <p>The name of the parameter to filter on.</p>
*/
inline void SetKey(const char* value) { m_keyHasBeenSet = true; m_key.assign(value); }
/**
* <p>The name of the parameter to filter on.</p>
*/
inline Filter& WithKey(const Aws::String& value) { SetKey(value); return *this;}
/**
* <p>The name of the parameter to filter on.</p>
*/
inline Filter& WithKey(Aws::String&& value) { SetKey(std::move(value)); return *this;}
/**
* <p>The name of the parameter to filter on.</p>
*/
inline Filter& WithKey(const char* value) { SetKey(value); return *this;}
/**
* <p>The value to match.</p>
*/
inline const Aws::String& GetValue() const{ return m_value; }
/**
* <p>The value to match.</p>
*/
inline bool ValueHasBeenSet() const { return m_valueHasBeenSet; }
/**
* <p>The value to match.</p>
*/
inline void SetValue(const Aws::String& value) { m_valueHasBeenSet = true; m_value = value; }
/**
* <p>The value to match.</p>
*/
inline void SetValue(Aws::String&& value) { m_valueHasBeenSet = true; m_value = std::move(value); }
/**
* <p>The value to match.</p>
*/
inline void SetValue(const char* value) { m_valueHasBeenSet = true; m_value.assign(value); }
/**
* <p>The value to match.</p>
*/
inline Filter& WithValue(const Aws::String& value) { SetValue(value); return *this;}
/**
* <p>The value to match.</p>
*/
inline Filter& WithValue(Aws::String&& value) { SetValue(std::move(value)); return *this;}
/**
* <p>The value to match.</p>
*/
inline Filter& WithValue(const char* value) { SetValue(value); return *this;}
/**
* <p>The condition to apply. To include the objects that match the statement,
* specify <code>IS</code>. To exclude matching objects, specify
* <code>IS_NOT</code>.</p>
*/
inline const FilterConditionString& GetCondition() const{ return m_condition; }
/**
* <p>The condition to apply. To include the objects that match the statement,
* specify <code>IS</code>. To exclude matching objects, specify
* <code>IS_NOT</code>.</p>
*/
inline bool ConditionHasBeenSet() const { return m_conditionHasBeenSet; }
/**
* <p>The condition to apply. To include the objects that match the statement,
* specify <code>IS</code>. To exclude matching objects, specify
* <code>IS_NOT</code>.</p>
*/
inline void SetCondition(const FilterConditionString& value) { m_conditionHasBeenSet = true; m_condition = value; }
/**
* <p>The condition to apply. To include the objects that match the statement,
* specify <code>IS</code>. To exclude matching objects, specify
* <code>IS_NOT</code>.</p>
*/
inline void SetCondition(FilterConditionString&& value) { m_conditionHasBeenSet = true; m_condition = std::move(value); }
/**
* <p>The condition to apply. To include the objects that match the statement,
* specify <code>IS</code>. To exclude matching objects, specify
* <code>IS_NOT</code>.</p>
*/
inline Filter& WithCondition(const FilterConditionString& value) { SetCondition(value); return *this;}
/**
* <p>The condition to apply. To include the objects that match the statement,
* specify <code>IS</code>. To exclude matching objects, specify
* <code>IS_NOT</code>.</p>
*/
inline Filter& WithCondition(FilterConditionString&& value) { SetCondition(std::move(value)); return *this;}
private:
Aws::String m_key;
bool m_keyHasBeenSet;
Aws::String m_value;
bool m_valueHasBeenSet;
FilterConditionString m_condition;
bool m_conditionHasBeenSet;
};
} // namespace Model
} // namespace ForecastService
} // namespace Aws
| 31.489691 | 125 | 0.65117 |
ea9409a5fc57195fb7ee65ad640a8918efdef23a | 5,295 | h | C | sceneobject.h | fossabot/Mycraft | efa76da4c5025ff885ce68acf7939fd0928107fd | [
"MIT"
] | null | null | null | sceneobject.h | fossabot/Mycraft | efa76da4c5025ff885ce68acf7939fd0928107fd | [
"MIT"
] | 1 | 2019-07-01T23:27:21.000Z | 2019-07-01T23:27:21.000Z | sceneobject.h | fossabot/Mycraft | efa76da4c5025ff885ce68acf7939fd0928107fd | [
"MIT"
] | 2 | 2019-07-01T04:35:39.000Z | 2020-03-10T21:29:56.000Z | /*Class describing a generalized object in the scene */
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#define NumberOf(array) (sizeof(array)/sizeof(array[0]))
class sceneObject {
private:
GLfloat * verticies;
int sv, sc, sf;
GLubyte * faces;
GLfloat * colors;
GLfloat * textures;
bool textured;
GLenum PrimType;
const char* name;
public:
//Name, Verticies, Faces, Colors, Textures
sceneObject();
sceneObject(const char *, GLfloat*, int, GLubyte*, int, GLfloat*, int, GLfloat*, int);
const char * getName() {return name;};
GLfloat * getVerts() {return verticies;};
int sizeVerts() {return sv;};
GLubyte * getInds() {return faces;};
int sizeInds() {return sf;};
GLfloat * getColors() {return colors;};
int sizeCols() {return sc;};
bool isTextured() {return textured;};
GLfloat * getTexture() {return textures;};
GLenum primitive() {return PrimType;};
};
//null constructor
sceneObject::sceneObject() {
verticies = NULL;
faces = NULL;
colors = NULL;
textures = NULL;
textured = false;
sc = 0;
sf = 0;
sv = 0;
PrimType = GL_POLYGON;
name = "NULL";
}
sceneObject::sceneObject(const char * nm, GLfloat * ver, int sv1, GLubyte * fac, int sf1, GLfloat * col, int sc1, GLfloat * tex, int pr) {
name = nm;
sv = sv1;
sc = sc1;
sf = sf1;
verticies = ver;
faces = fac;
colors = col;
textures = tex;
PrimType = pr;
if (tex != NULL) {textured = true;} else {textured = false;}
}
//Make a few sample sceneobjects
//Make a cube
GLfloat wd = 1 ;
GLfloat _cubecol[8][3] = {
{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0},
{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}} ;
GLfloat cubeverts[8][3] = {
{-wd, -wd, 0.0}, {-wd, wd, 0.0}, {wd, wd, 0.0}, {wd, -wd, 0.0},
{-wd, -wd, wd}, {wd, -wd, wd}, {wd, wd, wd}, {-wd, wd, wd}
} ;
GLfloat cubecol[8][3] ;
GLubyte cubeinds[6][4] = {
{0, 1, 2, 3}, // BOTTOM
{4, 5, 6, 7}, // TOP
{0, 4, 7, 1}, // LEFT
{0, 3, 5, 4}, // FRONT
{3, 2, 6, 5}, // RIGHT
{1, 7, 6, 2} // BACK
} ;
sceneObject mycube ((const char *)"MYCUBE", (GLfloat*)cubeverts, sizeof(cubeverts), (GLubyte*)cubeinds, sizeof(cubeinds), (GLfloat*) _cubecol, sizeof(_cubecol), (GLfloat*)NULL, GL_QUADS);
//make a floor
int worldSize = 10;
GLfloat floorverts[4][3] = {
{worldSize, worldSize, 0.0}, {-worldSize, worldSize, 0.0}, {-worldSize, -worldSize, 0.0}, {worldSize, -worldSize, 0.0}
} ;
GLfloat floorcol[4][3] = {
{0.0, 0.3, 0.0}, {0.0, 0.3, 0.0}, {0.0, 0.3, 0.0}, {0.0, 0.3, 0.0}
} ;
GLubyte floorinds[1][4] = { {0, 1, 2, 3} } ;
GLfloat floortex[4][2] = {
{20.0, 20.0}, {0.0, 20.0}, {0.0, 0.0}, {20.0, 0.0}
} ;
sceneObject myfloor ((const char *)"FLOOR", (GLfloat*)floorverts, sizeof(floorverts), (GLubyte*)floorinds, sizeof(floorinds), (GLfloat*) floorcol, sizeof(floorcol), (GLfloat*)NULL, GL_POLYGON);
//make a dude
GLfloat dudelen = .3;
GLfloat dudewidth = .15;
GLfloat boardlength = 1;
GLfloat dudeverts[10][3] = {
{-dudewidth, -dudelen/2, 0.0}, {-dudewidth, dudelen/2, 0.0}, {-dudewidth, 0.0, dudelen},
{dudewidth, -dudelen/2, 0.0}, {dudewidth, dudelen/2, 0.0}, {dudewidth, 0.0, dudelen},
{-dudewidth, -boardlength, 0.0}, {-dudewidth, boardlength, 2*dudelen},
{dudewidth, -boardlength, 0.0}, {dudewidth, boardlength, 2*dudelen}
} ;
GLfloat dudecol[10][3] = {
{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},
{0.5, 0.0, 0.0},{0.5, 0.0, 0.0},{0.5, 0.0,0.0},{0.5, 0.0, 0.0}
} ;
GLubyte dudeinds[10][3] = { {0, 1, 2}, {3, 4, 5}, {0, 1, 4}, {4, 3, 0}, {0, 3, 5} , {5, 2, 0} , {1, 2, 5} ,{5, 4, 1}, {6, 7, 8}, {8, 9, 7}} ;
sceneObject dude ((const char *)"DUDE", (GLfloat*)dudeverts, sizeof(dudeverts), (GLubyte*)dudeinds, sizeof(dudeinds), (GLfloat*) dudecol, sizeof(dudecol), (GLfloat*)NULL, GL_TRIANGLES);
//ADDING AN IMPORTED OBJECT
std::vector<std::string> split(std::string const &input) {
std::stringstream buffer(input);
std::vector<std::string> ret;
std::copy(std::istream_iterator<std::string>(buffer),
std::istream_iterator<std::string>(),
std::back_inserter(ret));
return ret;
}
/*Read an object file*/
void loadObjFile(const char* filename, std::vector<vec3> &verts, std::vector<vec3> &faces) {
std::string line;
std::ifstream myfile (filename);
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
// std::cout << line<<std::endl;
if (line[0] == 'v' && line[1] == ' ') {
std::vector<std::string> sline = split(line);
GLfloat a = (GLfloat)atof(sline[1].c_str());
GLfloat b = (GLfloat)atof(sline[2].c_str());
GLfloat c = (GLfloat)atof(sline[3].c_str());
verts.push_back(vec3(a,b,c));
}
if (line[0] == 'f') {
std::vector<std::string> sline = split(line);
GLuint d = (GLuint)(atoi(sline[1].c_str()) - 1);
for (int i = 3; i < sline.size(); i ++) {
GLuint e = (GLuint)(atoi(sline[i-1].c_str()) - 1);
GLuint f = (GLuint)(atoi(sline[i].c_str()) - 1);
faces.push_back(vec3(d,e,f));
}
}
}
myfile.close();
}
}
//Used for imported objects
| 30.606936 | 193 | 0.593579 |
ea94ab99a809d04e5e79316cf431c42f69c234bb | 3,681 | h | C | Common/Common/Source/i2c_util.h | KakuheikiCreator/TWELITE | 9159970b2095d52cfdfff8939cd7e03d9b7a573b | [
"BSD-2-Clause"
] | 1 | 2020-03-12T09:22:02.000Z | 2020-03-12T09:22:02.000Z | Common/Common/Source/i2c_util.h | takashi4356/TWELITE | 9159970b2095d52cfdfff8939cd7e03d9b7a573b | [
"BSD-2-Clause"
] | null | null | null | Common/Common/Source/i2c_util.h | takashi4356/TWELITE | 9159970b2095d52cfdfff8939cd7e03d9b7a573b | [
"BSD-2-Clause"
] | 1 | 2018-12-24T02:18:25.000Z | 2018-12-24T02:18:25.000Z | /****************************************************************************
*
* MODULE :I2C Utility functions header file
*
* CREATED:2015/03/22 08:32:00
* AUTHOR :Nakanohito
*
* DESCRIPTION:
* I2C接続機能を提供するユーティリティ関数群
* I2C Utility functions (header file)
*
* CHANGE HISTORY:
*
* LAST MODIFIED BY:
*
****************************************************************************
* Copyright (c) 2015, Nakanohito
* This software is released under the BSD 2-Clause License.
* http://opensource.org/licenses/BSD-2-Clause
****************************************************************************/
#ifndef I2CUTIL_H_INCLUDED
#define I2CUTIL_H_INCLUDED
#if defined __cplusplus
extern "C" {
#endif
/****************************************************************************/
/*** Include files ***/
/****************************************************************************/
/****************************************************************************/
/*** Macro Definitions ***/
/****************************************************************************/
// I2C Execution result status : ACK
#define I2CUTIL_STS_ACK TRUE
// I2C Execution result status : NACK
#define I2CUTIL_STS_NACK FALSE
// I2C Execution result status : ERROR
#define I2CUTIL_STS_ERR (0xFF)
/****************************************************************************/
/*** Type Definitions ***/
/****************************************************************************/
/****************************************************************************/
/*** Exported Variables ***/
/****************************************************************************/
/****************************************************************************/
/*** Local Variables ***/
/****************************************************************************/
/****************************************************************************/
/*** Local Function Prototypes ***/
/****************************************************************************/
/****************************************************************************/
/*** Exported Functions ***/
/****************************************************************************/
// 初期化処理
PUBLIC void vI2C_init(uint8 u8PreScaler);
// 読み込み開始
PUBLIC bool_t bI2C_startRead(uint8 u8Address);
// 書き込み開始処理
PUBLIC bool_t bI2C_startWrite(uint8 u8Address);
// 読み込み処理(継続)
PUBLIC bool_t bI2C_read(uint8* pu8Data, uint8 u8Length, bool_t bAckEndFlg);
// 書き込み処理(継続)
PUBLIC uint8 u8I2C_write(uint8 u8Data);
// 書き込み処理(終端)
PUBLIC uint8 u8I2C_writeStop(uint8 u8Data);
// 読み書き終了処理(ACK返信)
PUBLIC bool_t bI2C_stopACK();
// 読み書き終了処理(NACK返信)
PUBLIC bool_t bI2C_stopNACK();
// バス駆動周波数参照
PUBLIC uint32 u32I2C_getFrequency();
/****************************************************************************/
/*** Local Functions ***/
/****************************************************************************/
#if defined __cplusplus
}
#endif
#endif /* I2CUTIL_H_INCLUDED */
/****************************************************************************/
/*** END OF FILE ***/
/****************************************************************************/
| 39.159574 | 78 | 0.298832 |
ea95e4468ed005b1bd6d5f13b0fb69790eb51480 | 1,873 | h | C | common/common_errors.h | abadona/qsimscan | 3ae8524d7f97a0586ed3b283c49d28c298a3f558 | [
"MIT"
] | 10 | 2015-11-20T00:19:13.000Z | 2021-02-25T10:33:14.000Z | common/common_errors.h | abadona/qsimscan | 3ae8524d7f97a0586ed3b283c49d28c298a3f558 | [
"MIT"
] | 1 | 2016-08-24T07:09:42.000Z | 2016-08-24T07:09:42.000Z | common/common_errors.h | abadona/qsimscan | 3ae8524d7f97a0586ed3b283c49d28c298a3f558 | [
"MIT"
] | 1 | 2020-03-10T03:02:24.000Z | 2020-03-10T03:02:24.000Z | //////////////////////////////////////////////////////////////////////////////
//// This software module is developed by SciDM (Scientific Data Management) in 1998-2015
////
//// This program is free software; you can redistribute, reuse,
//// or modify it with no restriction, under the terms of the MIT License.
////
//// 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.
////
//// For any questions please contact Denis Kaznadzey at dkaznadzey@yahoo.com
//////////////////////////////////////////////////////////////////////////////
#ifndef __common_errors_h__
#define __common_errors_h__
#ifndef __common_errors_cpp__
extern const char* ERR_NoMemory;
extern const char* ERR_Internal;
extern const char* ERR_FileNotFound;
extern const char* ERR_OSError;
extern const char* ERR_OutOfBounds;
// synonyms
#define NOEMEM ERR_NoMemory
#define INTERNAL ERR_Internal
#define MAKE_ERROR_TYPE(C,N) class C : public Rerror\
{\
public:\
C (const char* s = "")\
: Rerror (N)\
{\
if (*s)\
{\
msg_ += ": ";\
msg_ += s;\
}\
}\
};
MAKE_ERROR_TYPE (MemoryRerror, ERR_NoMemory);
MAKE_ERROR_TYPE (InternalRerror, ERR_Internal);
MAKE_ERROR_TYPE (FileNotFoundRerror, ERR_FileNotFound);
MAKE_ERROR_TYPE (OutOfBoundsRerror, ERR_OutOfBounds);
#endif
class OSRerror : public Rerror
{
const char* get_err_str () const;
const char* get_errno_str () const;
public:
OSRerror (const char* s = "")
: Rerror (ERR_OSError)
{
msg_ += ": errno ";
msg_ += get_errno_str ();
msg_ += ": ";
msg_ += get_err_str ();
if (*s)
{
msg_ += ": ";
msg_ += s;
}
}
};
#endif // __common_errors_h__
| 25.657534 | 89 | 0.595836 |
ea96d14dd41ef49eede45799ae3fe6266680ae7b | 635 | h | C | LLSearchViewController/LLSearchViewController/LLSearchViewControllerBase/ExtensionView/NBSSearchShopHistoryView.h | lilongcnc/LLSearchViewController | 9535a2c059eecf35abf9f58aa5a930cad9374131 | [
"MIT"
] | 31 | 2017-08-23T13:08:00.000Z | 2021-02-23T06:41:44.000Z | LLSearchViewController/LLSearchViewController/LLSearchViewControllerBase/ExtensionView/NBSSearchShopHistoryView.h | lilongcnc/LLSearchViewController | 9535a2c059eecf35abf9f58aa5a930cad9374131 | [
"MIT"
] | 3 | 2017-09-01T07:11:12.000Z | 2018-07-30T01:51:09.000Z | LLSearchViewController/LLSearchViewController/LLSearchViewControllerBase/ExtensionView/NBSSearchShopHistoryView.h | lilongcnc/LLSearchViewController | 9535a2c059eecf35abf9f58aa5a930cad9374131 | [
"MIT"
] | 5 | 2017-08-25T06:42:29.000Z | 2018-05-07T07:31:24.000Z | //
// NBSSearchShopHistoryView.h
// LLSearchViewController
//
// Created by 李龙 on 2017/7/14.
//
//
#import <UIKit/UIKit.h>
@class HistorySearchHistroyViewP;
typedef void (^historyTagonClickBlock)(UILabel *tagLabel);
@interface NBSSearchShopHistoryView : UIView
+ (instancetype)searchShopCategoryViewWithPresenter:(HistorySearchHistroyViewP *)presenter WithFrame:(CGRect)rect;
/**
刷新数据
*/
- (void)reloadData;
/**
历史标签被点击
@param clickBlock <#clickBlock description#>
*/
- (void)historyTagonClick:(historyTagonClickBlock)clickBlock;
/**
消除所有按钮被点击
*/
@property (nonatomic,copy) void(^clearHistoryBtnOnClick)();
@end
| 15.875 | 114 | 0.746457 |
ea9817b063551b9a56cf5cf82b9ba074791da4a2 | 4,212 | h | C | Engine/source/T3D/physics/physicsCommon.h | vbillet/Torque3D | ece8823599424ea675e5f79d9bcb44e42cba8cae | [
"MIT"
] | 2,113 | 2015-01-01T11:23:01.000Z | 2022-03-28T04:51:46.000Z | Engine/source/T3D/physics/physicsCommon.h | Ashry00/Torque3D | 33e3e41c8b7eb41c743a589558bc21302207ef97 | [
"MIT"
] | 948 | 2015-01-02T01:50:00.000Z | 2022-02-27T05:56:40.000Z | Engine/source/T3D/physics/physicsCommon.h | Ashry00/Torque3D | 33e3e41c8b7eb41c743a589558bc21302207ef97 | [
"MIT"
] | 944 | 2015-01-01T09:33:53.000Z | 2022-03-15T22:23:03.000Z | //-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// 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 _T3D_PHYSICSCOMMON_H_
#define _T3D_PHYSICSCOMMON_H_
#ifndef _MPOINT3_H_
#include "math/mPoint3.h"
#endif
#ifndef _MQUAT_H_
#include "math/mQuat.h"
#endif
#ifndef _MMATRIX_H_
#include "math/mMatrix.h"
#endif
#ifndef _REFBASE_H_
#include "core/util/refBase.h"
#endif
/// Helper structure which defines the state of a single physics body.
struct PhysicsState
{
/// Constructor.
PhysicsState()
: position( Point3F::Zero ),
momentum( Point3F::Zero ),
orientation( QuatF::Identity ),
angularMomentum( Point3F::Zero ),
sleeping( false ),
linVelocity( Point3F::Zero ),
angVelocity( Point3F::Zero )
{
}
/// The primary physics state.
// @{
/// The position of the body.
Point3F position;
/// The momentum in kilogram meters per second.
Point3F momentum;
/// The orientation of the body.
QuatF orientation;
/// The angular momentum.
Point3F angularMomentum;
/// Is true if the shape is asleep.
bool sleeping;
// @}
/// The secondary physics state derived from the primary state.
/// @{
/// The linear velocity derived from the momentum.
Point3F linVelocity;
///
Point3F angVelocity;
/*
Vector velocity; ///< velocity in meters per second (calculated from momentum).
Quaternion spin; ///< quaternion rate of change in orientation.
Vector angularVelocity; ///< angular velocity (calculated from angularMomentum).
Matrix bodyToWorld; ///< body to world coordinates matrix.
Matrix worldToBody; ///< world to body coordinates matrix.
*/
/// @}
/// Interpolates between two physics states leaving the
/// result in this physics state.
inline PhysicsState& interpolate( const PhysicsState &a, const PhysicsState &b, F32 t )
{
F32 inverseT = 1.0f - t;
position = a.position*inverseT + b.position*t;
momentum = a.momentum*inverseT + b.momentum*t;
orientation.interpolate( a.orientation, b.orientation, t );
angularMomentum = a.angularMomentum*inverseT + b.angularMomentum*t;
// Recalculate the velocities
//linVelocity =
//angVelocity
return *this;
}
/// Helper builds the transform from the state.
inline MatrixF getTransform() const
{
MatrixF xfm;
orientation.setMatrix( &xfm );
xfm.setPosition( position );
return xfm;
}
};
/// The event type passed to the physics reset signal.
/// @see PhysicsPlugin::getPhysicsResetSignal().
enum PhysicsResetEvent
{
PhysicsResetEvent_Store,
PhysicsResetEvent_Restore
};
/// The signal for system wide physics events.
/// @see PhysicsPlugin
typedef Signal<void(PhysicsResetEvent reset)> PhysicsResetSignal;
class PhysicsCollision;
/// A strong reference to a physics collision shape.
typedef StrongRefPtr<PhysicsCollision> PhysicsCollisionRef;
#endif // _T3D_PHYSICSCOMMON_H_ | 29.87234 | 97 | 0.67284 |
ea9832e4241c7d7ee58327b2606d357f176521af | 1,176 | h | C | base/include/base/network/epoll.h | pretty-wise/link | 16a4241c4978136d8c4bd1caab20bdf37df9caaf | [
"Unlicense"
] | null | null | null | base/include/base/network/epoll.h | pretty-wise/link | 16a4241c4978136d8c4bd1caab20bdf37df9caaf | [
"Unlicense"
] | 5 | 2019-12-27T05:51:10.000Z | 2022-02-12T02:24:58.000Z | base/include/base/network/epoll.h | pretty-wise/link | 16a4241c4978136d8c4bd1caab20bdf37df9caaf | [
"Unlicense"
] | null | null | null | /*
* Copywrite 2014-2015 Krzysztof Stasik. All rights reserved.
*/
#pragma once
#include "base/core/types.h"
#include "base/network/socket.h"
#include <functional>
namespace Base {
namespace Epoll {
enum EpollOperation {
OP_READ = 0x1,
OP_WRITE = 0x2,
OP_ERROR = 0x4,
OP_ALL = OP_READ | OP_WRITE | OP_ERROR
};
inline void ToString(int operations, char string[3]) {
string[0] = (operations & OP_READ) == OP_READ ? 'r' : '-';
string[1] = (operations & OP_WRITE) == OP_WRITE ? 'w' : '-';
string[2] = (operations & OP_ERROR) == OP_ERROR ? 'e' : '-';
}
}
typedef int EpollHandle;
EpollHandle EpollCreate(u32 max_events);
void EpollDestroy(EpollHandle context);
bool EpollAdd(EpollHandle context, Socket::Handle socket, void *user_data,
int operations);
bool EpollUpdate(EpollHandle context, Socket::Handle socket, void *user_data,
int opetations);
void EpollRemove(EpollHandle context, Socket::Handle);
int EpollWait(EpollHandle context, s32 timeout_ms, const s32 max_events,
std::function<void(void *user_data, int operations,
int debug_data)> result);
} // namespace Base
| 25.021277 | 77 | 0.671769 |
ea9923ad68f388ae6e71a263c0b995a5c44f65c9 | 2,065 | h | C | Week_5/11 Programming Assignment/Utility/profile.h | Hitoku/basics-of-c-plus-plus-development-red-belt | 06840c0445beb5082816cb3ed9b05be325bc77d8 | [
"Unlicense"
] | 1 | 2022-01-12T22:02:00.000Z | 2022-01-12T22:02:00.000Z | Week_5/11 Programming Assignment/Utility/profile.h | Hrodvintir/basics-of-c-plus-plus-development-red-belt | 63068e474a1ddbbed54bd73de7e9945e4fe49fbc | [
"Unlicense"
] | null | null | null | Week_5/11 Programming Assignment/Utility/profile.h | Hrodvintir/basics-of-c-plus-plus-development-red-belt | 63068e474a1ddbbed54bd73de7e9945e4fe49fbc | [
"Unlicense"
] | 6 | 2020-12-03T19:31:45.000Z | 2022-02-02T10:33:56.000Z | #pragma once
#ifndef _PROFILE_H_
#define _PROFILE_H_
#include <chrono>
#include <iostream>
#include <string>
//-------------------------------------------------------------------------------------------------
class LogDuration
{
public:
explicit LogDuration(const std::string& msg = "") :
message(msg + " | "),
start(std::chrono::steady_clock::now())
{
}
~LogDuration()
{
auto finish = std::chrono::steady_clock::now();
auto duration = finish - start;
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration);
duration -= seconds;
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
duration -= milliseconds;
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(duration);
duration -= microseconds;
auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
duration -= nanoseconds;
std::cerr
<< "================================================================================" << "\n"
<< message
<< seconds.count() << " sec, "
<< milliseconds.count() << " mils "
<< microseconds.count() << " mics "
<< nanoseconds.count() << " nans " << "\n"
<< "================================================================================" << std::endl;
}
private:
std::string message;
std::chrono::steady_clock::time_point start;
};
//-------------------------------------------------------------------------------------------------
#define UNIQ_ID_IMPL(lineno) _a_local_var_##lineno
#define UNIQ_ID(lineno) UNIQ_ID_IMPL(lineno)
//-------------------------------------------------------------------------------------------------
#define LOG_DURATION(message) LogDuration UNIQ_ID(__LINE__) {message};
//-------------------------------------------------------------------------------------------------
#endif //_PROFILE_H_ | 38.962264 | 108 | 0.432446 |
ea9952046d23417c5e5d673698ae7e3c875aec57 | 241 | h | C | ASHookDemo/ASHookDemo/ExampleViewController.h | sedios/ashook | 91d19e099d9b6bdb5fd88e1f8a2f43935a0f9de7 | [
"MIT"
] | null | null | null | ASHookDemo/ASHookDemo/ExampleViewController.h | sedios/ashook | 91d19e099d9b6bdb5fd88e1f8a2f43935a0f9de7 | [
"MIT"
] | null | null | null | ASHookDemo/ASHookDemo/ExampleViewController.h | sedios/ashook | 91d19e099d9b6bdb5fd88e1f8a2f43935a0f9de7 | [
"MIT"
] | null | null | null | //
// ExampleViewController.h
// ASHookDemo
//
// Created by Adam Szedelyi on 2017. 03. 13..
// Copyright © 2017. Adam Szedelyi. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface ExampleViewController : NSViewController
@end
| 17.214286 | 57 | 0.709544 |
ea99dcf678624a396d8f1e21d8431bc1fbef8ac5 | 131 | c | C | 0x0C-preprocessor/2-main.c | Samhaydarr/holbertonschool-c | d0384a27dc105cbce8f990568792ba03e99026f9 | [
"Apache-2.0"
] | null | null | null | 0x0C-preprocessor/2-main.c | Samhaydarr/holbertonschool-c | d0384a27dc105cbce8f990568792ba03e99026f9 | [
"Apache-2.0"
] | null | null | null | 0x0C-preprocessor/2-main.c | Samhaydarr/holbertonschool-c | d0384a27dc105cbce8f990568792ba03e99026f9 | [
"Apache-2.0"
] | null | null | null | #include <stdio.h>
/**
* main - entry point.
*
* Return: .
*/
int main(void)
{
printf("%s\n", __BASE_FILE__);
return (0);
}
| 10.076923 | 31 | 0.549618 |
ea9a049122c5b54cff117d7c5b6473498b4d2e42 | 1,530 | h | C | CrazyCanvas/Include/World/Level.h | IbexOmega/CrazyCanvas | f60f01aaf9c988e4da8990dc1ef3caac20cecf7e | [
"MIT"
] | 18 | 2020-09-04T08:00:54.000Z | 2021-08-29T23:04:45.000Z | CrazyCanvas/Include/World/Level.h | IbexOmega/LambdaEngine | f60f01aaf9c988e4da8990dc1ef3caac20cecf7e | [
"MIT"
] | 32 | 2020-09-12T19:24:50.000Z | 2020-12-11T14:29:44.000Z | CrazyCanvas/Include/World/Level.h | IbexOmega/LambdaEngine | f60f01aaf9c988e4da8990dc1ef3caac20cecf7e | [
"MIT"
] | 2 | 2020-12-15T15:36:13.000Z | 2021-03-27T14:27:02.000Z | #pragma once
#include "LambdaEngine.h"
#include "LevelModule.h"
#include "LevelObjectCreator.h"
#include "Containers/THashTable.h"
#include "Containers/TArray.h"
#include "Containers/String.h"
#include "ECS/Entity.h"
#include "Game/Multiplayer/MultiplayerUtils.h"
#include "Threading/API/SpinLock.h"
#include "ECS/ComponentOwner.h"
#include "ECS/Components/World/LevelRegisteredComponent.h"
struct LevelCreateDesc
{
LambdaEngine::String Name = "";
LambdaEngine::TArray<LevelModule*> LevelModules;
};
class Level : public LambdaEngine::ComponentOwner
{
public:
DECL_UNIQUE_CLASS(Level);
Level();
~Level();
bool Init(const LevelCreateDesc* pDesc);
bool CreateObject(ELevelObjectType levelObjectType, const void* pData, LambdaEngine::TArray<LambdaEngine::Entity>& createdEntities);
bool DeleteObject(LambdaEngine::Entity entity);
bool RegisterObjectDeletion(LambdaEngine::Entity entity);
LambdaEngine::TArray<LambdaEngine::Entity> GetEntities(ELevelObjectType levelObjectType);
ELevelObjectType GetLevelObjectType(LambdaEngine::Entity entity) const;
private:
void LevelRegisteredDestructor(LevelRegisteredComponent& levelRegisteredComponent, LambdaEngine::Entity entity);
private:
LambdaEngine::String m_Name = "";
LambdaEngine::SpinLock m_SpinLock;
LambdaEngine::THashTable<LambdaEngine::Entity, ELevelObjectType> m_EntityToLevelObjectTypeMap;
LambdaEngine::THashTable<ELevelObjectType, uint32> m_EntityTypeMap;
LambdaEngine::TArray<LambdaEngine::TArray<LambdaEngine::Entity>> m_LevelEntities;
}; | 27.321429 | 133 | 0.804575 |
ea9a377c6cd62a515ad9e03db6f915745e9b9579 | 11,860 | h | C | aws-cpp-sdk-lexv2-runtime/include/aws/lexv2-runtime/model/DialogAction.h | perfectrecall/aws-sdk-cpp | fb8cbebf2fd62720b65aeff841ad2950e73d8ebd | [
"Apache-2.0"
] | 1 | 2022-02-12T08:09:30.000Z | 2022-02-12T08:09:30.000Z | aws-cpp-sdk-lexv2-runtime/include/aws/lexv2-runtime/model/DialogAction.h | perfectrecall/aws-sdk-cpp | fb8cbebf2fd62720b65aeff841ad2950e73d8ebd | [
"Apache-2.0"
] | 1 | 2021-10-14T16:57:00.000Z | 2021-10-18T10:47:24.000Z | aws-cpp-sdk-lexv2-runtime/include/aws/lexv2-runtime/model/DialogAction.h | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2021-11-09T11:58:03.000Z | 2021-11-09T11:58:03.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/lexv2-runtime/LexRuntimeV2_EXPORTS.h>
#include <aws/lexv2-runtime/model/DialogActionType.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/lexv2-runtime/model/StyleType.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace LexRuntimeV2
{
namespace Model
{
/**
* <p>The next action that Amazon Lex V2 should take.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/runtime.lex.v2-2020-08-07/DialogAction">AWS
* API Reference</a></p>
*/
class AWS_LEXRUNTIMEV2_API DialogAction
{
public:
DialogAction();
DialogAction(Aws::Utils::Json::JsonView jsonValue);
DialogAction& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>The next action that the bot should take in its interaction with the user.
* The possible values are:</p> <ul> <li> <p> <code>Close</code> - Indicates that
* there will not be a response from the user. For example, the statement "Your
* order has been placed" does not require a response.</p> </li> <li> <p>
* <code>ConfirmIntent</code> - The next action is asking the user if the intent is
* complete and ready to be fulfilled. This is a yes/no question such as "Place the
* order?"</p> </li> <li> <p> <code>Delegate</code> - The next action is determined
* by Amazon Lex V2.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action
* is to elicit a slot value from the user.</p> </li> </ul>
*/
inline const DialogActionType& GetType() const{ return m_type; }
/**
* <p>The next action that the bot should take in its interaction with the user.
* The possible values are:</p> <ul> <li> <p> <code>Close</code> - Indicates that
* there will not be a response from the user. For example, the statement "Your
* order has been placed" does not require a response.</p> </li> <li> <p>
* <code>ConfirmIntent</code> - The next action is asking the user if the intent is
* complete and ready to be fulfilled. This is a yes/no question such as "Place the
* order?"</p> </li> <li> <p> <code>Delegate</code> - The next action is determined
* by Amazon Lex V2.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action
* is to elicit a slot value from the user.</p> </li> </ul>
*/
inline bool TypeHasBeenSet() const { return m_typeHasBeenSet; }
/**
* <p>The next action that the bot should take in its interaction with the user.
* The possible values are:</p> <ul> <li> <p> <code>Close</code> - Indicates that
* there will not be a response from the user. For example, the statement "Your
* order has been placed" does not require a response.</p> </li> <li> <p>
* <code>ConfirmIntent</code> - The next action is asking the user if the intent is
* complete and ready to be fulfilled. This is a yes/no question such as "Place the
* order?"</p> </li> <li> <p> <code>Delegate</code> - The next action is determined
* by Amazon Lex V2.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action
* is to elicit a slot value from the user.</p> </li> </ul>
*/
inline void SetType(const DialogActionType& value) { m_typeHasBeenSet = true; m_type = value; }
/**
* <p>The next action that the bot should take in its interaction with the user.
* The possible values are:</p> <ul> <li> <p> <code>Close</code> - Indicates that
* there will not be a response from the user. For example, the statement "Your
* order has been placed" does not require a response.</p> </li> <li> <p>
* <code>ConfirmIntent</code> - The next action is asking the user if the intent is
* complete and ready to be fulfilled. This is a yes/no question such as "Place the
* order?"</p> </li> <li> <p> <code>Delegate</code> - The next action is determined
* by Amazon Lex V2.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action
* is to elicit a slot value from the user.</p> </li> </ul>
*/
inline void SetType(DialogActionType&& value) { m_typeHasBeenSet = true; m_type = std::move(value); }
/**
* <p>The next action that the bot should take in its interaction with the user.
* The possible values are:</p> <ul> <li> <p> <code>Close</code> - Indicates that
* there will not be a response from the user. For example, the statement "Your
* order has been placed" does not require a response.</p> </li> <li> <p>
* <code>ConfirmIntent</code> - The next action is asking the user if the intent is
* complete and ready to be fulfilled. This is a yes/no question such as "Place the
* order?"</p> </li> <li> <p> <code>Delegate</code> - The next action is determined
* by Amazon Lex V2.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action
* is to elicit a slot value from the user.</p> </li> </ul>
*/
inline DialogAction& WithType(const DialogActionType& value) { SetType(value); return *this;}
/**
* <p>The next action that the bot should take in its interaction with the user.
* The possible values are:</p> <ul> <li> <p> <code>Close</code> - Indicates that
* there will not be a response from the user. For example, the statement "Your
* order has been placed" does not require a response.</p> </li> <li> <p>
* <code>ConfirmIntent</code> - The next action is asking the user if the intent is
* complete and ready to be fulfilled. This is a yes/no question such as "Place the
* order?"</p> </li> <li> <p> <code>Delegate</code> - The next action is determined
* by Amazon Lex V2.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action
* is to elicit a slot value from the user.</p> </li> </ul>
*/
inline DialogAction& WithType(DialogActionType&& value) { SetType(std::move(value)); return *this;}
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline const Aws::String& GetSlotToElicit() const{ return m_slotToElicit; }
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline bool SlotToElicitHasBeenSet() const { return m_slotToElicitHasBeenSet; }
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline void SetSlotToElicit(const Aws::String& value) { m_slotToElicitHasBeenSet = true; m_slotToElicit = value; }
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline void SetSlotToElicit(Aws::String&& value) { m_slotToElicitHasBeenSet = true; m_slotToElicit = std::move(value); }
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline void SetSlotToElicit(const char* value) { m_slotToElicitHasBeenSet = true; m_slotToElicit.assign(value); }
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline DialogAction& WithSlotToElicit(const Aws::String& value) { SetSlotToElicit(value); return *this;}
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline DialogAction& WithSlotToElicit(Aws::String&& value) { SetSlotToElicit(std::move(value)); return *this;}
/**
* <p>The name of the slot that should be elicited from the user.</p>
*/
inline DialogAction& WithSlotToElicit(const char* value) { SetSlotToElicit(value); return *this;}
/**
* <p>Configures the slot to use spell-by-letter or spell-by-word style. When you
* use a style on a slot, users can spell out their input to make it clear to your
* bot.</p> <ul> <li> <p>Spell by letter - "b" "o" "b"</p> </li> <li> <p>Spell by
* word - "b as in boy" "o as in oscar" "b as in boy"</p> </li> </ul> <p>For more
* information, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/using-spelling.html"> Using
* spelling to enter slot values </a>.</p>
*/
inline const StyleType& GetSlotElicitationStyle() const{ return m_slotElicitationStyle; }
/**
* <p>Configures the slot to use spell-by-letter or spell-by-word style. When you
* use a style on a slot, users can spell out their input to make it clear to your
* bot.</p> <ul> <li> <p>Spell by letter - "b" "o" "b"</p> </li> <li> <p>Spell by
* word - "b as in boy" "o as in oscar" "b as in boy"</p> </li> </ul> <p>For more
* information, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/using-spelling.html"> Using
* spelling to enter slot values </a>.</p>
*/
inline bool SlotElicitationStyleHasBeenSet() const { return m_slotElicitationStyleHasBeenSet; }
/**
* <p>Configures the slot to use spell-by-letter or spell-by-word style. When you
* use a style on a slot, users can spell out their input to make it clear to your
* bot.</p> <ul> <li> <p>Spell by letter - "b" "o" "b"</p> </li> <li> <p>Spell by
* word - "b as in boy" "o as in oscar" "b as in boy"</p> </li> </ul> <p>For more
* information, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/using-spelling.html"> Using
* spelling to enter slot values </a>.</p>
*/
inline void SetSlotElicitationStyle(const StyleType& value) { m_slotElicitationStyleHasBeenSet = true; m_slotElicitationStyle = value; }
/**
* <p>Configures the slot to use spell-by-letter or spell-by-word style. When you
* use a style on a slot, users can spell out their input to make it clear to your
* bot.</p> <ul> <li> <p>Spell by letter - "b" "o" "b"</p> </li> <li> <p>Spell by
* word - "b as in boy" "o as in oscar" "b as in boy"</p> </li> </ul> <p>For more
* information, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/using-spelling.html"> Using
* spelling to enter slot values </a>.</p>
*/
inline void SetSlotElicitationStyle(StyleType&& value) { m_slotElicitationStyleHasBeenSet = true; m_slotElicitationStyle = std::move(value); }
/**
* <p>Configures the slot to use spell-by-letter or spell-by-word style. When you
* use a style on a slot, users can spell out their input to make it clear to your
* bot.</p> <ul> <li> <p>Spell by letter - "b" "o" "b"</p> </li> <li> <p>Spell by
* word - "b as in boy" "o as in oscar" "b as in boy"</p> </li> </ul> <p>For more
* information, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/using-spelling.html"> Using
* spelling to enter slot values </a>.</p>
*/
inline DialogAction& WithSlotElicitationStyle(const StyleType& value) { SetSlotElicitationStyle(value); return *this;}
/**
* <p>Configures the slot to use spell-by-letter or spell-by-word style. When you
* use a style on a slot, users can spell out their input to make it clear to your
* bot.</p> <ul> <li> <p>Spell by letter - "b" "o" "b"</p> </li> <li> <p>Spell by
* word - "b as in boy" "o as in oscar" "b as in boy"</p> </li> </ul> <p>For more
* information, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/using-spelling.html"> Using
* spelling to enter slot values </a>.</p>
*/
inline DialogAction& WithSlotElicitationStyle(StyleType&& value) { SetSlotElicitationStyle(std::move(value)); return *this;}
private:
DialogActionType m_type;
bool m_typeHasBeenSet;
Aws::String m_slotToElicit;
bool m_slotToElicitHasBeenSet;
StyleType m_slotElicitationStyle;
bool m_slotElicitationStyleHasBeenSet;
};
} // namespace Model
} // namespace LexRuntimeV2
} // namespace Aws
| 48.806584 | 146 | 0.648061 |
ea9a3e514eeb9447ebabb719a91ff0cc9997e399 | 498 | h | C | src/rviz_cloud_annotation/pc_utils/include/pc_utils/common/point_type.h | OuyangJunyuan/PCAT-Ground-Optimized | f17bdaa4ad44afaf9d6c0494c17babb9dd566162 | [
"Unlicense"
] | 2 | 2021-12-23T07:38:31.000Z | 2021-12-23T14:34:46.000Z | src/rviz_cloud_annotation/pc_utils/include/pc_utils/common/point_type.h | OuyangJunyuan/PCAT-Ground-Optimized | f17bdaa4ad44afaf9d6c0494c17babb9dd566162 | [
"Unlicense"
] | null | null | null | src/rviz_cloud_annotation/pc_utils/include/pc_utils/common/point_type.h | OuyangJunyuan/PCAT-Ground-Optimized | f17bdaa4ad44afaf9d6c0494c17babb9dd566162 | [
"Unlicense"
] | null | null | null | //
// Created by nrsl on 2021/10/10.
//
#ifndef PC_UTILS_POINT_TYPE_H
#define PC_UTILS_POINT_TYPE_H
#include <boost/preprocessor/seq.hpp>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
/***
* @brief supported point type
*/
#define PC_UTILS_POINT_TYPE \
((pcl::PointXYZ, XYZ)) \
((pcl::PointXYZI, XYZI)) \
((pcl::PointXYZL, XYZL)) \
((pcl::PointNormal, XYZN)) \
((pcl::PointXYZRGBNormal,XYZRGBN))
#endif //PC_UTILS_POINT_TYPE_H
| 19.92 | 37 | 0.634538 |
ea9c33f025a44c25474811a068493c9d326f526d | 3,047 | h | C | test/helper.h | Thalhammer/snowman | 24e025d8c1237e405d60b5be18a57ff5e36c485c | [
"Apache-2.0"
] | 33 | 2021-05-13T23:09:06.000Z | 2022-03-10T09:31:41.000Z | test/helper.h | Thalhammer/snowman | 24e025d8c1237e405d60b5be18a57ff5e36c485c | [
"Apache-2.0"
] | 12 | 2021-05-13T22:39:03.000Z | 2021-10-30T14:13:19.000Z | test/helper.h | Thalhammer/snowman | 24e025d8c1237e405d60b5be18a57ff5e36c485c | [
"Apache-2.0"
] | 6 | 2021-05-14T19:18:01.000Z | 2022-01-18T08:04:53.000Z | #pragma once
#include <gtest/gtest.h>
#include <matrix-wrapper.h>
#include <ostream>
#include <string>
#include <vector>
template <typename... Args>
void GTEST_WARN(const std::string& fmt, Args... args) {
std::string msg = "[ ] " + fmt + "\n";
testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, msg.c_str(), std::forward<Args>(args)...);
}
std::vector<short> read_sample_file(const std::string& filename, bool treat_wave = false);
std::string read_sample_file_as_string(const std::string& filename, bool treat_wave = false);
bool file_exists(const std::string& name);
std::string detect_project_root();
std::string read_file(const std::string& file);
std::string md5sum(const std::string& data);
std::string md5sum(const void* const data, size_t len);
std::string md5sum_file(const std::string& file);
inline size_t hash(const snowboy::MatrixBase& b) {
std::hash<int> h;
size_t res = 0;
for (int r = 0; r < b.m_rows; r++) {
for (int c = 0; c < b.m_cols; c++) {
res += h(b.m_data[r * b.m_stride + c] * 10000);
}
}
return res;
}
inline snowboy::Matrix random_matrix(unsigned int* seed) {
snowboy::Matrix m;
m.Resize(10 + rand_r(seed) % 50, 10 + rand_r(seed) % 50);
for (size_t i = 0; i < m.m_rows * m.m_stride; i++) {
m.m_data[i] = (rand_r(seed) % 10000) / 1000;
}
return m;
}
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::vector<T>& o);
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::vector<T>& o) {
s << "vector<" << typeid(T).name() << "> [" << o.size() << "] {";
for (auto& e : o)
s << " " << e;
s << " }";
return s;
}
#define MEMCHECK_ENABLED (!defined(__SANITIZE_ADDRESS__) || __SANITIZE_ADDRESS__ != 1)
struct MemoryChecker {
struct stacktrace {
void* trace[50];
void capture();
};
struct snapshot {
ssize_t num_malloc = 0;
ssize_t num_malloc_failed = 0;
ssize_t num_malloc_bytes = 0;
ssize_t num_free = 0;
ssize_t num_realloc = 0;
ssize_t num_realloc_failed = 0;
ssize_t num_realloc_moved = 0;
ssize_t num_realloc_bytes = 0;
ssize_t num_memalign = 0;
ssize_t num_memalign_bytes = 0;
ssize_t num_memalign_failed = 0;
ssize_t num_chunks_allocated = 0;
ssize_t num_chunks_allocated_max = 0;
ssize_t num_bytes_allocated = 0;
ssize_t num_bytes_allocated_max = 0;
};
snapshot info;
MemoryChecker();
~MemoryChecker();
};
std::ostream& operator<<(std::ostream& str, const MemoryChecker::stacktrace& o);
std::ostream& operator<<(std::ostream& str, const MemoryChecker& o);
#if MEMCHECK_ENABLED
#define MEMCHECK_START() MemoryChecker check{};
#define MEMCHECK_REPORT() check
#define MEMCHECK_DUMP() std::cout << MEMCHECK_REPORT() << std::endl;
#define MEMCHECK_ASSERT_MAXMEM_LE(x) ASSERT_LE(check.info.num_bytes_allocated_max, x)
#else
#define MEMCHECK_START() \
do { \
} while (false)
#define MEMCHECK_REPORT() "<memcheck disabled due to asan>"
#define MEMCHECK_DUMP() \
do { \
} while (false)
#define MEMCHECK_ASSERT_MAXMEM_LE(x) ASSERT_TRUE(true)
#endif
| 29.872549 | 109 | 0.683951 |
ea9d844c03fe5ec21dc22617812924720e17b43b | 1,040 | h | C | ace/tao/orbsvcs/orbsvcs/esf/ESF_Defaults.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | ace/tao/orbsvcs/orbsvcs/esf/ESF_Defaults.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | ace/tao/orbsvcs/orbsvcs/esf/ESF_Defaults.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | /* -*- C++ -*- */
/**
* @file ESF_Defaults.h
*
* ESF_Defaults.h,v 1.3 2000/10/31 03:11:12 coryan Exp
*
* In this file we set the compile time defaults for the framework.
*
*
* @author Carlos O'Ryan (coryan@cs.wustl.edu)
*
* http://doc.ece.uci.edu/~coryan/EC/index.html
*/
#ifndef TAO_ESF_DEFAULTS_H
#define TAO_ESF_DEFAULTS_H
#ifndef TAO_ESF_ENABLE_DEBUG_MESSAGES
#define TAO_ESF_ENABLE_DEBUG_MESSAGES 0
#endif /* TAO_ESF_ENABLE_DEBUG_MESSAGES */
// Control the maximum degree of concurrency tolerated by the EC, some
// kind of limit is required to avoid starvation of delayed write
// operations.
#ifndef TAO_ESF_DEFAULT_BUSY_HWM
# define TAO_ESF_DEFAULT_BUSY_HWM 1024
#endif /* TAO_ESF_DEFAULT_BUSY_HWM */
#ifndef TAO_ESF_DEFAULT_MAX_WRITE_DELAY
# define TAO_ESF_DEFAULT_MAX_WRITE_DELAY 2048
#endif /* TAO_ESF_DEFAULT_MAX_WRITE_DELAY */
#ifndef TAO_ESF_DEFAULT_ORB_ID
# define TAO_ESF_DEFAULT_ORB_ID "" /* */
#endif /* TAO_ESF_DEFAULT_ORB_ID */
#endif /* TAO_ESF_DEFAULTS_H */
| 27.368421 | 71 | 0.729808 |
eaa036d19d41e27f2e2665fc702c09311de3df14 | 1,857 | h | C | SimSpark/spark/lib/oxygen/physicsserver/int/sliderjointint.h | IllyasvielEin/Robocup3dInstaller | 12e91d9372dd08a92feebf98e916c98bc2242ff4 | [
"MIT"
] | null | null | null | SimSpark/spark/lib/oxygen/physicsserver/int/sliderjointint.h | IllyasvielEin/Robocup3dInstaller | 12e91d9372dd08a92feebf98e916c98bc2242ff4 | [
"MIT"
] | null | null | null | SimSpark/spark/lib/oxygen/physicsserver/int/sliderjointint.h | IllyasvielEin/Robocup3dInstaller | 12e91d9372dd08a92feebf98e916c98bc2242ff4 | [
"MIT"
] | null | null | null | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
this file is part of rcssserver3D
Fri May 9 2003
Copyright (C) 2002,2003 Koblenz University
Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
$Id$
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef OXYGEN_SLIDERJOINTINT_H
#define OXYGEN_SLIDERJOINTINT_H
#ifndef Q_MOC_RUN
#include <boost/shared_ptr.hpp>
#endif
#include <oxygen/oxygen_defines.h>
namespace oxygen
{
class RigidBody;
class OXYGEN_API SliderJointInt
{
public:
virtual ~SliderJointInt() {}
/** Creates a Slider Joint within the given world */
virtual long CreateSliderJoint(long world) = 0;
/** returns the slider linear position, i.e. the slider's
`extension'. When the axis is set, the current position of the
attached bodies is examined and that position will be the zero
position.
*/
virtual float GetPosition(long jointID) = 0;
/** returns the time derivative of the sliders linear position */
virtual float GetPositionRate(long jointID) = 0;
/** Sets the direction of the slider joint's axis */
virtual void SetSliderAxis(salt::Vector3f& up, long jointID) = 0;
};
} //namespace oxygen
#endif //OXYGEN_SLIDERJOINTINT_H
| 30.95 | 71 | 0.72644 |
eaa0f970b8236a16948311c66f0c300ad471154f | 3,671 | h | C | reflex/inc/Reflex/Builder/TypedefBuilder.h | paulwratt/cin-5.34.00 | 036a8202f11a4a0e29ccb10d3c02f304584cda95 | [
"MIT"
] | 10 | 2018-03-26T07:41:44.000Z | 2021-11-06T08:33:24.000Z | reflex/inc/Reflex/Builder/TypedefBuilder.h | paulwratt/cin-5.34.00 | 036a8202f11a4a0e29ccb10d3c02f304584cda95 | [
"MIT"
] | null | null | null | reflex/inc/Reflex/Builder/TypedefBuilder.h | paulwratt/cin-5.34.00 | 036a8202f11a4a0e29ccb10d3c02f304584cda95 | [
"MIT"
] | 1 | 2020-11-17T03:17:00.000Z | 2020-11-17T03:17:00.000Z | // @(#)root/reflex:$Id$
// Author: Stefan Roiser 2004
// Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.
#ifndef Reflex_TypedefBuilder
#define Reflex_TypedefBuilder
// Include files
#include "Reflex/Builder/TypeBuilder.h"
#include "Reflex/Type.h"
namespace Reflex {
// forward declarations
/**
* @class TypedefBuilderImpl TypedefBuilder.h Reflex/Builder/TypedefBuilderImpl.h
* @author Stefan Roiser
* @date 14/3/2005
* @ingroup RefBld
*/
class RFLX_API TypedefBuilderImpl {
public:
/** constructor */
TypedefBuilderImpl(const char* typ,
const Type &typedefType);
/** destructor */
virtual ~TypedefBuilderImpl() {}
/**
* AddProperty will add a property to the typedef currently being built
* @param key the PropertyNth key
* @param value the value of the PropertyNth
*/
void AddProperty(const char* key,
Any value);
/**
* AddProperty will add a property to the typedef currently being built
* @param key the PropertyNth key
* @param value the value of the PropertyNth
*/
void AddProperty(const char* key,
const char* value);
/*
* ToType will return the currently produced Type (class)
* @return the type currently being built
*/
Type ToType();
private:
/** the typedef currently being built */
Type fTypedef;
}; // class TypdefBuilderImpl
/**
* @class TypedefBuilder TypedefBuilder.h Reflex/Builder/TypedefBuilder.h
* @author Stefan Roiser
* @date 30/3/2004
* @ingroup RefBld
*/
template <typename T>
class TypedefBuilder {
public:
/** constructor */
TypedefBuilder(const char* nam);
/** destructor */
virtual ~TypedefBuilder() {}
/**
* AddProperty will add a property to the typedef currently being built
* @param key the property key
* @param value the value of the property
* @return a reference to the building class
*/
template <typename P>
TypedefBuilder& AddProperty(const char* key,
P value);
/*
* ToType will return the currently produced Type (class)
* @return the type currently being built
*/
Type ToType();
private:
/** the type of the typedef */
TypedefBuilderImpl fTypedefBuilderImpl;
}; // class TypedefBuilder
} // namespace Reflex
//-------------------------------------------------------------------------------
template <typename T>
inline Reflex::TypedefBuilder<T>::TypedefBuilder(const char* nam)
//-------------------------------------------------------------------------------
: fTypedefBuilderImpl(nam, TypeDistiller<T>::Get()) {
}
//-------------------------------------------------------------------------------
template <typename T> template <typename P>
inline Reflex::TypedefBuilder<T>&
Reflex::TypedefBuilder<T
>::AddProperty(const char* key,
P value) {
//-------------------------------------------------------------------------------
fTypedefBuilderImpl.AddProperty(key, value);
return *this;
}
//-------------------------------------------------------------------------------
template <typename T> inline Reflex::Type
Reflex::TypedefBuilder<T
>::ToType() {
//-------------------------------------------------------------------------------
return fTypedefBuilderImpl.ToType();
}
#endif // Reflex_TypedefBuilder
| 25.852113 | 81 | 0.587578 |
eaa2cb84718b73b2cd905a12817a68b921cdcab6 | 448 | h | C | CoCoRx/AVCaptureDevice+CoCoRx.h | CoCoKit/CoCoRx | 35a7939597fbed8c2230ee56aeca02dc9d675593 | [
"MIT"
] | null | null | null | CoCoRx/AVCaptureDevice+CoCoRx.h | CoCoKit/CoCoRx | 35a7939597fbed8c2230ee56aeca02dc9d675593 | [
"MIT"
] | null | null | null | CoCoRx/AVCaptureDevice+CoCoRx.h | CoCoKit/CoCoRx | 35a7939597fbed8c2230ee56aeca02dc9d675593 | [
"MIT"
] | null | null | null | //
// AVCaptureDevice+CoCoRx.h
// CoCoRx
//
// Created by iScarlett CoCo on 2019/3/21.
// Copyright © 2019 iScarlett CoCo. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
#import <ReactiveObjC/ReactiveObjC.h>
NS_ASSUME_NONNULL_BEGIN
@interface AVCaptureDevice (CoCoRx)
/*
获取相机权限
*/
+ (RACSignal *)requestVideoAuthorizationSignal;
/*
获取麦克风权限
*/
+ (RACSignal *)requestAudioAuthorizationSignal;
@end
NS_ASSUME_NONNULL_END
| 15.448276 | 57 | 0.745536 |
eaa2d663258c1607b66528a6e3f472f4ec008034 | 815 | h | C | ProficiencyExercise/iOSProject/Application/Proxy/AbstractProxy/AbstractProxy.h | harshal-wani/iOSProficiencyExercise | 370ff31b76388550cb97c99c9bbb9cb42ae6df5d | [
"MIT"
] | 1 | 2019-03-20T04:57:17.000Z | 2019-03-20T04:57:17.000Z | ProficiencyExercise/iOSProject/Application/Proxy/AbstractProxy/AbstractProxy.h | harshal-wani/iOSProficiencyExercise | 370ff31b76388550cb97c99c9bbb9cb42ae6df5d | [
"MIT"
] | null | null | null | ProficiencyExercise/iOSProject/Application/Proxy/AbstractProxy/AbstractProxy.h | harshal-wani/iOSProficiencyExercise | 370ff31b76388550cb97c99c9bbb9cb42ae6df5d | [
"MIT"
] | null | null | null | //
// AbstractProxy.h
// iOSProject
//
#import <Foundation/Foundation.h>
#import "CommonFilesImport.h"
#import "AFNetworking.h"
#define BASEURL [NSURL URLWithString:BASEURLString]
@interface AbstractProxy : NSObject
- (void)getRequestDataWithURL:(NSString *)url
andRequestName:(NSString *)requestName;
//Server request callback methods
- (void)successWithRequest:(AFHTTPRequestOperation *)operation
withRespose:(id)responseObject
withRequestName:(NSString *)requestName;
- (void)failedWithRequest:(AFHTTPRequestOperation *)operation
witherror:(NSError *)error
withRequestName:(NSString *)requestName;
//JSON object Parsing
- (id)JSONValueReturnsDictionary:(NSString *)jsonString;
- (id)JSONValueReturnsArray:(NSString *)jsonString;
@end
| 25.46875 | 62 | 0.727607 |
eaa42137bed1b9f77420c76b2d7279d6cfbdb55c | 1,867 | h | C | PrivateFrameworks/BaseBoard/BSAuditToken.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/BaseBoard/BSAuditToken.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/BaseBoard/BSAuditToken.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 "BSXPCCoding.h"
#import "NSCopying.h"
#import "NSSecureCoding.h"
@class NSString;
@interface BSAuditToken : NSObject <NSCopying, BSXPCCoding, NSSecureCoding>
{
NSString *_bundleID;
CDStruct_4c969caf _auditToken;
struct os_unfair_lock_s _secTaskLock;
struct __SecTask *_lazy_secTaskLock_secTask;
}
+ (BOOL)supportsSecureCoding;
+ (id)tokenFromNSXPCConnection:(id)arg1;
+ (id)tokenFromXPCConnection:(id)arg1;
+ (id)tokenFromMachMessage:(CDStruct_c91b0553 *)arg1;
+ (id)tokenFromXPCMessage:(id)arg1;
+ (id)tokenFromAuditTokenRef:(CDStruct_4c969caf *)arg1;
+ (id)tokenFromAuditToken:(CDStruct_4c969caf)arg1;
+ (id)tokenForCurrentProcess;
@property(readonly, nonatomic) CDStruct_4c969caf realToken; // @synthesize realToken=_auditToken;
@property(copy, nonatomic) NSString *bundleID; // @synthesize bundleID=_bundleID;
- (void).cxx_destruct;
- (id)copyWithZone:(struct _NSZone *)arg1;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
- (BOOL)isEqual:(id)arg1;
- (id)_bundleIDGeneratingIfNeeded:(BOOL)arg1;
- (id)_valueFromData:(id)arg1 ofType:(const char *)arg2;
- (id)_dataWithValue:(id)arg1;
- (void)_accessSecTask:(CDUnknownBlockType)arg1;
- (void)encodeWithCoder:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (void)encodeWithXPCDictionary:(id)arg1;
- (id)initWithXPCDictionary:(id)arg1;
- (id)valueForEntitlement:(id)arg1;
- (BOOL)hasEntitlement:(id)arg1;
@property(readonly, nonatomic) int pid; // @dynamic pid;
- (void)dealloc;
- (id)initWithXPCMessage:(id)arg1;
- (id)initWithAuditToken:(CDStruct_4c969caf)arg1;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly) Class superclass;
@end
| 31.644068 | 97 | 0.758436 |
eaa46fbe04ef36e74e440001ddc5a2223d67dd12 | 9,374 | c | C | nuttx/configs/hdk/muc/src/usb3813.c | AriDine/MotoWallet | 47562467292024d09bfeb2c6a597bc536a6b7574 | [
"Apache-2.0"
] | 4 | 2018-06-30T17:04:44.000Z | 2022-02-22T04:00:32.000Z | nuttx/nuttx/configs/hdk/muc/src/usb3813.c | vixadd/FMoto | a266307517a19069813b3480d10073f73970c11b | [
"MIT"
] | 11 | 2017-10-22T09:45:51.000Z | 2019-05-28T23:25:29.000Z | nuttx/nuttx/configs/hdk/muc/src/usb3813.c | vixadd/Moto.Mod.MDK.Capstone | a266307517a19069813b3480d10073f73970c11b | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2015 Google Inc. All rights reserved.
* Copyright (C) 2016 Motorola Mobility, LLC. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Author: Fabien Parent <fparent@baylibre.com>
* Author: Alexandre Bailon <abailon@baylibre.com>
*/
#include <nuttx/config.h>
#include <nuttx/usb.h>
#include <nuttx/gpio.h>
#include <nuttx/arch.h>
#include <nuttx/i2c.h>
#include <arch/byteorder.h>
#include <string.h>
#include <debug.h>
#define HUB_RESET_ASSERTION_TIME_IN_USEC 5 /* us */
#define HUB_RESET_DEASSERTION_TIME_IN_MSEC 300 /* ms */
struct i2c_dev_info {
struct i2c_dev_s *i2c;
uint16_t i2c_addr;
};
struct dev_private_s {
uint8_t rst_n;
struct i2c_dev_info i2c_info;
};
struct dev_private_s s_data;
#define HUB_I2C_ADDR 0x2D
#define MAX_SMBUS_DATA_LEN 12
#define HUB_I2C_BUS 2
static bool s_hsic_uplink = false;
void usb3813_set_hsic_uplink(bool uplink)
{
s_hsic_uplink = uplink;
}
static int smbus_read(struct i2c_dev_info *i2c, uint8_t *data, uint8_t data_len)
{
struct i2c_msg_s msg[2];
/* use 0x0004 for read per spec */
uint16_t tmp = cpu_to_be16(0x0004);
msg[0].addr = i2c->i2c_addr;
msg[0].flags = 0;
msg[0].buffer = (uint8_t *)&tmp;
msg[0].length = 2;
msg[1].addr = i2c->i2c_addr;
msg[1].flags = I2C_M_READ;
msg[1].buffer = data;
msg[1].length = data_len;
int ret = I2C_TRANSFER(i2c->i2c, msg, 2);
if (ret != 0) {
lldbg("SmBus read transfer failed %d\n", ret);
return -1;
}
return 0;
}
static int smbus_write(struct i2c_dev_info *i2c, uint8_t *data, uint8_t data_len)
{
struct i2c_msg_s msg;
uint8_t tmp[MAX_SMBUS_DATA_LEN + 2];
if (data_len > (MAX_SMBUS_DATA_LEN))
return -1;
/* use address 0x0000 per spec */
tmp[0] = 0;
tmp[1] = 0;
int i;
for (i = 0; i < data_len; i++) {
tmp[i + 2] = data[i];
}
msg.addr = i2c->i2c_addr;
msg.flags = 0;
msg.buffer = tmp;
msg.length = data_len + 2;
int ret = I2C_TRANSFER(i2c->i2c, &msg, 1);
if (ret != 0) {
lldbg("SMBus write transfer failed %d\n", ret);
return -1;
}
return 0;
}
static int send_config_register_access(struct i2c_dev_info *i2c)
{
struct i2c_msg_s msg;
uint8_t tmp[3];
/* special i2c command - 0x9937 to request read/write operation*/
tmp[0] = 0x99;
tmp[1] = 0x37;
tmp[2] = 0x00;
msg.addr = i2c->i2c_addr;
msg.flags = 0;
msg.buffer = tmp;
msg.length = 3;
int ret = I2C_TRANSFER(i2c->i2c, &msg, 1);
if (ret != 0) {
lldbg("SMBus config register access failed %d\n", ret);
return -1;
}
return 0;
}
static int send_usb_attach(struct i2c_dev_info *i2c)
{
struct i2c_msg_s msg;
uint8_t tmp[3];
/* special i2c command - 0xaa55 to change hub state to normal from cfg */
tmp[0] = 0xaa;
tmp[1] = 0x55;
tmp[2] = 0x00;
msg.addr = i2c->i2c_addr;
msg.flags = 0;
msg.buffer = tmp;
msg.length = 3;
int ret = I2C_TRANSFER(i2c->i2c, &msg, 1);
if (ret != 0) {
lldbg("SMBus USB attach failed %d\n", ret);
return -1;
}
return 0;
}
static int read_config(struct i2c_dev_info *i2c, uint16_t address,
uint8_t *data, uint8_t data_len)
{
uint8_t tmp[5];
uint8_t tmp_data[MAX_SMBUS_DATA_LEN + 1];
if (data_len > MAX_SMBUS_DATA_LEN)
return -1;
tmp[0] = 4; /* number of bytes to write to memory */
tmp[1] = 1; /* read configuration register */
tmp[2] = data_len; /* bytes reading */
tmp[3] = (address >> 8) & 0xFF; /* M address of data to read */
tmp[4] = address & 0xFF; /* L address of data to read */
if (smbus_write(i2c, tmp, sizeof(tmp)) < 0)
return -1;
if (send_config_register_access(i2c) < 0)
return -1;
if (smbus_read(i2c, tmp_data, data_len + 1) < 0)
return -1;
memcpy(data, tmp_data + 1, data_len);
return 0;
}
static int write_config(struct i2c_dev_info *i2c, uint16_t address,
uint8_t *data, uint8_t data_len)
{
uint8_t tmp[MAX_SMBUS_DATA_LEN + 5 + 1]; /* hdr & final zero */
if (data_len > MAX_SMBUS_DATA_LEN) {
lldbg("SMBus write data too big. (len=%u)\n", data_len);
return -1;
}
tmp[0] = 4 + data_len; /* number of bytes to write to memory */
tmp[1] = 0; /* wtie configuration register */
tmp[2] = data_len; /* bytes writing */
tmp[3] = (address >> 8) & 0xFF; /* M address of data to read */
tmp[4] = address & 0xFF; /* L address of data to read */
int i;
for (i = 0; i < data_len; i++) {
tmp[i + 5] = data[i];
}
tmp[i + 5] = 0x00;
if (smbus_write(i2c, tmp, 5 + data_len + 1) < 0) {
return -1;
}
return send_config_register_access(i2c);
}
/**
* Init the USB3813 hub
*
* Activate the GPIO line
*
* @param dev Device
* @return 0 if successful
*/
static int usb3813_open(struct device *dev)
{
gpio_activate(s_data.rst_n);
s_data.i2c_info.i2c = up_i2cinitialize(HUB_I2C_BUS);
s_data.i2c_info.i2c_addr = HUB_I2C_ADDR;
return 0;
}
/**
* Deinit the USB3813 hub
*
* Deactivate the GPIO line
*
* @param dev Device
*/
static void usb3813_close(struct device *dev)
{
gpio_deactivate(s_data.rst_n);
up_i2cuninitialize(s_data.i2c_info.i2c);
}
/**
* Hold the usb hub under reset
*
* @param dev Device
* @return 0 if successful
*/
static int usb3813_hold_reset(struct device *dev)
{
gpio_direction_out(s_data.rst_n, 0);
up_udelay(HUB_RESET_ASSERTION_TIME_IN_USEC);
return 0;
}
/**
* Release the usb hub from reset
*
* @param dev Device
* @return 0 if successful
*/
static int usb3813_release_reset(struct device *dev)
{
gpio_direction_out(s_data.rst_n, 1);
up_mdelay(HUB_RESET_DEASSERTION_TIME_IN_MSEC);
uint16_t vid, pid, devid;
if (read_config(&s_data.i2c_info, 0x3000, (uint8_t *)&vid, sizeof(vid)) == 0)
lldbg("HUB VID %0x\n", vid);
if (read_config(&s_data.i2c_info, 0x3002, (uint8_t *)&pid, sizeof(pid)) == 0)
lldbg("HUB PID %0x\n", pid);
if (read_config(&s_data.i2c_info, 0x3004, (uint8_t *)&devid, sizeof(devid)) == 0)
lldbg("HUB DEVICE ID %0x\n", devid);
uint8_t conn_cfg;
if (read_config(&s_data.i2c_info, 0x318E, &conn_cfg, 1) != 0) {
lldbg("Failed to read current connection config\n");
return -1;
}
if (s_hsic_uplink) {
conn_cfg |= 0x03;
if (write_config(&s_data.i2c_info, 0x318E, &conn_cfg, 1) != 0) {
lldbg("Failed to write connection config\n");
return -1;
}
}
return send_usb_attach(&s_data.i2c_info);
}
static int usb3813_probe(struct device *dev)
{
struct device_resource *res;
memset(&s_data, 0, sizeof(s_data));
res = device_resource_get_by_name(dev, DEVICE_RESOURCE_TYPE_GPIO, "hub_rst_n");
if (!res) {
lldbg("failed to get rst_n gpio\n");
return -ENODEV;
}
s_data.rst_n = res->start;
return 0;
}
/**
* Reset the USB Hub
*
* @param dev Device
* @return 0 if successful
*/
static int usb3813_reset(struct device *dev)
{
int retval;
retval = usb3813_hold_reset(dev);
if (!retval) {
return retval;
}
retval = usb3813_release_reset(dev);
return retval;
}
static struct device_hsic_type_ops usb3813_type_ops = {
.reset = usb3813_reset,
.hold_reset = usb3813_hold_reset,
.release_reset = usb3813_release_reset,
};
static struct device_driver_ops usb3813_driver_ops = {
.probe = usb3813_probe,
.open = usb3813_open,
.close = usb3813_close,
.type_ops = &usb3813_type_ops,
};
struct device_driver usb3813_driver = {
.type = DEVICE_TYPE_HSIC_DEVICE,
.name = "usb3813",
.desc = "USB3813 HSIC Hub Driver",
.ops = &usb3813_driver_ops,
};
| 25.612022 | 85 | 0.644442 |
eaa8ab1df437d1a6721c5e3521c6a241d0f22bae | 3,414 | h | C | SpatialGDK/Source/SpatialGDK/Public/Schema/RPCPayload.h | eddyrainy/UnrealGDK | eb86c58d23d55e74b584b91c2d35702ba08448be | [
"MIT"
] | null | null | null | SpatialGDK/Source/SpatialGDK/Public/Schema/RPCPayload.h | eddyrainy/UnrealGDK | eb86c58d23d55e74b584b91c2d35702ba08448be | [
"MIT"
] | null | null | null | SpatialGDK/Source/SpatialGDK/Public/Schema/RPCPayload.h | eddyrainy/UnrealGDK | eb86c58d23d55e74b584b91c2d35702ba08448be | [
"MIT"
] | null | null | null | // Copyright (c) Improbable Worlds Ltd, All Rights Reserved
#pragma once
#include "Schema/Component.h"
#include "SpatialConstants.h"
#include "Utils/SchemaUtils.h"
#include <WorkerSDK/improbable/c_schema.h>
#include <WorkerSDK/improbable/c_worker.h>
namespace SpatialGDK
{
struct RPCPayload
{
RPCPayload() = delete;
RPCPayload(uint32 InOffset, uint32 InIndex, TArray<uint8>&& Data) : Offset(InOffset), Index(InIndex), PayloadData(MoveTemp(Data))
{}
RPCPayload(const Schema_Object* RPCObject)
{
Offset = Schema_GetUint32(RPCObject, SpatialConstants::UNREAL_RPC_PAYLOAD_OFFSET_ID);
Index = Schema_GetUint32(RPCObject, SpatialConstants::UNREAL_RPC_PAYLOAD_RPC_INDEX_ID);
PayloadData = SpatialGDK::GetBytesFromSchema(RPCObject, SpatialConstants::UNREAL_RPC_PAYLOAD_RPC_PAYLOAD_ID);
}
int64 CountDataBits() const
{
return PayloadData.Num() * 8;
}
static void WriteToSchemaObject(Schema_Object* RPCObject, uint32 Offset, uint32 Index, const uint8* Data, int32 NumElems)
{
Schema_AddUint32(RPCObject, SpatialConstants::UNREAL_RPC_PAYLOAD_OFFSET_ID, Offset);
Schema_AddUint32(RPCObject, SpatialConstants::UNREAL_RPC_PAYLOAD_RPC_INDEX_ID, Index);
AddBytesToSchema(RPCObject, SpatialConstants::UNREAL_RPC_PAYLOAD_RPC_PAYLOAD_ID, Data, sizeof(uint8) * NumElems);
}
uint32 Offset;
uint32 Index;
TArray<uint8> PayloadData;
};
struct RPCsOnEntityCreation : Component
{
static const Worker_ComponentId ComponentId = SpatialConstants::RPCS_ON_ENTITY_CREATION_ID;
RPCsOnEntityCreation() = default;
bool HasRPCPayloadData() const
{
return RPCs.Num() > 0;
}
RPCsOnEntityCreation(const Worker_ComponentData& Data)
{
Schema_Object* ComponentsObject = Schema_GetComponentDataFields(Data.schema_type);
uint32 RPCCount = Schema_GetObjectCount(ComponentsObject, SpatialConstants::UNREAL_RPC_PAYLOAD_OFFSET_ID);
for (uint32 i = 0; i < RPCCount; i++)
{
Schema_Object* ComponentObject = Schema_IndexObject(ComponentsObject, SpatialConstants::UNREAL_RPC_PAYLOAD_OFFSET_ID, i);
RPCs.Add(RPCPayload(ComponentObject));
}
}
Worker_ComponentData CreateRPCPayloadData() const
{
Worker_ComponentData Data = {};
Data.component_id = ComponentId;
Data.schema_type = Schema_CreateComponentData();
Schema_Object* ComponentObject = Schema_GetComponentDataFields(Data.schema_type);
for (const auto& Payload : RPCs)
{
Schema_Object* Obj = Schema_AddObject(ComponentObject, SpatialConstants::UNREAL_RPC_PAYLOAD_OFFSET_ID);
RPCPayload::WriteToSchemaObject(Obj, Payload.Offset, Payload.Index, Payload.PayloadData.GetData(), Payload.PayloadData.Num());
}
return Data;
}
static Worker_ComponentUpdate CreateClearFieldsUpdate()
{
Worker_ComponentUpdate Update = {};
Update.component_id = ComponentId;
Update.schema_type = Schema_CreateComponentUpdate();
Schema_Object* UpdateObject = Schema_GetComponentUpdateFields(Update.schema_type);
Schema_AddComponentUpdateClearedField(Update.schema_type, SpatialConstants::UNREAL_RPC_PAYLOAD_OFFSET_ID);
return Update;
}
static Worker_CommandRequest CreateClearFieldsCommandRequest()
{
Worker_CommandRequest CommandRequest = {};
CommandRequest.component_id = ComponentId;
CommandRequest.command_index = SpatialConstants::CLEAR_RPCS_ON_ENTITY_CREATION;
CommandRequest.schema_type = Schema_CreateCommandRequest();
return CommandRequest;
}
TArray<RPCPayload> RPCs;
};
} // namespace SpatialGDK
| 31.036364 | 130 | 0.796719 |
eaa9585c7347518f3054e6b176b9521d05e7c01a | 7,889 | c | C | linux-4.14.90-dev/linux-4.14.90/drivers/soc/fsl/qbman/bman_ccsr.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 34 | 2019-07-19T20:44:15.000Z | 2022-03-07T12:09:00.000Z | linux-4.14.90-dev/linux-4.14.90/drivers/soc/fsl/qbman/bman_ccsr.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 1 | 2020-09-08T10:34:56.000Z | 2021-09-07T15:15:02.000Z | linux-4.14.90-dev/linux-4.14.90/drivers/soc/fsl/qbman/bman_ccsr.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 20 | 2021-10-22T02:21:23.000Z | 2022-03-31T04:55:35.000Z | /* Copyright (c) 2009 - 2016 Freescale Semiconductor, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Freescale Semiconductor nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* ALTERNATIVELY, this software may be distributed under the terms of the
* GNU General Public License ("GPL") as published by the Free Software
* Foundation, either version 2 of that License or (at your option) any
* later version.
*
* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``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 Freescale Semiconductor BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "bman_priv.h"
u16 bman_ip_rev;
EXPORT_SYMBOL(bman_ip_rev);
/* Register offsets */
#define REG_FBPR_FPC 0x0800
#define REG_ECSR 0x0a00
#define REG_ECIR 0x0a04
#define REG_EADR 0x0a08
#define REG_EDATA(n) (0x0a10 + ((n) * 0x04))
#define REG_SBEC(n) (0x0a80 + ((n) * 0x04))
#define REG_IP_REV_1 0x0bf8
#define REG_IP_REV_2 0x0bfc
#define REG_FBPR_BARE 0x0c00
#define REG_FBPR_BAR 0x0c04
#define REG_FBPR_AR 0x0c10
#define REG_SRCIDR 0x0d04
#define REG_LIODNR 0x0d08
#define REG_ERR_ISR 0x0e00
#define REG_ERR_IER 0x0e04
#define REG_ERR_ISDR 0x0e08
/* Used by all error interrupt registers except 'inhibit' */
#define BM_EIRQ_IVCI 0x00000010 /* Invalid Command Verb */
#define BM_EIRQ_FLWI 0x00000008 /* FBPR Low Watermark */
#define BM_EIRQ_MBEI 0x00000004 /* Multi-bit ECC Error */
#define BM_EIRQ_SBEI 0x00000002 /* Single-bit ECC Error */
#define BM_EIRQ_BSCN 0x00000001 /* pool State Change Notification */
struct bman_hwerr_txt {
u32 mask;
const char *txt;
};
static const struct bman_hwerr_txt bman_hwerr_txts[] = {
{ BM_EIRQ_IVCI, "Invalid Command Verb" },
{ BM_EIRQ_FLWI, "FBPR Low Watermark" },
{ BM_EIRQ_MBEI, "Multi-bit ECC Error" },
{ BM_EIRQ_SBEI, "Single-bit ECC Error" },
{ BM_EIRQ_BSCN, "Pool State Change Notification" },
};
/* Only trigger low water mark interrupt once only */
#define BMAN_ERRS_TO_DISABLE BM_EIRQ_FLWI
/* Pointer to the start of the BMan's CCSR space */
static u32 __iomem *bm_ccsr_start;
static inline u32 bm_ccsr_in(u32 offset)
{
return ioread32be(bm_ccsr_start + offset/4);
}
static inline void bm_ccsr_out(u32 offset, u32 val)
{
iowrite32be(val, bm_ccsr_start + offset/4);
}
static void bm_get_version(u16 *id, u8 *major, u8 *minor)
{
u32 v = bm_ccsr_in(REG_IP_REV_1);
*id = (v >> 16);
*major = (v >> 8) & 0xff;
*minor = v & 0xff;
}
/* signal transactions for FBPRs with higher priority */
#define FBPR_AR_RPRIO_HI BIT(30)
static void bm_set_memory(u64 ba, u32 size)
{
u32 exp = ilog2(size);
/* choke if size isn't within range */
DPAA_ASSERT(size >= 4096 && size <= 1024*1024*1024 &&
is_power_of_2(size));
/* choke if '[e]ba' has lower-alignment than 'size' */
DPAA_ASSERT(!(ba & (size - 1)));
bm_ccsr_out(REG_FBPR_BARE, upper_32_bits(ba));
bm_ccsr_out(REG_FBPR_BAR, lower_32_bits(ba));
bm_ccsr_out(REG_FBPR_AR, exp - 1);
}
/*
* Location and size of BMan private memory
*
* Ideally we would use the DMA API to turn rmem->base into a DMA address
* (especially if iommu translations ever get involved). Unfortunately, the
* DMA API currently does not allow mapping anything that is not backed with
* a struct page.
*/
static dma_addr_t fbpr_a;
static size_t fbpr_sz;
static int bman_fbpr(struct reserved_mem *rmem)
{
fbpr_a = rmem->base;
fbpr_sz = rmem->size;
WARN_ON(!(fbpr_a && fbpr_sz));
return 0;
}
RESERVEDMEM_OF_DECLARE(bman_fbpr, "fsl,bman-fbpr", bman_fbpr);
static irqreturn_t bman_isr(int irq, void *ptr)
{
u32 isr_val, ier_val, ecsr_val, isr_mask, i;
struct device *dev = ptr;
ier_val = bm_ccsr_in(REG_ERR_IER);
isr_val = bm_ccsr_in(REG_ERR_ISR);
ecsr_val = bm_ccsr_in(REG_ECSR);
isr_mask = isr_val & ier_val;
if (!isr_mask)
return IRQ_NONE;
for (i = 0; i < ARRAY_SIZE(bman_hwerr_txts); i++) {
if (bman_hwerr_txts[i].mask & isr_mask) {
dev_err_ratelimited(dev, "ErrInt: %s\n",
bman_hwerr_txts[i].txt);
if (bman_hwerr_txts[i].mask & ecsr_val) {
/* Re-arm error capture registers */
bm_ccsr_out(REG_ECSR, ecsr_val);
}
if (bman_hwerr_txts[i].mask & BMAN_ERRS_TO_DISABLE) {
dev_dbg(dev, "Disabling error 0x%x\n",
bman_hwerr_txts[i].mask);
ier_val &= ~bman_hwerr_txts[i].mask;
bm_ccsr_out(REG_ERR_IER, ier_val);
}
}
}
bm_ccsr_out(REG_ERR_ISR, isr_val);
return IRQ_HANDLED;
}
static int fsl_bman_probe(struct platform_device *pdev)
{
int ret, err_irq;
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct resource *res;
u16 id, bm_pool_cnt;
u8 major, minor;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "Can't get %pOF property 'IORESOURCE_MEM'\n",
node);
return -ENXIO;
}
bm_ccsr_start = devm_ioremap(dev, res->start, resource_size(res));
if (!bm_ccsr_start)
return -ENXIO;
bm_get_version(&id, &major, &minor);
if (major == 1 && minor == 0) {
bman_ip_rev = BMAN_REV10;
bm_pool_cnt = BM_POOL_MAX;
} else if (major == 2 && minor == 0) {
bman_ip_rev = BMAN_REV20;
bm_pool_cnt = 8;
} else if (major == 2 && minor == 1) {
bman_ip_rev = BMAN_REV21;
bm_pool_cnt = BM_POOL_MAX;
} else {
dev_err(dev, "Unknown Bman version:%04x,%02x,%02x\n",
id, major, minor);
return -ENODEV;
}
bm_set_memory(fbpr_a, fbpr_sz);
err_irq = platform_get_irq(pdev, 0);
if (err_irq <= 0) {
dev_info(dev, "Can't get %pOF IRQ\n", node);
return -ENODEV;
}
ret = devm_request_irq(dev, err_irq, bman_isr, IRQF_SHARED, "bman-err",
dev);
if (ret) {
dev_err(dev, "devm_request_irq() failed %d for '%pOF'\n",
ret, node);
return ret;
}
/* Disable Buffer Pool State Change */
bm_ccsr_out(REG_ERR_ISDR, BM_EIRQ_BSCN);
/*
* Write-to-clear any stale bits, (eg. starvation being asserted prior
* to resource allocation during driver init).
*/
bm_ccsr_out(REG_ERR_ISR, 0xffffffff);
/* Enable Error Interrupts */
bm_ccsr_out(REG_ERR_IER, 0xffffffff);
bm_bpalloc = devm_gen_pool_create(dev, 0, -1, "bman-bpalloc");
if (IS_ERR(bm_bpalloc)) {
ret = PTR_ERR(bm_bpalloc);
dev_err(dev, "bman-bpalloc pool init failed (%d)\n", ret);
return ret;
}
/* seed BMan resource pool */
ret = gen_pool_add(bm_bpalloc, DPAA_GENALLOC_OFF, bm_pool_cnt, -1);
if (ret) {
dev_err(dev, "Failed to seed BPID range [%d..%d] (%d)\n",
0, bm_pool_cnt - 1, ret);
return ret;
}
return 0;
};
static const struct of_device_id fsl_bman_ids[] = {
{
.compatible = "fsl,bman",
},
{}
};
static struct platform_driver fsl_bman_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = fsl_bman_ids,
.suppress_bind_attrs = true,
},
.probe = fsl_bman_probe,
};
builtin_platform_driver(fsl_bman_driver);
| 29.996198 | 80 | 0.717074 |
eaaa11cbf264517200332105c9e45170ac7ea8ef | 873 | h | C | src/aadcUser/GoalControl/Tasks/Task_PullOutRight.h | kimsoohwan/Cariosity2018 | 49f935623c41d627b45c47a219358f9d7d207fdf | [
"BSD-4-Clause"
] | null | null | null | src/aadcUser/GoalControl/Tasks/Task_PullOutRight.h | kimsoohwan/Cariosity2018 | 49f935623c41d627b45c47a219358f9d7d207fdf | [
"BSD-4-Clause"
] | null | null | null | src/aadcUser/GoalControl/Tasks/Task_PullOutRight.h | kimsoohwan/Cariosity2018 | 49f935623c41d627b45c47a219358f9d7d207fdf | [
"BSD-4-Clause"
] | 1 | 2019-10-03T12:23:26.000Z | 2019-10-03T12:23:26.000Z | #pragma once
#include "stdafx.h"
#include "Task.h"
using namespace fhw;
class cTask_PullOutRight : public cTask
{
private:
enum eState {
INIT,
STRAIGHT,
STEERING,
DONE
};
tFloat32 targetDistance;
tFloat64 targetHeading;
eState state;
tTimeStamp waitEndTime;
public:
/*! Default constructor. Sets parent Task. */
cTask_PullOutRight(tBool isFirstTaskOfManeuver = tFalse);
/*! Destructor. */
virtual ~cTask_PullOutRight() = default;
/*! Calculates actuator steering info from egoState and map
* --> needs to be overridden by specific Task implementations! */
tResult execute(tTaskResult &taskResult) override;
tFloat64 normalizeAngle(tFloat64 value);
tFloat64 getRelativeAngle(tFloat64 ofAngle, tFloat64 toAngle);
std::pair<tFloat32, int> nextParkingSpot();
};
| 19.4 | 69 | 0.680412 |
eaabe1b758f2c85de3800885d381f6267808a4d0 | 1,397 | c | C | worksheet4/collision.c | nasay/cfdlab | 6fae95b8f926609b0c8643d31d5f2a2858ee3f71 | [
"MIT"
] | 1 | 2020-01-11T17:50:18.000Z | 2020-01-11T17:50:18.000Z | worksheet4/collision.c | nasay/cfdlab | 6fae95b8f926609b0c8643d31d5f2a2858ee3f71 | [
"MIT"
] | null | null | null | worksheet4/collision.c | nasay/cfdlab | 6fae95b8f926609b0c8643d31d5f2a2858ee3f71 | [
"MIT"
] | null | null | null | #include "helper.h"
#include "collision.h"
void computePostCollisionDistributions(double *currentCell, const double * const tau, const double *const feq){
/* Compute the post-collision distribution f*[i] according to BGK update rule. See Eq 14. */
int i;
double fi;
for (i=0; i<Q; i++) {
fi = currentCell[i];
currentCell[i] = fi - (fi - feq[i]) / *tau;
}
}
void doCollision(double *collideField, int *flagField, const double * const tau, int * length){
/*
* For each inner grid cell in collideField, compute the post-collide
* distribution
*/
double density;
double velocity[D];
double feq[Q];
double * currentCell;
int x,y,z;
int node[3];
int n[3] = { length[0] + 2, length[1] + 2, length[2] + 2 };
// Loop over inner cells: compare to streaming.c
for (z = 1; z <= length[2]; z++) {
node[2] = z;
for (y = 1; y <= length[1]; y++) {
node[1] = y;
for (x = 1; x <= length[0]; x++) {
node[0] = x;
currentCell = getEl(collideField, node, 0, n);
computeDensity(currentCell, &density);
computeVelocity(currentCell, &density, velocity);
computeFeq(&density, velocity, feq);
computePostCollisionDistributions(currentCell, tau, feq);
}
}
}
}
| 27.392157 | 111 | 0.549749 |
eaacbe70aedce74096f27169a5ca6bc65f38c630 | 1,101 | h | C | src/config.h | hscnhs/bjoern | df2127a4047327d2ad67ff5a778a669d30b711c8 | [
"BSD-2-Clause"
] | null | null | null | src/config.h | hscnhs/bjoern | df2127a4047327d2ad67ff5a778a669d30b711c8 | [
"BSD-2-Clause"
] | null | null | null | src/config.h | hscnhs/bjoern | df2127a4047327d2ad67ff5a778a669d30b711c8 | [
"BSD-2-Clause"
] | null | null | null | #ifndef _CONFIG_H
#define _CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
enum control_server {
START = 0, //default
RESTART,
STOP,
};
enum arg_type {
ARG_START,
ARG_END,
ARG_PARENT,
ARG_OPT_BOOL,
ARG_OPT_STRING,
};
typedef struct Config
{
char* host; //http mode, need port
char* unixsock; //unix sock mode
char* wsgi; //wsgi callable object
char* home; //virtualenv ?
char* pid; //only work with daemon mode
//char *command; //for -c
int port;
int daemon; //daemonize
//int start;
//int stop;
//int restart;
control_server cs; //restart and stop only work with daemon mode
};
typedef struct ArgumentOption
{
char option;
char* long_option;
void* value;
const char* help;
arg_type type;
ArgumentOption** next; // for child argument
};
typedef struct Argparse {
int index;
int argc;
char** argv;
char* value; //current value
ArgumentOption* options;
};
extern void argparse(Argparse* ap, ArgumentOption* ao, int argc, char** argv);
#ifdef __cplusplus
}
#endif
#endif | 17.758065 | 78 | 0.646685 |
eaad9a0b43bdc0c9ad78a2503628f2224761602f | 482 | h | C | HHServiceSDK/location/HHLocationManager.h | hao1208hao/HHServiceSDK | 175464546240cb9339a3e5479485ca3d904d516a | [
"MIT"
] | null | null | null | HHServiceSDK/location/HHLocationManager.h | hao1208hao/HHServiceSDK | 175464546240cb9339a3e5479485ca3d904d516a | [
"MIT"
] | null | null | null | HHServiceSDK/location/HHLocationManager.h | hao1208hao/HHServiceSDK | 175464546240cb9339a3e5479485ca3d904d516a | [
"MIT"
] | null | null | null | //
// HHLocationManager.h
// HHServiceSDK
//
// Created by haohao on 2018/11/8.
// Copyright © 2018年 haohao. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
//#import "HHSingleton.h"
@interface HHLocationManager : CLLocationManager
//SingletonH(Instance);
//开始定位
-(void) startLocationMonitor;
//关闭定位
-(void)stopLocation;
//获取位置信息
-(NSString*)getLocationInfo;
//获取经度
-(NSString*)getLongitude;
//获取纬度
-(NSString*)getLatitude;
@end
| 14.176471 | 50 | 0.715768 |
eaae88db8766bfd05b68532a588945b5ce4e376e | 684 | h | C | Tools/Category/UIKit/UIView+XLNib.h | shanglu/Category | 224cfe8502eb0cffcbb6affed193f7c311e29376 | [
"MIT"
] | null | null | null | Tools/Category/UIKit/UIView+XLNib.h | shanglu/Category | 224cfe8502eb0cffcbb6affed193f7c311e29376 | [
"MIT"
] | null | null | null | Tools/Category/UIKit/UIView+XLNib.h | shanglu/Category | 224cfe8502eb0cffcbb6affed193f7c311e29376 | [
"MIT"
] | null | null | null | //
// UIView+XLNib.h
// Tools
//
// Created by 路 on 2020/4/17.
// Copyright © 2020 路. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIView (XLNib)
+ (UINib *)xl_loadNib;
+ (UINib *)xl_loadNibNamed:(NSString*)nibName;
+ (UINib *)xl_loadNibNamed:(NSString*)nibName bundle:(NSBundle *)bundle;
+ (instancetype)xl_loadInstanceFromNib;
+ (instancetype)xl_loadInstanceFromNibWithName:(NSString *)nibName;
+ (instancetype)xl_loadInstanceFromNibWithName:(NSString *)nibName owner:(nullable id)owner;
+ (instancetype)xl_loadInstanceFromNibWithName:(NSString *)nibName owner:(nullable id)owner bundle:(NSBundle *)bundle;
@end
NS_ASSUME_NONNULL_END
| 26.307692 | 118 | 0.761696 |
eab092d1002cef9e8c3f1e7662567546ef3314c4 | 2,308 | h | C | chrome/browser/ui/webui/help/version_updater_win.h | google-ar/chromium | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 777 | 2017-08-29T15:15:32.000Z | 2022-03-21T05:29:41.000Z | chrome/browser/ui/webui/help/version_updater_win.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 66 | 2017-08-30T18:31:18.000Z | 2021-08-02T10:59:35.000Z | chrome/browser/ui/webui/help/version_updater_win.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 123 | 2017-08-30T01:19:34.000Z | 2022-03-17T22:55:31.000Z | // Copyright 2015 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.
// Windows implementation of version update functionality, used by the WebUI
// About/Help page.
#ifndef CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_WIN_H_
#define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_WIN_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/google/google_update_win.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
class VersionUpdaterWin : public VersionUpdater,
public UpdateCheckDelegate {
public:
// |owner_widget| is the parent widget hosting the update check UI. Any UI
// needed to install an update (e.g., a UAC prompt for a system-level install)
// will be parented to this widget. |owner_widget| may be given a value of
// nullptr in which case the UAC prompt will be parented to the desktop.
explicit VersionUpdaterWin(gfx::AcceleratedWidget owner_widget);
~VersionUpdaterWin() override;
// VersionUpdater:
void CheckForUpdate(const StatusCallback& callback,
const PromoteCallback&) override;
// UpdateCheckDelegate:
void OnUpdateCheckComplete(const base::string16& new_version) override;
void OnUpgradeProgress(int progress,
const base::string16& new_version) override;
void OnUpgradeComplete(const base::string16& new_version) override;
void OnError(GoogleUpdateErrorCode error_code,
const base::string16& html_error_message,
const base::string16& new_version) override;
private:
void BeginUpdateCheckOnFileThread(bool install_update_if_possible);
// A task run on the UI thread with the result of checking for a pending
// restart.
void OnPendingRestartCheck(bool is_update_pending_restart);
// The widget owning the UI for the update check.
gfx::AcceleratedWidget owner_widget_;
// Callback used to communicate update status to the client.
StatusCallback callback_;
// Used for callbacks.
base::WeakPtrFactory<VersionUpdaterWin> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin);
};
#endif // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_WIN_H_
| 38.466667 | 80 | 0.758232 |
eab2af03cb2f592a0f76ba81e6ca5ea52210c27a | 987 | h | C | components/about_handler/about_protocol_handler.h | google-ar/chromium | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | components/about_handler/about_protocol_handler.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | components/about_handler/about_protocol_handler.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | // Copyright (c) 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 COMPONENTS_ABOUT_HANDLER_ABOUT_PROTOCOL_HANDLER_H_
#define COMPONENTS_ABOUT_HANDLER_ABOUT_PROTOCOL_HANDLER_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "net/url_request/url_request_job_factory.h"
namespace about_handler {
// Implements a ProtocolHandler for About jobs.
class AboutProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
AboutProtocolHandler();
~AboutProtocolHandler() override;
net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override;
bool IsSafeRedirectTarget(const GURL& location) const override;
private:
DISALLOW_COPY_AND_ASSIGN(AboutProtocolHandler);
};
} // namespace about_handler
#endif // COMPONENTS_ABOUT_HANDLER_ABOUT_PROTOCOL_HANDLER_H_
| 31.83871 | 80 | 0.802432 |
eab3c73ec57a0fb79e8b837ee45c867448521c99 | 5,656 | c | C | lib/string.c | onkwon/yaos | c9571f22b310002e16bb012215dfbfb84a1e264b | [
"Apache-2.0"
] | 40 | 2015-09-28T13:21:33.000Z | 2022-03-31T05:57:52.000Z | lib/string.c | onkwon/yaos | c9571f22b310002e16bb012215dfbfb84a1e264b | [
"Apache-2.0"
] | 43 | 2015-08-04T06:27:55.000Z | 2019-10-06T05:58:24.000Z | lib/string.c | onkwon/yaos | c9571f22b310002e16bb012215dfbfb84a1e264b | [
"Apache-2.0"
] | 18 | 2015-09-29T22:37:18.000Z | 2021-06-04T06:40:23.000Z | #include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef CONFIG_FLOAT
size_t ftoa(double v, char *buf, int flen, size_t maxlen)
{
double f;
int i;
char c;
size_t off = 0;
if (v < 0) {
buf[off++] = '-';
v = -v;
}
f = v;
i = (int)f;
itoa(i, &buf[off], 10);
off += strlen(&buf[off]);
buf[off++] = '.';
while ((f = f - (double)i) != (double)0.0 && off < maxlen-1) {
c = (int)(f * 10) + '0';
if (!isdigit(c))
break;
buf[off++] = c;
v *= 10;
f = v;
i = (int)f;
if (--flen == 0)
break;
}
/*
while (flen-- > 0 && off < maxlen-1)
buf[off++] = '0';
*/
if (buf[off-1] == '.')
off--;
buf[off] = '\0';
return off;
}
#else
size_t ftoa(double v, char *buf, int flen, size_t maxlen)
{
return 0;
}
#endif
#if 0
#include <string.h>
#include <stdbool.h>
/* TODO: Support all double-precision numbers
* It only gets a few small floating-point numbers correctly and has bad
* rounding erros. */
double atof(const char *s)
{
#ifdef CONFIG_FLOAT
double v;
int integer, decimal, *p;
unsigned int ndigit;
int sign;
integer = decimal = 0;
ndigit = 1;
sign = 1;
if (*s == '-') {
sign = -1;
s++;
}
for (p = &integer; *s; s++) {
if (*s == '.') {
p = &decimal;
ndigit = 1;
continue;
}
*p *= 10;
*p += *s - '0';
ndigit *= 10;
}
v = (double)integer;
if (decimal)
v += (double)decimal / ndigit;
return v * sign;
#else
return 0;
#endif
}
#define BASE_MAX 16
/* TODO: Get the result from the first digits
* if n is less than the actual string length as the converting result,
* it saves from the last digits, not from the first digits. */
size_t itos(int v, char *buf, int base, size_t n)
{
unsigned int u;
bool is_negative;
size_t i;
char *p, t;
if (!buf || base > BASE_MAX)
return 0;
is_negative = false;
p = buf;
n--; /* to preserve a null byte */
if (v < 0 && base == 10) {
is_negative = true;
v = -v;
n--;
*p++ = '-';
}
u = (unsigned int)v;
for (i = 0; u && (i < n); i++) {
t = "0123456789abcdef"[u % base];
u /= base;
*p++ = t;
}
if (!i) { /* in case of u == 0 */
*p++ = '0';
i = 1;
}
*p = '\0';
n = i; /* Note that the local variable, n, is redefined here */
p = buf + is_negative;
for (i = 0; i < (n >> 1); i++) {
t = p[i];
p[i] = p[n-i-1];
p[n-i-1] = t;
}
return n + is_negative;
}
size_t ftos(double v, char *buf, int flen, size_t maxlen)
{
#ifdef CONFIG_FLOAT
double f;
int i;
char c;
size_t off = 0;
if (v < 0) {
buf[off++] = '-';
v = -v;
}
f = v;
i = (int)f;
off += itos(i, &buf[off], 10, maxlen - off - 1);
buf[off++] = '.';
while ((f = f - (double)i) != (double)0.0 && off < maxlen-1) {
c = (int)(f * 10) + '0';
if (!isdigit(c))
break;
buf[off++] = c;
v *= 10;
f = v;
i = (int)f;
if (--flen == 0)
break;
}
/*
while (flen-- > 0 && off < maxlen-1)
buf[off++] = '0';
*/
if (buf[off-1] == '.')
off--;
buf[off] = '\0';
return off;
#else
return 0;
#endif
}
int strtoi(const char *s, int base)
{
unsigned int digit;
int v = 0;
while (*s) {
digit = *s - '0';
if (digit > ('Z' - '0')) /* lower case */
digit = *s - 'a' + 10;
else if (digit > 9) /* upper case */
digit = *s - 'A' + 10;
if (digit >= base)
break;
v = v * base + digit;
s++;
}
return v;
}
int atoi(const char *s)
{
int v;
int base = 10;
int sign = 1;
if (!s) return 0;
if (s[0] == '0') {
if (s[1] == 'x' || s[1] == 'X')
base = 16, s += 2;
} else if (s[0] == '-')
sign = -1, s++;
for (v = 0; *s; s++) {
v *= base;
v += c2i(*s);
}
return v * sign;
}
int strncmp(const char *s1, const char *s2, size_t n)
{
if (!s1 || !s2) return -1;
for (; n > 0; s1++, s2++, n--) {
if (*s1 != *s2)
return *(const unsigned char *)s1 -
*(const unsigned char *)s2;
else if (!*s1)
return 0;
}
return 0;
}
int strcmp(const char *s1, const char *s2)
{
if (!s1 || !s2) return -1;
for (; *s1 == *s2; s1++, s2++)
if (!*s1) return 0;
return *(const unsigned char *)s1 - *(const unsigned char *)s2;
}
char *strncpy(char *d, const char *s, size_t n)
{
char *p;
if (!d || !s) return NULL;
for (p = d; *s && n; n--) *p++ = *s++;
for (; n--; *p++ = '\0');
return d;
}
char *strcpy(char *d, const char *s)
{
char *p;
if (!d || !s) return NULL;
for (p = d; *s;) *p++ = *s++;
return d;
}
size_t strnlen(const char *s, size_t n)
{
register const char *p;
if (!s) return 0;
for (p = s; *p && n; p++, n--);
return p - s;
}
size_t strlen(const char *s)
{
register const char *p;
if (!s) return 0;
for (p = s; *p; p++);
return p - s;
}
char *strtok(char *line, const char *const token)
{
static char *saveline = NULL;
char *p;
register unsigned int i, j;
if (line) saveline = line;
if (!saveline || !*saveline || !token) return NULL;
for (i = 0; saveline[i]; i++) {
for (j = 0; token[j] && (saveline[i] != token[j]); j++) ;
if (token[j]) break;
}
p = saveline;
saveline += i;
if (*saveline)
*saveline++ = '\0';
return p;
}
unsigned int toknum(const char *line, const char *const token)
{
register unsigned int i, cnt = 0;
if (!line || !token) return 0;
while (*line) {
for (i = 0; token[i] && (*line != token[i]); i++) ;
if (token[i]) cnt++;
line++;
}
return cnt;
}
char *strchr(char *s, const char c)
{
for (; s && *s; s++)
if (*s == c) return s;
return NULL;
}
char *strstr(const char *string, const char *word)
{
const char *s, *s1, *s2;
if (!word || !*word || !string) return NULL;
s = string;
while (*s) {
s1 = s;
s2 = word;
while (*s1 && *s2 && !(*s1 - *s2))
s1++, s2++;
if (!*s2) return (char *)s;
s++;
}
return NULL;
}
#endif
| 14.57732 | 72 | 0.512907 |
eab3f3f9068f227001692753a53f9b6fa1423501 | 392 | h | C | packages/seacas/libraries/svdi/cgi/fortyp.h | jschueller/seacas | 14c34ae08b757cba43a3a03ec0f129c8a168a9d3 | [
"Python-2.0",
"Zlib",
"BSD-2-Clause",
"MIT",
"NetCDF",
"BSL-1.0",
"X11",
"BSD-3-Clause"
] | 82 | 2016-02-04T18:38:25.000Z | 2022-03-29T03:01:49.000Z | packages/seacas/libraries/svdi/cgi/fortyp.h | jschueller/seacas | 14c34ae08b757cba43a3a03ec0f129c8a168a9d3 | [
"Python-2.0",
"Zlib",
"BSD-2-Clause",
"MIT",
"NetCDF",
"BSL-1.0",
"X11",
"BSD-3-Clause"
] | 206 | 2015-11-20T01:57:47.000Z | 2022-03-31T21:12:04.000Z | packages/seacas/libraries/svdi/cgi/fortyp.h | jschueller/seacas | 14c34ae08b757cba43a3a03ec0f129c8a168a9d3 | [
"Python-2.0",
"Zlib",
"BSD-2-Clause",
"MIT",
"NetCDF",
"BSL-1.0",
"X11",
"BSD-3-Clause"
] | 68 | 2016-01-13T22:46:51.000Z | 2022-03-31T06:25:05.000Z | /*
* Copyright(C) 1999-2020 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
* See packages/seacas/LICENSE for details
*/
#ifndef FORTYP_H
#define FORTYP_H
/* typedef long f_integer; */
typedef int f_integer;
typedef float f_real;
#endif
| 23.058824 | 73 | 0.734694 |
eab4271c243f5a2f53ed66c007a0f048975e9eee | 581 | h | C | tests/altium_crap/Soft Designs/C to Hardware/Spinning 3D Cube/Embedded/3dcube.h | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
] | 1 | 2020-06-08T11:17:46.000Z | 2020-06-08T11:17:46.000Z | tests/altium_crap/Soft Designs/C to Hardware/Spinning 3D Cube/Embedded/3dcube.h | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
] | null | null | null | tests/altium_crap/Soft Designs/C to Hardware/Spinning 3D Cube/Embedded/3dcube.h | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
] | null | null | null | // 3D.H - some general settings
#ifndef _3D_H_
#define _3D_H_
#include <stdint.h>
// scaling for fixed point arithmetic
#define FIXEDPOINTSCALE 14
// number of divisions in full circle for gonio
#define ROTATIONSTEPS 64
// side of square bitmaps
#define BMPSIZE 100
#define PI 3.14159265359
#define VGA_W 240
#define VGA_H 320
#define VGA_PIXELS (VGA_W * VGA_H)
#define rgb(r, g, b) ((int16_t) ((((uint16_t) r) << 11) | (((uint16_t) g) << 6) | ((uint16_t) b)))
typedef struct
{
int16_t xx, xy, xz;
int16_t yx, yy, yz;
int16_t zx, zy, zz;
} matrix_t;
#endif
| 17.088235 | 98 | 0.678141 |
eab6bd9525639e5bb3ea467f8e289be9ed45640c | 2,736 | h | C | src/common/stackTrace.h | EthVM/pgbackrest | 09ef03b7ef69d2760756146cad86b784b0b5d7c3 | [
"MIT"
] | 1 | 2019-10-24T07:34:30.000Z | 2019-10-24T07:34:30.000Z | src/common/stackTrace.h | EthVM/pgbackrest | 09ef03b7ef69d2760756146cad86b784b0b5d7c3 | [
"MIT"
] | null | null | null | src/common/stackTrace.h | EthVM/pgbackrest | 09ef03b7ef69d2760756146cad86b784b0b5d7c3 | [
"MIT"
] | null | null | null | /***********************************************************************************************************************************
Stack Trace Handler
***********************************************************************************************************************************/
#ifndef COMMON_STACKTRACE_H
#define COMMON_STACKTRACE_H
#include <stdbool.h>
#include <sys/types.h>
#include "common/logLevel.h"
/***********************************************************************************************************************************
Maximum size of a single parameter (including NULL terminator)
***********************************************************************************************************************************/
#define STACK_TRACE_PARAM_MAX 4096
/***********************************************************************************************************************************
Macros to access internal functions
***********************************************************************************************************************************/
#define STACK_TRACE_PUSH(logLevel) \
stackTracePush(__FILE__, __func__, logLevel)
#ifdef NDEBUG
#define STACK_TRACE_POP(test) \
stackTracePop();
#else
#define STACK_TRACE_POP(test) \
stackTracePop(__FILE__, __func__, test);
#endif
/***********************************************************************************************************************************
Internal Functions
***********************************************************************************************************************************/
#ifdef WITH_BACKTRACE
void stackTraceInit(const char *exe);
#endif
#ifndef NDEBUG
void stackTraceTestStart(void);
void stackTraceTestStop(void);
bool stackTraceTest(void);
#endif
LogLevel stackTracePush(const char *fileName, const char *functionName, LogLevel functionLogLevel);
#ifdef NDEBUG
void stackTracePop(void);
#else
void stackTracePop(const char *fileName, const char *functionName, bool test);
#endif
size_t stackTraceToZ(char *buffer, size_t bufferSize, const char *fileName, const char *functionName, unsigned int fileLine);
void stackTraceParamLog(void);
const char *stackTraceParam(void);
char *stackTraceParamBuffer(const char *param);
void stackTraceParamAdd(size_t bufferSize);
void stackTraceClean(unsigned int tryDepth);
#endif
| 44.852459 | 132 | 0.381944 |