hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
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
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
eb5506fda3d3fba80d4c37583f6794a64fa47f07
3,008
h
C
QtWebApp/logging/dualfilelogger.h
dashinfantry/harbour-webcontrol
adc8e0a5925570ced85c03164a1869b8fc2f709e
[ "MIT" ]
null
null
null
QtWebApp/logging/dualfilelogger.h
dashinfantry/harbour-webcontrol
adc8e0a5925570ced85c03164a1869b8fc2f709e
[ "MIT" ]
null
null
null
QtWebApp/logging/dualfilelogger.h
dashinfantry/harbour-webcontrol
adc8e0a5925570ced85c03164a1869b8fc2f709e
[ "MIT" ]
null
null
null
/** @file @author Stefan Frings */ #ifndef DUALFILELOGGER_H #define DUALFILELOGGER_H #include <QString> #include <QSettings> #include <QtGlobal> #include "logglobal.h" #include "logger.h" #include "filelogger.h" namespace stefanfrings { /** Writes log messages into two log files simultaneously. I recommend to configure: - One "main" logfile with minLevel=1 or 2 and bufferSize=0. This file is for the operator to see when a problem occured. - A second "debug" logfile with minLevel=1 or 2 and bufferSize=100. This file is for the developer who may need more details (the debug messages) about the situation that leaded to the error. @see FileLogger for a description of the two underlying loggers. */ class DECLSPEC DualFileLogger : public Logger { Q_OBJECT Q_DISABLE_COPY(DualFileLogger) public: /** Constructor. @param firstSettings Configuration settings for the first logfile, usually stored in an INI file. Must not be 0. Settings are read from the current group, so the caller must have called settings->beginGroup(). Because the group must not change during runtime, it is recommended to provide a separate QSettings instance that is not used by other parts of the program. The FileLogger does not take over ownership of the QSettings instance, so the caller should destroy it during shutdown. @param secondSettings Same as firstSettings, but for the second log file. @param refreshInterval Interval of checking for changed config settings in msec, or 0=disabled @param parent Parent object. */ DualFileLogger(QSettings* firstSettings, QSettings* secondSettings, const int refreshInterval=10000, QObject *parent = nullptr); /** Decorate and log the message, if type>=minLevel. This method is thread safe. @param type Message type (level) @param message Message text @param file Name of the source file where the message was generated (usually filled with the macro __FILE__) @param function Name of the function where the message was generated (usually filled with the macro __LINE__) @param line Line Number of the source file, where the message was generated (usually filles with the macro __func__ or __FUNCTION__) @see LogMessage for a description of the message decoration. */ virtual void log(const QtMsgType type, const QString& message, const QString &file="", const QString &function="", const int line=0); /** Clear the thread-local data of the current thread. This method is thread safe. @param buffer Whether to clear the backtrace buffer @param variables Whether to clear the log variables */ virtual void clear(const bool buffer=true, const bool variables=true); private: /** First logger */ FileLogger* firstLogger; /** Second logger */ FileLogger* secondLogger; }; } // end of namespace #endif // DUALFILELOGGER_H
36.240964
157
0.717088
[ "object" ]
eb5b42300eb501b6c85793175cb1f078ea6ad44b
6,630
c
C
tests/openacc-users-group/NAS_SHOC_OpenACC_2.5/reference/ref_adi.c
passlab/accparser
e8c18d16432eb5122ab0de04d3519d8559d23a34
[ "BSD-2-Clause" ]
null
null
null
tests/openacc-users-group/NAS_SHOC_OpenACC_2.5/reference/ref_adi.c
passlab/accparser
e8c18d16432eb5122ab0de04d3519d8559d23a34
[ "BSD-2-Clause" ]
null
null
null
tests/openacc-users-group/NAS_SHOC_OpenACC_2.5/reference/ref_adi.c
passlab/accparser
e8c18d16432eb5122ab0de04d3519d8559d23a34
[ "BSD-2-Clause" ]
null
null
null
#pragma acc parallel present (rhs) num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels present (rhs) #pragma acc loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel present (rhs) num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels present (rhs) #pragma acc loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel present (us, vs, ws, qs, u, speed, rhs) num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels present (us, vs, ws, qs, u, speed, rhs) #pragma acc loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc data present (rho_i, us, speed, rhs) create (lhsX, lhspX, lhsmX, rhonX, rhsX) #pragma acc parallel loop gang num_gangs (nz2+1) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc data present (rho_i, vs, speed, rhs) create (lhsY, lhspY, lhsmY, rhoqY) #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (nz2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (gp2-2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc data present (rho_i, ws, speed, rhs) create (lhsZ, lhspZ, lhsmZ, rhosZ) #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker #pragma acc loop vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector #pragma acc parallel loop gang num_gangs (ny2) num_workers (8) vector_length (32) #pragma acc kernels loop gang #pragma acc loop worker vector
45.724138
111
0.782353
[ "vector" ]
eb6845fc42ffc0412c83180df77519542468c386
1,568
c
C
nitan/kungfu/skill/baihong-jianfa/jing.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/kungfu/skill/baihong-jianfa/jing.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/kungfu/skill/baihong-jianfa/jing.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// This program is a part of NITAN MudLIB // jingtian.c 白虹驚天 #include <ansi.h> #include <combat.h> inherit F_SSERVER; int perform(object me, object target) { object weapon, ob; string msg; if (! me->is_fighting()) return notify_fail("「白虹驚天」只能在戰鬥中使用。\n"); if( !objectp(weapon=query_temp("weapon", me) ) || query("skill_type", weapon) != "sword" ) return notify_fail("你使用的武器不對。\n"); if ((int)me->query_skill("shenghuo-xuanming", 1) < 100) return notify_fail("你的聖火玄冥功火候還不到家, 不能使用這一絕技 !\n"); if ((int)me->query_skill("sword", 1) < 100) return notify_fail("你的基本劍法火候還不到家, 不能使用這一絕技 !\n"); if ((int)me->query_skill("baihong-jianfa", 1) < 100) return notify_fail("你的逍遙劍法火候還不到家, 不能使用這一絕技 !\n"); if( query("neili", me)<500 ) return notify_fail("你的真氣不夠!\n"); if( query("max_neili", me)<1000 ) return notify_fail("你的內力修為不夠!\n"); msg = HIC "\n$N長嘯一聲,手彈長劍,身形飄忽不定,使的正是白虹驚劍法的絕技「白虹驚天」!\n" NOR; message_combatd(msg, me); me->clean_up_enemy(); ob = me->select_opponent(); COMBAT_D->do_attack(me,ob,query_temp("weapon", me),0); COMBAT_D->do_attack(me,ob,query_temp("weapon", me),0); COMBAT_D->do_attack(me,ob,query_temp("weapon", me),0); COMBAT_D->do_attack(me,ob,query_temp("weapon", me),0); addn("neili", -random(150)-50, me); me->start_busy(1 + random(4)); return 1; }
32
67
0.560587
[ "object" ]
eb7049e83bcf1b80e3046b63662015f160a8a4a8
11,146
c
C
gl.c
jbperin/oricFlappyOric
73250092b9f37b48d602526c99a13f3483c6b562
[ "MIT" ]
null
null
null
gl.c
jbperin/oricFlappyOric
73250092b9f37b48d602526c99a13f3483c6b562
[ "MIT" ]
null
null
null
gl.c
jbperin/oricFlappyOric
73250092b9f37b48d602526c99a13f3483c6b562
[ "MIT" ]
null
null
null
#include "config.h" #include "glOric.h" #define LORES_SCREEN_WIDTH 40 #define LORES_SCREEN_HEIGHT 26 /* __ * / _\ ___ ___ _ __ ___ * \ \ / __| / _ \| '_ \ / _ \ * _\ \ | (__ | __/| | | || __/ * \__/ \___| \___||_| |_| \___| */ /* 16____________________________\_______17 // .. . .\ /| // .. .. . / | // . . . / | // .. . . / | // . . . / | // .. . . / | // .. .. . / | // . . ./ | // _____________ . / | // 4 7 //. | // ..| | / . | // .. | 10.... | ____11 / . HAUT | // . | .. | / / . | // .. | . | / / . | // . | .. | / / . | // .. | . | / / . | // .. |.. | / / . | // 5______________6/ / . | 12.....................................................13 . | | . | | . | | . | | SPACE / . | | /_______\\____/ . | | ///8 /\ /9 . | | // PROF // / . | | // / / \ . | | //17________\\/__/______\_____\\_______18 | 1 2 \. / | //: | .\ / | // : | . || / | // : | . / | // : | . / | // : | . / | // : | . / | // : | . / | // .0_______________3 . MAX_PROF / | // . 2*LARG .. // | // .. . / | // . . / | // T .. . / | // S . . / | // I .. . / | // D .. . / | // . . / | // .. . / |/ \\ / 15..........................M.A.X._.L.A.R G\\..........14 \\\ */ #define LARG 4 #define DIST 20 #define HAUT 26 #define POS 11 #define PROF 8 #define SPACE 6 #define MAX_LARG 12 #define MAX_HAUT 23 #define MAX_PROF 60 #define SCREW 1 char geomPipe []= { /* Nb Coords = */ 20, /* Nb Faces = */ 8, /* Nb Segments = */ 16, /* Nb Particules = */ 6, // Coord List : X, Y, Z, unused DIST, -LARG, -HAUT, 0, DIST, -LARG, -POS-SPACE, 1, DIST, LARG, -POS-SPACE, 2, DIST, LARG, -HAUT, 3, DIST, -LARG, 0, 4, DIST, -LARG, -POS, 5, DIST, LARG, -POS, 6, DIST, LARG, 0, 7, DIST+PROF, -LARG+SCREW, -POS-SPACE, 8, DIST+PROF, +LARG-SCREW, -POS-SPACE, 9, DIST+PROF, -LARG+SCREW, -POS, 10, DIST+PROF, LARG-SCREW, -POS, 11, 12, -MAX_LARG, 0, 12, 12, +MAX_LARG, 0, 13, 12, +MAX_LARG, -MAX_HAUT, 14, 12, -MAX_LARG, -MAX_HAUT, 15, MAX_PROF, -MAX_LARG, 0, 16, MAX_PROF, +MAX_LARG, 0, 17, MAX_PROF, +MAX_LARG, -MAX_HAUT, 18, MAX_PROF, -MAX_LARG, -MAX_HAUT, 19, // Face List : idxPoint1, idxPoint2, idxPoint3, character 0, 1, 2, 'h'+128, 0, 2, 3, 'h'+128, 4, 5, 6, 'h'+128, 4, 6, 7, 'h'+128, 1, 2, 8, 'h', 2, 8, 9, 'h', 5, 6, 10, 'h', 6,10, 11, 'h', // Segment List : idxPoint1, idxPoint2, idxPoint3, character 0, 1, 'i'+128, 0, 1, 2, 'k'+128, 0, 2, 3, 'g'+128, 0, 4, 5, 'i'+128, 0, 5, 6, 'k'+128, 0, 6, 7, 'g'+128, 0, 8, 9, 'k'+128, 0, 10, 11, 'k'+128, 0, 16, 12, '.', 0, 17, 13, '.', 0, 14, 18, '.', 0, 15, 19, '.', 0, 16, 17, '-', 0, 17, 18, ':', 0, 18, 19, '-', 0, 19, 16, ':', 0, // Particule List : idxPoint1, character 1, 'l'+128, 2, 'j'+128, 5, 'l'+128, 6, 'j'+128, 4, ' ', 7, ' ', }; void initGl (){ int ii; /* * Scene geometry */ nbPoints = 0; nbSegments = 0; nbFaces = 0; nbParticules = 0; addGeom(0, 0, 0, 1, 1, 1, 0, geomPipe); /* * Camera position and Orientation */ CamPosX = 12; CamPosY = 0; CamPosZ = -13; CamRotZ = 0; CamRotX = 0; change_char(36, 0x80, 0x40, 020, 0x10, 0x08, 0x04, 0x02, 0x01); for (ii = 0; ii<=LORES_SCREEN_HEIGHT; ii++){ fbuffer[ii*LORES_SCREEN_WIDTH]=COLOR ; fbuffer[ii*LORES_SCREEN_WIDTH+1]=INK ; } } /* ___ _ * / \ _ __ __ _ __ __(_) _ __ __ _ * / /\ /| '__| / _` |\ \ /\ / /| || '_ \ / _` | * / /_// | | | (_| | \ V V / | || | | || (_| | * /___,' |_| \__,_| \_/\_/ |_||_| |_| \__, | * |___/ */ extern signed char points2aH[]; extern signed char points2aV[]; void glDrawParticules(){ unsigned char ii; unsigned char idxPt; for (ii = 0; ii < nbParticules; ii++) { idxPt = particulesPt[ii]; zplot( (SCREEN_WIDTH -points2aH[idxPt]) >> 1, // PX (SCREEN_HEIGHT - points2aV[idxPt]) >> 1, // PY 0, // points2dL[idxPt]-2, // distance particulesChar[ii] // character 2 display ); } } /* ___ _ _ _ * / __\ _ _ (_)| | __| | * /__\//| | | || || | / _` | * / \/ \| |_| || || || (_| | * \_____/ \__,_||_||_| \__,_| */ void addGeom( signed char X, signed char Y, signed char Z, unsigned char sizeX, unsigned char sizeY, unsigned char sizeZ, unsigned char orientation, char geom[]) { int kk; for (kk=0; kk< geom[0]; kk++){ points3dX[nbPoints] = X + ((orientation == 0) ? sizeX * geom[4+kk*SIZEOF_3DPOINT+0]: sizeY * geom[4+kk*SIZEOF_3DPOINT+1]);// X + ii; points3dY[nbPoints] = Y + ((orientation == 0) ? sizeY * geom[4+kk*SIZEOF_3DPOINT+1]: sizeX * geom[4+kk*SIZEOF_3DPOINT+0]);// Y + jj; points3dZ[nbPoints] = Z + geom[4+kk*SIZEOF_3DPOINT+2]*sizeZ;// ; nbPoints++; } for (kk=0; kk< geom[1]; kk++){ facesPt1[nbFaces] = nbPoints - (geom[0]-geom[4+geom[0]*SIZEOF_3DPOINT+kk*SIZEOF_FACE+0]); // Index Point 1 facesPt2[nbFaces] = nbPoints - (geom[0]-geom[4+geom[0]*SIZEOF_3DPOINT+kk*SIZEOF_FACE+1]); // Index Point 2 facesPt3[nbFaces] = nbPoints - (geom[0]-geom[4+geom[0]*SIZEOF_3DPOINT+kk*SIZEOF_FACE+2]); // Index Point 3 facesChar[nbFaces] = geom[4+geom[0]*SIZEOF_3DPOINT+kk*SIZEOF_FACE+3]; // Character nbFaces++; } for (kk=0; kk< geom[2]; kk++){ segmentsPt1[nbSegments] = nbPoints - (geom[0]-geom[4+geom[0]*SIZEOF_3DPOINT+geom[1]*SIZEOF_FACE+kk*SIZEOF_SEGMENT + 0]); // Index Point 1 segmentsPt2[nbSegments] = nbPoints - (geom[0]-geom[4+geom[0]*SIZEOF_3DPOINT+geom[1]*SIZEOF_FACE+kk*SIZEOF_SEGMENT + 1]); // Index Point 2 segmentsChar[nbSegments] = geom[4+geom[0]*SIZEOF_3DPOINT+geom[1]*SIZEOF_FACE+kk*SIZEOF_SEGMENT + 2]; // Character nbSegments++; } for (kk=0; kk< geom[3]; kk++){ particulesPt[nbParticules] = nbPoints - (geom[0]-geom[4 + geom[0]*SIZEOF_3DPOINT + geom[1]*SIZEOF_FACE + geom[2]*SIZEOF_SEGMENT + kk*SIZEOF_PARTICULE + 0]); // Index Point particulesChar[nbParticules] = geom[4 + geom[0]*SIZEOF_3DPOINT + geom[1]*SIZEOF_FACE + geom[2]*SIZEOF_SEGMENT + kk*SIZEOF_PARTICULE + 1]; // Character nbParticules++; } } void change_char(char c, unsigned char patt01, unsigned char patt02, unsigned char patt03, unsigned char patt04, unsigned char patt05, unsigned char patt06, unsigned char patt07, unsigned char patt08) { unsigned char* adr; adr = (unsigned char*)(0xB400 + c * 8); *(adr++) = patt01; *(adr++) = patt02; *(adr++) = patt03; *(adr++) = patt04; *(adr++) = patt05; *(adr++) = patt06; *(adr++) = patt07; *(adr++) = patt08; } /* * /\/\ ___ __ __ ___ * / \ / _ \ \ \ / / / _ \ * / /\/\ \| (_) | \ V / | __/ * \/ \/ \___/ \_/ \___| * */ void moveShape (unsigned char pos, unsigned char counter){ points3dX[ 0] = counter; points3dX[ 1] = counter; points3dX[ 2] = counter; points3dX[ 3] = counter; points3dX[ 4] = counter; points3dX[ 5] = counter; points3dX[ 6] = counter; points3dX[ 7] = counter; points3dX[ 8] = counter+PROF; points3dX[ 9] = counter+PROF; points3dX[10] = counter+PROF; points3dX[11] = counter+PROF; points3dZ[ 1] = -pos-SPACE; points3dZ[ 2] = -pos-SPACE; points3dZ[ 8] = -pos-SPACE; points3dZ[ 9] = -pos-SPACE; points3dZ[ 5] = -pos; points3dZ[ 6] = -pos; points3dZ[ 10] = -pos; points3dZ[ 11] = -pos; }
37.402685
202
0.337161
[ "geometry" ]
64bf2f1969961768d5ec6be4fbc94c48114590e9
1,780
c
C
kubernetes/unit-test/test_v1_namespace_list.c
CyshallChan/k8s-c-client
5bf6cd5262dbc3c1bcca1aca2a586b824f40b944
[ "Apache-2.0" ]
null
null
null
kubernetes/unit-test/test_v1_namespace_list.c
CyshallChan/k8s-c-client
5bf6cd5262dbc3c1bcca1aca2a586b824f40b944
[ "Apache-2.0" ]
null
null
null
kubernetes/unit-test/test_v1_namespace_list.c
CyshallChan/k8s-c-client
5bf6cd5262dbc3c1bcca1aca2a586b824f40b944
[ "Apache-2.0" ]
null
null
null
#ifndef v1_namespace_list_TEST #define v1_namespace_list_TEST // the following is to include only the main from the first c file #ifndef TEST_MAIN #define TEST_MAIN #define v1_namespace_list_MAIN #endif // TEST_MAIN #include <stdlib.h> #include <string.h> #include <stdio.h> #include <stdbool.h> #include "../external/cJSON.h" #include "../model/v1_namespace_list.h" v1_namespace_list_t* instantiate_v1_namespace_list(int include_optional); #include "test_v1_list_meta.c" v1_namespace_list_t* instantiate_v1_namespace_list(int include_optional) { v1_namespace_list_t* v1_namespace_list = NULL; if (include_optional) { v1_namespace_list = v1_namespace_list_create( "0", list_createList(), "0", // false, not to have infinite recursion instantiate_v1_list_meta(0) ); } else { v1_namespace_list = v1_namespace_list_create( "0", list_createList(), "0", NULL ); } return v1_namespace_list; } #ifdef v1_namespace_list_MAIN void test_v1_namespace_list(int include_optional) { v1_namespace_list_t* v1_namespace_list_1 = instantiate_v1_namespace_list(include_optional); cJSON* jsonv1_namespace_list_1 = v1_namespace_list_convertToJSON(v1_namespace_list_1); printf("v1_namespace_list :\n%s\n", cJSON_Print(jsonv1_namespace_list_1)); v1_namespace_list_t* v1_namespace_list_2 = v1_namespace_list_parseFromJSON(jsonv1_namespace_list_1); cJSON* jsonv1_namespace_list_2 = v1_namespace_list_convertToJSON(v1_namespace_list_2); printf("repeating v1_namespace_list:\n%s\n", cJSON_Print(jsonv1_namespace_list_2)); } int main() { test_v1_namespace_list(1); test_v1_namespace_list(0); printf("Hello world \n"); return 0; } #endif // v1_namespace_list_MAIN #endif // v1_namespace_list_TEST
26.567164
101
0.769101
[ "model" ]
64cc7c211136591192fcdde92847ef37f03c2238
1,903
h
C
include/HBTK/AerofoilParser.h
hjabird/Quad1D
4f0291bc729ac689df64d0366e8947b12af28684
[ "MIT" ]
null
null
null
include/HBTK/AerofoilParser.h
hjabird/Quad1D
4f0291bc729ac689df64d0366e8947b12af28684
[ "MIT" ]
null
null
null
include/HBTK/AerofoilParser.h
hjabird/Quad1D
4f0291bc729ac689df64d0366e8947b12af28684
[ "MIT" ]
null
null
null
#pragma once /*//////////////////////////////////////////////////////////////////////////// AerofoilParser.h Parses aerofoil .dat files and spits out AerofoilGeometry objects. Copyright 2018 HJA Bird Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *///////////////////////////////////////////////////////////////////////////// #include <istream> #include "AerofoilGeometry.h" #include "BasicParser.h" namespace HBTK { class AerofoilParser : public BasicParser<AerofoilParser> { public: // Binds the parser to the geometry object where the imformation is placed. AerofoilParser(AerofoilGeometry & target); // The name of the foil as described by the file. std::string foil_name; protected: friend class BasicParser<AerofoilParser>; // Called by basic parser. void main_parser(std::istream & input, std::ostream & error_stream); // Where we're dumping our data. AerofoilGeometry & m_foil; }; }
36.596154
78
0.716763
[ "geometry", "object" ]
64d830ef87caa2233c65682fb49706d36856c9d1
7,228
h
C
third_party/blink/renderer/bindings/core/v8/v8_script_runner.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2022-02-10T00:36:35.000Z
2022-02-10T00:36:35.000Z
third_party/blink/renderer/bindings/core/v8/v8_script_runner.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
third_party/blink/renderer/bindings/core/v8/v8_script_runner.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
/* * Copyright (C) 2009 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: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_SCRIPT_RUNNER_H_ #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_SCRIPT_RUNNER_H_ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "v8/include/v8.h" namespace WTF { class TextPosition; } namespace blink { class ClassicScript; class ExecutionContext; class ModuleScript; class ModuleScriptCreationParams; class ReferrerScriptInfo; class ScriptEvaluationResult; class ScriptSourceCode; class ScriptState; enum class ExecuteScriptPolicy { kExecuteScriptWhenScriptsDisabled, kDoNotExecuteScriptWhenScriptsDisabled }; class CORE_EXPORT V8ScriptRunner final { STATIC_ONLY(V8ScriptRunner); public: // Rethrow errors flag in // https://html.spec.whatwg.org/C/#run-a-classic-script // implemented by CompileAndRunScript() and // https://html.spec.whatwg.org/C/#run-a-module-script // implemented by EvaluateModule(). class RethrowErrorsOption final { STACK_ALLOCATED(); public: RethrowErrorsOption(RethrowErrorsOption&&) = default; RethrowErrorsOption& operator=(RethrowErrorsOption&&) = default; RethrowErrorsOption(const RethrowErrorsOption&) = delete; RethrowErrorsOption& operator=(const RethrowErrorsOption&) = delete; // Rethrow errors flag is false. static RethrowErrorsOption DoNotRethrow() { return RethrowErrorsOption(absl::nullopt); } // Rethrow errors flag is true. // When an exception is to be rethrown, // For classic scripts: // The exception is rethrown to V8, and ScriptEvaluationResult doesn't // retain the exception. // When script's muted errors is true, a NetworkError with // `message` is thrown. This is used only for importScripts(), and // `message` is used to throw NetworkErrors with the same message text, // no matter whether the NetworkError is thrown inside or outside // V8ScriptRunner. // For module scripts: // The exception is caught and // ScriptEvaluationResult::GetExceptionForModule() returns the exception // to be rethrown. static RethrowErrorsOption Rethrow(const String& message) { return RethrowErrorsOption(message); } bool ShouldRethrow() const { return static_cast<bool>(message_); } String Message() const { return *message_; } private: explicit RethrowErrorsOption(absl::optional<String> message) : message_(std::move(message)) {} // `nullopt` <=> rethrow errors is false. absl::optional<String> message_; }; // For the following methods, the caller sites have to hold // a HandleScope and a ContextScope. static v8::MaybeLocal<v8::Script> CompileScript( ScriptState*, const ScriptSourceCode&, SanitizeScriptErrors, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason, v8::Local<v8::Data> host_defined_options); static v8::MaybeLocal<v8::Module> CompileModule( v8::Isolate*, const ModuleScriptCreationParams&, const WTF::TextPosition&, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason, const ReferrerScriptInfo&); static ScriptEvaluationResult CompileAndRunScript(ScriptState*, ClassicScript*, ExecuteScriptPolicy, RethrowErrorsOption); static v8::MaybeLocal<v8::Value> CompileAndRunInternalScript( v8::Isolate*, ScriptState*, const ScriptSourceCode&); static v8::MaybeLocal<v8::Value> CallAsConstructor( v8::Isolate*, v8::Local<v8::Object>, ExecutionContext*, int argc = 0, v8::Local<v8::Value> argv[] = nullptr); static v8::MaybeLocal<v8::Value> CallFunction(v8::Local<v8::Function>, ExecutionContext*, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> argv[], v8::Isolate*); // https://html.spec.whatwg.org/C/#run-a-module-script // Callers must enter a v8::HandleScope before calling. // See the class comments of RethrowErrorsOption and ScriptEvaluationResult // for exception handling and return value semantics. static ScriptEvaluationResult EvaluateModule(ModuleScript*, RethrowErrorsOption); // Only to be used from ModuleRecord::ReportException(). static void ReportExceptionForModule(v8::Isolate*, v8::Local<v8::Value> exception, const String& file_name, const WTF::TextPosition&); // Reports an exception to the message handler, as if it were an uncaught // exception. Can only be called on the main thread. // // TODO(adamk): This should live on V8ThrowException, but it depends on // V8Initializer and so can't trivially move to platform/bindings. static void ReportException(v8::Isolate*, v8::Local<v8::Value> exception); private: static v8::MaybeLocal<v8::Value> RunCompiledScript( v8::Isolate*, v8::Local<v8::Script>, v8::Local<v8::Data> host_defined_options, ExecutionContext*); }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_SCRIPT_RUNNER_H_
40.606742
79
0.684007
[ "object" ]
64df65f632d230bca7fbe3e23034e6d0db43b403
1,784
h
C
src/ui/a11y/lib/gesture_manager/interaction_context.h
winksaville/Fuchsia
a0ec86f1d51ae8d2538ff3404dad46eb302f9b4f
[ "BSD-3-Clause" ]
3
2020-08-02T04:46:18.000Z
2020-08-07T10:10:53.000Z
src/ui/a11y/lib/gesture_manager/interaction_context.h
winksaville/Fuchsia
a0ec86f1d51ae8d2538ff3404dad46eb302f9b4f
[ "BSD-3-Clause" ]
null
null
null
src/ui/a11y/lib/gesture_manager/interaction_context.h
winksaville/Fuchsia
a0ec86f1d51ae8d2538ff3404dad46eb302f9b4f
[ "BSD-3-Clause" ]
1
2020-08-07T10:11:49.000Z
2020-08-07T10:11:49.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_UI_A11Y_LIB_GESTURE_MANAGER_INTERACTION_CONTEXT_H_ #define SRC_UI_A11Y_LIB_GESTURE_MANAGER_INTERACTION_CONTEXT_H_ #include <fuchsia/ui/input/accessibility/cpp/fidl.h> #include <map> #include "src/ui/a11y/lib/gesture_manager/gesture_handler.h" namespace a11y { class GestureHandler; // An InteractionContext holds additional data an Interaction needs to classify gestures. class InteractionContext { public: InteractionContext(GestureHandler* gesture_handler); ~InteractionContext() = default; GestureHandler* gesture_handler() { return gesture_handler_; } // Resets the state of the context for a new Interaction. // Right now, this only clears all cached Accessibility Pointer Events. void Reset(); // Adds an Accessibility Pointer Event to the context. void AddPointerEvent(fuchsia::ui::input::accessibility::PointerEvent pointer_event); // Helper method to get the latest added Accessibility Pointer Event. const fuchsia::ui::input::accessibility::PointerEvent* LastAddedEvent() const { return last_added_event_; } private: GestureHandler* gesture_handler_; // A cache of Accessibility Pointer Events keyed by pointer_id. This assumes // that there is only one |device_id|, hence unique pointer IDs. std::map<input::Gesture::PointerId, std::vector<fuchsia::ui::input::accessibility::PointerEvent>> pointer_events_; // A pointer to the last added Accessibility Pointer Event. fuchsia::ui::input::accessibility::PointerEvent* last_added_event_ = nullptr; }; } // namespace a11y #endif // SRC_UI_A11Y_LIB_GESTURE_MANAGER_INTERACTION_CONTEXT_H_
33.660377
99
0.779148
[ "vector" ]
64e5581a561faadde930002e45eb370778548d91
1,216
h
C
eagleeye/test/nano/FixedResizedOpTest.h
jianzfb/eagleeye
e28810033eb656b181b6291ca702da825c4946c2
[ "Apache-2.0" ]
12
2020-09-21T02:24:11.000Z
2022-03-10T03:02:03.000Z
eagleeye/test/nano/FixedResizedOpTest.h
jianzfb/eagleeye
e28810033eb656b181b6291ca702da825c4946c2
[ "Apache-2.0" ]
1
2020-11-30T08:22:50.000Z
2020-11-30T08:22:50.000Z
eagleeye/test/nano/FixedResizedOpTest.h
jianzfb/eagleeye
e28810033eb656b181b6291ca702da825c4946c2
[ "Apache-2.0" ]
3
2020-03-16T12:10:55.000Z
2021-07-20T09:58:15.000Z
#ifndef _EAGLEEYE_FIXEDRESIZEDOPTEST_H_ #define _EAGLEEYE_FIXEDRESIZEDOPTEST_H_ #include "eagleeye/common/EagleeyeMacro.h" #include "eagleeye/basic/Tensor.h" #include "eagleeye/engine/nano/op/FixedResizeOp.h" #include <iostream> namespace eagleeye{ namespace nano{ void test_FixedResizedOp_on_CPU(){ Tensor<short> t(std::vector<int64_t>{1,3,20,20}); short* t_ptr = t.dataptr(); for(int i=-10; i<10; ++i){ int count = 0; for(int j=-10; j<10; ++j){ int y = i+10; int x = j+10; int c = 0; t_ptr[c*20*20 + y*20+x] = (count % 255 - 127)/float(127) * 32768; count += 1; c = 1; t_ptr[c*20*20 + y*20+x] = (count % 255 - 127)/float(127) * 32768; count += 1; c = 2; t_ptr[c*20*20 + y*20+x] = (count % 255 - 127)/float(127) * 32768; count += 1; } } FixedResizeOp* resized_op = new FixedResizeOp(1,1,"resize"); Tensor<short> output(std::vector<int64_t>{1,3,40,40}); std::vector<Tensor<short>> input_list={t}; std::vector<Tensor<short>> output_list={output}; resized_op->foward_on_cpu(output_list, input_list); } } } #endif
28.952381
77
0.573191
[ "vector" ]
64eba7a1c6591b962c5f9a05560d91bdc071fab5
3,624
h
C
src/mjs/native_object.h
mras0/mjs
3351b9c5df92efa905a2c40649cf58f118e2d7c8
[ "MIT" ]
120
2018-10-26T13:33:54.000Z
2022-01-29T18:30:38.000Z
src/mjs/native_object.h
mras0/mjs
3351b9c5df92efa905a2c40649cf58f118e2d7c8
[ "MIT" ]
1
2019-02-10T16:23:10.000Z
2019-02-10T16:23:10.000Z
src/mjs/native_object.h
mras0/mjs
3351b9c5df92efa905a2c40649cf58f118e2d7c8
[ "MIT" ]
5
2018-12-02T20:02:06.000Z
2018-12-04T04:19:24.000Z
#ifndef MJS_NATIVE_OBJECT_H #define MJS_NATIVE_OBJECT_H #include "object.h" namespace mjs { #define DEFINE_NATIVE_PROPERTY(Class, Property) add_native_property<Class, &Class::get_##Property, &Class::put_##Property>(#Property, property_attribute::dont_enum | property_attribute::dont_delete) #define DEFINE_NATIVE_PROPERTY_READONLY(Class, Property) add_native_property<Class, &Class::get_##Property>(#Property, property_attribute::dont_enum | property_attribute::dont_delete | property_attribute::read_only) class native_object : public object { public: value get(const std::wstring_view& name) const override { if (auto it = find(name)) { return it->get(*this); } return object::get(name); } void put(const string& name, const value& val, property_attribute attr) override { if (!do_native_put(name, val)) { object::put(name, val, attr); } } bool delete_property(const std::wstring_view& name) override; private: using get_func = value (*)(const native_object&); using put_func = void (*)(native_object&, const value&); struct native_object_property { char name[32]; property_attribute attributes; get_func get; put_func put; native_object_property(const char* name, property_attribute attributes, get_func get, put_func put); }; gc_heap_ptr_untracked<gc_vector<native_object_property>> native_properties_; native_object_property* find(const char* name) const; native_object_property* find(const std::wstring_view& v) const; void do_add_native_property(const char* name, property_attribute attributes, get_func get, put_func put); protected: explicit native_object(const string& class_name, const object_ptr& prototype); template<typename T, value (T::* Get)() const, void (T::* Put)(const value&) = nullptr> void add_native_property(const char* name, property_attribute attributes) { static_assert(std::is_base_of_v<native_object, T>); put_func put = nullptr; if (Put != nullptr) { put = [](native_object& o, const value& v) { (static_cast<T&>(o).*Put)(v); }; } do_add_native_property(name, attributes, [](const native_object& o) { return (static_cast<const T&>(o).*Get)(); }, put); } bool do_redefine_own_property(const string& name, const value& val, property_attribute attr) override; void add_own_property_names(std::vector<string>& names, bool check_enumerable) const override; property_attribute do_own_property_attributes(const std::wstring_view& name) const override { if (auto it = find(name)) { return it->attributes; } return object::do_own_property_attributes(name); } void update_property_attributes(const char* name, property_attribute attributes) { auto it = find(name); assert(it); assert(((attributes & property_attribute::read_only) != property_attribute::none) || it->put); it->attributes = attributes; } bool do_native_put(const string& name, const value& val) { if (auto it = find(name.view())) { if (!has_attributes(it->attributes, property_attribute::read_only)) { it->put(*this, val); } return true; } else { return false; } } void fixup(); void do_debug_print_extra(std::wostream& os, int indent_incr, int max_nest, int indent) const override; }; } // namespace mjs #endif
35.529412
215
0.660044
[ "object", "vector" ]
64ec33135a9a5c526968e45ffc47b4fc01e009f9
16,950
c
C
trans/src/alpha/eval.c
partouf/tendra
424aa60b8db6acbc9f4fa423536a4838e7a6fe0f
[ "BSD-3-Clause" ]
null
null
null
trans/src/alpha/eval.c
partouf/tendra
424aa60b8db6acbc9f4fa423536a4838e7a6fe0f
[ "BSD-3-Clause" ]
null
null
null
trans/src/alpha/eval.c
partouf/tendra
424aa60b8db6acbc9f4fa423536a4838e7a6fe0f
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright 2011, The TenDRA Project. * Copyright 1997, United Kingdom Secretary of State for Defence. * * See doc/copyright/ for the full copyright terms. */ /* * This file contains functions which output data to the assembler * file. The parameters are an exp and an index into the table of * externals. */ #include <assert.h> #include <stdio.h> #include <shared/bool.h> #include <shared/check.h> #include <shared/error.h> #include <shared/xalloc.h> #include <local/ash.h> #include <local/exp.h> #include <local/fbase.h> #include <tdf/shape.h> #include <tdf/tag.h> #include <reader/exp.h> #include <construct/installtypes.h> #include <construct/dec.h> #include <construct/ash.h> #include <construct/exp.h> #include <flpt/flpt.h> #include <utility/int64.h> #include <utility/max.h> #include <main/driver.h> #include <main/flags.h> #include <main/print.h> #include <symtab/syms.h> #include "addr.h" #include "main.h" #include "frames.h" #include "reg_defs.h" #include "pseudo.h" #include "ibinasm.h" #include "out_ba.h" #include "shape_range.h" #include "inst_fmt.h" #include "eval.h" #include "procrec.h" /* * storage types */ char *s_byte = "byte"; char *s_word = "word"; char *s_long = "long"; char *s_quad = "quad"; /* * The current alignment of the program */ int current_alignment = -1; static long G_number = 64; /* to give choice of .sdata or data */ int data_lab = 33; /* anonymous label in data space - $$n in assember o/p */ /* but also gives it a symno for .G output */ int next_dlab_sym(void) { symnofordata (data_lab); return data_lab++; } /* various pieces of info for outputting data depending on shape */ static mm scmm = { scmm_max, scmm_min, "\t.byte %ld :%ld\n" }; static mm uscmm = { uscmm_max, uscmm_min, "\t.byte %ld :%ld\n" }; static mm shmm = { shmm_max, shmm_min, "\t.word %ld :%ld\n" }; static mm ushmm = { ushmm_max, ushmm_min, "\t.word %ld :%ld\n" }; static mm swmm = { swmm_max, swmm_min, "\t.long %ld :%ld\n" }; static mm uswmm = { uswmm_max, uswmm_min, "\t.long %ld :%ld\n" }; static mm u64mm = { u64mm_max, u64mm_min, "\t.quad %ld :%ld\n" }; static mm s64mm = { s64mm_max, s64mm_min, "\t.quad %ld :%ld\n" }; /* * Find the data size from the range of an integer shape. */ mm maxmin(shape s) { switch (s->tag) { case scharhd: return scmm; case ucharhd: return uscmm; case swordhd: return shmm; case uwordhd: return ushmm; case slonghd: return swmm; case ulonghd: return uswmm; case s64hd: return s64mm; case u64hd: return u64mm; default: return uswmm; } } /* * Output the label parameter if non negative else interprets it * to be an index into the externals and outputs the identifier. */ static char * outlab(int l) { if (l >= 0) { asm_printf( "$$%d", l); } else { char *extname = main_globals[-l - 1]->name; asm_printf( "%s", extname); } return NULL; } /* * Output an IEEE format floating point number */ static void outfloat(exp e, int rep, ash a) { INT64 val; int fv; r2l ieeeflt; UNUSED(a); fv = sh(e)->tag - shrealhd; ieeeflt = real2longs_IEEE(&flptnos[no(e)], fv); switch(fv) { case 0: if (as_file) { asm_printop(".long 0x%08x : %d # .s floating", ieeeflt.i1, rep); } out_value(0, ilong, make_INT64(0, ieeeflt.i1), rep); /* out_value(0,ilong,ieeeflt.i1,rep);*/ break; case 1: if (as_file) { asm_printop(".quad 0x%08x%08x : %d # .t floating", ieeeflt.i2, ieeeflt.i1, rep); } /* val = ((long)ieeeflt.i2<<32) + (unsigned)ieeeflt.i1;*/ val = make_INT64(ieeeflt.i2, (unsigned)ieeeflt.i1); out_value(0, iquad, val, rep); break; default: error(ERR_INTERNAL, "invalid floating variety"); } } /* * evaluate the exp 'e' and return the resulting value */ static INT64 evalexp(exp e) { switch (e->tag) { case val_tag: if (al2(sh(e)) >= 8 && sh(e)->tag == offsethd) { return INT64_shift_right(flt64_to_INT64(exp_to_f64(e)), 3, 1); } return flt64_to_INT64(exp_to_f64(e)); case bitf_to_int_tag: return evalexp (child (e)); case int_to_bitf_tag: { ash a; INT64 w; w = evalexp(child(e)); a = ashof(sh(e)); if (a.ashalign != 1) { error(ERR_INTERNAL, "should be align 1"); } if (a.ashsize != 64) { w = INT64_and(w, INT64_subtract(INT64_shift_left(make_INT64(0, 1), a.ashsize, 1), make_INT64(0, 1), 1)); } return w; } case not_tag: return INT64_not(evalexp (child (e))); case and_tag: return INT64_and(evalexp(child(e)), evalexp(next(child(e)))); case or_tag: return INT64_or(evalexp(child(e)), evalexp(next(child(e)))); case xor_tag: return INT64_xor(evalexp(child(e)), evalexp(next(child(e)))); case shr_tag: return INT64_shift_right(evalexp(child(e)), low_INT64(evalexp(next(child(e)))), 1); case shl_tag: return INT64_shift_left(evalexp(child(e)), low_INT64(evalexp(next(child(e)))), 1); case concatnof_tag: { ash a; INT64 wd; wd = evalexp (child (e)); a = ashof (sh (child (e))); return INT64_or(wd, INT64_shift_left(evalexp(next(child(e))), a.ashsize, 1)); } case clear_tag: { ash a; a = ashof(sh(e)); if (a.ashsize > REG_SIZE) { error(ERR_INTERNAL, "clearshape"); } return zero_int64; } case general_env_offset_tag: case env_offset_tag: return make_INT64(0, frame_offset(child(e))); case env_size_tag: { exp tag = child(child(e)); procrec *pr = &procrecs[no(child(tag))]; return (pr->frame_size + pr->callee_size) >> 3; } case offset_add_tag: return evalexp(child(e)) + evalexp(next(child(e))); case offset_max_tag: return MAX(evalexp(child(e)), evalexp(next(child(e)))); case offset_pad_tag: return rounder(evalexp(child(e)), shape_align(sh(e)) >> 3); case offset_mult_tag: return evalexp(child(e)) * evalexp(next(child(e))); case offset_div_tag: case offset_div_by_int_tag: return evalexp(child(e)) / evalexp(next(child(e))); case offset_subtract_tag: return evalexp(child(e)) - evalexp(next(child(e))); case offset_negate_tag: return -evalexp(child(e)); default: error(ERR_INTERNAL, "tag not in evalexp"); } return zero_int64; } /* * This function outputs values to the assembler file. * The alignment of the last value to be output is retained and, * if it differs from the current one, a new alignment is set. */ static void oneval(INT64 val, int al, int rep) { char *store_type; static int lastal = -1; unsigned int bval; if (al != lastal) { set_align(al); lastal = al; } switch (al) { case 8: store_type = s_byte; bval = ibyte; break; case 16: store_type = s_word; bval = iword; break; case 32: store_type = s_long; bval = ilong; break; case 64: store_type = s_quad; bval = iquad; break; default: store_type = s_long; bval = ilong; break; } if (as_file) { asm_printf("\t.%s ", store_type); out_INT64(val); asm_printf(" :%d\n", rep); } out_value(0, bval, val, rep); } static INT64 bits_list(int val) { int loop; INT64 result; result = make_INT64(0, 0); /* assert(val <=31);*/ assert(val <= 64); for (loop = 0; loop < val; loop++) { result = INT64_shift_left(result, 1, 1); result = INT64_or(result, make_INT64(0, 1)); #if 0 result <<= 1; result |= 1; #endif } return result; } /* * Outputs the expression 'e', rep times. */ static void evalone(exp e, int rep) { ash a; int overflow; if (e == NULL) { return; } a = ashof(sh (e)); switch (e->tag) { case string_tag: { long char_size = e->props; long strsize = shape_size(sh(e)) / char_size; char *st = nostr(e); long strs = shape_size(sh(e)) >> 3; int i, j; int hex_output = 0; if (rep != 1 && as_file) { asm_printop(".repeat %d", rep); } set_align(a.ashalign); if (as_file) { if (strsize < 256 && (char_size == 8)) { asm_printf("\t.ascii\t\""); for (j = 0; j < strsize; ++j) { if (st[j] >= 32 && st[j] < 0x7f && (!hex_output)) { if (st[j] == '\"') { asm_printf("\\\""); } else if (st[j] == '\\') { asm_printf("\\\\"); } else { asm_printf("%c", st[j]); } } else { asm_printf("\\X%x", st[j] & 0xff); hex_output = 1; } } asm_printf("\"\n"); } else { for (j = 0; j < strsize; ) { switch(char_size) { case 8: IGNORE asm_printf( "\t.byte "); break; case 16: IGNORE asm_printf( "\t.word "); break; case 32: IGNORE asm_printf( "\t.long "); break; case 64: IGNORE asm_printf( "\t.quad "); break; } for (i = j; i < strsize && i - j < 8; i++) { switch (char_size) { case 8: asm_printf( "0x%x ", st[i] & 0xff); break; case 16: asm_printf( "0x%x ", ((unsigned short *) st)[i]); break; case 32: asm_printf( "0x%x ", ((int *) st)[i]); break; case 64: { flt64 bigint; bigint = flt_to_f64(((flpt*)st)[i], is_signed(sh(e)), &overflow); out_INT64(flt64_to_INT64(bigint)); asm_printf( " "); break; } } } j = i; asm_printf( "\n"); } } } out_chars(0, iascii, strs, rep); if (char_size == 64) { /* replace the float indexes used to represent the array */ char *newst = xcalloc(strs, sizeof(char)); int i; for (i = 0; i < strsize; ++i) { ((INT64*)newst)[i] = flt64_to_INT64(flt_to_f64(((flpt*)st)[i], is_signed(sh(e)), &overflow)); } out_data(newst, strs); } else { out_data(st, strs); } return; } case real_tag: outfloat(e, rep, a); return; case null_tag: no (e) = 0; FALL_THROUGH; case val_tag: if (isbigval(e)) { oneval(flt64_to_INT64(exp_to_f64(e)), a.ashalign, rep); } else { if ((al2(sh(e)) >= 8) && (sh(e)->tag == offsethd)) { no(e) = no(e) >> 3; } if (is_signed(sh(e))) { oneval(make_INT64(0, no(e)), a.ashalign, rep); } else { oneval(make_INT64(0L, (unsigned)uno(e)), a.ashalign, rep); } } return; case name_tag: { dec * globdec = nextg(child (e)); /* must be global name */ char *name = globdec->name; long symdef = globdec->sym_number; char *storage_type; int storage_id; switch(a.ashalign) { case 8: storage_type = s_byte; storage_id = ibyte; break; case 16: storage_type = s_word; storage_id = iword; break; case 32: storage_type = s_long; storage_id = ilong; break; case 64: storage_type = s_quad; storage_id = iquad; break; } set_align(a.ashalign); if (as_file) { if (no (e) == 0) { asm_printop(".%s %s : %d", storage_type, name, rep); } } out_value(symnos[symdef], storage_id, make_INT64(0, no(e) / 8), rep); return; } case compound_tag: { exp tup = child (e); INT64 val; bool first_bits = 1; long bits_start = 0; long offs = 0; if (rep != 1) { error(ERR_INTERNAL, "CAN'T REP TUPLES"); } set_align(a.ashalign); for (;;) { ash ae; ae = ashof(sh(next(tup))); offs = no(tup); if (ae.ashalign == 1) { INT64 vb = evalexp(next(tup)); if (first_bits) { val = INT64_and(vb, bits_list(ae.ashsize)); /*val = vb & bits_list(ae.ashsize);*/ bits_start = offs; first_bits = 0; } else if (offs - bits_start + ae.ashsize <= REG_SIZE) { val = INT64_or(val, INT64_shift_left( INT64_and(vb, bits_list(ae.ashsize)), offs - bits_start, 1)); /* val |= ((vb&bits_list(ae.ashsize)) << (offs-bits_start)); */ } else { if (endian == ENDIAN_BIG) { for (;;) { oneval(INT64_shift_right(val, 24, 1), 8, 1); /*oneval(val>>24, 8, 1);*/ val = INT64_shift_left(val, 8, 1); /*val <<=8;*/ bits_start += 8; if (offs - bits_start <= 0) { break; } } break; } else { assert(endian == ENDIAN_LITTLE); for (;;) { oneval(INT64_and(val, make_INT64(0, 255)), 8, 1); /* oneval(val &255, 8,1); */ /* val >>= 8; */ val = INT64_shift_right(val, 8, 1); bits_start += 8; if (offs - bits_start <= 0) { break; } } } val = vb; } } else { if (!first_bits) { first_bits = 1; if (endian == ENDIAN_BIG) { for (;;) { oneval(INT64_shift_right(val, 24, 1), 8, 1); /* oneval(val>>24, 8, 1);*/ val = INT64_shift_left(val, 8, 1); /* val <<=8; */ bits_start += 8; if (offs - bits_start <= 0) { break; } } break; } else { assert(endian == ENDIAN_LITTLE); for (;;) { oneval(INT64_and(val, make_INT64(0, 255)), 8, 1); /*oneval(val &255, 8,1);*/ val = INT64_shift_right(val, 8, 1); /*val >>=8;*/ bits_start += 8; if ( offs - bits_start <= 0) { break; } } } } evalone(next(tup), 1); } if (next(tup)->last) { offs += ae.ashsize; for (; !first_bits;) { if (endian == ENDIAN_BIG) { oneval(INT64_shift_right(val, 24, 1), 8, 1); /* oneval(val >> 24, 8, 1); */ val = INT64_shift_left(val, 8, 1); /* val <<= 8; */ bits_start += 8; if (offs - bits_start <= 0) { break; } } else { assert(endian == ENDIAN_LITTLE); oneval(INT64_and(val, make_INT64(0, 255)), 8, 1); /* oneval(val & 255, 8, 1); */ val = INT64_shift_right(val, 8, 1); /* val >>= 8; */ bits_start += 8; if ( offs - bits_start <= 0) { break; } } } while (a.ashsize > offs) { /* pad out unions etc */ oneval(make_INT64(0, 0), 8, 1); /* oneval(0,8,1);*/ offs += 8; } return; } tup = next(next(tup)); } } case nof_tag: { exp s = child(e); if (rep != 1) { error(ERR_INTERNAL, "CAN'T REP TUPLES"); } set_align(a.ashalign); if (s == NULL) { return; } for (;;) { evalone(s, 1); if (s->last) { return; } s = next(s); } } case ncopies_tag: if (child(e)->tag == compound_tag || child(e)->tag == concatnof_tag || child(e)->tag == nof_tag) { int n; for (n = rep * no(e); n > 0; n--) { evalone(child(e), 1); } } else { evalone (child (e), rep * no (e)); } return; case concatnof_tag: if (a.ashalign == 1) { INT64 ee = evalexp(e); /*long ee = evalexp (e);*/ exp dad = father(e); ash abits; abits = ashof(sh(dad)); oneval(ee, abits.ashalign, rep); } else { if (rep != 1) { error(ERR_INTERNAL, "CAN'T REP concat"); } evalone (child (e), 1); evalone (next (child (e)), 1); } return; case clear_tag: if (as_file) { asm_printop(".space %d", ((a.ashsize + 7) >> 3) * rep); } out_value (0, ispace, make_INT64(0, ((a.ashsize + 7) >> 3) * rep), 1); return; case not_tag: case and_tag: case or_tag: case shl_tag: case shr_tag: case bitf_to_int_tag: case int_to_bitf_tag: case general_env_offset_tag: case env_offset_tag: case env_size_tag: case offset_add_tag: case offset_max_tag: case offset_pad_tag: case offset_mult_tag: case offset_div_tag: case offset_div_by_int_tag: case offset_subtract_tag: case offset_negate_tag: { #if 1 INT64 ee = evalexp (e); oneval(ee, a.ashalign, rep); #endif return; } #if 1 case chvar_tag: { sh(child(e)) = sh(e); evalone(child(e), 1); error(ERR_WARN, "Dubious change variety"); return; } #endif default: error(ERR_INTERNAL, "tag not in evaluated"); } } /* * This outputs data from the evaluated exp into either .sdata * or .data depending on size and labels this data either with * either id in main_globals or an anonymous label derived from l. * The result is the instore "address" of the constant. A negative l * implies that this is the initialisation of a global variable. */ instore evaluated(exp e, int l) { int lab = (l == 0) ? next_dlab_sym () : (l < 0) ? l : -l; int lab0 = lab; ash a; instore isa; exp z = e; isa.adval = 0; isa.b.offset = 0; isa.b.base = lab0; if (e->tag == clear_tag) { /* uninitialised global */ int size = (ashof (sh (e)).ashsize + 7) >> 3; bool temp = (l == 0 || (main_globals[-lab - 1]->name)[0] == '$'); if (as_file) { asm_printf( (temp) ? "\t.lcomm\t" : "\t.comm\t"); outlab(lab); asm_printf( " %d\n", size); } out_value((lab >= 0) ? tempsnos[lab - 32] : symnos[-lab - 1], (temp) ? ilcomm : icomm, make_INT64(0, size), 1); return isa; } a = ashof(sh(z)); if (a.ashsize <= G_number) { if (as_file) { asm_printop(".sdata"); } out_common(0, isdata); } else { if (as_file) { asm_printop(".data"); } out_common(0, idata); } if (as_file) { IGNORE outlab(lab); asm_printf( ":\n"); } out_common((lab > 0) ? tempsnos[lab - 32] : symnos[-lab - 1], ilabel); if (as_file) { asm_printop(".align 3"); asm_printop(".align 0"); } out_value(0, ialign, make_INT64(0, 3), 0); out_value(0, ialign, make_INT64(0, 0), 0); current_alignment = 8; evalone(z, 1); return isa; }
22.660428
98
0.583776
[ "shape" ]
64ed1e1599fab2a3f6438f282f1d374f04a4f955
42,256
c
C
sys/ufs/lfs/ulfs_extattr.c
calmsacibis995/minix
dfba95598f553b6560131d35a76658f1f8c9cf38
[ "Unlicense" ]
null
null
null
sys/ufs/lfs/ulfs_extattr.c
calmsacibis995/minix
dfba95598f553b6560131d35a76658f1f8c9cf38
[ "Unlicense" ]
null
null
null
sys/ufs/lfs/ulfs_extattr.c
calmsacibis995/minix
dfba95598f553b6560131d35a76658f1f8c9cf38
[ "Unlicense" ]
null
null
null
/* $NetBSD: ulfs_extattr.c,v 1.7 2014/02/07 15:29:23 hannken Exp $ */ /* from NetBSD: ufs_extattr.c,v 1.41 2012/12/08 13:42:36 manu Exp */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson * Copyright (c) 2002-2003 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed by Robert Watson for the TrustedBSD Project. * * This software was developed for the FreeBSD Project in part by Network * Associates Laboratories, the Security Research Division of Network * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), * as part of the DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ /* * Support for file system extended attributes on the ULFS1 file system. * * Extended attributes are defined in the form name=value, where name is * a nul-terminated string in the style of a file name, and value is a * binary blob of zero or more bytes. The ULFS1 extended attribute service * layers support for extended attributes onto a backing file, in the style * of the quota implementation, meaning that it requires no underlying format * changes to the file system. This design choice exchanges simplicity, * usability, and easy deployment for performance. */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.7 2014/02/07 15:29:23 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_lfs.h" #endif #include <sys/param.h> #include <sys/systm.h> #include <sys/reboot.h> #include <sys/kauth.h> #include <sys/kernel.h> #include <sys/namei.h> #include <sys/kmem.h> #include <sys/fcntl.h> #include <sys/lwp.h> #include <sys/vnode.h> #include <sys/mount.h> #include <sys/lock.h> #include <sys/dirent.h> #include <sys/extattr.h> #include <sys/sysctl.h> #include <ufs/lfs/ulfs_extattr.h> #include <ufs/lfs/ulfsmount.h> #include <ufs/lfs/ulfs_inode.h> #include <ufs/lfs/ulfs_bswap.h> #include <ufs/lfs/ulfs_extern.h> int ulfs_extattr_sync = 1; int ulfs_extattr_autocreate = 1024; static int ulfs_extattr_valid_attrname(int attrnamespace, const char *attrname); static int ulfs_extattr_enable_with_open(struct ulfsmount *ump, struct vnode *vp, int attrnamespace, const char *attrname, struct lwp *l); static int ulfs_extattr_enable(struct ulfsmount *ump, int attrnamespace, const char *attrname, struct vnode *backing_vnode, struct lwp *l); static int ulfs_extattr_disable(struct ulfsmount *ump, int attrnamespace, const char *attrname, struct lwp *l); static int ulfs_extattr_get(struct vnode *vp, int attrnamespace, const char *name, struct uio *uio, size_t *size, kauth_cred_t cred, struct lwp *l); static int ulfs_extattr_list(struct vnode *vp, int attrnamespace, struct uio *uio, size_t *size, int flag, kauth_cred_t cred, struct lwp *l); static int ulfs_extattr_set(struct vnode *vp, int attrnamespace, const char *name, struct uio *uio, kauth_cred_t cred, struct lwp *l); static int ulfs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, kauth_cred_t cred, struct lwp *l); static struct ulfs_extattr_list_entry *ulfs_extattr_find_attr(struct ulfsmount *, int, const char *); static int ulfs_extattr_get_header(struct vnode *, struct ulfs_extattr_list_entry *, struct ulfs_extattr_header *, off_t *); /* * Convert a FreeBSD extended attribute and namespace to a consistent string * representation. * * The returned value, if not NULL, is guaranteed to be an allocated object * of its size as returned by strlen() + 1 and must be freed by the caller. */ static char * from_freebsd_extattr(int attrnamespace, const char *attrname) { const char *namespace; char *attr; size_t len; if (attrnamespace == EXTATTR_NAMESPACE_SYSTEM) namespace = "system"; else if (attrnamespace == EXTATTR_NAMESPACE_USER) namespace = "user"; else return NULL; /* <namespace>.<attrname>\0 */ len = strlen(namespace) + 1 + strlen(attrname) + 1; attr = kmem_alloc(len, KM_SLEEP); snprintf(attr, len, "%s.%s", namespace, attrname); return attr; } /* * Internal wrapper around a conversion-check-free sequence. */ static int internal_extattr_check_cred(vnode_t *vp, int attrnamespace, const char *name, kauth_cred_t cred, int access_mode) { char *attr; int error; attr = from_freebsd_extattr(attrnamespace, name); if (attr == NULL) return EINVAL; error = extattr_check_cred(vp, attr, cred, access_mode); kmem_free(attr, strlen(attr) + 1); return error; } /* * Per-FS attribute lock protecting attribute operations. * XXX Right now there is a lot of lock contention due to having a single * lock per-FS; really, this should be far more fine-grained. */ static void ulfs_extattr_uepm_lock(struct ulfsmount *ump) { /* XXX Why does this need to be recursive? */ if (mutex_owned(&ump->um_extattr.uepm_lock)) { ump->um_extattr.uepm_lockcnt++; return; } mutex_enter(&ump->um_extattr.uepm_lock); } static void ulfs_extattr_uepm_unlock(struct ulfsmount *ump) { if (ump->um_extattr.uepm_lockcnt != 0) { KASSERT(mutex_owned(&ump->um_extattr.uepm_lock)); ump->um_extattr.uepm_lockcnt--; return; } mutex_exit(&ump->um_extattr.uepm_lock); } /*- * Determine whether the name passed is a valid name for an actual * attribute. * * Invalid currently consists of: * NULL pointer for attrname * zero-length attrname (used to retrieve application attribute list) */ static int ulfs_extattr_valid_attrname(int attrnamespace, const char *attrname) { if (attrname == NULL) return (0); if (strlen(attrname) == 0) return (0); return (1); } /* * Autocreate an attribute storage */ static struct ulfs_extattr_list_entry * ulfs_extattr_autocreate_attr(struct vnode *vp, int attrnamespace, const char *attrname, struct lwp *l) { struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); struct vnode *backing_vp; struct nameidata nd; struct pathbuf *pb; char *path; struct ulfs_extattr_fileheader uef; struct ulfs_extattr_list_entry *uele; int error; path = PNBUF_GET(); /* * We only support system and user namespace autocreation */ switch (attrnamespace) { case EXTATTR_NAMESPACE_SYSTEM: (void)snprintf(path, PATH_MAX, "%s/%s/%s/%s", mp->mnt_stat.f_mntonname, ULFS_EXTATTR_FSROOTSUBDIR, ULFS_EXTATTR_SUBDIR_SYSTEM, attrname); break; case EXTATTR_NAMESPACE_USER: (void)snprintf(path, PATH_MAX, "%s/%s/%s/%s", mp->mnt_stat.f_mntonname, ULFS_EXTATTR_FSROOTSUBDIR, ULFS_EXTATTR_SUBDIR_USER, attrname); break; default: PNBUF_PUT(path); return NULL; break; } /* * XXX unlock/lock should only be done when setting extattr * on backing store or one of its parent directory * including root, but we always do it for now. */ KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE); VOP_UNLOCK(vp); pb = pathbuf_create(path); NDINIT(&nd, CREATE, LOCKPARENT, pb); error = vn_open(&nd, O_CREAT|O_RDWR, 0600); /* * Reacquire the lock on the vnode */ KASSERT(VOP_ISLOCKED(vp) == 0); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0) { pathbuf_destroy(pb); PNBUF_PUT(path); return NULL; } KASSERT(nd.ni_vp != NULL); KASSERT(VOP_ISLOCKED(nd.ni_vp) == LK_EXCLUSIVE); KASSERT(VOP_ISLOCKED(nd.ni_dvp) == 0); /* * backing_vp is the backing store. */ backing_vp = nd.ni_vp; pathbuf_destroy(pb); PNBUF_PUT(path); uef.uef_magic = ULFS_EXTATTR_MAGIC; uef.uef_version = ULFS_EXTATTR_VERSION; uef.uef_size = ulfs_extattr_autocreate; error = vn_rdwr(UIO_WRITE, backing_vp, &uef, sizeof(uef), 0, UIO_SYSSPACE, IO_NODELOCKED|IO_APPEND, l->l_cred, NULL, l); VOP_UNLOCK(backing_vp); if (error != 0) { printf("%s: write uef header failed for %s, error = %d\n", __func__, attrname, error); vn_close(backing_vp, FREAD|FWRITE, l->l_cred); return NULL; } /* * Now enable attribute. */ error = ulfs_extattr_enable(ump,attrnamespace, attrname, backing_vp, l); KASSERT(VOP_ISLOCKED(backing_vp) == 0); if (error != 0) { printf("%s: enable %s failed, error %d\n", __func__, attrname, error); vn_close(backing_vp, FREAD|FWRITE, l->l_cred); return NULL; } uele = ulfs_extattr_find_attr(ump, attrnamespace, attrname); if (uele == NULL) { printf("%s: atttribute %s created but not found!\n", __func__, attrname); vn_close(backing_vp, FREAD|FWRITE, l->l_cred); return NULL; } printf("%s: EA backing store autocreated for %s\n", mp->mnt_stat.f_mntonname, attrname); return uele; } /* * Locate an attribute given a name and mountpoint. * Must be holding uepm lock for the mount point. */ static struct ulfs_extattr_list_entry * ulfs_extattr_find_attr(struct ulfsmount *ump, int attrnamespace, const char *attrname) { struct ulfs_extattr_list_entry *search_attribute; for (search_attribute = LIST_FIRST(&ump->um_extattr.uepm_list); search_attribute != NULL; search_attribute = LIST_NEXT(search_attribute, uele_entries)) { if (!(strncmp(attrname, search_attribute->uele_attrname, ULFS_EXTATTR_MAXEXTATTRNAME)) && (attrnamespace == search_attribute->uele_attrnamespace)) { return (search_attribute); } } return (0); } /* * Initialize per-FS structures supporting extended attributes. Do not * start extended attributes yet. */ void ulfs_extattr_uepm_init(struct ulfs_extattr_per_mount *uepm) { uepm->uepm_flags = 0; uepm->uepm_lockcnt = 0; LIST_INIT(&uepm->uepm_list); mutex_init(&uepm->uepm_lock, MUTEX_DEFAULT, IPL_NONE); uepm->uepm_flags |= ULFS_EXTATTR_UEPM_INITIALIZED; } /* * Destroy per-FS structures supporting extended attributes. Assumes * that EAs have already been stopped, and will panic if not. */ void ulfs_extattr_uepm_destroy(struct ulfs_extattr_per_mount *uepm) { if (!(uepm->uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED)) panic("ulfs_extattr_uepm_destroy: not initialized"); if ((uepm->uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) panic("ulfs_extattr_uepm_destroy: called while still started"); /* * It's not clear that either order for the next two lines is * ideal, and it should never be a problem if this is only called * during unmount, and with vfs_busy(). */ uepm->uepm_flags &= ~ULFS_EXTATTR_UEPM_INITIALIZED; mutex_destroy(&uepm->uepm_lock); } /* * Start extended attribute support on an FS. */ int ulfs_extattr_start(struct mount *mp, struct lwp *l) { struct ulfsmount *ump; int error = 0; ump = VFSTOULFS(mp); ulfs_extattr_uepm_lock(ump); if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED)) { error = EOPNOTSUPP; goto unlock; } if (ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED) { error = EBUSY; goto unlock; } ump->um_extattr.uepm_flags |= ULFS_EXTATTR_UEPM_STARTED; ump->um_extattr.uepm_ucred = l->l_cred; kauth_cred_hold(ump->um_extattr.uepm_ucred); unlock: ulfs_extattr_uepm_unlock(ump); return (error); } /* * Helper routine: given a locked parent directory and filename, return * the locked vnode of the inode associated with the name. Will not * follow symlinks, may return any type of vnode. Lock on parent will * be released even in the event of a failure. In the event that the * target is the parent (i.e., "."), there will be two references and * one lock, requiring the caller to possibly special-case. */ static int ulfs_extattr_lookup(struct vnode *start_dvp, int lockparent, const char *dirname, struct vnode **vp, struct lwp *l) { struct vop_lookup_v2_args vargs; struct componentname cnp; struct vnode *target_vp; char *pnbuf; int error; KASSERT(VOP_ISLOCKED(start_dvp) == LK_EXCLUSIVE); pnbuf = PNBUF_GET(); memset(&cnp, 0, sizeof(cnp)); cnp.cn_nameiop = LOOKUP; cnp.cn_flags = ISLASTCN | lockparent; cnp.cn_cred = l->l_cred; cnp.cn_nameptr = pnbuf; error = copystr(dirname, pnbuf, MAXPATHLEN, &cnp.cn_namelen); if (error) { if (lockparent == 0) { VOP_UNLOCK(start_dvp); } PNBUF_PUT(pnbuf); printf("ulfs_extattr_lookup: copystr failed\n"); return (error); } cnp.cn_namelen--; /* trim nul termination */ vargs.a_desc = NULL; vargs.a_dvp = start_dvp; vargs.a_vpp = &target_vp; vargs.a_cnp = &cnp; error = ulfs_lookup(&vargs); PNBUF_PUT(pnbuf); if (error) { if (lockparent == 0) { VOP_UNLOCK(start_dvp); } return (error); } #if 0 if (target_vp == start_dvp) panic("ulfs_extattr_lookup: target_vp == start_dvp"); #endif if (target_vp != start_dvp) { error = vn_lock(target_vp, LK_EXCLUSIVE); if (lockparent == 0) VOP_UNLOCK(start_dvp); if (error) { vrele(target_vp); return error; } } KASSERT(VOP_ISLOCKED(target_vp) == LK_EXCLUSIVE); *vp = target_vp; return (0); } /* * Enable an EA using the passed filesystem, backing vnode, attribute name, * namespace, and proc. Will perform a VOP_OPEN() on the vp, so expects vp * to be locked when passed in. The vnode will be returned unlocked, * regardless of success/failure of the function. As a result, the caller * will always need to vrele(), but not vput(). */ static int ulfs_extattr_enable_with_open(struct ulfsmount *ump, struct vnode *vp, int attrnamespace, const char *attrname, struct lwp *l) { int error; error = VOP_OPEN(vp, FREAD|FWRITE, l->l_cred); if (error) { printf("ulfs_extattr_enable_with_open.VOP_OPEN(): failed " "with %d\n", error); VOP_UNLOCK(vp); return (error); } mutex_enter(vp->v_interlock); vp->v_writecount++; mutex_exit(vp->v_interlock); vref(vp); VOP_UNLOCK(vp); error = ulfs_extattr_enable(ump, attrnamespace, attrname, vp, l); if (error != 0) vn_close(vp, FREAD|FWRITE, l->l_cred); return (error); } /* * Given a locked directory vnode, iterate over the names in the directory * and use ulfs_extattr_lookup() to retrieve locked vnodes of potential * attribute files. Then invoke ulfs_extattr_enable_with_open() on each * to attempt to start the attribute. Leaves the directory locked on * exit. */ static int ulfs_extattr_iterate_directory(struct ulfsmount *ump, struct vnode *dvp, int attrnamespace, struct lwp *l) { struct vop_readdir_args vargs; struct statvfs *sbp = &ump->um_mountp->mnt_stat; struct dirent *dp, *edp; struct vnode *attr_vp; struct uio auio; struct iovec aiov; char *dirbuf; int error, eofflag = 0; if (dvp->v_type != VDIR) return (ENOTDIR); dirbuf = kmem_alloc(LFS_DIRBLKSIZ, KM_SLEEP); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_offset = 0; UIO_SETUP_SYSSPACE(&auio); vargs.a_desc = NULL; vargs.a_vp = dvp; vargs.a_uio = &auio; vargs.a_cred = l->l_cred; vargs.a_eofflag = &eofflag; vargs.a_ncookies = NULL; vargs.a_cookies = NULL; while (!eofflag) { auio.uio_resid = LFS_DIRBLKSIZ; aiov.iov_base = dirbuf; aiov.iov_len = LFS_DIRBLKSIZ; error = ulfs_readdir(&vargs); if (error) { printf("ulfs_extattr_iterate_directory: ulfs_readdir " "%d\n", error); return (error); } /* * XXXRW: While in LFS, we always get LFS_DIRBLKSIZ returns from * the directory code on success, on other file systems this * may not be the case. For portability, we should check the * read length on return from ulfs_readdir(). */ edp = (struct dirent *)&dirbuf[LFS_DIRBLKSIZ]; for (dp = (struct dirent *)dirbuf; dp < edp; ) { if (dp->d_reclen == 0) break; /* Skip "." and ".." */ if (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) goto next; error = ulfs_extattr_lookup(dvp, LOCKPARENT, dp->d_name, &attr_vp, l); if (error == ENOENT) { goto next; /* keep silent */ } else if (error) { printf("ulfs_extattr_iterate_directory: lookup " "%s %d\n", dp->d_name, error); } else if (attr_vp == dvp) { vrele(attr_vp); } else if (attr_vp->v_type != VREG) { vput(attr_vp); } else { error = ulfs_extattr_enable_with_open(ump, attr_vp, attrnamespace, dp->d_name, l); vrele(attr_vp); if (error) { printf("ulfs_extattr_iterate_directory: " "enable %s %d\n", dp->d_name, error); } else if (bootverbose) { printf("%s: EA %s loaded\n", sbp->f_mntonname, dp->d_name); } } next: dp = (struct dirent *) ((char *)dp + dp->d_reclen); if (dp >= edp) break; } } kmem_free(dirbuf, LFS_DIRBLKSIZ); return (0); } /* * Auto-start of extended attributes, to be executed (optionally) at * mount-time. */ int ulfs_extattr_autostart(struct mount *mp, struct lwp *l) { struct vnode *rvp, *attr_dvp, *attr_system_dvp, *attr_user_dvp; int error; /* * Does ULFS_EXTATTR_FSROOTSUBDIR exist off the filesystem root? * If so, automatically start EA's. */ error = VFS_ROOT(mp, &rvp); if (error) { printf("ulfs_extattr_autostart.VFS_ROOT() returned %d\n", error); return (error); } KASSERT(VOP_ISLOCKED(rvp) == LK_EXCLUSIVE); error = ulfs_extattr_lookup(rvp, 0, ULFS_EXTATTR_FSROOTSUBDIR, &attr_dvp, l); if (error) { /* rvp ref'd but now unlocked */ KASSERT(VOP_ISLOCKED(rvp) == 0); vrele(rvp); return (error); } if (rvp == attr_dvp) { /* Should never happen. */ KASSERT(VOP_ISLOCKED(rvp) == LK_EXCLUSIVE); vrele(attr_dvp); vput(rvp); return (EINVAL); } KASSERT(VOP_ISLOCKED(rvp) == 0); vrele(rvp); KASSERT(VOP_ISLOCKED(attr_dvp) == LK_EXCLUSIVE); if (attr_dvp->v_type != VDIR) { printf("ulfs_extattr_autostart: %s != VDIR\n", ULFS_EXTATTR_FSROOTSUBDIR); goto return_vput_attr_dvp; } error = ulfs_extattr_start(mp, l); if (error) { printf("ulfs_extattr_autostart: ulfs_extattr_start failed (%d)\n", error); goto return_vput_attr_dvp; } /* * Look for two subdirectories: ULFS_EXTATTR_SUBDIR_SYSTEM, * ULFS_EXTATTR_SUBDIR_USER. For each, iterate over the sub-directory, * and start with appropriate type. Failures in either don't * result in an over-all failure. attr_dvp is left locked to * be cleaned up on exit. */ error = ulfs_extattr_lookup(attr_dvp, LOCKPARENT, ULFS_EXTATTR_SUBDIR_SYSTEM, &attr_system_dvp, l); KASSERT(VOP_ISLOCKED(attr_dvp) == LK_EXCLUSIVE); if (error == 0) { KASSERT(VOP_ISLOCKED(attr_system_dvp) == LK_EXCLUSIVE); error = ulfs_extattr_iterate_directory(VFSTOULFS(mp), attr_system_dvp, EXTATTR_NAMESPACE_SYSTEM, l); if (error) printf("ulfs_extattr_iterate_directory returned %d\n", error); KASSERT(VOP_ISLOCKED(attr_system_dvp) == LK_EXCLUSIVE); vput(attr_system_dvp); } error = ulfs_extattr_lookup(attr_dvp, LOCKPARENT, ULFS_EXTATTR_SUBDIR_USER, &attr_user_dvp, l); KASSERT(VOP_ISLOCKED(attr_dvp) == LK_EXCLUSIVE); if (error == 0) { KASSERT(VOP_ISLOCKED(attr_user_dvp) == LK_EXCLUSIVE); error = ulfs_extattr_iterate_directory(VFSTOULFS(mp), attr_user_dvp, EXTATTR_NAMESPACE_USER, l); if (error) printf("ulfs_extattr_iterate_directory returned %d\n", error); KASSERT(VOP_ISLOCKED(attr_user_dvp) == LK_EXCLUSIVE); vput(attr_user_dvp); } /* Mask startup failures in sub-directories. */ error = 0; return_vput_attr_dvp: KASSERT(VOP_ISLOCKED(attr_dvp) == LK_EXCLUSIVE); vput(attr_dvp); return (error); } /* * Stop extended attribute support on an FS. */ void ulfs_extattr_stop(struct mount *mp, struct lwp *l) { struct ulfs_extattr_list_entry *uele; struct ulfsmount *ump = VFSTOULFS(mp); ulfs_extattr_uepm_lock(ump); /* * If we haven't been started, no big deal. Just short-circuit * the processing work. */ if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) { goto unlock; } while (LIST_FIRST(&ump->um_extattr.uepm_list) != NULL) { uele = LIST_FIRST(&ump->um_extattr.uepm_list); ulfs_extattr_disable(ump, uele->uele_attrnamespace, uele->uele_attrname, l); } ump->um_extattr.uepm_flags &= ~ULFS_EXTATTR_UEPM_STARTED; kauth_cred_free(ump->um_extattr.uepm_ucred); ump->um_extattr.uepm_ucred = NULL; unlock: ulfs_extattr_uepm_unlock(ump); } /* * Enable a named attribute on the specified filesystem; provide an * unlocked backing vnode to hold the attribute data. */ static int ulfs_extattr_enable(struct ulfsmount *ump, int attrnamespace, const char *attrname, struct vnode *backing_vnode, struct lwp *l) { struct ulfs_extattr_list_entry *attribute; struct iovec aiov; struct uio auio; int error = 0; if (!ulfs_extattr_valid_attrname(attrnamespace, attrname)) return (EINVAL); if (backing_vnode->v_type != VREG) return (EINVAL); attribute = kmem_zalloc(sizeof(*attribute), KM_SLEEP); if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) { error = EOPNOTSUPP; goto free_exit; } if (ulfs_extattr_find_attr(ump, attrnamespace, attrname)) { error = EEXIST; goto free_exit; } strncpy(attribute->uele_attrname, attrname, ULFS_EXTATTR_MAXEXTATTRNAME); attribute->uele_attrnamespace = attrnamespace; memset(&attribute->uele_fileheader, 0, sizeof(struct ulfs_extattr_fileheader)); attribute->uele_backing_vnode = backing_vnode; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = (void *) &attribute->uele_fileheader; aiov.iov_len = sizeof(struct ulfs_extattr_fileheader); auio.uio_resid = sizeof(struct ulfs_extattr_fileheader); auio.uio_offset = (off_t) 0; auio.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&auio); vn_lock(backing_vnode, LK_SHARED | LK_RETRY); error = VOP_READ(backing_vnode, &auio, IO_NODELOCKED, ump->um_extattr.uepm_ucred); if (error) goto unlock_free_exit; if (auio.uio_resid != 0) { printf("ulfs_extattr_enable: malformed attribute header\n"); error = EINVAL; goto unlock_free_exit; } /* * Try to determine the byte order of the attribute file. */ if (attribute->uele_fileheader.uef_magic != ULFS_EXTATTR_MAGIC) { attribute->uele_flags |= UELE_F_NEEDSWAP; attribute->uele_fileheader.uef_magic = ulfs_rw32(attribute->uele_fileheader.uef_magic, UELE_NEEDSWAP(attribute)); if (attribute->uele_fileheader.uef_magic != ULFS_EXTATTR_MAGIC) { printf("ulfs_extattr_enable: invalid attribute header " "magic\n"); error = EINVAL; goto unlock_free_exit; } } attribute->uele_fileheader.uef_version = ulfs_rw32(attribute->uele_fileheader.uef_version, UELE_NEEDSWAP(attribute)); attribute->uele_fileheader.uef_size = ulfs_rw32(attribute->uele_fileheader.uef_size, UELE_NEEDSWAP(attribute)); if (attribute->uele_fileheader.uef_version != ULFS_EXTATTR_VERSION) { printf("ulfs_extattr_enable: incorrect attribute header " "version\n"); error = EINVAL; goto unlock_free_exit; } LIST_INSERT_HEAD(&ump->um_extattr.uepm_list, attribute, uele_entries); VOP_UNLOCK(backing_vnode); return (0); unlock_free_exit: VOP_UNLOCK(backing_vnode); free_exit: kmem_free(attribute, sizeof(*attribute)); return (error); } /* * Disable extended attribute support on an FS. */ static int ulfs_extattr_disable(struct ulfsmount *ump, int attrnamespace, const char *attrname, struct lwp *l) { struct ulfs_extattr_list_entry *uele; int error = 0; if (!ulfs_extattr_valid_attrname(attrnamespace, attrname)) return (EINVAL); uele = ulfs_extattr_find_attr(ump, attrnamespace, attrname); if (!uele) return (ENODATA); LIST_REMOVE(uele, uele_entries); error = vn_close(uele->uele_backing_vnode, FREAD|FWRITE, l->l_cred); kmem_free(uele, sizeof(*uele)); return (error); } /* * VFS call to manage extended attributes in ULFS. If filename_vp is * non-NULL, it must be passed in locked, and regardless of errors in * processing, will be unlocked. */ int ulfs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, int attrnamespace, const char *attrname) { struct lwp *l = curlwp; struct ulfsmount *ump = VFSTOULFS(mp); int error; /* * Only privileged processes can configure extended attributes. */ error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_EXTATTR, 0, mp, NULL, NULL); if (error) { if (filename_vp != NULL) VOP_UNLOCK(filename_vp); return (error); } switch(cmd) { case ULFS_EXTATTR_CMD_START: if (filename_vp != NULL) { VOP_UNLOCK(filename_vp); return (EINVAL); } if (attrname != NULL) return (EINVAL); error = ulfs_extattr_autostart(mp, l); return (error); case ULFS_EXTATTR_CMD_STOP: if (filename_vp != NULL) { VOP_UNLOCK(filename_vp); return (EINVAL); } if (attrname != NULL) return (EINVAL); ulfs_extattr_stop(mp, l); return (0); case ULFS_EXTATTR_CMD_ENABLE: if (filename_vp == NULL) return (EINVAL); if (attrname == NULL) { VOP_UNLOCK(filename_vp); return (EINVAL); } /* * ulfs_extattr_enable_with_open() will always unlock the * vnode, regardless of failure. */ ulfs_extattr_uepm_lock(ump); error = ulfs_extattr_enable_with_open(ump, filename_vp, attrnamespace, attrname, l); ulfs_extattr_uepm_unlock(ump); return (error); case ULFS_EXTATTR_CMD_DISABLE: if (filename_vp != NULL) { VOP_UNLOCK(filename_vp); return (EINVAL); } if (attrname == NULL) return (EINVAL); ulfs_extattr_uepm_lock(ump); error = ulfs_extattr_disable(ump, attrnamespace, attrname, l); ulfs_extattr_uepm_unlock(ump); return (error); default: return (EINVAL); } } /* * Read extended attribute header for a given vnode and attribute. * Backing vnode should be locked and unlocked by caller. */ static int ulfs_extattr_get_header(struct vnode *vp, struct ulfs_extattr_list_entry *uele, struct ulfs_extattr_header *ueh, off_t *bap) { struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); struct inode *ip = VTOI(vp); off_t base_offset; struct iovec aiov; struct uio aio; int error; /* * Find base offset of header in file based on file header size, and * data header size + maximum data size, indexed by inode number. */ base_offset = sizeof(struct ulfs_extattr_fileheader) + ip->i_number * (sizeof(struct ulfs_extattr_header) + uele->uele_fileheader.uef_size); /* * Read in the data header to see if the data is defined, and if so * how much. */ memset(ueh, 0, sizeof(struct ulfs_extattr_header)); aiov.iov_base = ueh; aiov.iov_len = sizeof(struct ulfs_extattr_header); aio.uio_iov = &aiov; aio.uio_iovcnt = 1; aio.uio_rw = UIO_READ; aio.uio_offset = base_offset; aio.uio_resid = sizeof(struct ulfs_extattr_header); UIO_SETUP_SYSSPACE(&aio); error = VOP_READ(uele->uele_backing_vnode, &aio, IO_NODELOCKED, ump->um_extattr.uepm_ucred); if (error) return error; /* * Attribute headers are kept in file system byte order. * XXX What about the blob of data? */ ueh->ueh_flags = ulfs_rw32(ueh->ueh_flags, UELE_NEEDSWAP(uele)); ueh->ueh_len = ulfs_rw32(ueh->ueh_len, UELE_NEEDSWAP(uele)); ueh->ueh_i_gen = ulfs_rw32(ueh->ueh_i_gen, UELE_NEEDSWAP(uele)); /* Defined? */ if ((ueh->ueh_flags & ULFS_EXTATTR_ATTR_FLAG_INUSE) == 0) return ENODATA; /* Valid for the current inode generation? */ if (ueh->ueh_i_gen != ip->i_gen) { /* * The inode itself has a different generation number * than the uele data. For now, the best solution * is to coerce this to undefined, and let it get cleaned * up by the next write or extattrctl clean. */ printf("%s (%s): inode gen inconsistency (%u, %jd)\n", __func__, mp->mnt_stat.f_mntonname, ueh->ueh_i_gen, (intmax_t)ip->i_gen); return ENODATA; } /* Local size consistency check. */ if (ueh->ueh_len > uele->uele_fileheader.uef_size) return ENXIO; /* Return base offset */ if (bap != NULL) *bap = base_offset; return 0; } /* * Vnode operation to retrieve a named extended attribute. */ int ulfs_getextattr(struct vop_getextattr_args *ap) /* vop_getextattr { IN struct vnode *a_vp; IN int a_attrnamespace; IN const char *a_name; INOUT struct uio *a_uio; OUT size_t *a_size; IN kauth_cred_t a_cred; }; */ { struct mount *mp = ap->a_vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); int error; ulfs_extattr_uepm_lock(ump); error = ulfs_extattr_get(ap->a_vp, ap->a_attrnamespace, ap->a_name, ap->a_uio, ap->a_size, ap->a_cred, curlwp); ulfs_extattr_uepm_unlock(ump); return (error); } /* * Real work associated with retrieving a named attribute--assumes that * the attribute lock has already been grabbed. */ static int ulfs_extattr_get(struct vnode *vp, int attrnamespace, const char *name, struct uio *uio, size_t *size, kauth_cred_t cred, struct lwp *l) { struct ulfs_extattr_list_entry *attribute; struct ulfs_extattr_header ueh; struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); off_t base_offset; size_t len, old_len; int error = 0; if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) return (EOPNOTSUPP); if (strlen(name) == 0) return (EINVAL); error = internal_extattr_check_cred(vp, attrnamespace, name, cred, VREAD); if (error) return (error); attribute = ulfs_extattr_find_attr(ump, attrnamespace, name); if (!attribute) return (ENODATA); /* * Allow only offsets of zero to encourage the read/replace * extended attribute semantic. Otherwise we can't guarantee * atomicity, as we don't provide locks for extended attributes. */ if (uio != NULL && uio->uio_offset != 0) return (ENXIO); /* * Don't need to get a lock on the backing file if the getattr is * being applied to the backing file, as the lock is already held. */ if (attribute->uele_backing_vnode != vp) vn_lock(attribute->uele_backing_vnode, LK_SHARED | LK_RETRY); error = ulfs_extattr_get_header(vp, attribute, &ueh, &base_offset); if (error) goto vopunlock_exit; /* Return full data size if caller requested it. */ if (size != NULL) *size = ueh.ueh_len; /* Return data if the caller requested it. */ if (uio != NULL) { /* Allow for offset into the attribute data. */ uio->uio_offset = base_offset + sizeof(struct ulfs_extattr_header); /* * Figure out maximum to transfer -- use buffer size and * local data limit. */ len = MIN(uio->uio_resid, ueh.ueh_len); old_len = uio->uio_resid; uio->uio_resid = len; error = VOP_READ(attribute->uele_backing_vnode, uio, IO_NODELOCKED, ump->um_extattr.uepm_ucred); if (error) goto vopunlock_exit; uio->uio_resid = old_len - (len - uio->uio_resid); } vopunlock_exit: if (uio != NULL) uio->uio_offset = 0; if (attribute->uele_backing_vnode != vp) VOP_UNLOCK(attribute->uele_backing_vnode); return (error); } /* * Vnode operation to list extended attribute for a vnode */ int ulfs_listextattr(struct vop_listextattr_args *ap) /* vop_listextattr { IN struct vnode *a_vp; IN int a_attrnamespace; INOUT struct uio *a_uio; OUT size_t *a_size; IN int flag; IN kauth_cred_t a_cred; struct proc *a_p; }; */ { struct mount *mp = ap->a_vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); int error; ulfs_extattr_uepm_lock(ump); error = ulfs_extattr_list(ap->a_vp, ap->a_attrnamespace, ap->a_uio, ap->a_size, ap->a_flag, ap->a_cred, curlwp); ulfs_extattr_uepm_unlock(ump); return (error); } /* * Real work associated with retrieving list of attributes--assumes that * the attribute lock has already been grabbed. */ static int ulfs_extattr_list(struct vnode *vp, int attrnamespace, struct uio *uio, size_t *size, int flag, kauth_cred_t cred, struct lwp *l) { struct ulfs_extattr_list_entry *uele; struct ulfs_extattr_header ueh; struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); size_t listsize = 0; int error = 0; if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) return (EOPNOTSUPP); /* * XXX: We can move this inside the loop and iterate on individual * attributes. */ error = internal_extattr_check_cred(vp, attrnamespace, "", cred, VREAD); if (error) return (error); LIST_FOREACH(uele, &ump->um_extattr.uepm_list, uele_entries) { unsigned char attrnamelen; if (uele->uele_attrnamespace != attrnamespace) continue; error = ulfs_extattr_get_header(vp, uele, &ueh, NULL); if (error == ENODATA) continue; if (error != 0) return error; /* * Don't need to get a lock on the backing file if * the listattr is being applied to the backing file, * as the lock is already held. */ if (uele->uele_backing_vnode != vp) vn_lock(uele->uele_backing_vnode, LK_SHARED | LK_RETRY); /* * +1 for trailing NUL (listxattr flavor) * or leading name length (extattr_list_file flavor) */ attrnamelen = strlen(uele->uele_attrname); listsize += attrnamelen + 1; /* Return data if the caller requested it. */ if (uio != NULL) { /* * We support two flavors. Either NUL-terminated * strings (a la listxattr), or non NUL-terminated, * one byte length prefixed strings (for * extattr_list_file). EXTATTR_LIST_LENPREFIX switches * that second behavior. */ if (flag & EXTATTR_LIST_LENPREFIX) { uint8_t len = (uint8_t)attrnamelen; /* Copy leading name length */ error = uiomove(&len, sizeof(len), uio); if (error != 0) break; } else { /* Include trailing NULL */ attrnamelen++; } error = uiomove(uele->uele_attrname, (size_t)attrnamelen, uio); if (error != 0) break; } if (uele->uele_backing_vnode != vp) VOP_UNLOCK(uele->uele_backing_vnode); if (error != 0) return error; } if (uio != NULL) uio->uio_offset = 0; /* Return full data size if caller requested it. */ if (size != NULL) *size = listsize; return 0; } /* * Vnode operation to remove a named attribute. */ int ulfs_deleteextattr(struct vop_deleteextattr_args *ap) /* vop_deleteextattr { IN struct vnode *a_vp; IN int a_attrnamespace; IN const char *a_name; IN kauth_cred_t a_cred; }; */ { struct mount *mp = ap->a_vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); int error; ulfs_extattr_uepm_lock(ump); error = ulfs_extattr_rm(ap->a_vp, ap->a_attrnamespace, ap->a_name, ap->a_cred, curlwp); ulfs_extattr_uepm_unlock(ump); return (error); } /* * Vnode operation to set a named attribute. */ int ulfs_setextattr(struct vop_setextattr_args *ap) /* vop_setextattr { IN struct vnode *a_vp; IN int a_attrnamespace; IN const char *a_name; INOUT struct uio *a_uio; IN kauth_cred_t a_cred; }; */ { struct mount *mp = ap->a_vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); int error; ulfs_extattr_uepm_lock(ump); /* * XXX: No longer a supported way to delete extended attributes. */ if (ap->a_uio == NULL) { ulfs_extattr_uepm_unlock(ump); return (EINVAL); } error = ulfs_extattr_set(ap->a_vp, ap->a_attrnamespace, ap->a_name, ap->a_uio, ap->a_cred, curlwp); ulfs_extattr_uepm_unlock(ump); return (error); } /* * Real work associated with setting a vnode's extended attributes; * assumes that the attribute lock has already been grabbed. */ static int ulfs_extattr_set(struct vnode *vp, int attrnamespace, const char *name, struct uio *uio, kauth_cred_t cred, struct lwp *l) { struct ulfs_extattr_list_entry *attribute; struct ulfs_extattr_header ueh; struct iovec local_aiov; struct uio local_aio; struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); struct inode *ip = VTOI(vp); off_t base_offset; int error = 0, ioflag; if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) return (EOPNOTSUPP); if (!ulfs_extattr_valid_attrname(attrnamespace, name)) return (EINVAL); error = internal_extattr_check_cred(vp, attrnamespace, name, cred, VWRITE); if (error) return (error); attribute = ulfs_extattr_find_attr(ump, attrnamespace, name); if (!attribute) { attribute = ulfs_extattr_autocreate_attr(vp, attrnamespace, name, l); if (!attribute) return (ENODATA); } /* * Early rejection of invalid offsets/length. * Reject: any offset but 0 (replace) * Any size greater than attribute size limit */ if (uio->uio_offset != 0 || uio->uio_resid > attribute->uele_fileheader.uef_size) return (ENXIO); /* * Find base offset of header in file based on file header size, and * data header size + maximum data size, indexed by inode number. */ base_offset = sizeof(struct ulfs_extattr_fileheader) + ip->i_number * (sizeof(struct ulfs_extattr_header) + attribute->uele_fileheader.uef_size); /* * Write out a data header for the data. */ ueh.ueh_len = ulfs_rw32((uint32_t) uio->uio_resid, UELE_NEEDSWAP(attribute)); ueh.ueh_flags = ulfs_rw32(ULFS_EXTATTR_ATTR_FLAG_INUSE, UELE_NEEDSWAP(attribute)); ueh.ueh_i_gen = ulfs_rw32(ip->i_gen, UELE_NEEDSWAP(attribute)); local_aiov.iov_base = &ueh; local_aiov.iov_len = sizeof(struct ulfs_extattr_header); local_aio.uio_iov = &local_aiov; local_aio.uio_iovcnt = 1; local_aio.uio_rw = UIO_WRITE; local_aio.uio_offset = base_offset; local_aio.uio_resid = sizeof(struct ulfs_extattr_header); UIO_SETUP_SYSSPACE(&local_aio); /* * Don't need to get a lock on the backing file if the setattr is * being applied to the backing file, as the lock is already held. */ if (attribute->uele_backing_vnode != vp) vn_lock(attribute->uele_backing_vnode, LK_EXCLUSIVE | LK_RETRY); ioflag = IO_NODELOCKED; if (ulfs_extattr_sync) ioflag |= IO_SYNC; error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag, ump->um_extattr.uepm_ucred); if (error) goto vopunlock_exit; if (local_aio.uio_resid != 0) { error = ENXIO; goto vopunlock_exit; } /* * Write out user data. * XXX NOT ATOMIC WITH RESPECT TO THE HEADER. */ uio->uio_offset = base_offset + sizeof(struct ulfs_extattr_header); ioflag = IO_NODELOCKED; if (ulfs_extattr_sync) ioflag |= IO_SYNC; error = VOP_WRITE(attribute->uele_backing_vnode, uio, ioflag, ump->um_extattr.uepm_ucred); vopunlock_exit: uio->uio_offset = 0; if (attribute->uele_backing_vnode != vp) VOP_UNLOCK(attribute->uele_backing_vnode); return (error); } /* * Real work associated with removing an extended attribute from a vnode. * Assumes the attribute lock has already been grabbed. */ static int ulfs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, kauth_cred_t cred, struct lwp *l) { struct ulfs_extattr_list_entry *attribute; struct ulfs_extattr_header ueh; struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); struct iovec local_aiov; struct uio local_aio; off_t base_offset; int error = 0, ioflag; if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) return (EOPNOTSUPP); if (!ulfs_extattr_valid_attrname(attrnamespace, name)) return (EINVAL); error = internal_extattr_check_cred(vp, attrnamespace, name, cred, VWRITE); if (error) return (error); attribute = ulfs_extattr_find_attr(ump, attrnamespace, name); if (!attribute) return (ENODATA); /* * Don't need to get a lock on the backing file if the getattr is * being applied to the backing file, as the lock is already held. */ if (attribute->uele_backing_vnode != vp) vn_lock(attribute->uele_backing_vnode, LK_EXCLUSIVE | LK_RETRY); error = ulfs_extattr_get_header(vp, attribute, &ueh, &base_offset); if (error) goto vopunlock_exit; /* Flag it as not in use. */ ueh.ueh_flags = 0; /* No need to byte swap 0 */ ueh.ueh_len = 0; /* ...ditto... */ local_aiov.iov_base = &ueh; local_aiov.iov_len = sizeof(struct ulfs_extattr_header); local_aio.uio_iov = &local_aiov; local_aio.uio_iovcnt = 1; local_aio.uio_rw = UIO_WRITE; local_aio.uio_offset = base_offset; local_aio.uio_resid = sizeof(struct ulfs_extattr_header); UIO_SETUP_SYSSPACE(&local_aio); ioflag = IO_NODELOCKED; if (ulfs_extattr_sync) ioflag |= IO_SYNC; error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag, ump->um_extattr.uepm_ucred); if (error) goto vopunlock_exit; if (local_aio.uio_resid != 0) error = ENXIO; vopunlock_exit: VOP_UNLOCK(attribute->uele_backing_vnode); return (error); } /* * Called by ULFS when an inode is no longer active and should have its * attributes stripped. */ void ulfs_extattr_vnode_inactive(struct vnode *vp, struct lwp *l) { struct ulfs_extattr_list_entry *uele; struct mount *mp = vp->v_mount; struct ulfsmount *ump = VFSTOULFS(mp); /* * In that case, we cannot lock. We should not have any active vnodes * on the fs if this is not yet initialized but is going to be, so * this can go unlocked. */ if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED)) return; ulfs_extattr_uepm_lock(ump); if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) { ulfs_extattr_uepm_unlock(ump); return; } LIST_FOREACH(uele, &ump->um_extattr.uepm_list, uele_entries) ulfs_extattr_rm(vp, uele->uele_attrnamespace, uele->uele_attrname, lwp0.l_cred, l); ulfs_extattr_uepm_unlock(ump); } void ulfs_extattr_init(void) { } void ulfs_extattr_done(void) { }
26.34414
85
0.710313
[ "object" ]
64ffef1958900dba9912eb01244824ca1bc4812b
22,318
c
C
test/test_bit.c
snmsts/npt
2896d7ac1924ba63e864e2813e66936a2a46707f
[ "Unlicense" ]
null
null
null
test/test_bit.c
snmsts/npt
2896d7ac1924ba63e864e2813e66936a2a46707f
[ "Unlicense" ]
null
null
null
test/test_bit.c
snmsts/npt
2896d7ac1924ba63e864e2813e66936a2a46707f
[ "Unlicense" ]
null
null
null
#include "bit.c" #include "character.h" #include "clos.h" #include "common.h" #include "constant.h" #include "degrade.h" #include "object.h" #include "package.h" #include "readtable.h" #include "stream.h" #include "symbol.h" #include "syscall.h" #include "type.h" #include "type_table.h" static int test_bitp(void) { test(bitp(fixnumh(0)), "bitp1"); test(bitp(fixnumh(1)), "bitp2"); test(! bitp(fixnumh(2)), "bitp3"); test(! bitp(fixnumh(-1)), "bitp4"); test(! bitp(fixnumh(10)), "bitp5"); test(! bitp(T), "bitp6"); RETURN; } static int test_bit_getint(void) { int value; value = 999; test(! bit_getint(fixnumh(0), &value), "bit_getint1"); test(value == 0, "bit_getint2"); test(! bit_getint(fixnumh(1), &value), "bit_getint3"); test(value == 1, "bit_getint4"); value = 999; test(bit_getint(fixnumh(2), &value), "bit_getint5"); test(value == 999, "bit_getint6"); test(bit_getint(fixnumh(-1), &value), "bit_getint7"); test(bit_getint(fixnumh(10), &value), "bit_getint8"); test(bit_getint(T, &value), "bit_getint9"); RETURN; } /* * bitcons */ static int test_bitbuffer_local(void) { addr pos; LocalRoot local; LocalStack stack; struct bitbuffer_struct *str; size_t size, check; local = Local_Thread; push_local(local, &stack); bitbuffer_local(local, &pos, 10); test(GetType(pos) == LISPSYSTEM_BITBUFFER, "bitbuffer_local1"); str = BitBufferStruct(pos); test(str->index == 0, "bitbuffer_local2"); test(str->array == 0, "bitbuffer_local3"); test(str->data[0] == 0, "bitbuffer_local4"); test(str->data[9] == 0, "bitbuffer_local5"); size = lenbodyr(pos); check = sizeoft(struct bitbuffer_struct) + sizeoft(fixed) * 10UL; test(size == check, "bitbuffer_local6"); GetBitBuffer(pos, &pos); test(pos == Nil, "bitbuffer_local7"); rollback_local(local, stack); RETURN; } static int test_getfixedsize(void) { test(getfixedsize(0) == 0, "getfixedsize1"); test(getfixedsize(1) == 1, "getfixedsize2"); test(getfixedsize(2) == 1, "getfixedsize3"); test(getfixedsize(8*sizeoft(fixed) - 1) == 1, "getfixedsize4"); test(getfixedsize(8*sizeoft(fixed) + 0) == 1, "getfixedsize5"); test(getfixedsize(8*sizeoft(fixed) + 1) == 2, "getfixedsize6"); test(getfixedsize(8*sizeoft(fixed) + 2) == 2, "getfixedsize7"); test(getfixedsize(2*8*sizeoft(fixed) - 1) == 2, "getfixedsize8"); test(getfixedsize(2*8*sizeoft(fixed) + 0) == 2, "getfixedsize9"); test(getfixedsize(2*8*sizeoft(fixed) + 1) == 3, "getfixedsize10"); test(getfixedsize(2*8*sizeoft(fixed) + 2) == 3, "getfixedsize11"); RETURN; } static int test_bitcons_local(void) { addr pos, check; LocalRoot local; LocalStack stack; struct bitcons_struct *str; local = Local_Thread; push_local(local, &stack); bitcons_local(local, &pos, 3); test(GetType(pos) == LISPSYSTEM_BITCONS, "bitcons_local1"); str = BitConsStruct(pos); test(str->bitsize == sizeoft(fixed) * 8UL, "bitcons_local2"); test(str->fixedsize == 1, "bitcons_local3"); test(str->index == 0, "bitcons_local4"); GetBitConsRoot(pos, &check); test(GetType(check) == LISPSYSTEM_BITBUFFER, "bitcons_local5"); GetBitConsTail(pos, &pos); test(pos == check, "bitcons_local6"); rollback_local(local, stack); RETURN; } static int test_pushnext_bitcons(void) { addr pos, check, next; LocalRoot local; LocalStack stack; struct bitbuffer_struct *str; local = Local_Thread; push_local(local, &stack); bitcons_local(local, &pos, 5); pushnext_bitcons(local, pos, &next); GetBitConsRoot(pos, &check); test(check == next, "pushnext_bitcons1"); str = BitBufferStruct(next); str->index = 8UL * sizeoft(fixed) - 1UL; pushnext_bitcons(local, pos, &next); GetBitConsRoot(pos, &check); test(check == next, "pushnext_bitcons2"); str = BitBufferStruct(next); str->index = 8UL * sizeoft(fixed); pushnext_bitcons(local, pos, &next); GetBitConsRoot(pos, &check); test(check != next, "pushnext_bitcons3"); GetBitConsTail(pos, &check); test(check == next, "pushnext_bitcons4"); rollback_local(local, stack); RETURN; } static int test_push_bitcons(void) { addr pos, next; LocalRoot local; LocalStack stack; struct bitbuffer_struct *str; local = Local_Thread; push_local(local, &stack); bitcons_local(local, &pos, 1); push_bitcons(local, pos, 1); GetBitConsTail(pos, &next); str = BitBufferStruct(next); test(str->data[0], "push_bitcons1"); rollback_local(local, stack); RETURN; } /* * bitmemory */ static int test_bitmemory_unsafe(void) { addr pos; LocalRoot local; LocalStack stack; struct bitmemory_struct *str; local = Local_Thread; push_local(local, &stack); bitmemory_unsafe(local, &pos, 9999); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_unsafe1"); test(GetStatusDynamic(pos), "bitmemory_unsafe2"); str = BitMemoryStruct(pos); test(str->bitsize == 9999, "bitmemory_unsafe3"); test(str->fixedsize == getfixedsize(9999), "bitmemory_unsafe4"); rollback_local(local, stack); RETURN; } static int test_bitmemory_alloc(void) { addr pos; struct bitmemory_struct *str; bitmemory_alloc(NULL, &pos, 9999); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_alloc1"); test(! GetStatusDynamic(pos), "bitmemory_alloc2"); str = BitMemoryStruct(pos); test(str->bitsize == 9999, "bitmemory_alloc3"); test(str->fixedsize == getfixedsize(9999), "bitmemory_alloc4"); test(str->data[0] == 0, "bitmemory_alloc5"); test(str->data[1] == 0, "bitmemory_alloc6"); RETURN; } static int test_bitmemory_local(void) { addr pos; LocalRoot local; LocalStack stack; local = Local_Thread; push_local(local, &stack); bitmemory_local(local, &pos, 9999); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_local1"); test(GetStatusDynamic(pos), "bitmemory_local2"); rollback_local(local, stack); RETURN; } static int test_bitmemory_heap(void) { addr pos; bitmemory_heap(&pos, 9999); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_heap1"); test(! GetStatusDynamic(pos), "bitmemory_heap2"); RETURN; } static int test_bitcheck(struct bitmemory_struct *str, unsigned index, unsigned bit) { return (str->data[index] >> bit) & 1; } static int test_bitmemory_cons_alloc(void) { int i; addr cons, pos; LocalRoot local; LocalStack stack; struct bitmemory_struct *str; local = Local_Thread; push_local(local, &stack); bitcons_local(local, &cons, 0); for (i = 0; i < 99; i++) { push_bitcons(local, cons, 1); push_bitcons(local, cons, 1); push_bitcons(local, cons, 1); push_bitcons(local, cons, 0); push_bitcons(local, cons, 0); push_bitcons(local, cons, 0); push_bitcons(local, cons, 1); push_bitcons(local, cons, 1); } bitmemory_cons_alloc(local, &pos, cons); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_cons_alloc1"); test(GetStatusDynamic(pos), "bitmemory_cons_alloc2"); str = BitMemoryStruct(pos); test(str->bitsize == 8*99, "bitmemory_cons_alloc3"); test(str->fixedsize == getfixedsize(8*99), "bitmemory_cons_alloc4"); test( test_bitcheck(str, 0, 0), "bitmemory_cons_alloc5"); test( test_bitcheck(str, 0, 1), "bitmemory_cons_alloc6"); test( test_bitcheck(str, 0, 2), "bitmemory_cons_alloc7"); test(! test_bitcheck(str, 0, 3), "bitmemory_cons_alloc8"); test(! test_bitcheck(str, 0, 4), "bitmemory_cons_alloc9"); test(! test_bitcheck(str, 0, 5), "bitmemory_cons_alloc10"); test( test_bitcheck(str, 0, 6), "bitmemory_cons_alloc11"); test( test_bitcheck(str, 1, 0), "bitmemory_cons_alloc12"); test( test_bitcheck(str, 1, 1), "bitmemory_cons_alloc13"); test( test_bitcheck(str, 1, 2), "bitmemory_cons_alloc14"); test(! test_bitcheck(str, 1, 3), "bitmemory_cons_alloc15"); test(! test_bitcheck(str, 1, 4), "bitmemory_cons_alloc16"); test(! test_bitcheck(str, 1, 5), "bitmemory_cons_alloc17"); test( test_bitcheck(str, 1, 6), "bitmemory_cons_alloc18"); rollback_local(local, stack); RETURN; } static int test_bitmemory_cons_local(void) { addr cons, pos; LocalRoot local; LocalStack stack; struct bitmemory_struct *str; local = Local_Thread; push_local(local, &stack); bitcons_local(local, &cons, 0); push_bitcons(local, cons, 1); push_bitcons(local, cons, 1); push_bitcons(local, cons, 0); bitmemory_cons_local(local, &pos, cons); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_cons_local1"); test(GetStatusDynamic(pos), "bitmemory_cons_local2"); str = BitMemoryStruct(pos); test( test_bitcheck(str, 0, 0), "bitmemory_cons_local3"); test( test_bitcheck(str, 0, 1), "bitmemory_cons_local4"); test(! test_bitcheck(str, 0, 2), "bitmemory_cons_local5"); rollback_local(local, stack); RETURN; } static int test_bitmemory_cons_heap(void) { addr cons, pos; LocalRoot local; LocalStack stack; struct bitmemory_struct *str; local = Local_Thread; push_local(local, &stack); bitcons_local(local, &cons, 0); push_bitcons(local, cons, 1); push_bitcons(local, cons, 1); push_bitcons(local, cons, 0); bitmemory_cons_heap(&pos, cons); test(GetType(pos) == LISPTYPE_BITVECTOR, "bitmemory_cons_heap1"); test(! GetStatusDynamic(pos), "bitmemory_cons_heap2"); str = BitMemoryStruct(pos); test( test_bitcheck(str, 0, 0), "bitmemory_cons_heap3"); test( test_bitcheck(str, 0, 1), "bitmemory_cons_heap4"); test(! test_bitcheck(str, 0, 2), "bitmemory_cons_heap5"); rollback_local(local, stack); RETURN; } static int test_bitmemoryp(void) { addr pos; bitmemory_heap(&pos, 10); test(bitmemoryp(pos), "bitmemoryp1"); test(! bitmemoryp(Nil), "bitmemoryp2"); RETURN; } static int test_bitmemory_memset_byte(void) { addr pos; bitmemory_heap(&pos, 256); bitmemory_memset_byte(pos, 0xA0); test(! bitmemory_refint(pos, 0), "bitmemory_memset_byte1"); test(! bitmemory_refint(pos, 1), "bitmemory_memset_byte2"); test(! bitmemory_refint(pos, 2), "bitmemory_memset_byte3"); test(! bitmemory_refint(pos, 3), "bitmemory_memset_byte4"); test(! bitmemory_refint(pos, 4), "bitmemory_memset_byte5"); test( bitmemory_refint(pos, 5), "bitmemory_memset_byte6"); test(! bitmemory_refint(pos, 6), "bitmemory_memset_byte7"); test( bitmemory_refint(pos, 7), "bitmemory_memset_byte8"); test(! bitmemory_refint(pos, 64+0), "bitmemory_memset_byte9"); test(! bitmemory_refint(pos, 64+1), "bitmemory_memset_byte10"); test(! bitmemory_refint(pos, 64+2), "bitmemory_memset_byte11"); test(! bitmemory_refint(pos, 64+3), "bitmemory_memset_byte12"); test(! bitmemory_refint(pos, 64+4), "bitmemory_memset_byte13"); test( bitmemory_refint(pos, 64+5), "bitmemory_memset_byte14"); test(! bitmemory_refint(pos, 64+6), "bitmemory_memset_byte15"); test( bitmemory_refint(pos, 64+7), "bitmemory_memset_byte16"); RETURN; } static int test_bitmemory_memset(void) { addr pos; bitmemory_heap(&pos, 256); bitmemory_memset(pos, 0); test(! bitmemory_refint(pos, 0), "bitmemory_memset1"); test(! bitmemory_refint(pos, 66), "bitmemory_memset2"); bitmemory_memset(pos, 0); test(! bitmemory_refint(pos, 1), "bitmemory_memset3"); test(! bitmemory_refint(pos, 67), "bitmemory_memset4"); RETURN; } static int test_bitmemory_copy_unsafe(void) { int i, n; addr a, b; bitmemory_heap(&a, 100); for (i = n = 0; i < 10; i++) { bitmemory_setint(a, n++, 1); bitmemory_setint(a, n++, 1); bitmemory_setint(a, n++, 0); bitmemory_setint(a, n++, 0); bitmemory_setint(a, n++, 1); } bitmemory_heap(&b, 100); bitmemory_copy_unsafe(b, a, 100); test(bitmemory_equal(a, b), "bitmemory_copy_unsafe1"); RETURN; } static int test_bitmemory_length(void) { addr pos; size_t size; bitmemory_heap(&pos, 55); bitmemory_length(pos, &size); test(size == 55, "bitmemory_length1"); RETURN; } static int test_bitmemory_equal(void) { addr pos1, pos2; bitmemory_char_heap(&pos1, "1011"); bitmemory_char_heap(&pos2, "1011"); test(bitmemory_equal(pos1, pos2), "bitmemory_equal1"); bitmemory_char_heap(&pos1, "1101"); bitmemory_char_heap(&pos2, "1011"); test(! bitmemory_equal(pos1, pos2), "bitmemory_equal2"); bitmemory_char_heap(&pos1, "10110"); bitmemory_char_heap(&pos2, "1011"); test(! bitmemory_equal(pos1, pos2), "bitmemory_equal3"); bitmemory_char_heap(&pos1, "1011"); bitmemory_char_heap(&pos2, "10110"); test(! bitmemory_equal(pos1, pos2), "bitmemory_equal4"); bitmemory_char_heap(&pos1, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111"); bitmemory_char_heap(&pos2, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111"); test(bitmemory_equal(pos1, pos2), "bitmemory_equal5"); bitmemory_char_heap(&pos1, "10010111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111"); bitmemory_char_heap(&pos2, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111"); test(! bitmemory_equal(pos1, pos2), "bitmemory_equal6"); bitmemory_char_heap(&pos1, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111"); bitmemory_char_heap(&pos2, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110101"); test(! bitmemory_equal(pos1, pos2), "bitmemory_equal7"); RETURN; } static int test_bitmemory_refint(void) { addr pos; bitmemory_char_heap(&pos, "1011"); test( bitmemory_refint(pos, 0), "bitmemory_refint1"); test(! bitmemory_refint(pos, 1), "bitmemory_refint2"); test( bitmemory_refint(pos, 2), "bitmemory_refint3"); test( bitmemory_refint(pos, 3), "bitmemory_refint4"); RETURN; } static int test_bitmemory_getint(void) { int check; addr pos; bitmemory_char_heap(&pos, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110101"); bitmemory_getint(pos, 0, &check); test(check, "bitmemory_getint1"); bitmemory_getint(pos, 1, &check); test(! check, "bitmemory_getint2"); bitmemory_getint(pos, 2, &check); test(check, "bitmemory_getint3"); bitmemory_getint(pos, 3, &check); test(check, "bitmemory_getint4"); bitmemory_getint(pos, 65-1, &check); test(check, "bitmemory_getint5"); bitmemory_getint(pos, 65+0, &check); test(check, "bitmemory_getint6"); bitmemory_getint(pos, 65+1, &check); test(! check, "bitmemory_getint7"); bitmemory_getint(pos, 65+2, &check); test(check, "bitmemory_getint8"); bitmemory_getint(pos, 65+3, &check); test(check, "bitmemory_getint9"); RETURN; } static int test_bitmemory_setint(void) { addr pos1, pos2; bitmemory_char_heap(&pos1, "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110101"); bitmemory_char_heap(&pos2, "10110111111000000111111000001101010101010111100100100111001110110" "01010111111000000111111000001101010101010111100100100111001110111" "10110111111000000111111000001101010101010111100100100111001110101"); bitmemory_setint(pos1, 65-1, 0); bitmemory_setint(pos1, 65+0, 0); bitmemory_setint(pos1, 65+1, 1); bitmemory_setint(pos1, 65+2, 0); bitmemory_setint(pos1, 65+3, 1); test(bitmemory_equal(pos1, pos2), "bitmemory_setint1"); RETURN; } static int test_bitmemory_get(void) { addr pos, value; bitmemory_char_heap(&pos, "110010"); bitmemory_get(NULL, pos, 0, &value); test(RefFixnum(value) == 1, "bitmemory_get1"); bitmemory_get(NULL, pos, 1, &value); test(RefFixnum(value) == 1, "bitmemory_get2"); bitmemory_get(NULL, pos, 2, &value); test(RefFixnum(value) == 0, "bitmemory_get3"); bitmemory_get(NULL, pos, 4, &value); test(RefFixnum(value) == 1, "bitmemory_get4"); bitmemory_get(NULL, pos, 5, &value); test(RefFixnum(value) == 0, "bitmemory_get5"); RETURN; } static int test_bitmemory_aref(void) { addr pos, value; bitmemory_char_heap(&pos, "110010"); list_heap(&value, fixnumh(0), NULL); bitmemory_aref(NULL, pos, value, &value); test(RefFixnum(value) == 1, "bitmemory_aref1"); list_heap(&value, fixnumh(2), NULL); bitmemory_aref(NULL, pos, value, &value); test(RefFixnum(value) == 0, "bitmemory_aref2"); list_heap(&value, fixnumh(5), NULL); bitmemory_aref(NULL, pos, value, &value); test(RefFixnum(value) == 0, "bitmemory_aref3"); RETURN; } static int test_bitmemory_set(void) { addr pos, check; bitmemory_char_heap(&pos, "110010"); bitmemory_char_heap(&check, "100011"); bitmemory_set(pos, 1, fixnumh(0)); bitmemory_set(pos, 5, fixnumh(1)); test(bitmemory_equal(pos, check), "bitmemory_set1"); RETURN; } static int test_bitmemory_setf_aref(void) { addr pos, check, args; bitmemory_char_heap(&pos, "110010"); bitmemory_char_heap(&check, "100011"); list_heap(&args, fixnumh(1), NULL); bitmemory_setf_aref(pos, args, fixnumh(0)); list_heap(&args, fixnumh(5), NULL); bitmemory_setf_aref(pos, args, fixnumh(1)); test(bitmemory_equal(pos, check), "bitmemory_setf_aref1"); RETURN; } /* * bvarray */ static int test_array_bvarrayp(void) { addr pos, list; GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(array_bvarrayp(pos), "array_bvarrayp1"); GetTypeTable(&pos, Bit); list_heap(&list, fixnumh(10), fixnumh(20), NULL); make_array_common(&pos, list, pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(! array_bvarrayp(pos), "array_bvarrayp2"); GetTypeTable(&pos, T); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(! array_bvarrayp(pos), "array_bvarrayp3"); RETURN; } static int test_bvarrayp(void) { addr pos; GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, T, Nil, Nil, Nil); test(bvarrayp(pos), "bvarrayp1"); test(! bvarrayp(T), "bvarrayp2"); RETURN; } static int test_bitvectorp(void) { addr pos; bitmemory_heap(&pos, 10); test(bitvectorp(pos), "bitvectorp1"); GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(bitvectorp(pos), "bitvectorp2"); test(! bitvectorp(T), "bitvectorp3"); RETURN; } static int test_simple_array_bvarrayp(void) { addr pos, list; GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(simple_array_bvarrayp(pos), "simple_array_bvarrayp1"); GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, T, Nil, Nil, Nil); test(! simple_array_bvarrayp(pos), "simple_array_bvarrayp2"); GetTypeTable(&pos, Bit); list_heap(&list, fixnumh(10), fixnumh(20), NULL); make_array_common(&pos, list, pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(! simple_array_bvarrayp(pos), "simple_array_bvarrayp3"); GetTypeTable(&pos, T); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(! simple_array_bvarrayp(pos), "simple_array_bvarrayp4"); RETURN; } static int test_simple_bvarrayp(void) { addr pos; GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(simple_bvarrayp(pos), "simple_bvarrayp1"); GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, T, Nil, Nil, Nil); test(! simple_bvarrayp(pos), "simple_bvarrayp2"); test(! simple_bvarrayp(T), "simple_bvarrayp3"); RETURN; } static int test_simple_bitvectorp(void) { addr pos; bitmemory_heap(&pos, 10); test(simple_bitvectorp(pos), "simple_bitvectorp1"); GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, Nil, Nil, Nil, Nil); test(simple_bitvectorp(pos), "simple_bitvectorp2"); GetTypeTable(&pos, Bit); make_array_common(&pos, fixnumh(10), pos, Unbound, Unbound, T, Nil, Nil, Nil); test(! simple_bitvectorp(pos), "simple_bitvectorp3"); test(! simple_bitvectorp(T), "simple_bitvectorp4"); RETURN; } /* * main */ static int testbreak_bit(void) { /* bit */ TestBreak(test_bitp); TestBreak(test_bit_getint); /* bitcons */ TestBreak(test_bitbuffer_local); TestBreak(test_getfixedsize); TestBreak(test_bitcons_local); TestBreak(test_pushnext_bitcons); TestBreak(test_push_bitcons); /* bitmemory */ TestBreak(test_bitmemory_unsafe); TestBreak(test_bitmemory_alloc); TestBreak(test_bitmemory_local); TestBreak(test_bitmemory_heap); TestBreak(test_bitmemory_cons_alloc); TestBreak(test_bitmemory_cons_local); TestBreak(test_bitmemory_cons_heap); TestBreak(test_bitmemoryp); TestBreak(test_bitmemory_memset_byte); TestBreak(test_bitmemory_memset); TestBreak(test_bitmemory_copy_unsafe); TestBreak(test_bitmemory_length); TestBreak(test_bitmemory_equal); TestBreak(test_bitmemory_refint); TestBreak(test_bitmemory_getint); TestBreak(test_bitmemory_setint); TestBreak(test_bitmemory_get); TestBreak(test_bitmemory_aref); TestBreak(test_bitmemory_set); TestBreak(test_bitmemory_setf_aref); /* bvarray */ TestBreak(test_array_bvarrayp); TestBreak(test_bvarrayp); TestBreak(test_bitvectorp); TestBreak(test_simple_array_bvarrayp); TestBreak(test_simple_bvarrayp); TestBreak(test_simple_bitvectorp); return 0; } int test_bit(void) { int result; lispcode code; Execute ptr; TITLE; freelisp(); alloclisp(0, 0); lisp_info_enable = 1; ptr = Execute_Thread; begin_code(ptr, &code); if (code_run_p(code)) { build_lisproot(ptr); build_constant(); build_object(); build_character(); build_package(); build_stream(); build_symbol(); build_clos(ptr); build_condition(ptr); build_type(); build_syscall(); build_common(); build_readtable(); lisp_initialize = 1; result = testbreak_bit(); } end_code(ptr); freelisp(); TestCheck(code_error_p(code)); lisp_info_enable = 1; return result; }
26.921592
84
0.736087
[ "object" ]
8f00e198b50b031cdffbd09b6d36d329c6415083
2,306
h
C
s32v234_sdk/kernels/apu/apexcv_pro_affine/src/affine_transform_acf.h
intesight/Panorama4AIWAYS
46e1988e54a5155be3b3b47c486b3f722be00b5c
[ "WTFPL" ]
null
null
null
s32v234_sdk/kernels/apu/apexcv_pro_affine/src/affine_transform_acf.h
intesight/Panorama4AIWAYS
46e1988e54a5155be3b3b47c486b3f722be00b5c
[ "WTFPL" ]
null
null
null
s32v234_sdk/kernels/apu/apexcv_pro_affine/src/affine_transform_acf.h
intesight/Panorama4AIWAYS
46e1988e54a5155be3b3b47c486b3f722be00b5c
[ "WTFPL" ]
2
2021-01-21T02:06:16.000Z
2021-01-28T10:47:37.000Z
/***************************************************************************** * * NXP Confidential Proprietary * * Copyright (c) 2014-2016 Freescale Semiconductor * Copyright 2017-2018 NXP * All Rights Reserved * ****************************************************************************** * * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL NXP OR ITS 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. * ****************************************************************************/ /*!********************************************************************************* * \file affine_transform_apu.cpp * \brief ACF Affine Transform Wrapper. ***********************************************************************************/ /*!********************************************************************************* * @file * @brief ACF metadata and wrapper function for the \ref secAffineTransform "affine transformation". ***********************************************************************************/ #ifndef ACFAFFINETRANSFORMWRAP_H #define ACFAFFINETRANSFORMWRAP_H #ifdef ACF_KERNEL_METADATA #include "common_stringify_macros.h" #define AFFINE_BILINEAR_INTERPOLATE_K affine_bilinear_interpolate #define AFFINE_BILINEAR_INTERPOLATE_KN XSTR(AFFINE_BILINEAR_INTERPOLATE_K) #define INPUT "INPUT" #define MATRIX "MATRIX" #define IMAGE_WIDTH "IMAGE_WIDTH" #define IMAGE_HEIGHT "IMAGE_HEIGHT" #define OUTPUT "OUTPUT" extKernelInfoDecl(AFFINE_BILINEAR_INTERPOLATE_K); #endif // ACF_KERNEL_METADATA #endif /* ACFAFFINETRANSFORMWRAP_H */
44.346154
100
0.552038
[ "transform" ]
8f087356a8688497a1bb9a71e9af3b034a07a219
1,838
h
C
applications/FluidDynamicsApplication/custom_utilities/time_integrated_fic_data.h
lkusch/Kratos
e8072d8e24ab6f312765185b19d439f01ab7b27b
[ "BSD-4-Clause" ]
778
2017-01-27T16:29:17.000Z
2022-03-30T03:01:51.000Z
applications/FluidDynamicsApplication/custom_utilities/time_integrated_fic_data.h
lkusch/Kratos
e8072d8e24ab6f312765185b19d439f01ab7b27b
[ "BSD-4-Clause" ]
6,634
2017-01-15T22:56:13.000Z
2022-03-31T15:03:36.000Z
applications/FluidDynamicsApplication/custom_utilities/time_integrated_fic_data.h
lkusch/Kratos
e8072d8e24ab6f312765185b19d439f01ab7b27b
[ "BSD-4-Clause" ]
224
2017-02-07T14:12:49.000Z
2022-03-06T23:09:34.000Z
// | / | // ' / __| _` | __| _ \ __| // . \ | ( | | ( |\__ ` // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // // License: BSD License // Kratos default license: kratos/license.txt // // Main authors: Jordi Cotela // #if !defined(KRATOS_TIME_INTEGRATED_FIC_DATA_H) #define KRATOS_TIME_INTEGRATED_FIC_DATA_H #include "fluid_dynamics_application_variables.h" #include "custom_utilities/fic_data.h" namespace Kratos { ///@addtogroup FluidDynamicsApplication ///@{ ///@name Kratos classes ///@{ template< size_t TDim, size_t TNumNodes > class TimeIntegratedFICData : public FICData<TDim,TNumNodes,true> { public: ///@name Type Definitions ///@{ using NodalScalarData = typename FluidElementData<TDim,TNumNodes, false>::NodalScalarData; using NodalVectorData = typename FluidElementData<TDim,TNumNodes, false>::NodalVectorData; ///@} ///@name Public Members ///@{ NodalVectorData Velocity_OldStep1; NodalVectorData Velocity_OldStep2; double bdf0; double bdf1; double bdf2; ///@} ///@name Public Operations ///@{ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) override { FICData<TDim,TNumNodes,true>::Initialize(rElement,rProcessInfo); const Geometry< Node<3> >& r_geometry = rElement.GetGeometry(); this->FillFromHistoricalNodalData(Velocity_OldStep1,VELOCITY,r_geometry,1); this->FillFromHistoricalNodalData(Velocity_OldStep2,VELOCITY,r_geometry,2); const Vector& BDFVector = rProcessInfo[BDF_COEFFICIENTS]; bdf0 = BDFVector[0]; bdf1 = BDFVector[1]; bdf2 = BDFVector[2]; } static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) { int out = FICData<TDim,TNumNodes,true>::Check(rElement,rProcessInfo); return out; } ///@} }; ///@} ///@} } #endif
21.880952
90
0.685528
[ "geometry", "vector" ]
8f1d08832c62c6a0e593fc52b1f8890f87480847
1,163
h
C
include/type/Decimal.h
SirWumpus/libsnert
087968a94df77bf0685749b678258e7987b889c6
[ "BSD-2-Clause" ]
null
null
null
include/type/Decimal.h
SirWumpus/libsnert
087968a94df77bf0685749b678258e7987b889c6
[ "BSD-2-Clause" ]
null
null
null
include/type/Decimal.h
SirWumpus/libsnert
087968a94df77bf0685749b678258e7987b889c6
[ "BSD-2-Clause" ]
null
null
null
/* * Decimal.h * * Copyright 2004 by Anthony Howe. All rights reserved. */ #ifndef __com_snert_lib_type_Decimal_h__ #define __com_snert_lib_type_Decimal_h__ 1 #ifdef __cplusplus extern "C" { #endif #include <com/snert/lib/type/Object.h> #define OBJECT_DECIMAL \ OBJECT_OBJECT; \ double value typedef struct decimal { OBJECT_DECIMAL; } *Decimal; /*@-exportlocal@*/ /** * Create a new and initialised Decimal object. * * @param value * A double value. * * @return * A Decimal object; otherwise null on error. */ extern /*@only@*//*@null@*/ Decimal DecimalCreate(double value); /** * Create a new and initialised Decimal object. * * @param string * A C string representing a fractional decimal number. * * @return * A Decimal object; otherwise null on error. */ extern /*@only@*//*@null@*/ Decimal DecimalCreateFromString(const char *string); /** * Initialise an object. Typically used for static Objects. * * @param data * A pointer to a Decimal object to initialise. */ extern void DecimalInit(/*@out@*/ Decimal self); /*@=exportlocal@*/ #ifdef __cplusplus } #endif #endif /* __com_snert_lib_type_Decimal_h__ */
18.460317
80
0.698194
[ "object" ]
8f2ab56ab5de619cd640c147a31bb2bd70c6175f
4,098
h
C
PrivateFrameworks/iWorkImport.framework/TNChartFormulaStorage.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/iWorkImport.framework/TNChartFormulaStorage.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/iWorkImport.framework/TNChartFormulaStorage.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/iWorkImport.framework/iWorkImport */ @interface TNChartFormulaStorage : NSObject <NSCopying, NSMutableCopying> { unsigned long long mCachedNumberOfGroups; bool mCachedNumberOfGroupsValid; int mDirection; struct __CFDictionary { } * mStorage; } + (struct vector<TNChartFormulaType, std::__1::allocator<TNChartFormulaType> > { unsigned long long *x1; unsigned long long *x2; struct __compressed_pair<TNChartFormulaType *, std::__1::allocator<TNChartFormulaType> > { unsigned long long *x_3_1_1; } x3; })persistentFormulaTypes; - (id)areaFormulaWithCalcEngine:(id)arg1 inOwner:(struct __CFUUID { }*)arg2; - (unsigned long long)categoryLabelFormulaType; - (void)clearCachesForCalculationEngine:(id)arg1; - (id)copyWithZone:(struct _NSZone { }*)arg1; - (unsigned long long)count; - (bool)dataFormulaAreRegularForSeriesInsertionWithCalcEngine:(id)arg1 inOwner:(struct __CFUUID { }*)arg2; - (void)dealloc; - (id)description; - (int)direction; - (id)formulaForID:(struct { unsigned int x1 : 24; unsigned int x2 : 8; })arg1; - (id)formulaListForType:(unsigned long long)arg1; - (id)formulaTypeEnumerator; - (bool)formulasOfType:(unsigned long long)arg1 areAllStaticWithCalcEngine:(id)arg2 inEntity:(struct __CFUUID { }*)arg3; - (id)init; - (id)initWithArchive:(const struct ChartMediatorFormulaStorage { int (**x1)(); struct UnknownFieldSet { struct vector<google::protobuf::UnknownField, std::__1::allocator<google::protobuf::UnknownField> > {} *x_2_1_1; } x2; unsigned int x3[1]; int x4; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_5_1_1; int x_5_1_2; int x_5_1_3; int x_5_1_4; } x5; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_6_1_1; int x_6_1_2; int x_6_1_3; int x_6_1_4; } x6; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_7_1_1; int x_7_1_2; int x_7_1_3; int x_7_1_4; } x7; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_8_1_1; int x_8_1_2; int x_8_1_3; int x_8_1_4; } x8; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_9_1_1; int x_9_1_2; int x_9_1_3; int x_9_1_4; } x9; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_10_1_1; int x_10_1_2; int x_10_1_3; int x_10_1_4; } x10; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_11_1_1; int x_11_1_2; int x_11_1_3; int x_11_1_4; } x11; int x12; }*)arg1 unarchiver:(id)arg2; - (id)initWithChartFormulaStorage:(id)arg1; - (id)initWithDirection:(int)arg1; - (bool)isEqualToFormulaStorage:(id)arg1; - (bool)labelFormulasAreAllStaticWithCalcEngine:(id)arg1 inEntity:(struct __CFUUID { }*)arg2; - (id)mutableCopyWithZone:(struct _NSZone { }*)arg1; - (unsigned long long)numberOfDataFormulas; - (unsigned long long)numberOfGroupsWithCalcEngine:(id)arg1 inEntity:(struct __CFUUID { }*)arg2; - (unsigned long long)numberOfSeries; - (unsigned long long)p_calculateNumberOfGroupsWithCalcEngine:(id)arg1 inEntity:(struct __CFUUID { }*)arg2; - (struct __CFDictionary { }*)p_cfDictionary; - (void)saveToArchive:(struct ChartMediatorFormulaStorage { int (**x1)(); struct UnknownFieldSet { struct vector<google::protobuf::UnknownField, std::__1::allocator<google::protobuf::UnknownField> > {} *x_2_1_1; } x2; unsigned int x3[1]; int x4; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_5_1_1; int x_5_1_2; int x_5_1_3; int x_5_1_4; } x5; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_6_1_1; int x_6_1_2; int x_6_1_3; int x_6_1_4; } x6; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_7_1_1; int x_7_1_2; int x_7_1_3; int x_7_1_4; } x7; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_8_1_1; int x_8_1_2; int x_8_1_3; int x_8_1_4; } x8; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_9_1_1; int x_9_1_2; int x_9_1_3; int x_9_1_4; } x9; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_10_1_1; int x_10_1_2; int x_10_1_3; int x_10_1_4; } x10; struct RepeatedPtrField<TSCE::FormulaArchive> { void **x_11_1_1; int x_11_1_2; int x_11_1_3; int x_11_1_4; } x11; int x12; }*)arg1 archiver:(id)arg2; - (unsigned long long)seriesLabelFormulaType; @end
95.302326
1,062
0.763543
[ "vector" ]
8f39eabd730b5ac2293ad03af309a2abb52bc1a9
5,116
h
C
examples/cpp/lib/opc_client.h
birgerjohansson/fadecandy
242360f7fbb902ea16c7690d7e06c40bdcc066be
[ "MIT" ]
959
2015-01-06T08:55:11.000Z
2022-03-26T04:45:33.000Z
examples/cpp/lib/opc_client.h
birgerjohansson/fadecandy
242360f7fbb902ea16c7690d7e06c40bdcc066be
[ "MIT" ]
83
2015-03-12T15:32:53.000Z
2022-03-21T05:25:36.000Z
examples/cpp/lib/opc_client.h
birgerjohansson/fadecandy
242360f7fbb902ea16c7690d7e06c40bdcc066be
[ "MIT" ]
352
2015-01-04T06:50:19.000Z
2022-03-28T19:00:23.000Z
/* * Tiny and fast C++ client for Open Pixel Control * * Copyright (c) 2014 Micah Elizabeth Scott <micah@scanlime.org> * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include <vector> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> #include <signal.h> class OPCClient { public: OPCClient(); ~OPCClient(); bool resolve(const char *hostport, int defaultPort = 7890); bool write(const uint8_t *data, ssize_t length); bool write(const std::vector<uint8_t> &data); bool tryConnect(); bool isConnected(); struct Header { uint8_t channel; uint8_t command; uint8_t length[2]; void init(uint8_t channel, uint8_t command, uint16_t length) { this->channel = channel; this->command = command; this->length[0] = length >> 8; this->length[1] = (uint8_t)length; } uint8_t *data() { return (uint8_t*) &this[1]; } const uint8_t *data() const { return (uint8_t*) &this[1]; } // Use a Header() to manipulate packet data in a std::vector static Header& view(std::vector<uint8_t> &data) { return *(Header*) &data[0]; } static const Header& view(const std::vector<uint8_t> &data) { return *(Header*) &data[0]; } }; // Commands static const uint8_t SET_PIXEL_COLORS = 0; private: int fd; struct sockaddr_in address; bool connectSocket(); void closeSocket(); }; /***************************************************************************************** * Implementation *****************************************************************************************/ inline OPCClient::OPCClient() { fd = -1; memset(&address, 0, sizeof address); } inline OPCClient::~OPCClient() { closeSocket(); } inline void OPCClient::closeSocket() { if (isConnected()) { close(fd); fd = -1; } } inline bool OPCClient::resolve(const char *hostport, int defaultPort) { fd = -1; char *host = strdup(hostport); char *colon = strchr(host, ':'); int port = defaultPort; bool success = false; if (colon) { *colon = '\0'; port = strtol(colon + 1, 0, 10); } if (port) { struct addrinfo *addr; getaddrinfo(*host ? host : "localhost", 0, 0, &addr); for (struct addrinfo *i = addr; i; i = i->ai_next) { if (i->ai_family == PF_INET) { memcpy(&address, i->ai_addr, sizeof address); address.sin_port = htons(port); success = true; break; } } freeaddrinfo(addr); } free(host); return success; } inline bool OPCClient::isConnected() { return fd > 0; } inline bool OPCClient::tryConnect() { return isConnected() || connectSocket(); } inline bool OPCClient::write(const uint8_t *data, ssize_t length) { if (!tryConnect()) { return false; } while (length > 0) { int result = send(fd, data, length, 0); if (result <= 0) { closeSocket(); return false; } length -= result; data += result; } return true; } inline bool OPCClient::write(const std::vector<uint8_t> &data) { return write(&data[0], data.size()); } inline bool OPCClient::connectSocket() { fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (connect(fd, (struct sockaddr*) &address, sizeof address) < 0) { closeSocket(); return false; } int flag = 1; setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*) &flag, sizeof flag); #ifdef SO_NOSIGPIPE flag = 1; setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (char*) &flag, sizeof flag); #else signal(SIGPIPE, SIG_IGN); #endif return true; }
24.834951
91
0.585027
[ "vector" ]
8f43e4ebdafbe05439a662197e16d418301b1248
1,424
h
C
BSP_img/geom/Line2.h
Miracle2333/BSPPN
f29182972fd4a13c47d5fb08b7e4faea2aabd77d
[ "MIT" ]
null
null
null
BSP_img/geom/Line2.h
Miracle2333/BSPPN
f29182972fd4a13c47d5fb08b7e4faea2aabd77d
[ "MIT" ]
null
null
null
BSP_img/geom/Line2.h
Miracle2333/BSPPN
f29182972fd4a13c47d5fb08b7e4faea2aabd77d
[ "MIT" ]
null
null
null
#pragma once #include "Point2.h" #include <vector> #include <limits> class Line2 { public: Point2 point; Vector2 direction; std::vector<Point2 *> consensus_set; // ---------------------------------------------------------------------------------------------------- // public: inline Line2() : point(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()), direction(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()), consensus_set(std::vector<Point2 *>()) {} inline Line2(Point2 point, Vector2 direction) : point(point), direction(direction), consensus_set(std::vector<Point2 *>()) { Normalize(); } // ---------------------------------------------------------------------------------------------------- // // < 0: left // = 0: on the line // > 0: right double EstimateSide2D(const Point2 p) const { return direction.x*(point.y - p.y) + direction.y*(p.x - point.x); } inline void Normalize() { direction.Normalize(); } inline Line2 ParallelLine(const double &distance) const { return Line2(point + distance * direction.PerpendicularCW(), direction); } }; // ---------------------------------------------------------------------------------------------------- // // Writes Line2 line to output stream os. inline std::ostream & operator<<(std::ostream &os, const Line2 &line) { os << line.point << " " << line.direction; return os; }
23.344262
107
0.520365
[ "vector" ]
8f4c76a54ff93d50615abd42610ab8f6d350e629
1,416
h
C
neurvps/models/cpp/deform_conv_cpu.h
keatonkraiger/neurvps
c0b5176dbc4472f0ac8c0e8b77348b63622940c5
[ "MIT" ]
181
2020-07-10T12:45:59.000Z
2022-03-16T14:51:35.000Z
src/cpu/deform_conv_cpu.h
Jerrypiglet/Deformable-im2col-unfold-Deformable-Convolution-V2-PyTorch
b7598e95507d1848081f1bb315c67059555e14af
[ "MIT" ]
40
2020-08-21T02:47:51.000Z
2022-01-17T14:02:55.000Z
src/cpu/deform_conv_cpu.h
Jerrypiglet/Deformable-im2col-unfold-Deformable-Convolution-V2-PyTorch
b7598e95507d1848081f1bb315c67059555e14af
[ "MIT" ]
42
2020-09-14T12:53:48.000Z
2022-03-27T16:57:58.000Z
#pragma once #include <torch/extension.h> at::Tensor deform_conv_cpu_forward(const at::Tensor &input, const at::Tensor &weight, const at::Tensor &bias, const at::Tensor &offset, const int kernel_h, const int kernel_w, const int stride_h, const int stride_w, const int pad_h, const int pad_w, const int dilation_h, const int dilation_w, const int group, const int deformable_group, const int im2col_step); std::vector<at::Tensor> deform_conv_cpu_backward(const at::Tensor &input, const at::Tensor &weight, const at::Tensor &bias, const at::Tensor &offset, const at::Tensor &grad_output, const int kernel_h, const int kernel_w, const int stride_h, const int stride_w, const int pad_h, const int pad_w, const int dilation_h, const int dilation_w, const int group, const int deformable_group, const int im2col_step);
35.4
51
0.450565
[ "vector" ]
8f51b296397285b1da86f310743a63857621a9b6
4,739
c
C
ATMega162/graphics/ui.c
stemnic/TTK4155-Embedded-Project
3958a653c3095b35ae98054215e32ceb985b348c
[ "MIT" ]
null
null
null
ATMega162/graphics/ui.c
stemnic/TTK4155-Embedded-Project
3958a653c3095b35ae98054215e32ceb985b348c
[ "MIT" ]
null
null
null
ATMega162/graphics/ui.c
stemnic/TTK4155-Embedded-Project
3958a653c3095b35ae98054215e32ceb985b348c
[ "MIT" ]
null
null
null
/* * ui.c * * Created: 20/09/2019 12:33:10 * Author: Einar */ #include "oled_buffer.h" #include "ui.h" #include "simulator.h" #include "../drivers/io.h" #include "../drivers/oled.h" #include "../drivers/eeprom.h" #include <stdlib.h> uint8_t listSel = 0; uint8_t listLen = 0; int16_t ballx = -50; int8_t dirball = 1; uint8_t ballcnt = 0; uint8_t *lengths; uint8_t rtrigg = 0; uint8_t ltrigg = 0; uint8_t last_rtrigg = 0; uint8_t last_ltrigg = 0; uint8_t wipe_state = 0; /* Select the element of the main-menu list at given index Simply inverts the line, which gives a clear impression of index */ void ui_list_select(uint8_t row) { for (uint8_t j = 0; j < lengths[row] * 8 + 4; j++) { draw_data_at(row * 8 + 32, 63 - lengths[row] * 4 - 2 + j, 0xFF, 1, OLED_ADDR_INVERT); } } /* Init the ui-list with a given list of strings, with length len */ void ui_list_init(char **options, uint8_t len) { lengths = malloc(len); for (uint8_t i = 0; i < len; i++) { uint8_t len = 0; while (options[i][len] != '\0') len++; lengths[i] = len; draw_string_at(i * 8 + 32, 63-len * 4, options[i], FONT8x8, OLED_ADDR_LAYER); } listLen = len; listSel = 0; ui_list_select(listSel); } void ui_scores_init(uint16_t *run_scores, uint16_t *sim_scores) { wipe_state = 0; draw_string_at(0, 8, "Live", FONT8x8, OLED_ADDR_LAYER); for (uint8_t i = 0; i < 5; i++) { draw_num(i * 8 + 8, 0, run_scores[i], 0, OLED_ADDR_LAYER); } draw_string_at(0, 71, "Sim", FONT8x8, OLED_ADDR_LAYER); for (uint8_t i = 0; i < 5; i++) { draw_num(i * 8 + 8, 63, sim_scores[i], 0, OLED_ADDR_LAYER); } fill_box(52, 72, 63, 127, OLED_ADDR_LAYER); draw_string_at(54, 80, "Wipe", FONT8x8, OLED_ADDR_DISABLE); } void ui_scores_button() { if (wipe_state == 0) { fill_box(52, 72, 63, 127, OLED_ADDR_LAYER); draw_string_at(54, 80, "Sure?", FONT8x8, OLED_ADDR_DISABLE); wipe_state++; } else { wipe_state = 0; uint16_t run_scores[5] = {0, 0, 0, 0, 0}; uint16_t sim_scores[5] = {0, 0, 0, 0, 0}; wipe_scores(); wipe_buffer(); ui_scores_init(run_scores, sim_scores); } } /* Update the list with the given value of joystick_trigger, 1 to increment selection, -1 to decrement */ void ui_list_update(int8_t joystick_trigger) { if (joystick_trigger != 0 && (joystick_trigger != 1 || listSel > 0) && (joystick_trigger != -1 || listSel < listLen - 1)) { ui_list_select(listSel); ui_list_select(listSel -= joystick_trigger); } } /* Return the current selected list index */ uint8_t get_list_pos() { return listSel; } /* Draw a big number in the UI, for debug */ void ui_draw_big_number(uint8_t num) { draw_num(16, 90, num, 1, OLED_ADDR_LAYER); } /* Draw a big racket to the left and right of the screen, shifting them based on button presses */ void ui_draw_rackets(uint8_t left, uint8_t right) { if (last_ltrigg != ltrigg && left) { draw_image_at(last_ltrigg ? 4 : 0, 0, RACKET, 0, 32, 64, OLED_ADDR_DISABLE); last_ltrigg = ltrigg; } if (last_rtrigg != rtrigg && right) { draw_image_at(last_rtrigg ? 91 : 95, 0, RACKET, 1, 32, 64, OLED_ADDR_DISABLE); last_rtrigg = rtrigg; } if (left) { draw_image_at(ltrigg ? 4 : 0, 0, RACKET, 0, 32, 64, OLED_ADDR_LAYER); } if (right) { draw_image_at(rtrigg ? 91 : 95, 0, RACKET, 1, 32, 64, OLED_ADDR_LAYER); } } /* Tick for the UI-menu, updates the ball graphic The ball follows a simple parabolic curve */ void ui_menu_tick(uint8_t frames) { #ifndef DEBUG ballcnt = 0; draw_circle(5 + (ballx * ballx) / 125, 63 + ballx, 3, 1, OLED_ADDR_DISABLE); ballx += dirball * frames * 2; draw_circle(5 + (ballx * ballx) / 125, 63 + ballx, 3, 1, OLED_ADDR_LAYER); if (ballx >= 50) dirball = -1; if (ballx <= -50) dirball = 1; if (ballx < -30) ui_draw_rackets(1, 0); if (ballx > 30) ui_draw_rackets(0, 1); #endif } /* Initialize the menu with a given list of menu entries of length len */ void ui_menu_init(char **list, uint8_t len) { ui_list_init(list, len); ui_draw_rackets(1, 1); } /* Update menu graphics with controller input object */ void ui_menu_update(controller_input_t *_input) { controller_input_t input = *(_input); ui_list_update(input.joystick_trigger); uint8_t lch = 0; uint8_t rch = 0; if (input.button_one_changed) { ltrigg = input.button_one_value; lch = 1; } if (input.button_two_changed) { rtrigg = input.button_two_value; rch = 1; } ui_draw_rackets(lch, rch); } /* Tick the simulator with given input and actor position */ void ui_simulator_update(controller_input_t *_input, uint8_t pos) { #ifndef DEBUG controller_input_t input = *(_input); sim_update_actor_angle(255 - input.slider_two_value); if (input.joystick_button_changed && input.joystick_button) { sim_trigger_solenoid(); } sim_update_pos(pos / 2.8 + 20); #endif }
28.377246
124
0.682633
[ "object" ]
8f5211e0baef7ec21df6a12316ff5a034a6829c8
2,720
h
C
message/generation/swift-mt-generation/repository/SR2018/parsers/SwiftMtParser_MT398Listener.h
Yanick-Salzmann/message-converter-c
6dfdf56e12f19e0f0b63ee0354fda16968f36415
[ "MIT" ]
null
null
null
message/generation/swift-mt-generation/repository/SR2018/parsers/SwiftMtParser_MT398Listener.h
Yanick-Salzmann/message-converter-c
6dfdf56e12f19e0f0b63ee0354fda16968f36415
[ "MIT" ]
null
null
null
message/generation/swift-mt-generation/repository/SR2018/parsers/SwiftMtParser_MT398Listener.h
Yanick-Salzmann/message-converter-c
6dfdf56e12f19e0f0b63ee0354fda16968f36415
[ "MIT" ]
null
null
null
#include "repository/ISwiftMtParser.h" #include "SwiftMtMessage.pb.h" #include <vector> #include <string> #include "BaseErrorListener.h" #include "SwiftMtParser_MT398Lexer.h" // Generated from C:/programming/message-converter-c/message/generation/swift-mt-generation/repository/SR2018/grammars/SwiftMtParser_MT398.g4 by ANTLR 4.7.2 #pragma once #include "antlr4-runtime.h" #include "SwiftMtParser_MT398Parser.h" namespace message::definition::swift::mt::parsers::sr2018 { /** * This interface defines an abstract listener for a parse tree produced by SwiftMtParser_MT398Parser. */ class SwiftMtParser_MT398Listener : public antlr4::tree::ParseTreeListener { public: virtual void enterMessage(SwiftMtParser_MT398Parser::MessageContext *ctx) = 0; virtual void exitMessage(SwiftMtParser_MT398Parser::MessageContext *ctx) = 0; virtual void enterBh(SwiftMtParser_MT398Parser::BhContext *ctx) = 0; virtual void exitBh(SwiftMtParser_MT398Parser::BhContext *ctx) = 0; virtual void enterBh_content(SwiftMtParser_MT398Parser::Bh_contentContext *ctx) = 0; virtual void exitBh_content(SwiftMtParser_MT398Parser::Bh_contentContext *ctx) = 0; virtual void enterAh(SwiftMtParser_MT398Parser::AhContext *ctx) = 0; virtual void exitAh(SwiftMtParser_MT398Parser::AhContext *ctx) = 0; virtual void enterAh_content(SwiftMtParser_MT398Parser::Ah_contentContext *ctx) = 0; virtual void exitAh_content(SwiftMtParser_MT398Parser::Ah_contentContext *ctx) = 0; virtual void enterUh(SwiftMtParser_MT398Parser::UhContext *ctx) = 0; virtual void exitUh(SwiftMtParser_MT398Parser::UhContext *ctx) = 0; virtual void enterTr(SwiftMtParser_MT398Parser::TrContext *ctx) = 0; virtual void exitTr(SwiftMtParser_MT398Parser::TrContext *ctx) = 0; virtual void enterSys_block(SwiftMtParser_MT398Parser::Sys_blockContext *ctx) = 0; virtual void exitSys_block(SwiftMtParser_MT398Parser::Sys_blockContext *ctx) = 0; virtual void enterSys_element(SwiftMtParser_MT398Parser::Sys_elementContext *ctx) = 0; virtual void exitSys_element(SwiftMtParser_MT398Parser::Sys_elementContext *ctx) = 0; virtual void enterSys_element_key(SwiftMtParser_MT398Parser::Sys_element_keyContext *ctx) = 0; virtual void exitSys_element_key(SwiftMtParser_MT398Parser::Sys_element_keyContext *ctx) = 0; virtual void enterSys_element_content(SwiftMtParser_MT398Parser::Sys_element_contentContext *ctx) = 0; virtual void exitSys_element_content(SwiftMtParser_MT398Parser::Sys_element_contentContext *ctx) = 0; virtual void enterMt(SwiftMtParser_MT398Parser::MtContext *ctx) = 0; virtual void exitMt(SwiftMtParser_MT398Parser::MtContext *ctx) = 0; }; } // namespace message::definition::swift::mt::parsers::sr2018
40.597015
156
0.802574
[ "vector" ]
6bcae60fc45298630e36e35c1a8863aa325f5b63
1,521
h
C
include/object_tracking_2D/EdgeTracker.h
jih189/object_detection_ros
026803cbb9a12da47f524cb59670d348152bec25
[ "BSD-3-Clause" ]
49
2015-04-24T18:26:03.000Z
2018-05-31T09:27:38.000Z
include/object_tracking_2D/EdgeTracker.h
jih189/object_detection_ros
026803cbb9a12da47f524cb59670d348152bec25
[ "BSD-3-Clause" ]
5
2015-04-13T16:00:38.000Z
2018-03-06T05:47:10.000Z
include/object_tracking_2D/EdgeTracker.h
jih189/object_detection_ros
026803cbb9a12da47f524cb59670d348152bec25
[ "BSD-3-Clause" ]
32
2015-01-19T16:15:35.000Z
2018-05-20T16:34:08.000Z
#pragma once #include <iostream> #include <string> #include <vector> #include "opencv/cv.h" #include "TooN/TooN.h" #include "TooN/SVD.h" // for SVD #include "TooN/so3.h" // for special orthogonal group #include "TooN/se3.h" // for special Euclidean group #include "TooN/wls.h" // for weighted least square #include "ObjectModel.h" using namespace TooN; class CEdgeTracker { public: CEdgeTracker(int width, int height, CvMat* intrinsic, int maxd, bool limityrot = false); ~CEdgeTracker(void); void getEstimatedPoseIRLS(CvMat* pose_cur, CvMat* pose_pre, std::vector<CObjectModel::SamplePoint>& vSamplePt, int vs); void getEstimatedPoseIRLS_cov(CvMat* pose_cur, CvMat* pose_pre, std::vector<CObjectModel::SamplePoint>& vSamplePt, int vs,CvMat* covariance_pre); void PF_getJacobianAndError(CvMat* Mprev, std::vector<CObjectModel::SamplePoint>& vSamplePt, CvMat** J, CvMat** e); void PF_getError(CvMat* Mprev, std::vector<CObjectModel::SamplePoint>& vSamplePt, CvMat** e); Vector<6> calcJacobian(CvPoint3D32f& pts3, CvPoint2D32f& pts2, CvPoint2D32f& ptsnv, double ptsd, const SE3 &E); inline CvMat* getPose() { return pose_; } inline CvMat* getVariance() { return covariance_;} CvMat* Update(CvMat* J, CvMat* e, int NumOfVisibleSamplePoint, CvMat *covariance_old); protected: CvMat *pose_; CvMat* covariance_; int width_; int height_; CvMat* intrinsic_; int maxd_; bool limityrot_; Matrix<2,2> ja_; float alpha_; };
35.372093
148
0.707429
[ "vector" ]
6bcb3fc5c1fb56bf144eb9382e6f15b7a4b103ea
2,564
h
C
Ko-Fi Engine/Source/P_Actor.h
Chamfer-Studios/Ko-Fi-Engine
cdc7fd9fd8c30803ac2e3fe0ecaf1923bbd7532e
[ "MIT" ]
2
2022-02-26T23:35:53.000Z
2022-03-04T16:25:18.000Z
Ko-Fi Engine/Source/P_Actor.h
Chamfer-Studios/Ko-Fi-Engine
cdc7fd9fd8c30803ac2e3fe0ecaf1923bbd7532e
[ "MIT" ]
2
2022-02-23T09:41:09.000Z
2022-03-08T08:46:21.000Z
Ko-Fi Engine/Source/P_Actor.h
Chamfer-Studios/Ko-Fi-Engine
cdc7fd9fd8c30803ac2e3fe0ecaf1923bbd7532e
[ "MIT" ]
1
2022-03-03T18:41:32.000Z
2022-03-03T18:41:32.000Z
//#pragma once //#ifndef __P_ACTOR_H__ //#define __P_ACTOR_H__ //#include "MathGeoLib/Math/float3.h" //#include "P_Collision.h" //#include <functional> // //struct CollisionActor { //public: // inline void SetTransform(Transform* transform) { this->transform = transform; } // inline void SetCollider(Collider* collider) { this->collider = collider; } // inline void SetIsTrigger(bool isTrigger) { this->isTrigger = isTrigger; } // inline bool SetIsDynamic(bool isDynamic) { return this->isDynamic; } // // inline Transform* GetTransform() { return this->transform; } // inline bool GetIsTrigger() { return this->isTrigger; } // inline bool GetIsDynamic() { return this->isDynamic; } // inline std::function<void(Collision&, float)> OnCollision() { return this->onCollision; } // inline Collider* GetCollider() { return this->collider; } //protected: // Transform* transform = nullptr; // Collider* collider; // bool isTrigger = false; // bool isStatic = false; // bool isDynamic = true; // std::function<void(Collision&, float)> onCollision; //}; // //struct RigidBody : CollisionActor //{ //public: // inline void SetGravity(float3 gravity) { this->gravity = gravity; } // inline void SetForce(float3 force) { this->force = force; } // inline void SetVelocity(float3 velocity) { this->velocity = velocity; } // inline void SetMass(float mass) { this->mass = mass; } // inline void SetTakesGravity(bool takesGravity) { this->takesGravity = takesGravity; } // inline void SetStaticFriction(float staticFriction) { this->staticFriction = staticFriction; } // inline void SetDynamicFriction(float dynamicFriction) { this->dynamicFriction = dynamicFriction; } // inline void SetRestitution(float restitution) { this->restitution = restitution; } // // inline float3 GetGravity() { return this->gravity; } // inline float3 GetForce() { return this->force; } // inline float3 GetVelocity() { return this->velocity; } // inline float GetMass() { return this->mass; } // inline bool GetTakesGravity() { return this->takesGravity; } // inline float GetStaticFriction() { return this->staticFriction; } // inline float GetDynamicFriction() { return this->dynamicFriction; } // inline float GetRestitution() { return this->restitution; } // // //private: // float3 gravity = float3(0,0,0); //gravitational acceleration // float3 force = float3::zero; // float3 velocity = float3::zero; // // float mass = 1.0f; // bool takesGravity = true; // // float staticFriction = 0.0f; // float dynamicFriction = 0.0f; // float restitution = 0.0f; //}; //#endif // !__P_ACTOR_H__ //
39.446154
101
0.711388
[ "transform" ]
6bd084afbd4679ea3ebac02b05d0b669d48c6b61
26,735
h
C
inc/util/palCacheLayer.h
GPUOpen-Drivers/pal
bcec463efe5260776d486a5e3da0c549bc0a75d2
[ "MIT" ]
268
2017-12-22T11:03:10.000Z
2022-03-31T15:37:31.000Z
inc/util/palCacheLayer.h
GPUOpen-Drivers/pal
bcec463efe5260776d486a5e3da0c549bc0a75d2
[ "MIT" ]
79
2017-12-22T12:26:52.000Z
2022-03-30T13:06:30.000Z
inc/util/palCacheLayer.h
GPUOpen-Drivers/pal
bcec463efe5260776d486a5e3da0c549bc0a75d2
[ "MIT" ]
92
2017-12-22T12:21:16.000Z
2022-03-29T22:34:17.000Z
/* *********************************************************************************************************************** * * Copyright (c) 2018-2021 Advanced Micro Devices, Inc. All Rights Reserved. * * 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. * **********************************************************************************************************************/ /** *********************************************************************************************************************** * @file palCacheLayer.h * @brief PAL cache-utility library cache layer common interface declaraion. *********************************************************************************************************************** */ #pragma once #include "palUtil.h" #include "palMetroHash.h" #include "palHashSet.h" #include "palSysMemory.h" namespace Pal { class IDevice; class IPlatform; } namespace Util { /// Common declaration for an expected 128-bit hash value using Hash128 = MetroHash::Hash; class ICacheLayer; class IArchiveFile; class IPlatformKey; /** *********************************************************************************************************************** * @brief Lookup result from ICacheLayer::Query, entryId is specific to the cache layer it was queried from *********************************************************************************************************************** */ struct QueryResult { ICacheLayer* pLayer; ///< Pointer to the layer that responded to the query Hash128 hashId; ///< HashId referenced during query size_t dataSize; ///< Size of original data submitted to cache size_t storeSize; ///< Size of data stored in cache, which was possibly compressed down from dataSize. size_t promotionSize; ///< Size to use when storing in another cache union { uint64 entryId; ///< Unique entry id corresponding to found result void* pEntryInfo; ///< Private pointer to entry data corresponding to found result } context; }; /** *********************************************************************************************************************** * @brief Common cache layer interface. Allows all cache layers to be interfaced with agnostically *********************************************************************************************************************** */ class ICacheLayer { public: // Link Policy bitfield. Provides a hint as to how this layer should interact with the next enum LinkPolicy : uint32 { // Common flags PassData = 0x1 << 0, ///< Data should be passed to (or read from) the next layer PassCalls = 0x1 << 1, ///< Function calls should be passed to the next layer Skip = 0x1 << 2, ///< Load/Store Operations should skip this layer // Store flags BatchStore = 0x1 << 10, ///< Delay passing data to the next layer and batch for later // Load flags LoadOnQuery = 0x1 << 16 ///< Load data from the next layer at query time rather than load }; // Query flags bitfield. Specify some behaviors to Query(). enum QueryFlags : uint32 { ReserveEntryOnMiss = 0x1 << 0, ///< Reserve an entry on miss AcquireEntryRef = 0x1 << 1, ///< Increase the cache entry reference, equivalent of AcquireCacheRef(), so ///< user must call ReleaseCacheRef() when not needing that entry. }; /// Query for data by hash key /// /// @param [in] pHashId 128-bit precomputed hash used as a reference id for the cache entry /// @param [in] policy Allow Query to specify policy, like promote data from file layer to memory cache layer. /// @param [in] flags Specify some behaviors to Query /// @param [out] pQuery Query result containing the entry id and buffer size needed to call ICacheLayer::Load() /// /// @return Success if the hash id was found. Otherwise, one of the following may be returned: /// + Reserved returned if ReserveEntryOnMiss was specified, the entry was not found, and the entry was /// successfully reserved. /// + NotFound if no values was found for the given hash /// + NotReady if the hash ID was found but the data is not yet ready /// + ErrorInvalidPointer if pQuery or pHashId are nullptr /// + ErrorUnknown if there is an internal error. /// + Unsupported if the cache does not support it. /// /// @note If pQuery->dataSize == 0, the result should be treated as if NotReady were returned virtual Result Query( const Hash128* pHashId, uint32 policy, uint32 flags, QueryResult* pQuery) = 0; /// Store data with corresponding hash key /// /// @param [in] pHashId 128-bit precomputed hash used as a reference id for the cache entry /// @param [in] pData Data to be stored in the cache /// @param [in] dataSize Size of data to be stored /// @param [in] storeSize Size of the buffer to be used to store the data. /// Usually 0 except in cases of compression. /// This allows us to *actually* store less than dataSize, /// while tracking that we've stored dataSize worth of information. /// /// @return Success if the data was stored under the hash id. Otherwise, one of the following may be returned: /// + AlreadyExists if a value already exists for the given hash ID. Previous data will not be overwritten. /// + Unsupported if the cache cannot complete the operation (eg: read-only or does not support reservation) /// + ErrorInvalidPointer if pHashId is nullptr. /// + ErrorUnknown if there is an internal error. /// /// @note The id in the cache could be already reserved by Query with ReserveEntryOnMiss. Later, when the data is /// ready, call `Store` again with the same hash ID but with valid pData and datasize. The expected return /// code in this situation is expected to be Success and not AlreadyExists. virtual Result Store( const Hash128* pHashId, const void* pData, size_t dataSize, size_t storeSize = 0) = 0; /// Accquire a long-lived reference to a cache object /// /// @note The result populated by QueryResult will not be evicted until `ReleaseCacheRef()` is called. /// /// The primary purpose is a "zero-copy" style hit where the underlying data in the cache can be directly /// accessed by the caller using `ppData`. However in cases where the internal representation is not usable /// this function may still serve as a way to ensure that a delayed call to `Load()` will not result in /// failure due to eviction where supported. /// /// @param [in] pQuery Query result containing the entry id and buffer size needed to call ICacheLayer::Load() /// /// @return Success if the responder is able to provide an externally managed lifetime reference. Otherwise, one of /// the following may be returned: /// + ErrorInvalidPointer if pQuery or pHashId are nullptr /// + NotFound if entryId is not present in cache /// + Unsupported if the cache does not support external references /// + ErrorUnknown if there is an internal error. /// /// @note It is considered undefined behaviour to call function on any layer that did not directly respond to your /// query as pQuery->pLayer virtual Result AcquireCacheRef( const QueryResult* pQuery) { PAL_ASSERT(pQuery != nullptr); PAL_ASSERT(this == pQuery->pLayer); return Result::Unsupported; } /// Decriment the external reference count for a cache item /// /// @param [in] pQuery Query previously passed into ICacheLayer::AccquireCacheRef() /// /// @return Success if the cache is able to release the external reference. Otherwise, one of the following may be /// returned: /// + Unsupported if the cache does not support external references /// + ErrorUnknown if there is an internal error. /// /// @note: The pointer to memory previously returned by AccquireCacheRef() is not garunteed to be valid after /// this call and MUST not be accessed. /// /// @note It is considered undefined behaviour to call function on any layer that did not directly respond to your /// query as pQuery->pLayer virtual Result ReleaseCacheRef( const QueryResult* pQuery) { PAL_ASSERT(pQuery != nullptr); PAL_ASSERT(this == pQuery->pLayer); return Result::Unsupported; } /// Return the pointer to internal cache memory if available /// /// @param [in] pQuery Result returned from ICacheLayer::Query() /// @param [out] ppData Pointer to raw cache storage /// /// @return Success if the cache is able to accquire a read-lock on ppData. Otherwise, one of the following may be /// returned: /// + NotFound if entryId is not present in cache /// + NotReady if entryId is in the cache but the data cannot be accessed yet /// + ErrorInvalidArgument if the entry has not previously been incremented by AddCacheRef() /// + Unsupported if the cache (or entry) does not support internal data access /// + ErrorUnknown if there is an internal error. /// /// @note ppData is intended to be a "Zero-copy" return from this function. No additional buffer allocations /// should be performed. Data within the cache layer may be in an internal format and not suitable for /// direct use. In this case ppData MUST be set to nullptr and Result::Unsupported returned. /// /// @note It is considered undefined behaviour to call function on any layer that did not directly respond to your /// query as pQuery->pLayer virtual Result GetCacheData( const QueryResult* pQuery, const void** ppData) { PAL_ASSERT(pQuery != nullptr); PAL_ASSERT(ppData != nullptr); PAL_ASSERT(this == pQuery->pLayer); *ppData = nullptr; return Result::Unsupported; } /// Wait for an entry that is not ready. /// /// @param [in] pHashId 128-bit precomputed hash used as a reference id for the cache entry /// /// @return Success if the entry is ready. Otherwise, one of the following may be returned: /// + NotFound if no values was found for the given hash /// + Unsupported if the cache does not support explicit eviction /// + ErrorInvalidValue if the entry is bad. /// + ErrorInvalidPointer if pHashId is nullptr. /// + ErrorUnknown if there is an internal error. virtual Result WaitForEntry( const Hash128* pHashId) { return Result::Unsupported; } /// Explicitly remove data with corresponding hash key /// /// @param [in] pHashId 128-bit precomputed hash used as a reference id for the cache entry /// /// @return Success if the data was stored under the hash id. Otherwise, one of the following may be returned: /// + NotFound if no values was found for the given hash /// + Unsupported if the cache does not support explicit eviction /// + ErrorInvalidPointer if pHashId is nullptr. /// + ErrorUnknown if there is an internal error. virtual Result Evict( const Hash128* pHashId) { return Result::Unsupported; } /// Mark the Entry as bad with corresponding hash key /// An Entry could be reserved first and update data later, if the data is generated failly, we need mark previous /// reserved Entry as bad. After it's marked bad, it will be evicted when its refcount becomes zero. /// /// @param [in] pHashId 128-bit precomputed hash used as a reference id for the cache entry /// /// @return Success if the data is marked bad under the hash id. Otherwise, one of the following may be returned: /// + NotFound if no values was found for the given hash /// + Unsupported if the cache does not support this behavior /// + ErrorInvalidPointer if pHashId is nullptr. /// + ErrorUnknown if there is an internal error. virtual Result MarkEntryBad( const Hash128* pHashId) { return Result::Unsupported; } /// Load data from cache to buffer by entry id retrieved from Query() /// /// @param [in] pQuery Result returned from ICacheLayer::Query() /// @param [out] pBuffer Buffer to place data from cache /// /// @return Success if data was loaded to the provided buffer. Otherwise, one of the following may be returned: /// + NotFound if entryId is not present in cache /// + NotReady if entryId is reserved in the cache but the data is not ready /// + ErrorInvalidPointer if pBuffer is nullptr /// + ErrorUnknown if there is an internal error. virtual Result Load( const QueryResult* pQuery, void* pBuffer) = 0; /// Link one cache layer on top of another, does not transfer ownership of the object /// /// @param [in] pNextLayer ICacheLayer object to become the next layer under this layer /// /// @return Success if the cache layers were linked together. Otherwise, one of the following may be returned: /// + ErrorInvalidPointer if pNextLayer is nullptr /// + ErrorUnknown if there is an internal error. virtual Result Link( ICacheLayer* pNextLayer) = 0; /// Set the layer's link policy for loading /// /// @param [in] loadPolicy LinkPolicy flags indicating preferred behaviour on Query/Load where available /// /// @return Success if the load policy was applied. Otherwise, one of the following may be returned: /// + ErrorInvalidValue if an invalid policy is provided /// + ErrorUnknown if there is an internal error. virtual Result SetLoadPolicy( uint32 loadPolicy) = 0; /// Set the layer's link policy for storing /// /// @param [in] storePolicy LinkPolicy flags indicating preferred behaviour on Store where available /// /// @return Success if the load policy was applied. Otherwise, one of the following may be returned: /// + ErrorInvalidValue if an invalid policy is provided /// + ErrorUnknown if there is an internal error. virtual Result SetStorePolicy( uint32 storePolicy) = 0; /// Retrieve the layer beneath this layer /// /// @return Pointer to the layer linked beneath this layer. Nullptr if layer is not linked. virtual ICacheLayer* GetNextLayer() const = 0; /// Retrieve the layer's link policy for loading /// /// @return Link policy used during Load(). virtual uint32 GetLoadPolicy() const = 0; /// Retrieve the layer's link policy for storing /// /// @return Link policy used during Store(). virtual uint32 GetStorePolicy() const = 0; /// Destroy Cache Layer virtual void Destroy() = 0; protected: ICacheLayer() {} virtual ~ICacheLayer() {} private: PAL_DISALLOW_COPY_AND_ASSIGN(ICacheLayer); }; /** *********************************************************************************************************************** * @brief Common cache layer construction information *********************************************************************************************************************** */ struct CacheLayerBaseCreateInfo { AllocCallbacks* pCallbacks; ///< Memory allocation callbacks to be used by the caching layer for all long term /// storage. Allocation callbacks must be valid for the life of the cache layer }; /** *********************************************************************************************************************** * @brief Information needed to create an in-memory key-value store *********************************************************************************************************************** */ struct MemoryCacheCreateInfo { CacheLayerBaseCreateInfo baseInfo; ///< Base cache layer creation info size_t maxObjectCount; ///< Maximum number of entries in cache size_t maxMemorySize; ///< Maximum total size of entries in cache bool evictOnFull; ///< Whether or not the cache should evict entries based on LRU to /// make room for new ones bool evictDuplicates; ///< Whether or not the cache should evict entries with a duplicate hash }; /// Get the memory size for a in-memory cache layer /// /// @param [in] pCreateInfo Information about cache being created /// /// @return Minimum size of memory buffer needed to pass to CreateMemoryCacheLayer() size_t GetMemoryCacheLayerSize( const MemoryCacheCreateInfo* pCreateInfo); /// Create an in-memory key-value caching layer /// /// @param [in] pCreateInfo Information about cache being created /// @param [in] pPlacementAddr Pointer to the location where the interface should be constructed. There must /// be as much size available here as reported by calling GetMemoryCacheLayerSize(). /// @param [out] ppCacheLayer Cache layer interface. On failure this value will be set to nullptr. /// /// @returns Success if the cache layer was created. Otherwise, one of the following errors may be returned: /// + ErrorUnknown if there is an internal error. Result CreateMemoryCacheLayer( const MemoryCacheCreateInfo* pCreateInfo, void* pPlacementAddr, ICacheLayer** ppCacheLayer); /// Get memoryCache entries number and total cache data size /// /// @param [in] pCacheLayer memory cache layer to be serialized. /// @param [out] pCurCount return entries number in memoryCache. /// @param [out] pCurSize return total cache data size in memoryCache. /// /// @return Success if serialize is successful. Result GetMemoryCacheLayerCurSize( ICacheLayer* pCacheLayer, size_t* pCurCount, size_t* pCurSize); /// Get all hashIds in entries in memoryCache /// /// @param [in] pCacheLayer memory cache layer to be serialized. /// @param [in] curCount return entries number in memoryCache. /// @param [out] pHashIds return total cache HashIds in memoryCache. /// /// @return Success if serialize is successful. Result GetMemoryCacheLayerHashIds( ICacheLayer* pCacheLayer, size_t curCount, Hash128* pHashIds); /** *********************************************************************************************************************** * @brief Information needed to create an archive file backed key-value store *********************************************************************************************************************** */ struct ArchiveFileCacheCreateInfo { CacheLayerBaseCreateInfo baseInfo; ///< Base cache layer creation info. IArchiveFile* pFile; ///< Archive file to use for storage, must exist for the lifetime of the /// cache layer. May be shared between multiple layers but no internal /// thread safety is provided. const IPlatformKey* pPlatformKey; ///< Optional platform key, allows for data stored to the archive file /// to be keyed to a specific driver/platform fingerprint. uint32 dataTypeId; ///< Optional 32-bit data type identifier, allows heterogenous data to be /// stored within an archive file. }; /// Get the memory size for a archive file backed cache layer /// /// @param [in] pCreateInfo Information about cache being created /// /// @return Minimum size of memory buffer needed to pass to CreateArchiveFileCacheLayer() size_t GetArchiveFileCacheLayerSize( const ArchiveFileCacheCreateInfo* pCreateInfo); /// Create an archive file backed caching layer /// /// @param [in] pCreateInfo Information about cache being created /// @param [in] pPlacementAddr Pointer to the location where the interface should be constructed. There must /// be as much size available here as reported by calling /// GetArchiveFileCacheLayerSize(). /// @param [out] ppCacheLayer Cache layer interface. On failure this value will be set to nullptr. /// /// @returns Success if the cache layer was created. Otherwise, one of the following errors may be returned: /// + ErrorUnknown if there is an internal error. Result CreateArchiveFileCacheLayer( const ArchiveFileCacheCreateInfo* pCreateInfo, void* pPlacementAddr, ICacheLayer** ppCacheLayer); /** *********************************************************************************************************************** * @brief Information needed to create a pipeline content tracker *********************************************************************************************************************** */ struct TrackingCacheCreateInfo { AllocCallbacks* pCallbacks; ///< Memory allocation callbacks to be used by the caching layer for all long term /// storage. Allocation callbacks must be valid for the life of the cache layer }; using TrackedHashSet = HashSet< Hash128, ForwardAllocator>; using TrackedHashIter = TrackedHashSet::Iterator; using GetTrackedHashes = TrackedHashIter(*)(const ICacheLayer*); /// Get the memory size for a pipeline tracking cache layer /// /// @return Minimum size of memory buffer needed to pass to CreateTrackingCacheLayer() size_t GetTrackingCacheLayerSize(); /// Create a pipeline tracking cache layer /// /// @param [in] pCreateInfo Information about cache being created /// @param [in] pPlacementAddr Pointer to the location where the interface should be constructed. There /// must be as much size available here as reported by calling /// GetTrackingCacheLayerSize(). /// @param [out] ppCacheLayer Cache layer interface. On failure this value will be set to nullptr. /// @param [out] ppGetTrackedHashes Function pointer for entry retrieval. On failure this value will be set to /// nullptr. /// /// @returns Success if the cache layer was created. Otherwise, one of the following errors may be returned: /// + ErrorUnknown if there is an internal error. Result CreateTrackingCacheLayer( const TrackingCacheCreateInfo* pCreateInfo, void* pPlacementAddr, ICacheLayer** ppCacheLayer, GetTrackedHashes* ppGetTrackedHashes); /** *********************************************************************************************************************** * @brief Information needed to create a compressing cache layer *********************************************************************************************************************** */ struct CompressingCacheLayerCreateInfo { AllocCallbacks* pCallbacks; ///< Memory allocation callbacks to be used by the caching layer for all long term /// storage. Allocation callbacks must be valid for the life of the cache layer bool useHighCompression; ///< True if we want to use the high compression codec, /// which takes a bit more time to compress but decompresses just as fast. bool decompressOnly; ///< True if we want to use the layer as a pass-through to support reading of any /// existing compressed data. }; /// Get the memory size for a compressing cache layer /// /// @return Minimum size of memory buffer needed to pass to CreateTrackingCacheLayer() size_t GetCompressingCacheLayerSize(); /// Create a compressing cache layer /// /// @param [in] pCreateInfo Information about cache being created /// @param [in] pPlacementAddr Pointer to the location where the interface should be constructed. There /// must be as much size available here as reported by calling /// GetTrackingCacheLayerSize(). /// @param [out] ppCacheLayer Cache layer interface. On failure this value will be set to nullptr. /// /// @returns Success if the cache layer was created. Otherwise, one of the following errors may be returned: /// + ErrorUnknown if there is an internal error. Result CreateCompressingCacheLayer( const CompressingCacheLayerCreateInfo* pCreateInfo, void* pPlacementAddr, ICacheLayer** ppCacheLayer); } // namespace Util
49.509259
120
0.595923
[ "object" ]
6bd94befb68a53785a6872268c89951c78e71546
3,561
h
C
weex_core/Source/include/JavaScriptCore/bytecode/DataFormat.h
sunshl/incubator-weex
40ae49e40c3dd725d6c546451075bd6e90001c9d
[ "Apache-2.0" ]
2
2017-10-18T01:36:31.000Z
2018-05-07T23:00:21.000Z
weex_core/Source/include/JavaScriptCore/bytecode/DataFormat.h
sunshl/incubator-weex
40ae49e40c3dd725d6c546451075bd6e90001c9d
[ "Apache-2.0" ]
4
2020-07-17T17:32:27.000Z
2021-09-01T18:49:48.000Z
weex_core/Source/include/JavaScriptCore/bytecode/DataFormat.h
sunshl/incubator-weex
40ae49e40c3dd725d6c546451075bd6e90001c9d
[ "Apache-2.0" ]
5
2019-05-28T11:48:42.000Z
2020-05-15T07:31:55.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. */ #pragma once #include <wtf/Assertions.h> namespace JSC { // === DataFormat === // // This enum tracks the current representation in which a value is being held. // Values may be unboxed primitives (int32, double, or cell), or boxed as a JSValue. // For boxed values, we may know the type of boxing that has taken place. // (May also need bool, array, object, string types!) enum DataFormat { DataFormatNone = 0, DataFormatInt32 = 1, DataFormatInt52 = 2, // Int52's are left-shifted by 16 by default. DataFormatStrictInt52 = 3, // "Strict" Int52 means it's not shifted. DataFormatDouble = 4, DataFormatBoolean = 5, DataFormatCell = 6, DataFormatStorage = 7, DataFormatJS = 8, DataFormatJSInt32 = DataFormatJS | DataFormatInt32, DataFormatJSDouble = DataFormatJS | DataFormatDouble, DataFormatJSCell = DataFormatJS | DataFormatCell, DataFormatJSBoolean = DataFormatJS | DataFormatBoolean, // Marker deliminating ordinary data formats and OSR-only data formats. DataFormatOSRMarker = 32, // Special data formats used only for OSR. DataFormatDead = 33, // Implies jsUndefined(). }; inline const char* dataFormatToString(DataFormat dataFormat) { switch (dataFormat) { case DataFormatNone: return "None"; case DataFormatInt32: return "Int32"; case DataFormatInt52: return "Int52"; case DataFormatStrictInt52: return "StrictInt52"; case DataFormatDouble: return "Double"; case DataFormatCell: return "Cell"; case DataFormatBoolean: return "Boolean"; case DataFormatStorage: return "Storage"; case DataFormatJS: return "JS"; case DataFormatJSInt32: return "JSInt32"; case DataFormatJSDouble: return "JSDouble"; case DataFormatJSCell: return "JSCell"; case DataFormatJSBoolean: return "JSBoolean"; case DataFormatDead: return "Dead"; default: RELEASE_ASSERT_NOT_REACHED(); return "Unknown"; } } inline bool isJSFormat(DataFormat format, DataFormat expectedFormat) { ASSERT(expectedFormat & DataFormatJS); return (format | DataFormatJS) == expectedFormat; } inline bool isJSInt32(DataFormat format) { return isJSFormat(format, DataFormatJSInt32); } inline bool isJSDouble(DataFormat format) { return isJSFormat(format, DataFormatJSDouble); } inline bool isJSCell(DataFormat format) { return isJSFormat(format, DataFormatJSCell); } inline bool isJSBoolean(DataFormat format) { return isJSFormat(format, DataFormatJSBoolean); } } // namespace JSC namespace WTF { class PrintStream; void printInternal(PrintStream&, JSC::DataFormat); } // namespace WTF
28.717742
84
0.706262
[ "object" ]
6be3ee9cd84e2ba30f0aa3ff4b95b3d798e4fc7c
1,519
h
C
libj++/include/java/lang/Iterable.h
dihedron/libjpp
11888c455221d82e538b9738d8cefdf41ae0c5bc
[ "BSD-3-Clause" ]
null
null
null
libj++/include/java/lang/Iterable.h
dihedron/libjpp
11888c455221d82e538b9738d8cefdf41ae0c5bc
[ "BSD-3-Clause" ]
null
null
null
libj++/include/java/lang/Iterable.h
dihedron/libjpp
11888c455221d82e538b9738d8cefdf41ae0c5bc
[ "BSD-3-Clause" ]
null
null
null
/* * Iterable.h * Copyright (C) 2016 Andrea Funto' <dihedron.dev@gmail.com> * See LICENSE for details and terms of use. */ #ifndef JAVA_LANG_ITERABLE #define JAVA_LANG_ITERABLE #include <java/lang/Object.h> #include <java/util/Iterator.h> namespace java { namespace lang { /// A pure virtual class implementing the Iterable interface. template<typename T> interface Iterable { public: /// Returns a reference to the shared Interface object. /// /// Returns the shared reference to the Interface object for /// this interface; all object share the same instance, which /// is a local static constant object: this makes sure that /// the Interface object is initialised as soon as this interface /// is referenced, and that there is no problem with concurrent /// access since it can only be instantiated once (see /// Scott Meyers, Effective C++, Item 4). /// \return a reference to the shared Interface object. static java::lang::Interface const & klass(); /// The method implementing the logic to return an iterator. /// /// When an object implements interface Iterable, it must /// provide a way to generate iterators that allow navigation /// over the set of items contained in the object. The general /// contract of the method run is that it returns an iterator /// allowing to change the elements on the collection in place. virtual java::util::Iterator<T> * iterator() = 0; }; } } #endif // JAVA_LANG_ITERABLE
33.755556
68
0.698486
[ "object" ]
6be7b6a12f72e393d2497f404e775fbeb34e9a3b
372
h
C
libs/core/src/core/nlp_sentence.h
madeso/euphoria
59b72d148a90ae7a19e197e91216d4d42f194fd5
[ "MIT" ]
24
2015-07-27T14:32:18.000Z
2021-11-15T12:11:31.000Z
libs/core/src/core/nlp_sentence.h
madeso/euphoria
59b72d148a90ae7a19e197e91216d4d42f194fd5
[ "MIT" ]
27
2021-07-09T21:18:40.000Z
2021-07-14T13:39:56.000Z
libs/core/src/core/nlp_sentence.h
madeso/euphoria
59b72d148a90ae7a19e197e91216d4d42f194fd5
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <string> #include <functional> #include <istream> namespace euphoria::core { using TextSentence = std::vector<std::string>; using OnSentenceFunction = std::function<void(const TextSentence&)>; bool parse_sentences(std::istream& data, OnSentenceFunction on_sentence); std::string sentence_to_string(const TextSentence& s); }
16.173913
68
0.766129
[ "vector" ]
6be83afce67df3e33e14ffcad1144a31640abf92
55,471
c
C
clicks/canfd6/lib/src/canfd6.c
StrahinjaJacimovic/mikrosdk_click_v2
f8002047c96605f340957a0d3fdbde33706d02ac
[ "MIT" ]
31
2020-10-02T14:15:14.000Z
2022-03-24T08:33:21.000Z
clicks/canfd6/lib/src/canfd6.c
greghol/mikrosdk_click_v2
76e5dec265dce5fca72c4b93f77afd668dde5dfa
[ "MIT" ]
4
2020-10-27T14:05:00.000Z
2022-03-10T09:38:57.000Z
clicks/canfd6/lib/src/canfd6.c
greghol/mikrosdk_click_v2
76e5dec265dce5fca72c4b93f77afd668dde5dfa
[ "MIT" ]
32
2020-11-28T07:56:42.000Z
2022-03-14T19:42:29.000Z
/**************************************************************************** ** Copyright (C) 2020 MikroElektronika d.o.o. ** Contact: https://www.mikroe.com/contact ** ** 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. ****************************************************************************/ /*! * @file canfd6.c * @brief CAN FD 6 Click Driver. */ #include "canfd6.h" // ------------------------------------------------------------- PRIVATE MACROS /** * @brief Dummy data. * @details Definition of dummy data. */ #define DUMMY 0x00 /** * @brief Bitmask last 4 bits. * @details Bitmask for masking least significant 4 bits. */ #define DEV_BITMASK_LASTB_4 0x0F /** * @brief Bitmask last 5 bits. * @details Bitmask for masking least significant 5 bits. */ #define DEV_BITMASK_LASTB_5 0x1F /** * @brief Bitmask last 6 bits. * @details Bitmask for masking least significant 6 bits. */ #define DEV_BITMASK_LASTB_6 0x3F /** * @brief Bitmask last 7 bits. * @details Bitmask for masking least significant 7 bits. */ #define DEV_BITMASK_LASTB_7 0x7F /** * @brief Bitmask last 8 bits. * @details Bitmask for masking a whole least significant byte. */ #define DEV_BITMASK_LASTB_8 0xFF /** * @brief Bitmask last 9 bits. * @details Bitmask for masking a least significant 9 bits. */ #define DEV_BITMASK_LASTB_9 0x1FF /** * @brief Bitmask last 6 bits of MSByte. * @details Bitmask for masking 6 bits of a most significant byte (uint16_t). */ #define DEV_BITMASK_FIRSTB_6 0x3F00 /** * @brief Bitmask half word. * @details Bitmask for masking a half of the word (uint32_t). */ #define DEV_BITMASK_HWORD 0x0000FFFF /** * @brief Bitmask last 29 bits. * @details Bitmask for masking a least significant 29 bits. */ #define DEV_BITMASK_LASTB_29 0x1FFFFFFF /** * @brief Bitmask second byte. * @details Bitmask for masking a second byte (uint32_t). */ #define DEV_BITMASK_SECOND_BYTE 0x00FF0000 /** * @brief Bitmask all. * @details Bitmask for masking a whole word. */ #define DEV_BITMASK_ALL 0xFFFFFFFF /** * @brief Mask lsb. * @details Mask for a least significant bit. */ #define DEV_MASK_BIT_1 0x01 /** * @brief Mask bit 30. * @details Mask for bit 30 from a whole word. */ #define DEV_MASK_BIT_30 0x20000000 /** * @brief Mask bit 31. * @details Mask for bit 31 from a whole word. */ #define DEV_MASK_BIT_31 0x40000000 /** * @brief Mask bit 32. * @details Mask for bit 32 from a whole word. */ #define DEV_MASK_BIT_32 0x80000000 /** * @brief Bitmask normal ID. * @details Bitmask for a normal header ID. */ #define DEV_BITMASK_NORMAL_ID 0x1FFC0000 /** * @brief Bitmask extended ID. * @details Bitmask for a extended header ID. */ #define DEV_BITMASK_EXTENDED_ID 0x1FFFFFFF /** * @brief Bitmask DLC. * @details Bitmask for a header DLC data. */ #define DEV_BITMASK_DLC 0x000F0000 /** * @brief Bitmask BRS. * @details Bitmask for a header BRS data. */ #define DEV_BITMASK_BRS 0x00100000 /** * @brief Bitmask FDF. * @details Bitmask for a header FDF data. */ #define DEV_BITMASK_FDF 0x00200000 /** * @brief Bitmask FIDX. * @details Bitmask for a header FIDX data. */ #define DEV_BITMASK_FIDX 0x7F000000 /** * @brief Write opcode. * @details Opcode for initialization of write data to the device. */ #define DEV_WRITE_OPCODE 0x61 /** * @brief Read opcode. * @details Opcode for initialization of read data to the device. */ #define DEV_READ_OPCODE 0x41 #ifdef CANFD6_MCAN_CACHE_CONFIGURATION /** * @brief MCAN Cache. * @details If caching is enabled, defines the necessary variables. */ uint32_t CANFD6_MCAN_CACHE[ 9 ]; #endif // ---------------------------------------------- PRIVATE FUNCTION DECLARATIONS //----------------------------------------------------------------------------- // Write Functions //----------------------------------------------------------------------------- /** * @brief CAN FD 6 single word write function. * @details This function writes a single 32-bit word to a desired address. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * @param[in] address : A 16-bit address of the destination register. * @param[in] data_in : A 32-bit word of data to write to the destination register. * * @note None. */ static void dev_write_word ( canfd6_t *ctx, uint16_t address, uint32_t data_in ); /** * @brief CAN FD 6 burst write init function. * @details This function is the start, where the register address and number of * words are transmitted. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * @param[in] address : A 16-bit address of the destination register. * @param[in] words : The number of 4-byte words that will be transferred. * * @note None. */ static void dev_burst_write_init ( canfd6_t *ctx, uint16_t address, uint8_t words ); /** * @brief CAN FD 6 burst write data function. * @details This function writes a single word at a time. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * @param[in] data_in : A 32-bit word of data to write to the destination register. * * @note None. */ static void dev_burst_write_data ( canfd6_t *ctx, uint32_t data_in ); /** * @brief CAN FD 6 burst write terminate function. * @details This function ends the burst transaction by pulling CS high. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * * @note None. */ static void dev_burst_write_terminate ( canfd6_t *ctx ); //----------------------------------------------------------------------------- // Read Functions //----------------------------------------------------------------------------- /** * @brief CAN FD 6 single word read function. * @details This function reads a single 32-bit from a desired address. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * @param[in] address : A 16-bit address of the destination register. * @return A 32-bit word of data from source register. * * @note None. */ static uint32_t dev_read_word ( canfd6_t *ctx, uint16_t address ); /** * @brief CAN FD 6 burst read init function. * @details This function is the start, where the register address and number of * words are transmitted. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * @param[in] address : A 16-bit address of the destination register. * @param[in] words : The number of 4-byte words that will be transferred. * * @note None. */ static void dev_burst_read_init ( canfd6_t *ctx, uint16_t address, uint8_t words ); /** * @brief CAN FD 6 burst read data function. * @details This function reads a single word at a time. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * @return A 32-bit single data word that is read at a time. * * @note None. */ static uint32_t dev_burst_read_data ( canfd6_t *ctx ); /** * @brief CAN FD 6 burst read terminate function. * @details This function ends the burst transaction by pulling CS high. * @param[in] ctx : Click context object. * See #canfd6_t object definition for detailed explanation. * * @note None. */ static void dev_burst_read_terminate ( canfd6_t *ctx ); // ------------------------------------------------ PUBLIC FUNCTION DEFINITIONS void canfd6_cfg_setup ( canfd6_cfg_t *cfg ) { cfg->sck = HAL_PIN_NC; cfg->miso = HAL_PIN_NC; cfg->mosi = HAL_PIN_NC; cfg->cs = HAL_PIN_NC; cfg->wkr = HAL_PIN_NC; cfg->rst = HAL_PIN_NC; cfg->wkp = HAL_PIN_NC; cfg->int_pin = HAL_PIN_NC; cfg->spi_speed = 100000; cfg->spi_mode = SPI_MASTER_MODE_0; cfg->cs_polarity = SPI_MASTER_CHIP_SELECT_POLARITY_ACTIVE_LOW; } err_t canfd6_init ( canfd6_t *ctx, canfd6_cfg_t *cfg ) { spi_master_config_t spi_cfg; spi_master_configure_default( &spi_cfg ); spi_cfg.sck = cfg->sck; spi_cfg.miso = cfg->miso; spi_cfg.mosi = cfg->mosi; ctx->chip_select = cfg->cs; if ( spi_master_open( &ctx->spi, &spi_cfg ) == SPI_MASTER_ERROR ) { return SPI_MASTER_ERROR; } if ( spi_master_set_default_write_data( &ctx->spi, DUMMY ) == SPI_MASTER_ERROR ) { return SPI_MASTER_ERROR; } if ( spi_master_set_mode( &ctx->spi, cfg->spi_mode ) == SPI_MASTER_ERROR ) { return SPI_MASTER_ERROR; } if ( spi_master_set_speed( &ctx->spi, cfg->spi_speed ) == SPI_MASTER_ERROR ) { return SPI_MASTER_ERROR; } spi_master_set_chip_select_polarity( cfg->cs_polarity ); spi_master_deselect_device( ctx->chip_select ); // It should contain the error status checking for every pin init. digital_out_init( &ctx->wkr, cfg->wkr ); digital_out_init( &ctx->rst, cfg->rst ); digital_out_init( &ctx->wkp, cfg->wkp ); digital_in_init( &ctx->int_pin, cfg->int_pin ); return SPI_MASTER_SUCCESS; } void canfd6_default_cfg ( canfd6_t *ctx ) { // Click default configuration. canfd6_rst_pin_state( ctx, CANFD6_PIN_STATE_LOW ); canfd6_wkr_pin_state( ctx, CANFD6_PIN_STATE_LOW ); canfd6_wkp_pin_state( ctx, CANFD6_PIN_STATE_LOW ); canfd6_device_clear_spierr( ctx ); canfd6_device_interrupt_enable_t canfd6_dev_ie = { 0 }; canfd6_device_configure_ie( ctx, &canfd6_dev_ie ); canfd6_device_interrupts_t canfd6_dev_ir = { 0 }; canfd6_device_read_interrupts( ctx, &canfd6_dev_ir ); if ( canfd6_dev_ir.PWRON ) { canfd6_device_clear_interrupts( ctx, &canfd6_dev_ir ); } canfd6_mcan_nominal_timing_simple_t canfd6_nominal_timing = { 0 }; canfd6_nominal_timing.nominal_bitrate_prescaler = 2; canfd6_nominal_timing.nominal_tqbefore_samplepoint = 32; canfd6_nominal_timing.nominal_tqafter_samplepoint = 8; canfd6_mcan_data_timing_simple_t canfd6_data_timing = { 0 }; canfd6_data_timing.data_bitrate_prescaler = 1; canfd6_data_timing.data_tqbefore_samplepoint = 15; canfd6_data_timing.data_tqafter_samplepoint = 5; canfd6_mcan_cccr_config_t canfd6_cccr_config = { 0 }; canfd6_cccr_config.FDOE = 1; canfd6_cccr_config.BRSE = 1; canfd6_mcan_global_filter_configuration_t canfd6_gfc = { 0 }; canfd6_gfc.RRFE = 1; canfd6_gfc.RRFS = 1; canfd6_gfc.ANFE = CANFD6_GFC_ACCEPT_INTO_RXFIFO0; canfd6_gfc.ANFS = CANFD6_GFC_ACCEPT_INTO_RXFIFO0; canfd6_mram_config_t canfd6_mram_configuration = { 0 }; canfd6_mram_configuration.sid_num_elements = 1; canfd6_mram_configuration.xid_num_elements = 1; canfd6_mram_configuration.rx0_num_elements = 5; canfd6_mram_configuration.rx0_element_size = CANFD6_MRAM_64_Byte_Data; canfd6_mram_configuration.rx1_num_elements = 0; canfd6_mram_configuration.rx1_element_size = CANFD6_MRAM_64_Byte_Data; canfd6_mram_configuration.rx_buf_num_elements = 0; canfd6_mram_configuration.rx_buf_element_size = CANFD6_MRAM_64_Byte_Data; canfd6_mram_configuration.tx_event_fifo_num_elements = 0; canfd6_mram_configuration.tx_buffer_num_elements = 2; canfd6_mram_configuration.tx_buf_element_size = CANFD6_MRAM_64_Byte_Data; canfd6_enable_protected_registers( ctx ); canfd6_configure_cccr_register( ctx, &canfd6_cccr_config ); canfd6_mcan_configure_globalfilter( ctx, &canfd6_gfc ); canfd6_mcan_configure_nominaltiming_simple( ctx, &canfd6_nominal_timing ); canfd6_mcan_configure_datatiming_simple( ctx, &canfd6_data_timing ); canfd6_mram_clear( ctx ); canfd6_mram_configure( ctx, &canfd6_mram_configuration ); canfd6_disable_protected_registers( ctx ); canfd6_mcan_interrupt_enable_t canfd6_mcan_ie = { 0 }; canfd6_mcan_ie.RF0NE = 1; canfd6_mcan_configure_interrupt_enable( ctx, &canfd6_mcan_ie ); canfd6_mcan_sid_filter_t canfd6_sid_id = { 0 }; canfd6_sid_id.SFT = CANFD6_SID_SFT_CLASSIC; canfd6_sid_id.SFEC = CANFD6_SID_SFEC_PRIORITYSTORERX0; canfd6_sid_id.SFID1 = 0x055; canfd6_sid_id.SFID2 = 0x7FF; canfd6_mcan_write_sid_filter( ctx, 0, &canfd6_sid_id ); canfd6_mcan_xid_filter_t canfd6_xid_id = { 0 }; canfd6_xid_id.EFT = CANFD6_XID_EFT_CLASSIC; canfd6_xid_id.EFEC = CANFD6_XID_EFEC_PRIORITYSTORERX0; canfd6_xid_id.EFID1 = 0x12345678; canfd6_xid_id.EFID2 = 0x1FFFFFFF; canfd6_mcan_write_xid_filter( ctx, 0, &canfd6_xid_id ); canfd6_dev_config_t canfd6_dev_config = { 0 }; canfd6_dev_config.SWE_DIS = 0; canfd6_dev_config.DEVICE_RESET = 0; canfd6_dev_config.WD_EN = 0; canfd6_dev_config.nWKRQ_CONFIG = 0; canfd6_dev_config.INH_DIS = 0; canfd6_dev_config.GPIO1_GPO_CONFIG = CANFD6_DEV_CONFIG_GPO1_MCAN_INT1; canfd6_dev_config.FAIL_SAFE_EN = 0; canfd6_dev_config.GPIO1_CONFIG = CANFD6_DEV_CONFIG_GPIO1_CONFIG_GPO; canfd6_dev_config.WD_ACTION = CANFD6_DEV_CONFIG_WDT_ACTION_nINT; canfd6_dev_config.WD_BIT_RESET = 0; canfd6_dev_config.nWKRQ_VOLTAGE = 0; canfd6_dev_config.GPO2_CONFIG = CANFD6_DEV_CONFIG_GPO2_NO_ACTION; canfd6_dev_config.CLK_REF = 1; canfd6_dev_config.WAKE_CONFIG = CANFD6_DEV_CONFIG_WAKE_BOTH_EDGES; canfd6_device_configure( ctx, &canfd6_dev_config ); canfd6_device_set_mode( ctx, CANFD6_DEVICE_MODE_NORMAL ); canfd6_mcan_clear_interrupts_all( ctx ); } void canfd6_wkr_pin_state ( canfd6_t *ctx, canfd6_pin_state_t state ) { digital_out_write( &ctx->wkr, state ); } void canfd6_rst_pin_state ( canfd6_t *ctx, canfd6_pin_state_t state ) { digital_out_write( &ctx->rst, state ); } void canfd6_wkp_pin_state ( canfd6_t *ctx, canfd6_pin_state_t state ) { digital_out_write( &ctx->wkp, state ); } uint8_t canfd6_get_int_pin ( canfd6_t *ctx ) { return digital_in_read( &ctx->int_pin ); } err_t canfd6_enable_protected_registers ( canfd6_t *ctx ) { uint8_t cnt_f; uint32_t read_val; uint32_t first_read; first_read = dev_read_word( ctx, CANFD6_REG_MCAN_CCCR ); if ( ( first_read & ( CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ) ) == ( CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ) ) { return CANFD6_OK; } first_read &= ~( CANFD6_REG_BITS_MCAN_CCCR_CSA | CANFD6_REG_BITS_MCAN_CCCR_CSR | CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ); for ( cnt_f = 5; cnt_f > 0; cnt_f-- ) { dev_write_word( ctx, CANFD6_REG_MCAN_CCCR, first_read | CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ); read_val = dev_read_word( ctx, CANFD6_REG_MCAN_CCCR ); if ( ( read_val & ( CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ) ) == ( CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ) ) { return CANFD6_OK; } else if ( cnt_f == 1 ) { return CANFD6_ERROR; } } return CANFD6_OK; } err_t canfd6_disable_protected_registers ( canfd6_t *ctx ) { uint8_t cnt_f; uint32_t read_val; read_val = dev_read_word( ctx, CANFD6_REG_MCAN_CCCR ); if ( ( read_val & CANFD6_REG_BITS_MCAN_CCCR_CCE ) == 0 ) { return CANFD6_OK; } for ( cnt_f = 5; cnt_f > 0; cnt_f-- ) { dev_write_word( ctx, CANFD6_REG_MCAN_CCCR, ( read_val & ~( CANFD6_REG_BITS_MCAN_CCCR_CSA | CANFD6_REG_BITS_MCAN_CCCR_CSR | CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ) ) ); read_val = dev_read_word( ctx, CANFD6_REG_MCAN_CCCR ); if ( ( read_val & CANFD6_REG_BITS_MCAN_CCCR_CCE ) == 0 ) { return CANFD6_OK; } else if ( cnt_f == 1 ) { return CANFD6_ERROR; } } return CANFD6_OK; } void canfd6_configure_cccr_register ( canfd6_t *ctx, canfd6_mcan_cccr_config_t *cccr_config ) { uint32_t value; value = cccr_config->word; value &= ~( CANFD6_REG_BITS_MCAN_CCCR_RESERVED_MASK | CANFD6_REG_BITS_MCAN_CCCR_CSA | CANFD6_REG_BITS_MCAN_CCCR_CCE | CANFD6_REG_BITS_MCAN_CCCR_INIT ); value |= ( CANFD6_REG_BITS_MCAN_CCCR_INIT | CANFD6_REG_BITS_MCAN_CCCR_CCE ); dev_write_word( ctx, CANFD6_REG_MCAN_CCCR, value ); } void canfd6_read_cccr_register ( canfd6_t *ctx, canfd6_mcan_cccr_config_t *cccr_config ) { cccr_config->word = dev_read_word( ctx, CANFD6_REG_MCAN_CCCR ); } void canfd6_mcan_read_datatimingfd_simple ( canfd6_t *ctx, canfd6_mcan_data_timing_simple_t *data_timing ) { uint32_t reg_data; reg_data = dev_read_word( ctx, CANFD6_REG_MCAN_DBTP ); data_timing->data_bitrate_prescaler = ( ( reg_data >> 16 ) & DEV_BITMASK_LASTB_5 ) + 1; data_timing->data_tqbefore_samplepoint = ( ( reg_data >> 8 ) & DEV_BITMASK_LASTB_5 ) + 2; data_timing->data_tqafter_samplepoint = ( ( reg_data >> 4 ) & DEV_BITMASK_LASTB_4 ) + 1; } void canfd6_mcan_read_datatimingfd_raw ( canfd6_t *ctx, canfd6_mcan_data_timing_raw_t *data_timing ) { uint32_t reg_data; reg_data = dev_read_word( ctx, CANFD6_REG_MCAN_DBTP ); data_timing->data_bitrate_prescaler = ( ( reg_data >> 16 ) & DEV_BITMASK_LASTB_5 ); data_timing->data_time_seg1_and_prop = ( ( reg_data >> 8 ) & DEV_BITMASK_LASTB_5 ); data_timing->data_time_seg2 = ( ( reg_data >> 4 ) & DEV_BITMASK_LASTB_4 ); data_timing->data_sync_jumpwidth = ( reg_data & DEV_BITMASK_LASTB_4 ); if ( reg_data & CANFD6_REG_BITS_MCAN_DBTP_TDC_EN ) { reg_data = dev_read_word( ctx, CANFD6_REG_MCAN_TDCR ); data_timing->tdc_offset = ( ( reg_data >> 8 ) & DEV_BITMASK_LASTB_7 ); data_timing->tdc_filter = ( reg_data & DEV_BITMASK_LASTB_7 ); } else { data_timing->tdc_offset = 0; data_timing->tdc_filter = 0; } } void canfd6_mcan_configure_datatiming_simple ( canfd6_t *ctx, canfd6_mcan_data_timing_simple_t *data_timing ) { uint32_t write_val; uint32_t tdco_write_val; uint32_t temp_val; temp_val = data_timing->data_bitrate_prescaler; if ( temp_val > 32 ) { temp_val = 32; } else if ( temp_val == 0 ) { temp_val = 1; } write_val = ( ( uint32_t )( temp_val - 1 ) ) << 16; temp_val = data_timing->data_tqbefore_samplepoint; if ( temp_val > 33 ) { temp_val = 33; } else if ( temp_val < 2 ) { temp_val = 2; } write_val |= ( ( uint32_t )( temp_val - 2 ) ) << 8; tdco_write_val = ( uint32_t )( temp_val - 1 ) << 8; temp_val = data_timing->data_tqafter_samplepoint; if ( temp_val > 16 ) { temp_val = 16; } else if ( temp_val == 0 ) { temp_val = 1; } write_val |= ( ( uint32_t )( temp_val - 1 ) ) << 4; write_val |= ( ( uint32_t )( temp_val - 1 ) ); write_val |= CANFD6_REG_BITS_MCAN_DBTP_TDC_EN; dev_write_word( ctx, CANFD6_REG_MCAN_DBTP, write_val ); dev_write_word( ctx, CANFD6_REG_MCAN_TDCR, tdco_write_val ); dev_write_word( ctx, CANFD6_REG_MCAN_TSCC, CANFD6_REG_BITS_MCAN_TSCC_COUNTER_EXTERNAL ); } void canfd6_mcan_configure_datatiming_raw ( canfd6_t *ctx, canfd6_mcan_data_timing_raw_t *data_timing ) { uint32_t write_val; write_val = ( ( uint32_t )( data_timing->data_bitrate_prescaler & DEV_BITMASK_LASTB_5 ) ) << 16; write_val |= ( ( uint32_t )( data_timing->data_time_seg1_and_prop & DEV_BITMASK_LASTB_5 ) ) << 8; write_val |= ( ( uint32_t )( data_timing->data_time_seg2 & DEV_BITMASK_LASTB_4 ) ) << 4; write_val |= ( ( uint32_t )( data_timing->data_sync_jumpwidth & DEV_BITMASK_LASTB_4 ) ); if ( ( data_timing->tdc_offset > 0 ) || ( data_timing->tdc_filter > 0 ) ) { write_val |= CANFD6_REG_BITS_MCAN_DBTP_TDC_EN; dev_write_word( ctx, CANFD6_REG_MCAN_DBTP, write_val ); write_val = ( uint32_t )( data_timing->tdc_offset & DEV_BITMASK_LASTB_7 ) << 8; write_val |= ( uint32_t )( data_timing->tdc_filter & DEV_BITMASK_LASTB_7 ); dev_write_word( ctx, CANFD6_REG_MCAN_TDCR, write_val ); } else { dev_write_word( ctx, CANFD6_REG_MCAN_DBTP, write_val ); } dev_write_word( ctx, CANFD6_REG_MCAN_TSCC, CANFD6_REG_BITS_MCAN_TSCC_COUNTER_EXTERNAL ); } void canfd6_mcan_read_nominaltiming_simple ( canfd6_t *ctx, canfd6_mcan_nominal_timing_simple_t *nom_timing ) { uint32_t read_val; read_val = dev_read_word( ctx, CANFD6_REG_MCAN_NBTP ); nom_timing->nominal_bitrate_prescaler = ( ( read_val >> 16 ) & DEV_BITMASK_LASTB_9 ) + 1; nom_timing->nominal_tqbefore_samplepoint = ( ( read_val >> 8 ) & DEV_BITMASK_LASTB_8 ) + 2; nom_timing->nominal_tqafter_samplepoint = ( read_val & DEV_BITMASK_LASTB_7 ) + 1; } void canfd6_mcan_read_nominaltiming_raw ( canfd6_t *ctx, canfd6_mcan_nominal_timing_raw_t *nom_timing ) { uint32_t read_val; read_val = dev_read_word( ctx, CANFD6_REG_MCAN_NBTP ); nom_timing->nominal_sync_jumpwidth = ( ( read_val >> 25 ) & DEV_BITMASK_LASTB_7 ); nom_timing->nominal_bitrate_prescaler = ( ( read_val >> 16 ) & DEV_BITMASK_LASTB_9 ); nom_timing->nominal_time_seg1_and_prop = ( ( read_val >> 8 ) & DEV_BITMASK_LASTB_8 ); nom_timing->nominal_time_seg2 = ( read_val & DEV_BITMASK_LASTB_7 ); } void canfd6_mcan_configure_nominaltiming_simple ( canfd6_t *ctx, canfd6_mcan_nominal_timing_simple_t *nom_timing ) { uint32_t write_val; uint32_t temp_val; temp_val = nom_timing->nominal_bitrate_prescaler; if ( temp_val > 512 ) { temp_val = 512; } else if ( temp_val == 0 ) { temp_val = 1; } write_val = ( ( uint32_t )( temp_val - 1 ) ) << 16; temp_val = nom_timing->nominal_tqbefore_samplepoint; if ( temp_val > 257 ) { temp_val = 257; } else if ( temp_val < 2 ) { temp_val = 2; } write_val |= ( ( uint32_t )( temp_val - 2 ) ) << 8; temp_val = nom_timing->nominal_tqafter_samplepoint; if ( temp_val > 128 ) { temp_val = 128; } else if ( temp_val < 2 ) { temp_val = 2; } write_val |= ( ( uint32_t )( temp_val - 1 ) ); write_val |= ( ( uint32_t )( temp_val - 1 ) ) << 25; dev_write_word( ctx, CANFD6_REG_MCAN_NBTP, write_val ); } void canfd6_mcan_configure_nominaltiming_raw ( canfd6_t *ctx, canfd6_mcan_nominal_timing_raw_t *nom_timing ) { uint32_t write_val; write_val = ( ( uint32_t )( nom_timing->nominal_sync_jumpwidth & DEV_BITMASK_LASTB_7 ) ) << 25; write_val |= ( ( uint32_t )( nom_timing->nominal_bitrate_prescaler & DEV_BITMASK_LASTB_9 ) ) << 16; write_val |= ( ( uint32_t )( nom_timing->nominal_time_seg1_and_prop ) ) << 8; write_val |= ( ( uint32_t )( nom_timing->nominal_time_seg2 & DEV_BITMASK_LASTB_7 ) ); dev_write_word( ctx, CANFD6_REG_MCAN_NBTP, write_val ); } void canfd6_mcan_configure_globalfilter ( canfd6_t *ctx, canfd6_mcan_global_filter_configuration_t *gfc ) { uint32_t write_val; write_val = ( gfc->word & CANFD6_REG_BITS_MCAN_GFC_MASK ); dev_write_word( ctx, CANFD6_REG_MCAN_GFC, write_val ); } err_t canfd6_mram_configure ( canfd6_t *ctx, canfd6_mram_config_t *mram_config ) { uint16_t start_address = 0x0000; uint32_t register_value = 0; uint32_t read_val = 0; uint8_t mram_val; mram_val = mram_config->sid_num_elements; if ( mram_val > 128 ) { mram_val = 128; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )( mram_val ) << 16 ) | ( ( uint32_t )start_address ); } start_address += ( 4 * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_SIDFC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_SIDFC ] = register_value; #endif mram_val = mram_config->xid_num_elements; if ( mram_val > 64 ) { mram_val = 64; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )( mram_val ) << 16 ) | ( ( uint32_t )start_address ); } start_address += ( 8 * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_XIDFC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_XIDFC ] = register_value; #endif mram_val = mram_config->rx0_num_elements; if ( mram_val > 64 ) { mram_val = 64; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )( mram_val ) << 16 ) | ( ( uint32_t )start_address ); register_value |= CANFD6_REG_BITS_MCAN_RXF0C_F0OM_OVERWRITE; } start_address += ( ( ( uint32_t )canfd6_mcan_txrxesc_data_byte_value( ( uint8_t )mram_config->rx0_element_size ) + 8 ) * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_RXF0C, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXF0C ] = register_value; #endif mram_val = mram_config->rx1_num_elements; if ( mram_val > 64 ) { mram_val = 64; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )( mram_val ) << 16 ) | ( ( uint32_t )start_address ); } start_address += ( ( ( uint32_t )canfd6_mcan_txrxesc_data_byte_value( ( uint8_t )mram_config->rx1_element_size ) + 8 ) * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_RXF1C, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXF1C ] = register_value; #endif mram_val = mram_config->rx_buf_num_elements; if ( mram_val > 64 ) { mram_val = 64; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )start_address ); } start_address += ( ( ( uint32_t )canfd6_mcan_txrxesc_data_byte_value( ( uint8_t )mram_config->rx_buf_element_size ) + 8 ) * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_RXBC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXBC ] = register_value; #endif mram_val = mram_config->tx_event_fifo_num_elements; if ( mram_val > 32 ) { mram_val = 32; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )( mram_val ) << 16 ) | ( ( uint32_t )start_address ); } start_address += ( 8 * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_TXEFC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_TXEFC ] = register_value; #endif mram_val = mram_config->tx_buffer_num_elements; if ( mram_val > 32 ) { mram_val = 32; } register_value = 0; if ( mram_val > 0 ) { register_value = ( ( uint32_t )( mram_val ) << 24 ) | ( ( uint32_t )start_address ); register_value |= CANFD6_REG_BITS_MCAN_TXBC_TFQM; } start_address += ( ( ( uint32_t )canfd6_mcan_txrxesc_data_byte_value( ( uint8_t )mram_config->tx_buf_element_size ) + 8 ) * ( uint16_t )mram_val ); dev_write_word( ctx, CANFD6_REG_MCAN_TXBC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_TXBC ] = register_value; #endif if ( ( start_address - 1 ) > ( CANFD6_MRAM_SIZE + CANFD6_REG_MRAM ) ) { return CANFD6_ERROR; } register_value = ( ( uint32_t )( mram_config->rx_buf_element_size ) << 8 ) | ( ( uint32_t )( mram_config->rx1_element_size ) << 4 ) | ( uint32_t )( mram_config->rx0_element_size ); dev_write_word( ctx, CANFD6_REG_MCAN_RXESC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXESC ] = register_value; #endif register_value = ( uint32_t )( mram_config->tx_buf_element_size ); dev_write_word( ctx, CANFD6_REG_MCAN_TXESC, register_value ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_TXESC ] = register_value; #endif return CANFD6_OK; } void canfd6_mram_clear ( canfd6_t *ctx ) { uint16_t cur_addr; const uint16_t end_addr = CANFD6_REG_MRAM + CANFD6_MRAM_SIZE; cur_addr = CANFD6_REG_MRAM; while ( cur_addr < end_addr ) { dev_write_word( ctx, cur_addr, 0 ); cur_addr += 4; } } uint8_t canfd6_mcan_read_nextfifo ( canfd6_t *ctx, canfd6_mcan_fifo_enum_t fifo_def, canfd6_mcan_rx_header_t *header, uint8_t data_payload[ ] ) { uint32_t rd_data; uint16_t start_address; uint8_t cnt_f; uint8_t get_index; uint8_t element_size; switch ( fifo_def ) { default: { rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXF0S ); if ( ( rd_data & DEV_BITMASK_LASTB_7 ) == 0 ) { return 0; } get_index = ( uint8_t )( ( rd_data & DEV_BITMASK_FIRSTB_6 ) >> 8 ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXF0C ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXF0C ); #endif start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXESC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXESC ); #endif rd_data &= 0x07; element_size = canfd6_mcan_txrxesc_data_byte_value( rd_data ); start_address += ( ( ( uint32_t )element_size + 8 ) * get_index ); break; } case CANFD6_RXFIFO1: { rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXF1S ); if ( ( rd_data & DEV_BITMASK_LASTB_7 ) == 0 ) { return 0; } get_index = ( uint8_t )( ( rd_data & DEV_BITMASK_FIRSTB_6 ) >> 8 ); #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXF1C ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXF1C ); #endif start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXESC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXESC ); #endif rd_data = ( rd_data & 0x70 ) >> 4; element_size = canfd6_mcan_txrxesc_data_byte_value( rd_data ); start_address += ( ( ( uint32_t )element_size + 8 ) * get_index ); break; } } dev_burst_read_init( ctx, start_address, 2 ); rd_data = dev_burst_read_data( ctx ); header->ESI = ( rd_data & DEV_MASK_BIT_32 ) >> 31; header->XTD = ( rd_data & DEV_MASK_BIT_31 ) >> 30; header->RTR = ( rd_data & DEV_MASK_BIT_30 ) >> 29; if ( header->XTD ) { header->ID = ( rd_data & DEV_BITMASK_EXTENDED_ID ); } else { header->ID = ( rd_data & DEV_BITMASK_NORMAL_ID ) >> 18; } rd_data = dev_burst_read_data( ctx ); dev_burst_read_terminate( ctx ); header->RXTS = ( rd_data & DEV_BITMASK_HWORD ); header->DLC = ( rd_data & DEV_BITMASK_DLC ) >> 16; header->BRS = ( rd_data & DEV_BITMASK_BRS ) >> 20; header->FDF = ( rd_data & DEV_BITMASK_FDF ) >> 21; header->FIDX = ( rd_data & DEV_BITMASK_FIDX ) >> 24; header->ANMF = ( rd_data & DEV_MASK_BIT_32 ) >> 31; if ( canfd6_mcan_dlc_to_bytes( header->DLC ) < element_size ) { element_size = canfd6_mcan_dlc_to_bytes( header->DLC ); } if ( element_size > 0 ) { dev_burst_read_init( ctx, start_address + 8, ( element_size + 3 ) >> 2 ); cnt_f = 0; while ( cnt_f < element_size ) { if ( ( cnt_f % 4 ) == 0 ) { rd_data = dev_burst_read_data( ctx ); } data_payload[ cnt_f ] = ( uint8_t )( ( rd_data >> ( ( cnt_f % 4 ) * 8 ) ) & DEV_BITMASK_LASTB_8 ); cnt_f++; if ( cnt_f > element_size ) { cnt_f = element_size; } } dev_burst_read_terminate( ctx ); } switch ( fifo_def ) { default: dev_write_word( ctx, CANFD6_REG_MCAN_RXF0A, get_index ); break; case CANFD6_RXFIFO1: dev_write_word( ctx, CANFD6_REG_MCAN_RXF1A, get_index ); break; } return cnt_f; } uint8_t canfd6_mcan_read_rxbuffer ( canfd6_t *ctx, uint8_t buf_index, canfd6_mcan_rx_header_t *header, uint8_t data_payload[ ] ) { uint32_t rd_data; uint16_t start_address; uint8_t cnt_f; uint8_t get_index; uint8_t element_size; get_index = buf_index; if ( get_index > 64 ) { get_index = 64; } #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXBC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXBC ); #endif start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_RXESC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_RXESC ); #endif rd_data = ( rd_data & 0x0700 ) >> 8; element_size = canfd6_mcan_txrxesc_data_byte_value( rd_data ); start_address += ( ( ( uint32_t )element_size + 8 ) * get_index ); dev_burst_read_init( ctx, start_address, 2 ); rd_data = dev_burst_read_data( ctx ); header->ESI = ( rd_data & DEV_MASK_BIT_32 ) >> 31; header->XTD = ( rd_data & DEV_MASK_BIT_31 ) >> 30; header->RTR = ( rd_data & DEV_MASK_BIT_30 ) >> 29; if ( header->XTD ) { header->ID = ( rd_data & DEV_BITMASK_EXTENDED_ID ); } else { header->ID = ( rd_data & DEV_BITMASK_NORMAL_ID ) >> 18; } rd_data = dev_burst_read_data( ctx ); dev_burst_read_terminate( ctx ); header->RXTS = ( rd_data & DEV_BITMASK_HWORD ); header->DLC = ( rd_data & DEV_BITMASK_DLC ) >> 16; header->BRS = ( rd_data & DEV_BITMASK_BRS ) >> 20; header->FDF = ( rd_data & DEV_BITMASK_FDF ) >> 21; header->FIDX = ( rd_data & DEV_BITMASK_FIDX ) >> 24; header->ANMF = ( rd_data & DEV_MASK_BIT_32 ) >> 31; if ( canfd6_mcan_dlc_to_bytes( header->DLC ) < element_size ) { element_size = canfd6_mcan_dlc_to_bytes( header->DLC ); } if ( element_size > 0 ) { dev_burst_read_init( ctx, start_address + 8, ( element_size + 3 ) >> 2 ); cnt_f = 0; while ( cnt_f < element_size ) { if ( ( cnt_f % 4 ) == 0 ) { rd_data = dev_burst_read_data( ctx ); } data_payload[ cnt_f ] = ( uint8_t )( ( rd_data >> ( ( cnt_f % 4 ) * 8 ) ) & DEV_BITMASK_LASTB_8 ); cnt_f++; if ( cnt_f > element_size ) { cnt_f = element_size; } } dev_burst_read_terminate( ctx ); } if ( get_index < 32 ) { dev_write_word( ctx, CANFD6_REG_MCAN_NDAT1, 1 << get_index ); } else { dev_write_word( ctx, CANFD6_REG_MCAN_NDAT2, 1 << ( get_index - 32 ) ); } return cnt_f; } uint32_t canfd6_mcan_write_txbuffer ( canfd6_t *ctx, uint8_t buf_index, canfd6_mcan_tx_header_t *header, uint8_t data_payload[ ] ) { uint32_t spi_data; uint16_t start_address; uint8_t cnt_f; uint8_t element_size; uint8_t temp; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION spi_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_TXBC ]; #else spi_data = dev_read_word( ctx, CANFD6_REG_MCAN_TXBC ); #endif start_address = ( uint16_t )( spi_data & DEV_BITMASK_HWORD ) + 0x8000; temp = ( uint8_t )( ( spi_data >> 24 ) & DEV_BITMASK_LASTB_6 ); element_size = temp > 32 ? 32 : temp; temp = ( uint8_t )( ( spi_data >> 16 ) & DEV_BITMASK_LASTB_6 ); element_size += temp > 32 ? 32 : temp; if ( buf_index > ( element_size - 1 ) ) { return 0; } #ifdef CANFD6_MCAN_CACHE_CONFIGURATION spi_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_TXESC ]; #else spi_data = dev_read_word( ctx, CANFD6_REG_MCAN_TXESC ); #endif element_size = canfd6_mcan_txrxesc_data_byte_value( spi_data & 0x07 ) + 8; start_address += ( ( uint32_t )element_size * buf_index ); element_size = ( canfd6_mcan_dlc_to_bytes( header->DLC & DEV_BITMASK_LASTB_4 ) + 8 ) >> 2; if ( canfd6_mcan_dlc_to_bytes( header->DLC & DEV_BITMASK_LASTB_4 ) % 4 ) { element_size += 1; } dev_burst_write_init( ctx, start_address, element_size ); spi_data = 0; spi_data |= ( ( uint32_t )header->ESI & DEV_MASK_BIT_1 ) << 31; spi_data |= ( ( uint32_t )header->XTD & DEV_MASK_BIT_1 ) << 30; spi_data |= ( ( uint32_t )header->RTR & DEV_MASK_BIT_1 ) << 29; if ( header->XTD ) spi_data |= ( ( uint32_t )header->ID & DEV_BITMASK_EXTENDED_ID ); else spi_data |= ( ( uint32_t )header->ID & 0x07FF ) << 18; dev_burst_write_data( ctx, spi_data ); spi_data = 0; spi_data |= ( ( uint32_t )header->DLC & DEV_BITMASK_LASTB_4 ) << 16; spi_data |= ( ( uint32_t )header->BRS & DEV_MASK_BIT_1 ) << 20; spi_data |= ( ( uint32_t )header->FDF & DEV_MASK_BIT_1 ) << 21; spi_data |= ( ( uint32_t )header->EFC & DEV_MASK_BIT_1 ) << 23; spi_data |= ( ( uint32_t )header->MM & DEV_BITMASK_LASTB_8 ) << 24; dev_burst_write_data( ctx, spi_data ); element_size = canfd6_mcan_dlc_to_bytes( header->DLC & DEV_BITMASK_LASTB_4 ); cnt_f = 0; while ( cnt_f < element_size ) { spi_data = 0; if ( ( element_size - cnt_f ) < 4 ) { while ( cnt_f < element_size ) { spi_data |= ( ( uint32_t )data_payload[ cnt_f ] << ( ( cnt_f % 4 ) * 8 ) ); cnt_f++; } dev_burst_write_data( ctx, spi_data ); } else { spi_data |= ( ( uint32_t )data_payload[ cnt_f++ ] ); spi_data |= ( ( uint32_t )data_payload[ cnt_f++ ] ) << 8; spi_data |= ( ( uint32_t )data_payload[ cnt_f++ ] ) << 16; spi_data |= ( ( uint32_t )data_payload[ cnt_f++ ] ) << 24; dev_burst_write_data( ctx, spi_data ); } if ( cnt_f > element_size ) { cnt_f = element_size; } } dev_burst_write_terminate( ctx ); return ( uint32_t )1 << buf_index; } err_t canfd6_mcan_transmit_buffer_contents ( canfd6_t *ctx, uint8_t buf_index ) { uint32_t write_val; uint8_t req_buf = buf_index; if ( req_buf > 31 ) { return CANFD6_ERROR; } write_val = 1 << req_buf; dev_write_word( ctx, CANFD6_REG_MCAN_TXBAR, write_val ); return CANFD6_OK; } err_t canfd6_mcan_write_sid_filter ( canfd6_t *ctx, uint8_t filter_index, canfd6_mcan_sid_filter_t *filter ) { uint32_t rd_data; uint16_t start_address; uint8_t get_index; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_SIDFC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_SIDFC ); #endif get_index = ( rd_data & DEV_BITMASK_SECOND_BYTE ) >> 16; if ( filter_index > get_index ) { return CANFD6_ERROR; } else { get_index = filter_index; } start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; start_address += ( get_index << 2 ); dev_write_word( ctx, start_address, filter->word ); return CANFD6_OK; } err_t canfd6_mcan_read_sid_filter ( canfd6_t *ctx, uint8_t filter_index, canfd6_mcan_sid_filter_t *filter ) { uint32_t rd_data; uint16_t start_address; uint8_t get_index; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_SIDFC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_SIDFC ); #endif get_index = ( rd_data & DEV_BITMASK_SECOND_BYTE ) >> 16; if ( filter_index > get_index ) { return CANFD6_ERROR; } else { get_index = filter_index; } start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; start_address += ( get_index << 2 ); filter->word = dev_read_word( ctx, start_address ); return CANFD6_OK; } err_t canfd6_mcan_write_xid_filter ( canfd6_t *ctx, uint8_t filter_index, canfd6_mcan_xid_filter_t *filter ) { uint32_t rd_data; uint32_t wr_data; uint16_t start_address; uint8_t get_index; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_XIDFC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_XIDFC ); #endif get_index = ( rd_data & DEV_BITMASK_SECOND_BYTE ) >> 16; if ( filter_index > get_index ) { return CANFD6_ERROR; } else { get_index = filter_index; } start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; start_address += ( get_index << 3 ); wr_data = ( uint32_t )( filter->EFEC ) << 29; wr_data |= ( uint32_t )( filter->EFID1 ); dev_write_word( ctx, start_address, wr_data ); start_address += 4; wr_data = ( uint32_t )( filter->EFT ) << 30; wr_data |= ( uint32_t )( filter->EFID2 ); dev_write_word( ctx, start_address, wr_data ); return CANFD6_OK; } err_t canfd6_mcan_read_xid_filter ( canfd6_t *ctx, uint8_t filter_index, canfd6_mcan_xid_filter_t *filter ) { uint32_t rd_data; uint16_t start_address; uint8_t get_index; #ifdef CANFD6_MCAN_CACHE_CONFIGURATION rd_data = CANFD6_MCAN_CACHE[ CANFD6_MCAN_CACHE_XIDFC ]; #else rd_data = dev_read_word( ctx, CANFD6_REG_MCAN_XIDFC ); #endif get_index = ( rd_data & DEV_BITMASK_SECOND_BYTE ) >> 16; if ( filter_index > get_index ) { return CANFD6_ERROR; } else { get_index = filter_index; } start_address = ( uint16_t )( rd_data & DEV_BITMASK_HWORD ) + CANFD6_REG_MRAM; start_address += ( get_index << 3 ); dev_burst_read_init( ctx, start_address, 2 ); rd_data = dev_burst_read_data( ctx ); filter->EFEC = ( canfd6_xid_efec_values_t )( ( rd_data >> 29 ) & 0x07 ); filter->EFID1 = rd_data & DEV_BITMASK_LASTB_29; rd_data = dev_burst_read_data( ctx ); dev_burst_read_terminate( ctx ); filter->EFT = ( canfd6_xid_eft_values_t )( ( rd_data >> 30 ) & 0x03 ); filter->EFID2 = rd_data & DEV_BITMASK_LASTB_29; return CANFD6_OK; } void canfd6_mcan_read_interrupts ( canfd6_t *ctx, canfd6_mcan_interrupts_t *ir ) { ir->word = dev_read_word( ctx, CANFD6_REG_MCAN_IR ); } void canfd6_mcan_clear_interrupts ( canfd6_t *ctx, canfd6_mcan_interrupts_t *ir ) { dev_write_word( ctx, CANFD6_REG_MCAN_IR, ir->word ); } void canfd6_mcan_clear_interrupts_all ( canfd6_t *ctx ) { dev_write_word( ctx, CANFD6_REG_MCAN_IR, DEV_BITMASK_ALL ); } void canfd6_mcan_read_interrupt_enable ( canfd6_t *ctx, canfd6_mcan_interrupt_enable_t *ie ) { ie->word = dev_read_word( ctx, CANFD6_REG_MCAN_IE ); } void canfd6_mcan_configure_interrupt_enable ( canfd6_t *ctx, canfd6_mcan_interrupt_enable_t *ie ) { dev_write_word( ctx, CANFD6_REG_MCAN_IE, ie->word ); dev_write_word( ctx, CANFD6_REG_MCAN_ILE, CANFD6_REG_BITS_MCAN_ILE_EINT0 ); } uint8_t canfd6_mcan_dlc_to_bytes ( uint8_t input_dlc ) { static const uint8_t lookup[ 7 ] = { 12, 16, 20, 24, 32, 48, 64 }; if ( input_dlc < 9 ) { return input_dlc; } if ( input_dlc < 16 ) { return lookup[ ( uint8_t )( input_dlc - 9 ) ]; } return 0; } uint8_t canfd6_mcan_txrxesc_data_byte_value ( uint8_t input_esc_value ) { static const uint8_t lookup[ 8 ] = { 8, 12, 16, 20, 24, 32, 48, 64 }; return lookup[ ( uint8_t )( input_esc_value & 0x07 ) ]; } uint16_t canfd6_device_read_version ( canfd6_t *ctx ) { uint32_t read_val; read_val = dev_read_word( ctx, CANFD6_REG_SPI_REVISION ); return ( uint16_t )( read_val & 0xFFFF ); } void canfd6_device_configure ( canfd6_t *ctx, canfd6_dev_config_t *dev_cfg ) { uint32_t read_dev = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); read_dev &= ~( CANFD6_REG_BITS_DEVICE_MODE_SWE_MASK | CANFD6_REG_BITS_DEVICE_MODE_DEVICE_RESET | CANFD6_REG_BITS_DEVICE_MODE_WDT_MASK | CANFD6_REG_BITS_DEVICE_MODE_NWKRQ_CONFIG_MASK | CANFD6_REG_BITS_DEVICE_MODE_INH_MASK | CANFD6_REG_BITS_DEVICE_MODE_GPO1_FUNC_MASK | CANFD6_REG_BITS_DEVICE_MODE_FAIL_SAFE_MASK | CANFD6_REG_BITS_DEVICE_MODE_GPO1_MODE_MASK | CANFD6_REG_BITS_DEVICE_MODE_WDT_ACTION_MASK | CANFD6_REG_BITS_DEVICE_MODE_WDT_RESET_BIT | CANFD6_REG_BITS_DEVICE_MODE_NWKRQ_VOLT_MASK | CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_ENMASK | CANFD6_REG_BITS_DEVICE_MODE_GPO2_MASK | CANFD6_REG_BITS_DEVICE_MODE_WD_CLK_MASK | CANFD6_REG_BITS_DEVICE_MODE_WAKE_PIN_MASK ); canfd6_dev_config_t tempCfg; tempCfg.word = dev_cfg->word; tempCfg.RESERVED0 = 0; tempCfg.RESERVED1 = 0; tempCfg.RESERVED2 = 0; tempCfg.RESERVED3 = 0; tempCfg.RESERVED4 = 0; tempCfg.RESERVED5 = 0; read_dev |= ( CANFD6_REG_BITS_DEVICE_MODE_FORCED_SET_BITS | tempCfg.word ); dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, read_dev ); } void canfd6_device_read_config ( canfd6_t *ctx, canfd6_dev_config_t *dev_cfg ) { dev_cfg->word = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); } void canfd6_device_read_interrupts ( canfd6_t *ctx, canfd6_device_interrupts_t *ir ) { ir->word = dev_read_word( ctx, CANFD6_REG_DEV_IR ); } void canfd6_device_clear_interrupts ( canfd6_t *ctx, canfd6_device_interrupts_t *ir ) { dev_write_word( ctx, CANFD6_REG_DEV_IR, ir->word ); } void canfd6_device_clear_interrupts_all ( canfd6_t *ctx ) { dev_write_word( ctx, CANFD6_REG_DEV_IR, DEV_BITMASK_ALL ); } void canfd6_device_clear_spierr ( canfd6_t *ctx ) { dev_write_word( ctx, CANFD6_REG_SPI_STATUS, DEV_BITMASK_ALL ); } void canfd6_device_read_interrupt_enable ( canfd6_t *ctx, canfd6_device_interrupt_enable_t *ie ) { ie->word = dev_read_word( ctx, CANFD6_REG_DEV_IE ); } void canfd6_device_configure_ie ( canfd6_t *ctx, canfd6_device_interrupt_enable_t *ie ) { dev_write_word( ctx, CANFD6_REG_DEV_IE, ie->word ); } err_t canfd6_device_set_mode ( canfd6_t *ctx, canfd6_device_mode_enum_t mode_define ) { uint32_t write_val = ( dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ) & ~CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_MASK ); switch ( mode_define ) { case CANFD6_DEVICE_MODE_NORMAL: write_val |= CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_NORMAL; break; case CANFD6_DEVICE_MODE_SLEEP: write_val |= CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_SLEEP; break; case CANFD6_DEVICE_MODE_STANDBY: write_val |= CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_STANDBY; break; default: return CANFD6_ERROR; } dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, write_val ); return CANFD6_OK; } canfd6_device_mode_enum_t canfd6_device_read_mode ( canfd6_t *ctx ) { uint32_t read_val = ( dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ) & CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_MASK ); switch ( read_val ) { case CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_NORMAL: return CANFD6_DEVICE_MODE_NORMAL; case CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_SLEEP: return CANFD6_DEVICE_MODE_SLEEP; case CANFD6_REG_BITS_DEVICE_MODE_DEVICEMODE_STANDBY: return CANFD6_DEVICE_MODE_STANDBY; default: return CANFD6_DEVICE_MODE_STANDBY; } } err_t canfd6_device_enable_testmode ( canfd6_t *ctx, canfd6_device_test_mode_enum_t mode_define ) { uint32_t rd_wr_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); rd_wr_val &= ~CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_MASK; switch ( mode_define ) { case CANFD6_DEVICE_TEST_MODE_NORMAL: canfd6_device_disable_testmode( ctx ); break; case CANFD6_DEVICE_TEST_MODE_CONTROLLER: rd_wr_val |= CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_CONTROLLER | CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_EN; break; case CANFD6_DEVICE_TEST_MODE_PHY: rd_wr_val |= CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_PHY | CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_EN; break; default: return CANFD6_ERROR; } dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, rd_wr_val ); return CANFD6_OK; } void canfd6_device_disable_testmode ( canfd6_t *ctx ) { uint32_t rd_wr_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); rd_wr_val &= ~( CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_MASK | CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_ENMASK ); dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, rd_wr_val ); } canfd6_device_test_mode_enum_t canfd6_device_read_testmode ( canfd6_t *ctx ) { uint32_t read_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); if ( read_val & CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_ENMASK ) { if ( read_val & CANFD6_REG_BITS_DEVICE_MODE_TESTMODE_CONTROLLER ) { return CANFD6_DEVICE_TEST_MODE_CONTROLLER; } else { return CANFD6_DEVICE_TEST_MODE_PHY; } } return CANFD6_DEVICE_TEST_MODE_NORMAL; } err_t canfd6_wdt_configure ( canfd6_t *ctx, canfd6_wdt_timer_enum_t wdt_timeout ) { uint32_t rd_wr_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); rd_wr_val &= ~CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_MASK; switch ( wdt_timeout ) { case CANFD6_WDT_60MS: rd_wr_val |= CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_60MS; break; case CANFD6_WDT_600MS: rd_wr_val |= CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_600MS; break; case CANFD6_WDT_3S: rd_wr_val |= CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_3S; break; case CANFD6_WDT_6S: rd_wr_val |= CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_6S; break; default: return CANFD6_ERROR; } dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, rd_wr_val ); return CANFD6_OK; } canfd6_wdt_timer_enum_t canfd6_wdt_read ( canfd6_t *ctx ) { uint32_t read_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); read_val &= CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_MASK; switch ( read_val ) { case CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_60MS: return CANFD6_WDT_60MS; case CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_600MS: return CANFD6_WDT_600MS; case CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_3S: return CANFD6_WDT_3S; case CANFD6_REG_BITS_DEVICE_MODE_WD_TIMER_6S: return CANFD6_WDT_6S; default: return CANFD6_WDT_60MS; } } void canfd6_wdt_enable ( canfd6_t *ctx ) { uint32_t rd_wr_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ) | CANFD6_REG_BITS_DEVICE_MODE_WDT_EN; dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, rd_wr_val ); } void canfd6_wdt_disable ( canfd6_t *ctx ) { uint32_t write_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); write_val &= ~CANFD6_REG_BITS_DEVICE_MODE_WDT_EN; dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, write_val ); } void canfd6_wdt_reset ( canfd6_t *ctx ) { uint32_t write_val = dev_read_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS ); write_val |= CANFD6_REG_BITS_DEVICE_MODE_WDT_RESET_BIT; dev_write_word( ctx, CANFD6_REG_DEV_MODES_AND_PINS, write_val ); } // ----------------------------------------------- PRIVATE FUNCTION DEFINITIONS static void dev_write_word ( canfd6_t *ctx, uint16_t address, uint32_t data_in ) { dev_burst_write_init( ctx, address, 1 ); dev_burst_write_data( ctx, data_in ); dev_burst_write_terminate( ctx ); } static uint32_t dev_read_word ( canfd6_t *ctx, uint16_t address ) { uint32_t returnData; dev_burst_read_init( ctx, address, 1 ); returnData = dev_burst_read_data( ctx ); dev_burst_read_terminate( ctx ); return returnData; } static void dev_burst_write_init ( canfd6_t *ctx, uint16_t address, uint8_t words ) { uint8_t tx_buf[ 4 ]; tx_buf[ 0 ] = DEV_WRITE_OPCODE; tx_buf[ 1 ] = ( uint8_t )( address >> 8 ); tx_buf[ 2 ] = ( uint8_t )address; tx_buf[ 3 ] = words; spi_master_select_device( ctx->chip_select ); spi_master_write( &ctx->spi, tx_buf, 4 ); } static void dev_burst_write_data ( canfd6_t *ctx, uint32_t data_in ) { uint8_t tx_buf[ 4 ]; tx_buf[ 0 ] = ( uint8_t ) ( ( data_in >> 24 ) & DEV_BITMASK_LASTB_8 ); tx_buf[ 1 ] = ( uint8_t ) ( ( data_in >> 16 ) & DEV_BITMASK_LASTB_8 ); tx_buf[ 2 ] = ( uint8_t ) ( ( data_in >> 8 ) & DEV_BITMASK_LASTB_8 ); tx_buf[ 3 ] = ( uint8_t ) ( data_in & DEV_BITMASK_LASTB_8 ); spi_master_write( &ctx->spi, tx_buf, 4 ); } static void dev_burst_write_terminate ( canfd6_t *ctx ) { spi_master_deselect_device( ctx->chip_select ); } static void dev_burst_read_init ( canfd6_t *ctx, uint16_t address, uint8_t words ) { uint8_t tx_buf[ 4 ]; tx_buf[ 0 ] = DEV_READ_OPCODE; tx_buf[ 1 ] = ( uint8_t )( address >> 8 ); tx_buf[ 2 ] = ( uint8_t )address; tx_buf[ 3 ] = words; spi_master_select_device( ctx->chip_select ); spi_master_write( &ctx->spi, tx_buf, 4 ); } static uint32_t dev_burst_read_data ( canfd6_t *ctx ) { uint8_t rx_buf[ 4 ]; uint32_t returnData; spi_master_read( &ctx->spi, rx_buf, 4 ); returnData = rx_buf[ 0 ]; returnData <<= 8; returnData |= rx_buf[ 1 ]; returnData <<= 8; returnData |= rx_buf[ 2 ]; returnData <<= 8; returnData |= rx_buf[ 3 ]; return returnData; } static void dev_burst_read_terminate ( canfd6_t *ctx ) { spi_master_deselect_device( ctx->chip_select ); } // ------------------------------------------------------------------------- END
34.843593
200
0.668151
[ "object" ]
6beaf5f13636361d64105c8cc32c4c874a2c036b
2,119
h
C
Include/Rallpack/ionchan_na_rallpack.h
ModelDBRepository/98003
af6dee5ea44814e7ca3e74a99837696db5b06db9
[ "Unlicense", "MIT" ]
null
null
null
Include/Rallpack/ionchan_na_rallpack.h
ModelDBRepository/98003
af6dee5ea44814e7ca3e74a99837696db5b06db9
[ "Unlicense", "MIT" ]
null
null
null
Include/Rallpack/ionchan_na_rallpack.h
ModelDBRepository/98003
af6dee5ea44814e7ca3e74a99837696db5b06db9
[ "Unlicense", "MIT" ]
null
null
null
// Sodium Ion Channel // // Copyright 2006 John L Baker. All rights reserved. // // File: ionchan_na_rallpack.h // // Release: 1.0.0 // Author: John Baker // Updated: 14 July 2006 // // Description: // // This header file contains the classes used to implement // the sodium (Na) channel definitions for the Rallpack benchmark. // Only include this header once #ifndef __IONCHAN_NA_RALLPACK_H_ #define __IONCHAN_NA_RALLPACK_H_ #include "bnsf.h" using namespace std; using namespace BNSF; namespace RALLPACK { // ------------------------------------------------- // Na Ion Channel Classes // ------------------------------------------------- // m gate class Na_m_gate : public VoltageDepTabGate { public: // Constructors and destructor Na_m_gate() {} virtual ~Na_m_gate() {} // Alpha and beta functions for table loading virtual Number alphaForTable(Number v); virtual Number betaForTable(Number v); // state vector label functions virtual const char* componentName() {return "Na"; } virtual const char** stateLabels() { static const char* sl[] = { "m" }; return sl; } protected: virtual AlphaBetaEntry** pAlphaBetaTable() { return &_abTable; } private: static AlphaBetaEntry* _abTable; }; // h gate class Na_h_gate : public VoltageDepTabGate { public: // constructors and destructor Na_h_gate() {} virtual ~Na_h_gate() {} virtual Number alphaForTable(Number v); virtual Number betaForTable(Number v); // state vector label functions virtual const char* componentName() {return "Na"; } virtual const char** stateLabels() { static const char* sl[] = { "h" }; return sl; } protected: virtual AlphaBetaEntry** pAlphaBetaTable() { return &_abTable; } private: static AlphaBetaEntry* _abTable; }; // Na channel class Na_channel : public M3HIonChannel { public: // Constructors and destructor Na_channel(Number gSpVal=0); virtual ~Na_channel(); // Reversal potential for Na inline Number Vrev() { return _Vrev; } protected: static const Number _Vrev; }; }; #endif // #ifndef __IONCHAN_NA_RALLPACK_H_
20.375
66
0.664936
[ "vector" ]
6bf01ebf6ae7e371299731d7ad8e7d9622d091c7
2,751
h
C
JCDT/JCDT_Lib/internal/parser/RecoverAst/RecoveredBlock.h
kuafuwang/JCDT
2b009ea887b4816303fed9e6e1dc104a90c67d16
[ "MIT" ]
1
2021-04-17T01:55:27.000Z
2021-04-17T01:55:27.000Z
JCDT/JCDT_Lib/internal/parser/RecoverAst/RecoveredBlock.h
kuafuwang/JCDT
2b009ea887b4816303fed9e6e1dc104a90c67d16
[ "MIT" ]
null
null
null
JCDT/JCDT_Lib/internal/parser/RecoverAst/RecoveredBlock.h
kuafuwang/JCDT
2b009ea887b4816303fed9e6e1dc104a90c67d16
[ "MIT" ]
1
2022-02-18T12:02:00.000Z
2022-02-18T12:02:00.000Z
#ifndef RecoveredBlock_INCLUDED #define RecoveredBlock_INCLUDED #include "RecoveryAst_Pre_declaration.h" #include <vector> #include <set> #include <string> using std::vector; namespace Jikes { // Open namespace Jikes block class RecoveredBlock :public RecoveredStatement { public: AstBlock* blockDeclaration; vector<RecoveredStatement*> statements; int statementCount; bool preserveContent =false; RecoveredLocalVariable* pendingArgument; RecoveredBlock(AstBlock* block, RecoveredElement* parent, int bracketBalance); /* * Record a nested block declaration */ RecoveredElement* add(AstBlock* nestedBlockDeclaration, int bracketBalanceValue); /* * Record a local declaration */ RecoveredElement* add(LocalDeclaration* localDeclaration, int bracketBalanceValue); /* * Record a local declaration */ RecoveredElement* add(LocalDeclaration* localDeclaration, int bracketBalanceValue, bool delegatedByParent); /* * Record a statement declaration */ RecoveredElement* add(AbstractStatement* stmt, int bracketBalanceValue); /* * Record a statement declaration */ RecoveredElement* add(AbstractStatement* stmt, int bracketBalanceValue, bool delegatedByParent); /* * Addition of a type to an initializer (act like inside method body) */ RecoveredElement* add(TypeDeclaration* typeDeclaration, int bracketBalanceValue); /* * Addition of a type to an initializer (act like inside method body) */ RecoveredElement* add(TypeDeclaration* typeDeclaration, int bracketBalanceValue, bool delegatedByParent); /* * Attach a recovered statement */ void attach(RecoveredStatement* recoveredStatement); /* * Answer the associated parsed structure */ Ast* parseTree(); AstBlock* updatedBlock(); /* * Rebuild a statement from the nested structure which is in scope */ AbstractStatement* updatedStatement(); /* * A closing brace got consumed, might have closed the current element, * in which case both the currentElement is exited */ RecoveredElement* updateOnClosingBrace(int braceStart, int braceEnd); /* * An opening brace got consumed, might be the expected opening one of the current element, * in which case the bodyStart is updated. */ RecoveredElement* updateOnOpeningBrace(int braceStart, int braceEnd); /* * Final update the corresponding parse node */ void updateParseTree(); /* * Rebuild a flattened block from the nested structure which is in scope */ AbstractStatement* updateStatement(); /* * Record a field declaration */ RecoveredElement* add(FieldDeclaration* fieldDeclaration, int bracketBalanceValue); }; }// end namespace #endif // _INCLUDED
25.472222
93
0.735005
[ "vector" ]
6bf1079d20e3bf6836b2a31b0de1a288abd49f93
2,038
h
C
Example/Pods/LibTorch/install/include/torch/csrc/api/include/torch/nn/modules/linear.h
mjjimenez/SamplePod
4bf2840c22675f1372e5db9bf6004a68d6b30b40
[ "MIT" ]
1
2020-02-24T06:23:07.000Z
2020-02-24T06:23:07.000Z
Example/Pods/LibTorch/install/include/torch/csrc/api/include/torch/nn/modules/linear.h
mjjimenez/SamplePod
4bf2840c22675f1372e5db9bf6004a68d6b30b40
[ "MIT" ]
4
2021-06-02T00:49:27.000Z
2022-01-13T01:59:34.000Z
Example/Pods/LibTorch/install/include/torch/csrc/api/include/torch/nn/modules/linear.h
mjjimenez/SamplePod
4bf2840c22675f1372e5db9bf6004a68d6b30b40
[ "MIT" ]
null
null
null
#pragma once #include <torch/nn/cloneable.h> #include <torch/nn/module.h> #include <torch/nn/options/linear.h> #include <torch/nn/pimpl.h> #include <torch/types.h> #include <cstddef> #include <vector> namespace torch { namespace nn { /// A placeholder identity operator that is argument-insensitive. class TORCH_API IdentityImpl : public Cloneable<IdentityImpl> { public: void reset() override; /// Pretty prints the `Identity` module into the given `stream`. void pretty_print(std::ostream& stream) const override; Tensor forward(const Tensor& input); }; /// A `ModuleHolder` subclass for `IdentityImpl`. /// See the documentation for `IdentityImpl` class to learn what methods it /// provides, or the documentation for `ModuleHolder` to learn about PyTorch's /// module storage semantics. TORCH_MODULE(Identity); // ============================================================================ /// Applies a linear transformation with optional bias. class TORCH_API LinearImpl : public Cloneable<LinearImpl> { public: LinearImpl(int64_t in, int64_t out) : LinearImpl(LinearOptions(in, out)) {} explicit LinearImpl(const LinearOptions& options_); void reset() override; /// Pretty prints the `Linear` module into the given `stream`. void pretty_print(std::ostream& stream) const override; /// Transforms the `input` tensor by multiplying with the `weight` and /// optionally adding the `bias`, if `with_bias` is true in the options. Tensor forward(const Tensor& input); /// The options used to configure this module. LinearOptions options; /// The learned weight. Tensor weight; /// The learned bias. If `with_bias` is false in the `options`, this tensor is /// undefined. Tensor bias; }; /// A `ModuleHolder` subclass for `LinearImpl`. /// See the documentation for `LinearImpl` class to learn what methods it /// provides, or the documentation for `ModuleHolder` to learn about PyTorch's /// module storage semantics. TORCH_MODULE(Linear); } // namespace nn } // namespace torch
29.970588
80
0.705103
[ "vector" ]
6bf2ddb0ee10534406ac9fa4413e1cc7e91d1090
32,669
c
C
source/bsp/processor/tm4c123/bsp_Interrupt_tm4c123.c
briancostabile/tiva-bsp
603187791cac3c28fd8ca77e286f3f68afa9a39a
[ "MIT" ]
null
null
null
source/bsp/processor/tm4c123/bsp_Interrupt_tm4c123.c
briancostabile/tiva-bsp
603187791cac3c28fd8ca77e286f3f68afa9a39a
[ "MIT" ]
null
null
null
source/bsp/processor/tm4c123/bsp_Interrupt_tm4c123.c
briancostabile/tiva-bsp
603187791cac3c28fd8ca77e286f3f68afa9a39a
[ "MIT" ]
1
2019-06-20T09:21:45.000Z
2019-06-20T09:21:45.000Z
/** * Copyright 2021 Brian Costabile * * 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. */ /*============================================================================*/ /** * @file bsp_Interrupt_tm4c123.c * @brief Contains Macros and defines for the interrupt controller specific * to the tm4c123 with SensorHub platform. */ #include "bsp_Types.h" #include "bsp_Platform.h" #include "bsp_Interrupt.h" #include "bsp_Mcu.h" #include "bsp_Pragma.h" #include "bsp_Reset.h" #include "bsp_Gpio.h" #include "bsp_I2c.h" #include "bsp_Uart.h" #include "bsp_Usb.h" #include "bsp_TimerGp.h" /*============================================================================== * Defines *============================================================================*/ #define BSP_INTERRUPT_HANDLER_NULL ((bsp_Interrupt_VectorHandler_t)NULL) /*============================================================================== * Macros *============================================================================*/ /*============================================================================== * Forward declaration of the default fault handlers. */ static void bsp_Interrupt_rstHandler(void); static void bsp_Interrupt_nmiHandler(void); static void bsp_Interrupt_faultHandler(void); static void bsp_Interrupt_defaultHandler(void); void __attribute__((weak)) bsp_Interrupt_sysTickHandler(void) { bsp_Interrupt_defaultHandler(); return; } void __attribute__((weak)) bsp_Interrupt_svCallHandler(void) { bsp_Interrupt_defaultHandler(); return; } void __attribute__((weak)) bsp_Interrupt_pendSvCallHandler(void) { bsp_Interrupt_defaultHandler(); return; } //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000 or at the start of // the program if located at a start address other than 0. // //***************************************************************************** /* 16 Exception Vectors */ extern uint32_t __STACK_TOP; const bsp_Interrupt_VectorHandler_t BSP_ATTR_SECTION(".vecsException") BSP_ATTR_USED bsp_Interrupt_vectorTableExceptions[] = { (bsp_Interrupt_VectorHandler_t)&(__STACK_TOP), bsp_Interrupt_rstHandler, // The reset handler bsp_Interrupt_nmiHandler, // The NMI handler bsp_Interrupt_faultHandler, // The hard fault handler bsp_Interrupt_faultHandler, // The MPU fault handler bsp_Interrupt_faultHandler, // The bus fault handler bsp_Interrupt_faultHandler, // The usage fault handler BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_Interrupt_svCallHandler, // SVCall handler bsp_Interrupt_defaultHandler, // Debug monitor handler BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_Interrupt_pendSvCallHandler, // The PendSV handler bsp_Interrupt_sysTickHandler, // The SysTick handler }; BSP_PRAGMA_DATA_REQUIRED(bsp_Interrupt_vectorTableExceptions) /* 139 Interrupt Vectors */ const bsp_Interrupt_VectorHandler_t BSP_ATTR_SECTION(".vecsInterrupt") BSP_ATTR_USED bsp_Interrupt_vectorTableInterrutps[] = { bsp_Gpio_interruptHandlerPortA, // GPIO Port A bsp_Gpio_interruptHandlerPortB, // GPIO Port B bsp_Gpio_interruptHandlerPortC, // GPIO Port C bsp_Gpio_interruptHandlerPortD, // GPIO Port D bsp_Gpio_interruptHandlerPortE, // GPIO Port E bsp_Uart_interruptHandler0, // UART0 Rx and Tx bsp_Uart_interruptHandler1, // UART1 Rx and Tx bsp_Interrupt_defaultHandler, // SSI0 Rx and Tx bsp_I2c_interruptHandler0, // I2C0 Master and Slave bsp_Interrupt_defaultHandler, // PWM Fault bsp_Interrupt_defaultHandler, // PWM Generator 0 bsp_Interrupt_defaultHandler, // PWM Generator 1 bsp_Interrupt_defaultHandler, // PWM Generator 2 bsp_Interrupt_defaultHandler, // Quadrature Encoder 0 bsp_Interrupt_defaultHandler, // ADC Sequence 0 bsp_Interrupt_defaultHandler, // ADC Sequence 1 bsp_Interrupt_defaultHandler, // ADC Sequence 2 bsp_Interrupt_defaultHandler, // ADC Sequence 3 bsp_Interrupt_defaultHandler, // Watchdog timer bsp_TimerGp_interruptHandlerTimer0A, // Timer 0 subtimer A bsp_TimerGp_interruptHandlerTimer0B, // Timer 0 subtimer B bsp_TimerGp_interruptHandlerTimer1A, // Timer 1 subtimer A bsp_TimerGp_interruptHandlerTimer1B, // Timer 1 subtimer B bsp_TimerGp_interruptHandlerTimer2A, // Timer 2 subtimer A bsp_TimerGp_interruptHandlerTimer2B, // Timer 2 subtimer B bsp_Interrupt_defaultHandler, // Analog Comparator 0 bsp_Interrupt_defaultHandler, // Analog Comparator 1 bsp_Interrupt_defaultHandler, // Analog Comparator 2 bsp_Interrupt_defaultHandler, // System Control (PLL, OSC, BO) bsp_Interrupt_defaultHandler, // FLASH Control bsp_Gpio_interruptHandlerPortF, // GPIO Port F bsp_Gpio_interruptHandlerPortG, // GPIO Port G bsp_Gpio_interruptHandlerPortH, // GPIO Port H bsp_Uart_interruptHandler2, // UART2 Rx and Tx bsp_Interrupt_defaultHandler, // SSI1 Rx and Tx bsp_TimerGp_interruptHandlerTimer3A, // Timer 3 subtimer A bsp_TimerGp_interruptHandlerTimer3B, // Timer 3 subtimer B bsp_I2c_interruptHandler1, // I2C1 Master and Slave bsp_Interrupt_defaultHandler, // Quadrature Encoder 1 bsp_Interrupt_defaultHandler, // CAN0 bsp_Interrupt_defaultHandler, // CAN1 bsp_Interrupt_defaultHandler, // CAN2 BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_Interrupt_defaultHandler, // Hibernate bsp_Usb_interruptHandler, // USB0 bsp_Interrupt_defaultHandler, // PWM Generator 3 bsp_Interrupt_defaultHandler, // uDMA Software Transfer bsp_Interrupt_defaultHandler, // uDMA Error bsp_Interrupt_defaultHandler, // ADC1 Sequence 0 bsp_Interrupt_defaultHandler, // ADC1 Sequence 1 bsp_Interrupt_defaultHandler, // ADC1 Sequence 2 bsp_Interrupt_defaultHandler, // ADC1 Sequence 3 BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_Gpio_interruptHandlerPortJ, // GPIO Port J bsp_Gpio_interruptHandlerPortK, // GPIO Port K bsp_Gpio_interruptHandlerPortL, // GPIO Port L bsp_Interrupt_defaultHandler, // SSI2 Rx and Tx bsp_Interrupt_defaultHandler, // SSI3 Rx and Tx bsp_Uart_interruptHandler3, // UART3 Rx and Tx bsp_Uart_interruptHandler4, // UART4 Rx and Tx bsp_Uart_interruptHandler5, // UART5 Rx and Tx bsp_Uart_interruptHandler6, // UART6 Rx and Tx bsp_Uart_interruptHandler7, // UART7 Rx and Tx BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_I2c_interruptHandler2, // I2C2 Master and Slave bsp_I2c_interruptHandler3, // I2C3 Master and Slave bsp_TimerGp_interruptHandlerTimer4A, // Timer 4 subtimer A bsp_TimerGp_interruptHandlerTimer4B, // Timer 4 subtimer B BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_TimerGp_interruptHandlerTimer5A, // Timer 5 subtimer A bsp_TimerGp_interruptHandlerTimer5B, // Timer 5 subtimer B bsp_Interrupt_defaultHandler, // Wide Timer 0 subtimer A bsp_Interrupt_defaultHandler, // Wide Timer 0 subtimer B bsp_Interrupt_defaultHandler, // Wide Timer 1 subtimer A bsp_Interrupt_defaultHandler, // Wide Timer 1 subtimer B bsp_Interrupt_defaultHandler, // Wide Timer 2 subtimer A bsp_Interrupt_defaultHandler, // Wide Timer 2 subtimer B bsp_Interrupt_defaultHandler, // Wide Timer 3 subtimer A bsp_Interrupt_defaultHandler, // Wide Timer 3 subtimer B bsp_Interrupt_defaultHandler, // Wide Timer 4 subtimer A bsp_Interrupt_defaultHandler, // Wide Timer 4 subtimer B bsp_Interrupt_defaultHandler, // Wide Timer 5 subtimer A bsp_Interrupt_defaultHandler, // Wide Timer 5 subtimer B bsp_Interrupt_defaultHandler, // FPU BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_Interrupt_defaultHandler, // I2C4 Master and Slave bsp_Interrupt_defaultHandler, // I2C5 Master and Slave bsp_Gpio_interruptHandlerPortM, // GPIO Port M bsp_Gpio_interruptHandlerPortN, // GPIO Port N bsp_Interrupt_defaultHandler, // Quadrature Encoder 2 BSP_INTERRUPT_HANDLER_NULL, // Reserved BSP_INTERRUPT_HANDLER_NULL, // Reserved bsp_Gpio_interruptHandlerPortP0, // GPIO Port P (Summary or P0) bsp_Gpio_interruptHandlerPortP1, // GPIO Port P1 bsp_Gpio_interruptHandlerPortP2, // GPIO Port P2 bsp_Gpio_interruptHandlerPortP3, // GPIO Port P3 bsp_Gpio_interruptHandlerPortP4, // GPIO Port P4 bsp_Gpio_interruptHandlerPortP5, // GPIO Port P5 bsp_Gpio_interruptHandlerPortP6, // GPIO Port P6 bsp_Gpio_interruptHandlerPortP7, // GPIO Port P7 bsp_Gpio_interruptHandlerPortQ0, // GPIO Port Q (Summary or Q0) bsp_Gpio_interruptHandlerPortQ1, // GPIO Port Q1 bsp_Gpio_interruptHandlerPortQ2, // GPIO Port Q2 bsp_Gpio_interruptHandlerPortQ3, // GPIO Port Q3 bsp_Gpio_interruptHandlerPortQ4, // GPIO Port Q4 bsp_Gpio_interruptHandlerPortQ5, // GPIO Port Q5 bsp_Gpio_interruptHandlerPortQ6, // GPIO Port Q6 bsp_Gpio_interruptHandlerPortQ7, // GPIO Port Q7 bsp_Interrupt_defaultHandler, // GPIO Port R bsp_Interrupt_defaultHandler, // GPIO Port S bsp_Interrupt_defaultHandler, // PWM 1 Generator 0 bsp_Interrupt_defaultHandler, // PWM 1 Generator 1 bsp_Interrupt_defaultHandler, // PWM 1 Generator 2 bsp_Interrupt_defaultHandler, // PWM 1 Generator 3 bsp_Interrupt_defaultHandler // PWM 1 Fault }; BSP_PRAGMA_DATA_REQUIRED(bsp_Interrupt_vectorTableInterrutps) /* Table with all of the priority settings for each system exception */ const uint32_t bsp_Interrupt_groupPriorityTableExceptions[] = { // 4-7: Memory Management, Bus Fault, Usage Fault, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 8-11: Reserved, Reserved, Reserved, SVC Call BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 12-15: Debug Monitor, Reserved, Pending SV, SYS Tick BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ) }; /* Table with all of the priority settings for each interrupt */ const uint32_t bsp_Interrupt_groupPriorityTableInterrupts[] = { // 0-3: GPIO Port A, GPIO Port B, GPIO Port C, GPIO Port D BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ) ), // 4-7: GPIO Port E, UART0 Rx and Tx, UART1 Rx and Tx, SSI0 Rx and Tx BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 8-11: I2C0 Master and Slave, PWM Fault, PWM Generator 0, PWM Generator 1 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 12-15: PWM Generator 2, Quadrature Encoder 0, ADC Sequence 0, ADC Sequence 1 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 16-19: ADC Sequence 2, ADC Sequence 3, Watchdog timer, Timer 0 subtimer A BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 20-23: Timer 0 subtimer B, Timer 1 subtimer A, Timer 1 subtimer B, Timer 2 subtimer A BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 24-27: Timer 2 subtimer B, Analog Comparator 0, Analog Comparator 1, Analog Comparator 2 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 28-31: System Control (PLL, OSC, BO), FLASH Control, GPIO Port F, GPIO Port G BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 32-35: GPIO Port H, UART2 Rx and Tx, SSI1 Rx and Tx, Timer 3 subtimer A BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 36-39: Timer 3 subtimer B, I2C1 Master and Slave, Quadrature Encoder 1, CAN0 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 40-43: CAN1, CAN2, Reserved, Hibernate BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 44-47: USB0, PWM Generator 3, uDMA Software Transfer, uDMA Error BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 48-51: ADC1 Sequence 0, ADC1 Sequence 1, ADC1 Sequence , ADC1 Sequence 3 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 52-55: Reserved, Reserved, GPIO Port J, GPIO Port K BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 56-59: GPIO Port L, SSI2 Rx and Tx, SSI3 Rx and Tx, UART3 Rx and Tx BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ) ), // 60-63: UART4 Rx and Tx, UART5 Rx and Tx, UART6 Rx and Tx, UART7 Rx and Tx BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ) ), // 64-67: Reserved, Reserved, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 68-71: I2C2 Master and Slave, I2C3 Master and Slave, Timer 4 subtimer A, Timer 4 subtimer B BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 5, 5 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 72-75: Reserved, Reserved, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 76-79: Reserved, Reserved, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 80-83: Reserved, Reserved, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 84-87: Reserved, Reserved, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 88-91: Reserved, Reserved, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 92-95: Timer 5 subtimer A, Timer 5 subtimer B, Wide Timer 0 subtimer A, Wide Timer 0 subtimer B BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 96-99: Wide Timer 1 subtimer A, Wide Timer 1 subtimer B, Wide Timer 2 subtimer A, Wide Timer 2 subtimer B BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 100-103: Wide Timer 3 subtimer A, Wide Timer 3 subtimer B, Wide Timer 4 subtimer A, Wide Timer 4 subtimer B BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 104-107: Wide Timer 5 subtimer A, Wide Timer 5 subtimer B, FPU, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 108-111: Reserved, I2C4 Master and Slave, I2C5 Master and Slave, GPIO Port M BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 112-115: GPIO Port N, Quadrature Encoder 2, Reserved, Reserved BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 116-119: GPIO Port P (Summary or P0), GPIO Port P1, GPIO Port P2, GPIO Port P3 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 120-123: GPIO Port P4, GPIO Port P5, GPIO Port P6, GPIO Port P7 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 124-127: GPIO Port Q (Summary or Q0), GPIO Port Q1, GPIO Port Q2, GPIO Port Q3 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 128-131: GPIO Port Q4, GPIO Port Q5, GPIO Port Q6, GPIO Port Q7 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 132-135: GPIO Port R, GPIO Port S, PWM 1 Generator 0, PWM 1 Generator 1 BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ), // 136-138: PWM 1 Generator 2, PWM 1 Generator 3, PWM 1 Fault, Invalid BSP_INTERRUPT_BUILD_PRI_REG( BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ), BSP_INTERRUPT_PRIORITY_GROUP_SUBGROUP( 1, 1 ) ) }; /*============================================================================== * Local Functions *============================================================================*/ /*==============================================================================*/ #if BSP_PRAGMA_COMPILER_GNU #include "hw_nvic.h" extern int main(void); extern uint32_t __data_load__; extern uint32_t __data_start__; extern uint32_t __data_end__; extern uint32_t __bss_start__; extern uint32_t __bss_end__; static void bsp_Interrupt_rstHandler(void) { uint32_t *pui32Src, *pui32Dest; // // Copy the data segment initializers from flash to SRAM. // pui32Src = &__data_load__; for(pui32Dest = &__data_start__; pui32Dest < &__data_end__; ) { *pui32Dest++ = *pui32Src++; } // // Zero fill the bss segment. // __asm(" ldr r0, =__bss_start__\n" " ldr r1, =__bss_end__\n" " mov r2, #0\n" " .thumb_func\n" "zero_loop:\n" " cmp r0, r1\n" " it lt\n" " strlt r2, [r0], #4\n" " blt zero_loop"); // // Enable the floating-point unit. This must be done here to handle the // case where main() uses floating-point and the function prologue saves // floating-point registers (which will fault if floating-point is not // enabled). Any configuration of the floating-point unit using DriverLib // APIs must be done here prior to the floating-point unit being enabled. // // Note that this does not use DriverLib since it might not be included in // this project. // ADDR_TO_REG(NVIC_CPAC) = ((ADDR_TO_REG(NVIC_CPAC) & ~(NVIC_CPAC_CP10_M | NVIC_CPAC_CP11_M)) | NVIC_CPAC_CP10_FULL | NVIC_CPAC_CP11_FULL); // // Call the application's entry point. // main(); } #else static void bsp_Interrupt_rstHandler(void) { extern void _c_int00(void); // // Jump to the CCS C initialization routine. This will enable the // floating-point unit as well, so that does not need to be done here. // __asm(" .global _c_int00\n" " b.w _c_int00"); } #endif /*==============================================================================*/ static void bsp_Interrupt_nmiHandler(void) { bsp_Reset_systemReset( BSP_RESET_SWREASON_UNHANDLED_INT ); } /*==============================================================================*/ static void bsp_Interrupt_faultHandler(void) { asm( " TST LR, #4 " ); asm( " ITE EQ " ); asm( " MRSEQ R0, MSP " ); asm( " MRSNE R0, PSP " ); asm( " LDR R1, [R0, #24] " ); asm( " B prvGetRegistersFromStack " ); } /*==============================================================================*/ void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress ) { bsp_Reset_systemFault( pulFaultStackAddress ); } /*==============================================================================*/ static void bsp_Interrupt_defaultHandler(void) { bsp_Reset_systemReset( BSP_RESET_SWREASON_UNHANDLED_INT ); }
58.546595
125
0.589213
[ "vector" ]
6bff4c76593658e0ec81693a255252de0fe652fb
6,294
h
C
Source/Utility/MythForest/Component/Visibility/VisibilityComponent.h
paintdream/paintsnow
3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781
[ "MIT" ]
null
null
null
Source/Utility/MythForest/Component/Visibility/VisibilityComponent.h
paintdream/paintsnow
3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781
[ "MIT" ]
null
null
null
Source/Utility/MythForest/Component/Visibility/VisibilityComponent.h
paintdream/paintsnow
3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781
[ "MIT" ]
null
null
null
// VisibilityComponent.h // PaintDream (paintdream@paintdream.com) // 2018-1-19 // #pragma once #include "../../Entity.h" #include "../../Component.h" #include "../Explorer/SpaceTraversal.h" #include "../Explorer/CameraCuller.h" #include "../../../../Core/Template/TBuffer.h" #include "../../../SnowyStream/Resource/ShaderResource.h" #include "../../../SnowyStream/Resource/TextureResource.h" #include "../../../SnowyStream/Resource/MeshResource.h" #include "../../../SnowyStream/Resource/Passes/ConstMapPass.h" #include "../Stream/StreamComponent.h" namespace PaintsNow { class SpaceComponent; class TransformComponent; class RenderableComponent; struct VisibilityComponentConfig { class WorldInstanceData : public TReflected<WorldInstanceData, PassBase::PartialData> { public: TObject<IReflect>& operator () (IReflect& reflect) override; MatrixFloat4x4 worldMatrix; Float3Pair boundingBox; Float4 instancedColor; }; typedef uint32_t InstanceKey; class InstanceGroup { public: InstanceGroup(); void Cleanup(); PassBase::PartialUpdater instanceUpdater; std::vector<Bytes> instancedData; IRender::Resource::QuickDrawCallDescription drawCallDescription; uint32_t instanceCount; }; class MergedInstanceGroup { public: MergedInstanceGroup(); InstanceGroup* groupPrototype; std::vector<Bytes> mergedInstanceData; uint32_t mergedInstanceCount; }; class CaptureData : public FrustrumCuller {}; class Cache { public: Int3 intPosition; Bytes payload; }; class TaskData; class Cell : public TAllocatedTiny<Cell, SharedTiny>, public Cache { public: enum { FACE_COUNT = 6, ALL_FACE_MASK = (1 << FACE_COUNT) - 1 }; Cell(); std::atomic<uint32_t> dispatched; // bitmask std::atomic<uint32_t> finished; // bitmask }; class TaskData { public: enum { STATUS_IDLE, STATUS_START, STATUS_DISPATCHED, STATUS_ASSEMBLING, STATUS_ASSEMBLED, STATUS_BAKING, STATUS_BAKED, STATUS_POSTPROCESS, }; TaskData() : status(STATUS_IDLE), pendingCount(0), faceIndex(0), pendingResourceCount(0), renderQueue(nullptr), renderTarget(nullptr) {} bool Continue() const { return pendingResourceCount == 0; } class WarpData { public: typedef std::unordered_map<InstanceKey, InstanceGroup> InstanceGroupMap; InstanceGroupMap instanceGroups; BytesCache bytesCache; }; uint32_t pendingCount; uint32_t status; uint32_t pendingResourceCount; uint32_t faceIndex; TShared<Cell> cell; IRender::Queue* renderQueue; IRender::Resource* renderTarget; TShared<TextureResource> texture; Bytes data; PerspectiveCamera camera; std::vector<WarpData> warpData; BytesCache globalBytesCache; #if defined(_MSC_VER) && _MSC_VER <= 1200 typedef std::unordered_map<InstanceKey, MergedInstanceGroup> MergedInstanceGroupMap; #else typedef std::unordered_map<InstanceKey, MergedInstanceGroup, std::hash<InstanceKey>, std::equal_to<InstanceKey>, TCacheAllocator<std::pair<const InstanceKey, MergedInstanceGroup> > > MergedInstanceGroupMap; #endif }; }; class VisibilityComponent : public TAllocatedTiny<VisibilityComponent, UniqueComponent<Component> >, public SpaceTraversal<VisibilityComponent, VisibilityComponentConfig> { public: friend class SpaceTraversal<VisibilityComponent, VisibilityComponentConfig>; VisibilityComponent(const TShared<StreamComponent>& streamComponent); enum { VISIBILITYCOMPONENT_PARALLEL = COMPONENT_CUSTOM_BEGIN, VISIBILITYCOMPONENT_CUSTOM_BEGIN = COMPONENT_CUSTOM_BEGIN << 1 }; typedef VisibilityComponentConfig::InstanceKey InstanceKey; typedef VisibilityComponentConfig::InstanceGroup InstanceGroup; typedef VisibilityComponentConfig::MergedInstanceGroup MergedInstanceGroup; typedef VisibilityComponentConfig::Cache Cache; typedef VisibilityComponentConfig::Cell Cell; TObject<IReflect>& operator () (IReflect& reflect) override; void Initialize(Engine& engine, Entity* entity) final; void Uninitialize(Engine& engine, Entity* entity) final; FLAG GetEntityFlagMask() const final; void DispatchEvent(Event& event, Entity* entity) final; Entity* GetHostEntity() const final; const Bytes& QuerySample(Engine& engine, const Float3& position); static bool IsVisible(const Bytes& sample, TransformComponent* transformComponent); void Setup(Engine& engine, float distance, const Float3& gridSize, uint32_t taskCount, uint32_t pixelKillThreshold, const UShort2& resolution); protected: void TickRender(Engine& engine); void RoutineTickTasks(Engine& engine); void ResolveTasks(Engine& engine); void DispatchTasks(Engine& engine); void PostProcess(TaskData& task); void CoTaskAssembleTask(Engine& engine, TaskData& task, const TShared<VisibilityComponent>& selfHolder); void SetupIdentities(Engine& engine, Entity* hostEntity); void RoutineSetupIdentities(Engine& engine, Entity* hostEntity); void CollectRenderableComponent(Engine& engine, TaskData& task, RenderableComponent* renderableComponent, WorldInstanceData& instanceData, uint32_t identity); void CollectComponents(Engine& engine, TaskData& task, const WorldInstanceData& instanceData, const CaptureData& captureData, Entity* entity); void CompleteCollect(Engine& engine, TaskData& task); TShared<SharedTiny> StreamLoadHandler(Engine& engine, const UShort3& coord, const TShared<SharedTiny>& tiny, const TShared<SharedTiny>& context); TShared<SharedTiny> StreamUnloadHandler(Engine& engine, const UShort3& coord, const TShared<SharedTiny>& tiny, const TShared<SharedTiny>& context); protected: TShared<StreamComponent> streamComponent; Entity* hostEntity; Float3 gridSize; float viewDistance; uint32_t taskCount; std::atomic<uint32_t> pendingSetupCount; UShort2 resolution; std::atomic<uint32_t> maxVisIdentity; uint16_t activeCellCacheIndex; uint16_t pixelKillThreshold; Cache cellCache[8]; TShared<TObjectAllocator<Cell> > cellAllocator; // Runtime Baker IRender::Queue* renderQueue; IRender::Resource* depthStencilResource; IRender::Resource* stateResource; IThread::Lock* collectLock; TShared<ShaderResourceImpl<ConstMapPass> > pipeline; std::vector<TaskData> tasks; std::vector<TShared<Cell> > bakePoints; }; }
33.478723
209
0.762154
[ "vector" ]
d4089ce2a917442a976097f3e21bb91b4874e801
2,787
h
C
Lib/QtWidgetOakView/TableView.h
vilaversoftware/OakModelView
c24d30b711fe0f2fdc336f2623dd9bc555867a9d
[ "Apache-2.0" ]
null
null
null
Lib/QtWidgetOakView/TableView.h
vilaversoftware/OakModelView
c24d30b711fe0f2fdc336f2623dd9bc555867a9d
[ "Apache-2.0" ]
null
null
null
Lib/QtWidgetOakView/TableView.h
vilaversoftware/OakModelView
c24d30b711fe0f2fdc336f2623dd9bc555867a9d
[ "Apache-2.0" ]
null
null
null
/* * OakModelView (http://oakmodelview.com/) * Author: Mikkel Nøhr Løvgreen (mikkel@oakmodelview.com) * ------------------------------------------------------------------------ * Licensed to Vilaversoftware IVS who 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. */ #pragma once #include <QTableWidget> #include <QToolBar> #include "OakModel.h" #include "TableQuery.h" namespace Oak::View::QtWidgets { // ============================================================================= // Class definition // ============================================================================= class TableView : public QWidget { Q_OBJECT public: TableView(QWidget *parent = nullptr); virtual ~TableView() override; void setBaseRef(Model::NodeQueryUPtr baseRef); void addValueRef(Model::LeafQuerySPtr valueRef); void updateTable(); void setOakModel(Model::OakModel* model); protected slots: void onSelectionChanged(); void onActionAdd(); void onActionDelete(); void onActionUp(); void onActionDown(); void onActionCut(); void onActionCopy(); void onActionPaste(); void onNodeChanged(QTableWidgetItem *node); protected: void onNodeInserteAfter(const Model::NodeIndex &nodeIndex); void onNodeMoveAfter(const Model::NodeIndex &sourceNodeIndex, const Model::NodeIndex &targetNodeIndex); void onNodeCloneAfter(const Model::NodeIndex &sourceNodeIndex, const Model::NodeIndex &targetNodeIndex); void onNodeRemoveBefore(const Model::NodeIndex& tNodeIndex); void onEntryChangeAfter(const Model::NodeIndex &nodeIndex, const std::string &valueName); virtual bool event(QEvent *event) override; void disableAllActions(); void updateAllActions(); QList<int> selectedRows() const; protected: Model::OakModel * m_model = nullptr; Model::Node m_rootNode; Model::TableQuery m_tableQuery; QTableWidget *m_tableWidget; QToolBar *m_toolBar; QAction * m_actionAdd; QAction * m_actionDelete; QAction * m_actionUp; QAction * m_actionDown; QAction * m_actionCut; QAction * m_actionCopy; QAction * m_actionPaste; QList<Model::Node> m_cutNodes; QList<Model::Node> m_copyNodes; }; } // namespace Oak::View::QtWidgets
28.731959
108
0.663437
[ "model" ]
d41c77c3018b5b3d1e8f3471298a3bc5ef40d0e5
9,565
h
C
src/clos/ffapp.h
Flasew/ffsim-opera
ec4dd1ffa1fd33e2267f9a11b60e8cbf8400f26c
[ "BSD-3-Clause" ]
null
null
null
src/clos/ffapp.h
Flasew/ffsim-opera
ec4dd1ffa1fd33e2267f9a11b60e8cbf8400f26c
[ "BSD-3-Clause" ]
null
null
null
src/clos/ffapp.h
Flasew/ffsim-opera
ec4dd1ffa1fd33e2267f9a11b60e8cbf8400f26c
[ "BSD-3-Clause" ]
null
null
null
#ifndef FF_APP_H #define FF_APP_H #include "loggers.h" // #undef max #include <vector> #include <string> #include <unordered_set> #include <unordered_map> #include "topology.h" #include "flat_topology.h" #include "eventlist.h" #include "ndp.h" #include "taskgraph_generated.h" // #include "taskgraph.pb.h" /* * An application that takes a Flex-flow generated task graph * and simulates it on top of the opera network */ class FFApplication; class FFDevice { public: enum FFDeviceType { DEVICE_GPU, DEVICE_CPU, DEVICE_GPU_COMM, DEVICE_DRAM_COMM, DEVICE_NW_COMM, }; enum FFDeviceState { DEVICE_IDLE, DEVICE_BUSY, }; FFApplication * ffapp; int node_id, gpu_id; float bandwidth; FFDeviceType type; FFDeviceState state; int from_gpu, to_gpu, from_node, to_node; simtime_picosec busy_up_to; // int nqueued_tasks; FFDevice(FFApplication * ffapp, std::string type, float bandwidth, int node_id, int gpu_id, int from_node, int to_node, int from_gpu, int to_gpu); FFDevice(FFApplication * ffapp, FlatBufTaskGraph::DeviceType devtype, uint64_t nodeid, uint64_t deviceproperty, uint64_t bandwidth); }; class FFTask : public EventSource { public: FFApplication * ffapp; // static EventList & evl; enum FFTaskType { TASK_FORWARD, TASK_BACKWARD, TASK_COMM, TASK_UPDATE, TASK_BARRIER, TASK_LATENCY, TASK_ALLREDUCE, }; enum FFTaskState { TASK_NOT_READY, TASK_READY, TASK_RUNNING, TASK_FINISHED, }; void add_nextask(FFTask * task); void taskstart(); void cleanup(); void start_flow(); virtual void doNextEvent(); // call task event void execute_compute(); virtual void reset() { state = FFTask::TASK_NOT_READY; ready_time = eventlist().now(); start_time = 0; finish_time = 0; } FFTaskType type; FFTaskState state; FFDevice* device; int counter; uint64_t xfersize = 0; std::vector<uint64_t> next_tasks; int src_node, dst_node; simtime_picosec ready_time, run_time; simtime_picosec start_time, finish_time; FFTask(FFApplication * ffapp, std::string type, FFDevice * device, uint64_t xfersize, float runtime); // FFTask(TaskGraphProtoBuf::Task_SimTaskType tasktype, FFDevice * device, uint64_t xfersize, float runtime); FFTask(FFApplication * ffapp, FlatBufTaskGraph::SimTaskType tasktype, FFDevice * device, uint64_t xfersize, float runtime); FFTask(FFApplication * ffapp, FFTaskType tasktype); }; class FFNewRingAllreduce; struct FFNewRingAllreduceFlow { FFNewRingAllreduce * ar; int id; int src_idx; int ring_idx; int round; }; class FFNewRingAllreduce : public FFTask { public: FFNewRingAllreduce(FFApplication * ffapp, std::vector<uint64_t> ng, const std::vector<std::vector<int>>& jumps, uint64_t sz, double local_runtime = 0); ~FFNewRingAllreduce() = default; std::vector<uint64_t> node_group; // group of nodes in the order of the ring const std::vector<std::vector<int>>& jumps; uint64_t operator_size; // total data size of the operator std::vector<int> total_jump; int finished_rings; std::vector<int> finished_curr_round; std::vector<int> curr_round; std::vector<std::vector<int>> finished_rounds; virtual void doNextEvent(); virtual void reset() { FFTask::reset(); std::fill(finished_curr_round.begin(), finished_curr_round.end(), 0); std::fill(curr_round.begin(), curr_round.end(), 0); for (auto & v: finished_rounds) { std::fill(v.begin(), v.end(), 0); } finished_rings = 0; } void start_flow(int src_idx, const std::vector<int>& jump, int ring_id, int id); }; void ar_finish_newring(void * arinfo); class FFRingAllreduce; struct FFRingAllreduceFlow { FFRingAllreduce * ar; int id; int src_idx; int round; }; class FFRingAllreduce : public FFTask { public: FFRingAllreduce(FFApplication * ffapp, std::vector<uint64_t> ng, uint64_t sz, double local_runtime = 0); ~FFRingAllreduce() = default; std::vector<uint64_t> node_group; // group of nodes in the order of the ring uint32_t operator_size; // total data size of the operator int finished_partitions; // number of finished partitions int finished_curr_round; int curr_round; std::vector<int> finished_rounds; virtual void doNextEvent(); virtual void reset() { FFTask::reset(); finished_curr_round = 0; curr_round = 0; finished_partitions = 0; std::fill(finished_rounds.begin(), finished_rounds.end(), 0); } // void start(); // void start_flow(int src_idx, int round); void start_flow(int src_idx, int id); }; void ar_finish_ring(void * arinfo); class FFPSAllreduce; struct FFPSAllreduceFlow { FFPSAllreduce * ar; int node_idx; int direction; }; class FFPSAllreduce : public FFTask { public: FFPSAllreduce(FFApplication * ffapp, std::vector<uint64_t> ng, uint64_t sz, double local_runtime = 0); ~FFPSAllreduce() = default; std::vector<uint64_t> node_group; // group of nodes uint32_t operator_size; // total data size of the operator int pserver; int curr_round; // will be 2 (scatter, gather) std::vector<int> finished_rounds; int finished_curr_round; virtual void doNextEvent(); virtual void reset() { FFTask::reset(); finished_curr_round = 0; curr_round = 0; std::fill(finished_rounds.begin(), finished_rounds.end(), 0); } void start_flow(int node_idx, int direction); }; void ar_finish_ps(void * arinfo); class FFDPSAllreduce; // struct FFDPSAllreduceFlow { // FFDPSAllreduce * ar; // int id; // int src_idx; // int round; // }; class FFDPSAllreduce : public FFTask { public: FFDPSAllreduce(FFApplication * ffapp, std::vector<uint64_t> ng, uint64_t sz, double local_runtime = 0); ~FFDPSAllreduce() = default; std::vector<uint64_t> node_group; // group of nodes in the order of the ring uint32_t operator_size; // total data size of the operator int finished_partitions; // number of finished partitions int finished_curr_round; int curr_round; virtual void doNextEvent(); virtual void reset() { FFTask::reset(); finished_curr_round = 0; curr_round = 0; finished_partitions = 0; } // void start(); // void start_flow(int src_idx, int round); void start_flow(int src_node, int dst_node); }; void ar_finish_dps(void * ar_ptr); class FFApplication { public: enum FFAllReduceStrategy { FF_RING_AR, FF_PS_AR, FF_DPS_AR, FF_DEFAULT_AR }; // FFApplication(Topology* top, int cwnd, double pull_rate, // NdpRtxTimerScanner & nrts, NdpSinkLoggerSampling & sl, EventList & eventlist, std::string taskgraph); // FFApplication(Topology* top, int ss, TcpSinkLoggerSampling & sl, TcpTrafficLogger & tl, // TcpRtxTimerScanner & rtx, EventList & eventlist, std::string taskgraph); FFApplication(Topology* top, int ss, ofstream * _fstream_out, // TcpSinkLoggerSampling & sl, TcpTrafficLogger & tl, TcpRtxTimerScanner & rtx, EventList & eventlist, FFAllReduceStrategy ars = FFApplication::FF_DEFAULT_AR); FFApplication(Topology* top, int ss, ofstream * _fstream_out, std::vector<int> gpus, // TcpSinkLoggerSampling & sl, TcpTrafficLogger & tl, TcpRtxTimerScanner & rtx, EventList & eventlist, FFAllReduceStrategy ars = FFApplication::FF_DEFAULT_AR); ~FFApplication(); void load_taskgraph_json(std::string & taskgraph); // void load_taskgraph_protobuf(std::string & taskgraph); void load_taskgraph_flatbuf(std::string & taskgraph); void start_init_tasks(); void reset_and_restart(); static std::vector<int> choose_gpus(std::unordered_set<int> & candidates, int n); static bool LoadFileRaw(const char *name, std::string *buf) { std::ifstream ifs(name, std::ifstream::binary); if (!ifs.is_open()) { return false; } // The fastest way to read a file into a string. ifs.seekg(0, std::ios::end); auto size = ifs.tellg(); (*buf).resize(static_cast<size_t>(size)); ifs.seekg(0, std::ios::beg); ifs.read(&(*buf)[0], (*buf).size()); return !ifs.bad(); } size_t nnodes, ngpupernode, nswitches; int cwnd; double pull_rate; std::unordered_map<uint64_t, FFTask*> tasks; std::unordered_map<uint64_t, FFDevice*> devices; Topology * topology; int ssthresh; EventList & eventlist; unordered_map<uint64_t, unsigned int> counters; // NdpRtxTimerScanner & ndpRtxScanner; // NdpSinkLoggerSampling & sinkLogger; // TcpSinkLoggerSampling & sinkLogger; // TcpTrafficLogger & tcpTrafficLogger; FFAllReduceStrategy allreduce_strategy; ofstream * fstream_out; TcpRtxTimerScanner & tcpRtxScanner; std::unordered_map<uint64_t, std::vector<std::vector<int>>> selected_jumps; bool fancy_ring; bool finished_once; static int total_apps; static int finished_apps; std::vector<int> gpus; simtime_picosec final_finish_time; simtime_picosec first_iter_time; size_t n_finished_tasks; }; void taskfinish(void * task); #endif // FF_APP_H
27.805233
143
0.669106
[ "vector" ]
d41d583e5be91df1403525ea50b36dca877f76e8
29,145
h
C
src/common/model/response_generated.h
sptrakesh/config-db
583ef3a3b636b2d56283194ff2b183bac2a36f21
[ "Apache-2.0" ]
null
null
null
src/common/model/response_generated.h
sptrakesh/config-db
583ef3a3b636b2d56283194ff2b183bac2a36f21
[ "Apache-2.0" ]
null
null
null
src/common/model/response_generated.h
sptrakesh/config-db
583ef3a3b636b2d56283194ff2b183bac2a36f21
[ "Apache-2.0" ]
null
null
null
// automatically generated by the FlatBuffers compiler, do not modify #ifndef FLATBUFFERS_GENERATED_RESPONSE_SPT_CONFIGDB_MODEL_H_ #define FLATBUFFERS_GENERATED_RESPONSE_SPT_CONFIGDB_MODEL_H_ #include "flatbuffers/flatbuffers.h" namespace spt { namespace configdb { namespace model { struct Value; struct ValueBuilder; struct Children; struct ChildrenBuilder; struct Success; struct SuccessBuilder; struct KeyValueResult; struct KeyValueResultBuilder; struct KeyValueResults; struct KeyValueResultsBuilder; struct Response; struct ResponseBuilder; inline const flatbuffers::TypeTable *ValueTypeTable(); inline const flatbuffers::TypeTable *ChildrenTypeTable(); inline const flatbuffers::TypeTable *SuccessTypeTable(); inline const flatbuffers::TypeTable *KeyValueResultTypeTable(); inline const flatbuffers::TypeTable *KeyValueResultsTypeTable(); inline const flatbuffers::TypeTable *ResponseTypeTable(); enum class ValueVariant : uint8_t { NONE = 0, Value = 1, Children = 2, Success = 3, MIN = NONE, MAX = Success }; inline const ValueVariant (&EnumValuesValueVariant())[4] { static const ValueVariant values[] = { ValueVariant::NONE, ValueVariant::Value, ValueVariant::Children, ValueVariant::Success }; return values; } inline const char * const *EnumNamesValueVariant() { static const char * const names[5] = { "NONE", "Value", "Children", "Success", nullptr }; return names; } inline const char *EnumNameValueVariant(ValueVariant e) { if (flatbuffers::IsOutRange(e, ValueVariant::NONE, ValueVariant::Success)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesValueVariant()[index]; } template<typename T> struct ValueVariantTraits { static const ValueVariant enum_value = ValueVariant::NONE; }; template<> struct ValueVariantTraits<spt::configdb::model::Value> { static const ValueVariant enum_value = ValueVariant::Value; }; template<> struct ValueVariantTraits<spt::configdb::model::Children> { static const ValueVariant enum_value = ValueVariant::Children; }; template<> struct ValueVariantTraits<spt::configdb::model::Success> { static const ValueVariant enum_value = ValueVariant::Success; }; bool VerifyValueVariant(flatbuffers::Verifier &verifier, const void *obj, ValueVariant type); bool VerifyValueVariantVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); enum class ResultVariant : uint8_t { NONE = 0, KeyValueResults = 1, Success = 2, MIN = NONE, MAX = Success }; inline const ResultVariant (&EnumValuesResultVariant())[3] { static const ResultVariant values[] = { ResultVariant::NONE, ResultVariant::KeyValueResults, ResultVariant::Success }; return values; } inline const char * const *EnumNamesResultVariant() { static const char * const names[4] = { "NONE", "KeyValueResults", "Success", nullptr }; return names; } inline const char *EnumNameResultVariant(ResultVariant e) { if (flatbuffers::IsOutRange(e, ResultVariant::NONE, ResultVariant::Success)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesResultVariant()[index]; } template<typename T> struct ResultVariantTraits { static const ResultVariant enum_value = ResultVariant::NONE; }; template<> struct ResultVariantTraits<spt::configdb::model::KeyValueResults> { static const ResultVariant enum_value = ResultVariant::KeyValueResults; }; template<> struct ResultVariantTraits<spt::configdb::model::Success> { static const ResultVariant enum_value = ResultVariant::Success; }; bool VerifyResultVariant(flatbuffers::Verifier &verifier, const void *obj, ResultVariant type); bool VerifyResultVariantVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); struct Value FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ValueBuilder Builder; struct Traits; static const flatbuffers::TypeTable *MiniReflectTypeTable() { return ValueTypeTable(); } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE = 4 }; const flatbuffers::String *value() const { return GetPointer<const flatbuffers::String *>(VT_VALUE); } template<size_t Index> auto get_field() const { if constexpr (Index == 0) return value(); else static_assert(Index != Index, "Invalid Field Index"); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUE) && verifier.VerifyString(value()) && verifier.EndTable(); } }; struct ValueBuilder { typedef Value Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_value(flatbuffers::Offset<flatbuffers::String> value) { fbb_.AddOffset(Value::VT_VALUE, value); } explicit ValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<Value> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Value>(end); return o; } }; inline flatbuffers::Offset<Value> CreateValue( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::String> value = 0) { ValueBuilder builder_(_fbb); builder_.add_value(value); return builder_.Finish(); } struct Value::Traits { using type = Value; static auto constexpr Create = CreateValue; static constexpr auto name = "Value"; static constexpr auto fully_qualified_name = "spt.configdb.model.Value"; static constexpr std::array<const char *, 1> field_names = { "value" }; template<size_t Index> using FieldType = decltype(std::declval<type>().get_field<Index>()); static constexpr size_t fields_number = 1; }; inline flatbuffers::Offset<Value> CreateValueDirect( flatbuffers::FlatBufferBuilder &_fbb, const char *value = nullptr) { auto value__ = value ? _fbb.CreateString(value) : 0; return spt::configdb::model::CreateValue( _fbb, value__); } struct Children FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ChildrenBuilder Builder; struct Traits; static const flatbuffers::TypeTable *MiniReflectTypeTable() { return ChildrenTypeTable(); } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE = 4 }; const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *value() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_VALUE); } template<size_t Index> auto get_field() const { if constexpr (Index == 0) return value(); else static_assert(Index != Index, "Invalid Field Index"); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUE) && verifier.VerifyVector(value()) && verifier.VerifyVectorOfStrings(value()) && verifier.EndTable(); } }; struct ChildrenBuilder { typedef Children Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_value(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> value) { fbb_.AddOffset(Children::VT_VALUE, value); } explicit ChildrenBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<Children> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Children>(end); return o; } }; inline flatbuffers::Offset<Children> CreateChildren( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> value = 0) { ChildrenBuilder builder_(_fbb); builder_.add_value(value); return builder_.Finish(); } struct Children::Traits { using type = Children; static auto constexpr Create = CreateChildren; static constexpr auto name = "Children"; static constexpr auto fully_qualified_name = "spt.configdb.model.Children"; static constexpr std::array<const char *, 1> field_names = { "value" }; template<size_t Index> using FieldType = decltype(std::declval<type>().get_field<Index>()); static constexpr size_t fields_number = 1; }; inline flatbuffers::Offset<Children> CreateChildrenDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<flatbuffers::Offset<flatbuffers::String>> *value = nullptr) { auto value__ = value ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*value) : 0; return spt::configdb::model::CreateChildren( _fbb, value__); } struct Success FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SuccessBuilder Builder; struct Traits; static const flatbuffers::TypeTable *MiniReflectTypeTable() { return SuccessTypeTable(); } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE = 4 }; bool value() const { return GetField<uint8_t>(VT_VALUE, 0) != 0; } template<size_t Index> auto get_field() const { if constexpr (Index == 0) return value(); else static_assert(Index != Index, "Invalid Field Index"); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_VALUE) && verifier.EndTable(); } }; struct SuccessBuilder { typedef Success Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_value(bool value) { fbb_.AddElement<uint8_t>(Success::VT_VALUE, static_cast<uint8_t>(value), 0); } explicit SuccessBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<Success> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Success>(end); return o; } }; inline flatbuffers::Offset<Success> CreateSuccess( flatbuffers::FlatBufferBuilder &_fbb, bool value = false) { SuccessBuilder builder_(_fbb); builder_.add_value(value); return builder_.Finish(); } struct Success::Traits { using type = Success; static auto constexpr Create = CreateSuccess; static constexpr auto name = "Success"; static constexpr auto fully_qualified_name = "spt.configdb.model.Success"; static constexpr std::array<const char *, 1> field_names = { "value" }; template<size_t Index> using FieldType = decltype(std::declval<type>().get_field<Index>()); static constexpr size_t fields_number = 1; }; struct KeyValueResult FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef KeyValueResultBuilder Builder; struct Traits; static const flatbuffers::TypeTable *MiniReflectTypeTable() { return KeyValueResultTypeTable(); } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_KEY = 4, VT_VALUE_TYPE = 6, VT_VALUE = 8 }; const flatbuffers::String *key() const { return GetPointer<const flatbuffers::String *>(VT_KEY); } spt::configdb::model::ValueVariant value_type() const { return static_cast<spt::configdb::model::ValueVariant>(GetField<uint8_t>(VT_VALUE_TYPE, 0)); } const void *value() const { return GetPointer<const void *>(VT_VALUE); } template<typename T> const T *value_as() const; const spt::configdb::model::Value *value_as_Value() const { return value_type() == spt::configdb::model::ValueVariant::Value ? static_cast<const spt::configdb::model::Value *>(value()) : nullptr; } const spt::configdb::model::Children *value_as_Children() const { return value_type() == spt::configdb::model::ValueVariant::Children ? static_cast<const spt::configdb::model::Children *>(value()) : nullptr; } const spt::configdb::model::Success *value_as_Success() const { return value_type() == spt::configdb::model::ValueVariant::Success ? static_cast<const spt::configdb::model::Success *>(value()) : nullptr; } template<size_t Index> auto get_field() const { if constexpr (Index == 0) return key(); else if constexpr (Index == 1) return value_type(); else if constexpr (Index == 2) return value(); else static_assert(Index != Index, "Invalid Field Index"); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_KEY) && verifier.VerifyString(key()) && VerifyField<uint8_t>(verifier, VT_VALUE_TYPE) && VerifyOffset(verifier, VT_VALUE) && VerifyValueVariant(verifier, value(), value_type()) && verifier.EndTable(); } }; template<> inline const spt::configdb::model::Value *KeyValueResult::value_as<spt::configdb::model::Value>() const { return value_as_Value(); } template<> inline const spt::configdb::model::Children *KeyValueResult::value_as<spt::configdb::model::Children>() const { return value_as_Children(); } template<> inline const spt::configdb::model::Success *KeyValueResult::value_as<spt::configdb::model::Success>() const { return value_as_Success(); } struct KeyValueResultBuilder { typedef KeyValueResult Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_key(flatbuffers::Offset<flatbuffers::String> key) { fbb_.AddOffset(KeyValueResult::VT_KEY, key); } void add_value_type(spt::configdb::model::ValueVariant value_type) { fbb_.AddElement<uint8_t>(KeyValueResult::VT_VALUE_TYPE, static_cast<uint8_t>(value_type), 0); } void add_value(flatbuffers::Offset<void> value) { fbb_.AddOffset(KeyValueResult::VT_VALUE, value); } explicit KeyValueResultBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<KeyValueResult> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<KeyValueResult>(end); return o; } }; inline flatbuffers::Offset<KeyValueResult> CreateKeyValueResult( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::String> key = 0, spt::configdb::model::ValueVariant value_type = spt::configdb::model::ValueVariant::NONE, flatbuffers::Offset<void> value = 0) { KeyValueResultBuilder builder_(_fbb); builder_.add_value(value); builder_.add_key(key); builder_.add_value_type(value_type); return builder_.Finish(); } struct KeyValueResult::Traits { using type = KeyValueResult; static auto constexpr Create = CreateKeyValueResult; static constexpr auto name = "KeyValueResult"; static constexpr auto fully_qualified_name = "spt.configdb.model.KeyValueResult"; static constexpr std::array<const char *, 3> field_names = { "key", "value_type", "value" }; template<size_t Index> using FieldType = decltype(std::declval<type>().get_field<Index>()); static constexpr size_t fields_number = 3; }; inline flatbuffers::Offset<KeyValueResult> CreateKeyValueResultDirect( flatbuffers::FlatBufferBuilder &_fbb, const char *key = nullptr, spt::configdb::model::ValueVariant value_type = spt::configdb::model::ValueVariant::NONE, flatbuffers::Offset<void> value = 0) { auto key__ = key ? _fbb.CreateString(key) : 0; return spt::configdb::model::CreateKeyValueResult( _fbb, key__, value_type, value); } struct KeyValueResults FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef KeyValueResultsBuilder Builder; struct Traits; static const flatbuffers::TypeTable *MiniReflectTypeTable() { return KeyValueResultsTypeTable(); } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE = 4 }; const flatbuffers::Vector<flatbuffers::Offset<spt::configdb::model::KeyValueResult>> *value() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<spt::configdb::model::KeyValueResult>> *>(VT_VALUE); } template<size_t Index> auto get_field() const { if constexpr (Index == 0) return value(); else static_assert(Index != Index, "Invalid Field Index"); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUE) && verifier.VerifyVector(value()) && verifier.VerifyVectorOfTables(value()) && verifier.EndTable(); } }; struct KeyValueResultsBuilder { typedef KeyValueResults Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_value(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<spt::configdb::model::KeyValueResult>>> value) { fbb_.AddOffset(KeyValueResults::VT_VALUE, value); } explicit KeyValueResultsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<KeyValueResults> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<KeyValueResults>(end); return o; } }; inline flatbuffers::Offset<KeyValueResults> CreateKeyValueResults( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<spt::configdb::model::KeyValueResult>>> value = 0) { KeyValueResultsBuilder builder_(_fbb); builder_.add_value(value); return builder_.Finish(); } struct KeyValueResults::Traits { using type = KeyValueResults; static auto constexpr Create = CreateKeyValueResults; static constexpr auto name = "KeyValueResults"; static constexpr auto fully_qualified_name = "spt.configdb.model.KeyValueResults"; static constexpr std::array<const char *, 1> field_names = { "value" }; template<size_t Index> using FieldType = decltype(std::declval<type>().get_field<Index>()); static constexpr size_t fields_number = 1; }; inline flatbuffers::Offset<KeyValueResults> CreateKeyValueResultsDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<flatbuffers::Offset<spt::configdb::model::KeyValueResult>> *value = nullptr) { auto value__ = value ? _fbb.CreateVector<flatbuffers::Offset<spt::configdb::model::KeyValueResult>>(*value) : 0; return spt::configdb::model::CreateKeyValueResults( _fbb, value__); } struct Response FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ResponseBuilder Builder; struct Traits; static const flatbuffers::TypeTable *MiniReflectTypeTable() { return ResponseTypeTable(); } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE_TYPE = 4, VT_VALUE = 6 }; spt::configdb::model::ResultVariant value_type() const { return static_cast<spt::configdb::model::ResultVariant>(GetField<uint8_t>(VT_VALUE_TYPE, 0)); } const void *value() const { return GetPointer<const void *>(VT_VALUE); } template<typename T> const T *value_as() const; const spt::configdb::model::KeyValueResults *value_as_KeyValueResults() const { return value_type() == spt::configdb::model::ResultVariant::KeyValueResults ? static_cast<const spt::configdb::model::KeyValueResults *>(value()) : nullptr; } const spt::configdb::model::Success *value_as_Success() const { return value_type() == spt::configdb::model::ResultVariant::Success ? static_cast<const spt::configdb::model::Success *>(value()) : nullptr; } template<size_t Index> auto get_field() const { if constexpr (Index == 0) return value_type(); else if constexpr (Index == 1) return value(); else static_assert(Index != Index, "Invalid Field Index"); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_VALUE_TYPE) && VerifyOffset(verifier, VT_VALUE) && VerifyResultVariant(verifier, value(), value_type()) && verifier.EndTable(); } }; template<> inline const spt::configdb::model::KeyValueResults *Response::value_as<spt::configdb::model::KeyValueResults>() const { return value_as_KeyValueResults(); } template<> inline const spt::configdb::model::Success *Response::value_as<spt::configdb::model::Success>() const { return value_as_Success(); } struct ResponseBuilder { typedef Response Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_value_type(spt::configdb::model::ResultVariant value_type) { fbb_.AddElement<uint8_t>(Response::VT_VALUE_TYPE, static_cast<uint8_t>(value_type), 0); } void add_value(flatbuffers::Offset<void> value) { fbb_.AddOffset(Response::VT_VALUE, value); } explicit ResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<Response> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Response>(end); return o; } }; inline flatbuffers::Offset<Response> CreateResponse( flatbuffers::FlatBufferBuilder &_fbb, spt::configdb::model::ResultVariant value_type = spt::configdb::model::ResultVariant::NONE, flatbuffers::Offset<void> value = 0) { ResponseBuilder builder_(_fbb); builder_.add_value(value); builder_.add_value_type(value_type); return builder_.Finish(); } struct Response::Traits { using type = Response; static auto constexpr Create = CreateResponse; static constexpr auto name = "Response"; static constexpr auto fully_qualified_name = "spt.configdb.model.Response"; static constexpr std::array<const char *, 2> field_names = { "value_type", "value" }; template<size_t Index> using FieldType = decltype(std::declval<type>().get_field<Index>()); static constexpr size_t fields_number = 2; }; inline bool VerifyValueVariant(flatbuffers::Verifier &verifier, const void *obj, ValueVariant type) { switch (type) { case ValueVariant::NONE: { return true; } case ValueVariant::Value: { auto ptr = reinterpret_cast<const spt::configdb::model::Value *>(obj); return verifier.VerifyTable(ptr); } case ValueVariant::Children: { auto ptr = reinterpret_cast<const spt::configdb::model::Children *>(obj); return verifier.VerifyTable(ptr); } case ValueVariant::Success: { auto ptr = reinterpret_cast<const spt::configdb::model::Success *>(obj); return verifier.VerifyTable(ptr); } default: return true; } } inline bool VerifyValueVariantVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) { if (!values || !types) return !values && !types; if (values->size() != types->size()) return false; for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { if (!VerifyValueVariant( verifier, values->Get(i), types->GetEnum<ValueVariant>(i))) { return false; } } return true; } inline bool VerifyResultVariant(flatbuffers::Verifier &verifier, const void *obj, ResultVariant type) { switch (type) { case ResultVariant::NONE: { return true; } case ResultVariant::KeyValueResults: { auto ptr = reinterpret_cast<const spt::configdb::model::KeyValueResults *>(obj); return verifier.VerifyTable(ptr); } case ResultVariant::Success: { auto ptr = reinterpret_cast<const spt::configdb::model::Success *>(obj); return verifier.VerifyTable(ptr); } default: return true; } } inline bool VerifyResultVariantVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) { if (!values || !types) return !values && !types; if (values->size() != types->size()) return false; for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { if (!VerifyResultVariant( verifier, values->Get(i), types->GetEnum<ResultVariant>(i))) { return false; } } return true; } inline const flatbuffers::TypeTable *ValueVariantTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_SEQUENCE, 0, -1 }, { flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 1 }, { flatbuffers::ET_SEQUENCE, 0, 2 } }; static const flatbuffers::TypeFunction type_refs[] = { spt::configdb::model::ValueTypeTable, spt::configdb::model::ChildrenTypeTable, spt::configdb::model::SuccessTypeTable }; static const char * const names[] = { "NONE", "Value", "Children", "Success" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *ResultVariantTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_SEQUENCE, 0, -1 }, { flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 1 } }; static const flatbuffers::TypeFunction type_refs[] = { spt::configdb::model::KeyValueResultsTypeTable, spt::configdb::model::SuccessTypeTable }; static const char * const names[] = { "NONE", "KeyValueResults", "Success" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_UNION, 3, type_codes, type_refs, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *ValueTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_STRING, 0, -1 } }; static const char * const names[] = { "value" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *ChildrenTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_STRING, 1, -1 } }; static const char * const names[] = { "value" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *SuccessTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_BOOL, 0, -1 } }; static const char * const names[] = { "value" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *KeyValueResultTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_STRING, 0, -1 }, { flatbuffers::ET_UTYPE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 } }; static const flatbuffers::TypeFunction type_refs[] = { spt::configdb::model::ValueVariantTypeTable }; static const char * const names[] = { "key", "value_type", "value" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *KeyValueResultsTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_SEQUENCE, 1, 0 } }; static const flatbuffers::TypeFunction type_refs[] = { spt::configdb::model::KeyValueResultTypeTable }; static const char * const names[] = { "value" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names }; return &tt; } inline const flatbuffers::TypeTable *ResponseTypeTable() { static const flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_UTYPE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 } }; static const flatbuffers::TypeFunction type_refs[] = { spt::configdb::model::ResultVariantTypeTable }; static const char * const names[] = { "value_type", "value" }; static const flatbuffers::TypeTable tt = { flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, nullptr, names }; return &tt; } inline const spt::configdb::model::Response *GetResponse(const void *buf) { return flatbuffers::GetRoot<spt::configdb::model::Response>(buf); } inline const spt::configdb::model::Response *GetSizePrefixedResponse(const void *buf) { return flatbuffers::GetSizePrefixedRoot<spt::configdb::model::Response>(buf); } inline bool VerifyResponseBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<spt::configdb::model::Response>(nullptr); } inline bool VerifySizePrefixedResponseBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifySizePrefixedBuffer<spt::configdb::model::Response>(nullptr); } inline void FinishResponseBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<spt::configdb::model::Response> root) { fbb.Finish(root); } inline void FinishSizePrefixedResponseBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<spt::configdb::model::Response> root) { fbb.FinishSizePrefixed(root); } } // namespace model } // namespace configdb } // namespace spt #endif // FLATBUFFERS_GENERATED_RESPONSE_SPT_CONFIGDB_MODEL_H_
33.119318
177
0.713673
[ "vector", "model" ]
d42077f1daac816721007688383d57a93b93ce35
2,003
h
C
source/sharpextern-1.1/imgcodecs.h
InstytutXR/OpenCV-Unity
3a5da9f245b0e4a8cd01147ffdd5d6291347fbd1
[ "Apache-2.0" ]
4
2021-11-15T13:48:25.000Z
2021-12-15T23:23:09.000Z
source/sharpextern-1.1/imgcodecs.h
InstytutXR/OpenCV-Unity
3a5da9f245b0e4a8cd01147ffdd5d6291347fbd1
[ "Apache-2.0" ]
null
null
null
source/sharpextern-1.1/imgcodecs.h
InstytutXR/OpenCV-Unity
3a5da9f245b0e4a8cd01147ffdd5d6291347fbd1
[ "Apache-2.0" ]
null
null
null
#ifndef _CPP_IMGCODECS_H_ #define _CPP_IMGCODECS_H_ #include "include_opencv.h" CVAPI(cv::Mat*) imgcodecs_imread(const char *filename, int flags) { cv::Mat ret = cv::imread(filename, flags); return new cv::Mat(ret); } CVAPI(int) imgcodecs_imreadmulti(const char *filename, std::vector<cv::Mat> *mats, int flags) { return cv::imreadmulti(filename, *mats, flags) ? 1 : 0; } CVAPI(int) imgcodecs_imwrite(const char *filename, cv::Mat *img, int *params, int paramsLength) { std::vector<int> paramsVec; paramsVec.assign(params, params + paramsLength); return cv::imwrite(filename, *img, paramsVec) ? 1 : 0; } CVAPI(cv::Mat*) imgcodecs_imdecode_Mat(cv::Mat *buf, int flags) { cv::Mat ret = cv::imdecode(*buf, flags); return new cv::Mat(ret); } CVAPI(cv::Mat*) imgcodecs_imdecode_vector(uchar *buf, size_t bufLength, int flags) { std::vector<uchar> bufVec(buf, buf + bufLength); cv::Mat ret = cv::imdecode(bufVec, flags); return new cv::Mat(ret); } CVAPI(cv::Mat*) imgcodecs_imdecode_InputArray(cv::_InputArray *buf, int flags) { cv::Mat ret = cv::imdecode(*buf, flags); return new cv::Mat(ret); } CVAPI(int) imgcodecs_imencode_vector(const char *ext, cv::_InputArray *img, std::vector<uchar> *buf, int *params, int paramsLength) { std::vector<int> paramsVec; if (params != NULL) paramsVec = std::vector<int>(params, params + paramsLength); return cv::imencode(ext, *img, *buf, paramsVec) ? 1 : 0; } CVAPI(void) imgcodecs_cvConvertImage_CvArr(CvArr *src, CvArr *dst, int flags) { cvConvertImage(src, dst, flags); } CVAPI(void) imgcodecs_cvConvertImage_Mat(cv::Mat *src, cv::Mat *dst, int flags) { IplImage srcImg = (IplImage)*src; IplImage dstImg = (IplImage)*dst; cvConvertImage(&srcImg, &dstImg, flags); } CVAPI(int) imgcodecs_cvHaveImageReader(const char *filename) { return cvHaveImageReader(filename); } CVAPI(int) imgcodecs_cvHaveImageWriter(const char *filename) { return cvHaveImageWriter(filename); } #endif
27.438356
95
0.702446
[ "vector" ]
d420c85e37881f4eaa2f714f731e19880fa4443b
2,123
h
C
zadkit/ZADKit.framework/Versions/A/Headers/ZADInterstitial.h
Raydem0n/zadkit
8dd52778d4f770cd84ba50db64cb0dcd2fca0261
[ "MIT" ]
null
null
null
zadkit/ZADKit.framework/Versions/A/Headers/ZADInterstitial.h
Raydem0n/zadkit
8dd52778d4f770cd84ba50db64cb0dcd2fca0261
[ "MIT" ]
null
null
null
zadkit/ZADKit.framework/Versions/A/Headers/ZADInterstitial.h
Raydem0n/zadkit
8dd52778d4f770cd84ba50db64cb0dcd2fca0261
[ "MIT" ]
null
null
null
// // ZADInterstitial.h // ZADKit // // Created by Ray Liu on 4/20/16. // Copyright © 2016 ZY. All rights reserved. // #import <Foundation/Foundation.h> #import "ZADRequest.h" #import "ZADInterstitialDelegate.h" @interface ZADInterstitial : UIView #pragma mark Pre-Request /// Required value passed in with initWithAdUnitID:. @property(nonatomic, readonly, copy) NSString *adUnitID; /// Optional delegate object that receives state change notifications from this ZADInterstitalAd. @property(nonatomic, weak) id<ZADInterstitialDelegate> delegate; #pragma mark Making an Ad Request /// Makes an interstitial ad request. Additional targeting options can be supplied with a request /// object. Only one interstitial request is allowed at a time. /// /// This is best to do several seconds before the interstitial is needed to preload its content. /// Then when transitioning between view controllers show the interstital with /// presentFromViewController. - (void)loadRequest:(ZADRequest *)request; #pragma mark Post-Request /// Returns YES if the interstitial is ready to be displayed. The delegate's /// interstitialAdDidReceiveAd: will be called after this property switches from NO to YES. @property(nonatomic, readonly, assign) BOOL isReady; /// Returns YES if this object has already been presented. Interstitial objects can only be used /// once even with different requests. @property(nonatomic, readonly, assign) BOOL hasBeenUsed; /// Presents the interstitial ad which takes over the entire screen until the user dismisses it. /// This has no effect unless isReady returns YES and/or the delegate's interstitialDidReceiveAd: /// has been received. /// /// Set rootViewController to the current view controller at the time this method is called. If your /// application does not use view controllers pass in nil and your views will be removed from the /// window to show the interstitial and restored when done. After the interstitial has been removed, /// the delegate's interstitialDidDismissScreen: will be called. - (void)presentFromRootViewController:(UIViewController *)rootViewController; @end
39.314815
100
0.778144
[ "object" ]
6a78520ef358d7bf800cf176f571950ad6cab84a
5,998
h
C
ni/src/lib/hlu/LegendP.h
tenomoto/ncl
a87114a689a1566e9aa03d85bcf6dc7325b47633
[ "Apache-2.0" ]
210
2016-11-24T09:05:08.000Z
2022-03-24T19:15:32.000Z
ni/src/lib/hlu/LegendP.h
tenomoto/ncl
a87114a689a1566e9aa03d85bcf6dc7325b47633
[ "Apache-2.0" ]
156
2017-09-22T09:56:48.000Z
2022-03-30T07:02:21.000Z
ni/src/lib/hlu/LegendP.h
tenomoto/ncl
a87114a689a1566e9aa03d85bcf6dc7325b47633
[ "Apache-2.0" ]
58
2016-12-14T00:15:22.000Z
2022-03-15T09:13:00.000Z
/* * $Id: LegendP.h,v 1.21 2008-05-27 20:55:30 dbrown Exp $ */ /************************************************************************ * * * Copyright (C) 1992 * * University Corporation for Atmospheric Research * * All Rights Reserved * * * ************************************************************************/ /* * File: LegendP.h * * Author: David I. Brown * National Center for Atmospheric Research * PO 3000, Boulder, Colorado * * Date: Fri Jun 11 15:17:49 MDT 1993 * * Description: Private header file for Legend class */ #ifndef _NLegendP_h #define _NLegendP_h #include <ncarg/hlu/ViewP.h> #include <ncarg/hlu/Workstation.h> #include <ncarg/hlu/Legend.h> /* defines */ #define NhlLG_MAX_ITEMS 256 #define NhlLG_MAX_LBL_STRINGS (NhlLG_MAX_ITEMS) #define NhlLG_DEF_ITEM_COUNT 16 #define NhlLG_DEF_COLOR NhlFOREGROUND #define NhlLG_DEF_LINE_INDEX 1 #define NhlLG_MIN_LINE_INDEX 0 #define NhlLG_DEF_MARKER_INDEX 1 #define NhlLG_MIN_MARKER_INDEX 0 #define NhlLG_DEF_STRING "Label_" #define NhlLG_DEF_ITEM_STRING "L" #define NhlLG_DEF_BAR_MAJOR 1.0 #define NhlLG_DEF_BAR_MINOR 0.33 #define NhlLg_DEF_LABEL_MINOR 0.33 #define NhlLG_DEF_CHAR_HEIGHT 0.04 #define NhlLG_DEF_TITLE_EXT 0.15 #define NhlLG_DEF_TITLE_OFF 0.03 typedef struct _lgLocInfo { float l,r,b,t; float lxtr,rxtr,bxtr,txtr; } lgLocInfo; typedef struct _NhlLegendLayerPart { /* public resource fields */ int legend_on; NhlOrientation orient; NhlJustification just; float box_major_ext; float box_minor_ext; int item_count; NhllgItemPlacementMode item_placement; NhlBoolean auto_manage; float label_angle_add; float label_off; float title_off; NhlBoundingBox margin; NhlGenArray line_labels; NhlBoolean mono_item_type; NhlMarkLineMode item_type; NhlGenArray item_types; NhlBoolean mono_dash_index; NhlDashIndex dash_index; NhlGenArray dash_indexes; NhlBoolean mono_marker_index; NhlMarkerIndex marker_index; NhlGenArray marker_indexes; NhlBoolean mono_line_color; NhlColorIndex line_color; NhlGenArray line_colors; NhlBoolean mono_marker_color; NhlColorIndex marker_color; NhlGenArray marker_colors; NhlBoolean mono_line_thickness; float line_thickness; NhlGenArray line_thicknesses; NhlBoolean mono_marker_thickness; float marker_thickness; NhlGenArray marker_thicknesses; NhlBoolean mono_line_label_font_height; float line_label_font_height; NhlGenArray line_label_font_heights; NhlBoolean mono_marker_size; float marker_size; NhlGenArray marker_sizes; NhlGenArray label_strings; NhlGenArray item_positions; NhlGenArray item_order; NhlBoolean mono_line_label_color; NhlColorIndex line_label_color; NhlGenArray line_label_colors; NhlBoolean mono_line_dash_seglen; float line_dash_seglen; NhlGenArray line_dash_seglens; NhlBoolean line_labels_on; NhlFont ll_font; float ll_aspect; float ll_thickness; NhlFontQuality ll_quality; float ll_const_spacing; char ll_func_code; NhlBoolean label_auto_stride; int labels_on; NhlPosition label_pos; NhlJustification label_just; NhllgLabelAlignmentMode label_alignment; int label_dir; float label_angle; NhlFont label_font; int label_color; float label_height; float label_aspect; float label_thickness; NhlFontQuality label_quality; float label_const_spacing; char label_func_code; NhlTextDirection label_direction; int label_stride; float title_ext; char *title_string; NhlBoolean title_on_set; int title_on; NhlPosition title_pos; NhlJustification title_just; NhlBoolean title_direction_set; int title_direction; float title_angle; NhlFont title_font; int title_color; float title_height; float title_aspect; float title_thickness; NhlFontQuality title_quality; float title_const_spacing; char title_func_code; int box_background; int box_line_on; int box_line_color; float box_line_thickness; int box_line_dash_pattern; float box_line_dash_seglen; int perim_on; int perim_color; int perim_fill; int perim_fill_color; float perim_thickness; int perim_dash_pattern; float perim_dash_seglen; int fill_background; float fill_line_thickness; /* private fields */ float lg_x; /* base position and size */ float lg_y; float lg_width; float lg_height; lgLocInfo perim; NhlBoundingBox adj_perim; /* perimeter minus margins */ float adj_width; /* width minus margins */ float adj_height; /* height minus margins */ lgLocInfo title; lgLocInfo labels; NhlBoundingBox bar; /* preliminary bar boundary */ NhlBoundingBox adj_bar; /* after external label, label angle */ NhlCoord box_size; /* size of box assuming uniform */ NhlCoord adj_box_size; /* size of box after adjustments */ float title_off_ndc; float label_off_ndc; float small_axis; int label_draw_count; int max_label_draw_count; int max_label_stride_count; float *item_locs; /* x or y depending on orientation */ int labels_id; /* multitext id */ float const_pos; /* constant position for labels */ float *label_locs; /* locations for multitext */ char **stride_labels; /* subset of label_strings */ int title_id; float title_x; float title_y; NhlBoolean new_draw_req; NhlTransDat *trans_dat; /* segment transform data */ float ll_pheight; float ll_pwidth; float actual_label_height; }NhlLegendLayerPart; typedef struct _NhlLegendLayerRec{ NhlBaseLayerPart base; NhlViewLayerPart view; NhlLegendLayerPart legend; }NhlLegendLayerRec; typedef struct _NhlLegendClassPart { char *foo; }NhlLegendClassPart; typedef struct _NhlLegendClassRec{ NhlBaseClassPart base_class; NhlViewClassPart view_class; NhlLegendClassPart legend_class; }NhlLegendClassRec; typedef struct _NhlLegendClassRec *NhlLegendClass; typedef struct _NhlLegendLayerRec *NhlLegendLayer; extern NhlLegendClassRec NhllegendClassRec; #endif /*_NLegendP_h*/
25.201681
73
0.754085
[ "transform" ]
6a7d2cd8c386cfd87ccef228c994a665cde3ceb2
2,905
h
C
cc/base/switches.h
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
cc/base/switches.h
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
cc/base/switches.h
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.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. // Defines all the "cc" command-line switches. #ifndef CC_BASE_SWITCHES_H_ #define CC_BASE_SWITCHES_H_ #include "base/check.h" #include "cc/base/base_export.h" // Since cc is used from the render process, anything that goes here also needs // to be added to render_process_host_impl.cc. namespace cc { namespace switches { // Switches for the renderer compositor only. CC_BASE_EXPORT extern const char kDisableThreadedAnimation[]; CC_BASE_EXPORT extern const char kDisableCompositedAntialiasing[]; CC_BASE_EXPORT extern const char kDisableMainFrameBeforeActivation[]; CC_BASE_EXPORT extern const char kEnableMainFrameBeforeActivation[]; CC_BASE_EXPORT extern const char kDisableCheckerImaging[]; CC_BASE_EXPORT extern const char kBrowserControlsHideThreshold[]; CC_BASE_EXPORT extern const char kBrowserControlsShowThreshold[]; CC_BASE_EXPORT extern const char kSlowDownRasterScaleFactor[]; CC_BASE_EXPORT extern const char kStrictLayerPropertyChangeChecking[]; CC_BASE_EXPORT extern const char kCheckDamageEarly[]; // Switches for both the renderer and ui compositors. CC_BASE_EXPORT extern const char kEnableGpuBenchmarking[]; // Switches for LayerTreeHost. CC_BASE_EXPORT extern const char kDisableLayerTreeHostMemoryPressure[]; // Debug visualizations. CC_BASE_EXPORT extern const char kShowCompositedLayerBorders[]; CC_BASE_EXPORT extern const char kUIShowCompositedLayerBorders[]; CC_BASE_EXPORT extern const char kShowFPSCounter[]; CC_BASE_EXPORT extern const char kUIShowFPSCounter[]; CC_BASE_EXPORT extern const char kShowLayerAnimationBounds[]; CC_BASE_EXPORT extern const char kUIShowLayerAnimationBounds[]; CC_BASE_EXPORT extern const char kShowPropertyChangedRects[]; CC_BASE_EXPORT extern const char kUIShowPropertyChangedRects[]; CC_BASE_EXPORT extern const char kShowSurfaceDamageRects[]; CC_BASE_EXPORT extern const char kUIShowSurfaceDamageRects[]; CC_BASE_EXPORT extern const char kShowScreenSpaceRects[]; CC_BASE_EXPORT extern const char kUIShowScreenSpaceRects[]; CC_BASE_EXPORT extern const char kHighlightNonLCDTextLayers[]; #if DCHECK_IS_ON() CC_BASE_EXPORT extern const char kLogOnUIDoubleBackgroundBlur[]; #endif // Parameters for kUIShowCompositedLayerBorders. CC_BASE_EXPORT extern const char kCompositedRenderPassBorders[]; CC_BASE_EXPORT extern const char kCompositedSurfaceBorders[]; CC_BASE_EXPORT extern const char kCompositedLayerBorders[]; CC_BASE_EXPORT extern const char kUIEnableLayerLists[]; // Test related. CC_BASE_EXPORT extern const char kCCLayerTreeTestNoTimeout[]; CC_BASE_EXPORT extern const char kCCLayerTreeTestLongTimeout[]; CC_BASE_EXPORT extern const char kCCScrollAnimationDurationForTesting[]; } // namespace switches } // namespace cc #endif // CC_BASE_SWITCHES_H_
40.915493
79
0.838554
[ "render" ]
6a7fa60053a814807bf790ab9a09533ec9c9e80e
5,741
h
C
libraries/AQ_Kinematics/Kinematics_ARG.h
HARSHAL-IITB/IITBQUAD
17e00ed00f8a57335524374d12f447d045a42c6a
[ "MIT" ]
null
null
null
libraries/AQ_Kinematics/Kinematics_ARG.h
HARSHAL-IITB/IITBQUAD
17e00ed00f8a57335524374d12f447d045a42c6a
[ "MIT" ]
null
null
null
libraries/AQ_Kinematics/Kinematics_ARG.h
HARSHAL-IITB/IITBQUAD
17e00ed00f8a57335524374d12f447d045a42c6a
[ "MIT" ]
null
null
null
/* AeroQuad v3.0.1 - February 2012 www.AeroQuad.com Copyright (c) 2012 Ted Carancho. All rights reserved. An Open Source Arduino based multicopter. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _AQ_KINEMATICS_ARG_ #define _AQ_KINEMATICS_ARG_ //===================================================================================================== // IMU.c // S.O.H. Madgwick // 25th September 2010 //===================================================================================================== // Description: // // Quaternion implementation of the 'DCM filter' [Mayhony et al]. // // User must define 'halfT' as the (sample period / 2), and the filter gains 'Kp' and 'Ki'. // // Global variables 'q0', 'q1', 'q2', 'q3' are the quaternion elements representing the estimated // orientation. See my report for an overview of the use of quaternions in this application. // // User must call 'IMUupdate()' every sample period and parse calibrated gyroscope ('gx', 'gy', 'gz') // and accelerometer ('ax', 'ay', 'ay') data. Gyroscope units are radians/second, accelerometer // units are irrelevant as the vector is normalised. // //===================================================================================================== //////////////////////////////////////////////////////////////////////////////// // ARG - Accelerometer, Rate Gyro //////////////////////////////////////////////////////////////////////////////// #include "Kinematics.h" #include <AQMath.h> float Kp = 0.0; // proportional gain governs rate of convergence to accelerometer/magnetometer float Ki = 0.0; // integral gain governs rate of convergence of gyroscope biases float halfT = 0.0; // half the sample period float q0 = 0.0, q1 = 0.0, q2 = 0.0, q3 = 0.0; // quaternion elements representing the estimated orientation float exInt = 0.0, eyInt = 0.0, ezInt = 0.0; // scaled integral error float previousEx = 0.0; float previousEy = 0.0; float previousEz = 0.0; //////////////////////////////////////////////////////////////////////////////// // argUpdate //////////////////////////////////////////////////////////////////////////////// void argUpdate(float gx, float gy, float gz, float ax, float ay, float az, float G_Dt) { float norm; float vx, vy, vz; float q0i, q1i, q2i, q3i; float ex, ey, ez; halfT = G_Dt/2; // normalise the measurements norm = sqrt(ax*ax + ay*ay + az*az); ax = ax / norm; ay = ay / norm; az = az / norm; // estimated direction of gravity and flux (v and w) vx = 2*(q1*q3 - q0*q2); vy = 2*(q0*q1 + q2*q3); vz = q0*q0 - q1*q1 - q2*q2 + q3*q3; // error is sum of cross product between reference direction of fields and direction measured by sensors ex = (vy*az - vz*ay); ey = (vz*ax - vx*az); ez = (vx*ay - vy*ax); // integral error scaled integral gain exInt = exInt + ex*Ki; if (isSwitched(previousEx,ex)) { exInt = 0.0; } previousEx = ex; eyInt = eyInt + ey*Ki; if (isSwitched(previousEy,ey)) { eyInt = 0.0; } previousEy = ey; ezInt = ezInt + ez*Ki; if (isSwitched(previousEz,ez)) { ezInt = 0.0; } previousEz = ez; // adjusted gyroscope measurements gx = gx + Kp*ex + exInt; gy = gy + Kp*ey + eyInt; gz = gz + Kp*ez + ezInt; // integrate quaternion rate and normalise q0i = (-q1*gx - q2*gy - q3*gz) * halfT; q1i = ( q0*gx + q2*gz - q3*gy) * halfT; q2i = ( q0*gy - q1*gz + q3*gx) * halfT; q3i = ( q0*gz + q1*gy - q2*gx) * halfT; q0 += q0i; q1 += q1i; q2 += q2i; q3 += q3i; // normalise quaternion norm = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3); q0 = q0 / norm; q1 = q1 / norm; q2 = q2 / norm; q3 = q3 / norm; } void eulerAngles() { kinematicsAngle[XAXIS] = atan2(2 * (q0*q1 + q2*q3), 1 - 2 *(q1*q1 + q2*q2)); kinematicsAngle[YAXIS] = asin(2 * (q0*q2 - q1*q3)); kinematicsAngle[ZAXIS] = atan2(2 * (q0*q3 + q1*q2), 1 - 2 *(q2*q2 + q3*q3)); } //////////////////////////////////////////////////////////////////////////////// // Initialize ARG //////////////////////////////////////////////////////////////////////////////// void initializeKinematics() { initializeBaseKinematicsParam(); q0 = 1.0; q1 = 0.0; q2 = 0.0; q3 = 0.0; exInt = 0.0; eyInt = 0.0; ezInt = 0.0; previousEx = 0; previousEy = 0; previousEz = 0; Kp = 0.2; // 2.0; Ki = 0.0005; //0.005; } //////////////////////////////////////////////////////////////////////////////// // Calculate ARG //////////////////////////////////////////////////////////////////////////////// void calculateKinematics(float rollRate, float pitchRate, float yawRate, float longitudinalAccel, float lateralAccel, float verticalAccel, float G_DT) { argUpdate(rollRate, pitchRate, yawRate, longitudinalAccel, lateralAccel, verticalAccel, G_Dt); eulerAngles(); } float getGyroUnbias(byte axis) { return correctedRateVector[axis]; } void calibrateKinematics() {} #endif
30.865591
117
0.522557
[ "vector" ]
6a8e7f628221e793ad1006d039008afeb500f45f
13,005
h
C
tsf/include/tencentcloud/tsf/v20180326/model/CreateContainGroupRequest.h
datalliance88/tencentcloud-sdk-cpp
fbb8ea8e385620ac41b0a9ceb5abf1405b8aac8c
[ "Apache-2.0" ]
null
null
null
tsf/include/tencentcloud/tsf/v20180326/model/CreateContainGroupRequest.h
datalliance88/tencentcloud-sdk-cpp
fbb8ea8e385620ac41b0a9ceb5abf1405b8aac8c
[ "Apache-2.0" ]
null
null
null
tsf/include/tencentcloud/tsf/v20180326/model/CreateContainGroupRequest.h
datalliance88/tencentcloud-sdk-cpp
fbb8ea8e385620ac41b0a9ceb5abf1405b8aac8c
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_TSF_V20180326_MODEL_CREATECONTAINGROUPREQUEST_H_ #define TENCENTCLOUD_TSF_V20180326_MODEL_CREATECONTAINGROUPREQUEST_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> #include <tencentcloud/tsf/v20180326/model/ProtocolPort.h> namespace TencentCloud { namespace Tsf { namespace V20180326 { namespace Model { /** * CreateContainGroup请求参数结构体 */ class CreateContainGroupRequest : public AbstractModel { public: CreateContainGroupRequest(); ~CreateContainGroupRequest() = default; std::string ToJsonString() const; /** * 获取分组所属应用ID * @return ApplicationId 分组所属应用ID */ std::string GetApplicationId() const; /** * 设置分组所属应用ID * @param ApplicationId 分组所属应用ID */ void SetApplicationId(const std::string& _applicationId); /** * 判断参数 ApplicationId 是否已赋值 * @return ApplicationId 是否已赋值 */ bool ApplicationIdHasBeenSet() const; /** * 获取分组所属命名空间ID * @return NamespaceId 分组所属命名空间ID */ std::string GetNamespaceId() const; /** * 设置分组所属命名空间ID * @param NamespaceId 分组所属命名空间ID */ void SetNamespaceId(const std::string& _namespaceId); /** * 判断参数 NamespaceId 是否已赋值 * @return NamespaceId 是否已赋值 */ bool NamespaceIdHasBeenSet() const; /** * 获取分组名称字段,长度1~60,字母或下划线开头,可包含字母数字下划线 * @return GroupName 分组名称字段,长度1~60,字母或下划线开头,可包含字母数字下划线 */ std::string GetGroupName() const; /** * 设置分组名称字段,长度1~60,字母或下划线开头,可包含字母数字下划线 * @param GroupName 分组名称字段,长度1~60,字母或下划线开头,可包含字母数字下划线 */ void SetGroupName(const std::string& _groupName); /** * 判断参数 GroupName 是否已赋值 * @return GroupName 是否已赋值 */ bool GroupNameHasBeenSet() const; /** * 获取实例数量 * @return InstanceNum 实例数量 */ int64_t GetInstanceNum() const; /** * 设置实例数量 * @param InstanceNum 实例数量 */ void SetInstanceNum(const int64_t& _instanceNum); /** * 判断参数 InstanceNum 是否已赋值 * @return InstanceNum 是否已赋值 */ bool InstanceNumHasBeenSet() const; /** * 获取0:公网 1:集群内访问 2:NodePort * @return AccessType 0:公网 1:集群内访问 2:NodePort */ int64_t GetAccessType() const; /** * 设置0:公网 1:集群内访问 2:NodePort * @param AccessType 0:公网 1:集群内访问 2:NodePort */ void SetAccessType(const int64_t& _accessType); /** * 判断参数 AccessType 是否已赋值 * @return AccessType 是否已赋值 */ bool AccessTypeHasBeenSet() const; /** * 获取数组对象,见下方定义 * @return ProtocolPorts 数组对象,见下方定义 */ std::vector<ProtocolPort> GetProtocolPorts() const; /** * 设置数组对象,见下方定义 * @param ProtocolPorts 数组对象,见下方定义 */ void SetProtocolPorts(const std::vector<ProtocolPort>& _protocolPorts); /** * 判断参数 ProtocolPorts 是否已赋值 * @return ProtocolPorts 是否已赋值 */ bool ProtocolPortsHasBeenSet() const; /** * 获取集群ID * @return ClusterId 集群ID */ std::string GetClusterId() const; /** * 设置集群ID * @param ClusterId 集群ID */ void SetClusterId(const std::string& _clusterId); /** * 判断参数 ClusterId 是否已赋值 * @return ClusterId 是否已赋值 */ bool ClusterIdHasBeenSet() const; /** * 获取最大分配 CPU 核数,对应 K8S limit * @return CpuLimit 最大分配 CPU 核数,对应 K8S limit */ std::string GetCpuLimit() const; /** * 设置最大分配 CPU 核数,对应 K8S limit * @param CpuLimit 最大分配 CPU 核数,对应 K8S limit */ void SetCpuLimit(const std::string& _cpuLimit); /** * 判断参数 CpuLimit 是否已赋值 * @return CpuLimit 是否已赋值 */ bool CpuLimitHasBeenSet() const; /** * 获取最大分配内存 MiB 数,对应 K8S limit * @return MemLimit 最大分配内存 MiB 数,对应 K8S limit */ std::string GetMemLimit() const; /** * 设置最大分配内存 MiB 数,对应 K8S limit * @param MemLimit 最大分配内存 MiB 数,对应 K8S limit */ void SetMemLimit(const std::string& _memLimit); /** * 判断参数 MemLimit 是否已赋值 * @return MemLimit 是否已赋值 */ bool MemLimitHasBeenSet() const; /** * 获取分组备注字段,长度应不大于200字符 * @return GroupComment 分组备注字段,长度应不大于200字符 */ std::string GetGroupComment() const; /** * 设置分组备注字段,长度应不大于200字符 * @param GroupComment 分组备注字段,长度应不大于200字符 */ void SetGroupComment(const std::string& _groupComment); /** * 判断参数 GroupComment 是否已赋值 * @return GroupComment 是否已赋值 */ bool GroupCommentHasBeenSet() const; /** * 获取更新方式:0:快速更新 1:滚动更新 * @return UpdateType 更新方式:0:快速更新 1:滚动更新 */ int64_t GetUpdateType() const; /** * 设置更新方式:0:快速更新 1:滚动更新 * @param UpdateType 更新方式:0:快速更新 1:滚动更新 */ void SetUpdateType(const int64_t& _updateType); /** * 判断参数 UpdateType 是否已赋值 * @return UpdateType 是否已赋值 */ bool UpdateTypeHasBeenSet() const; /** * 获取滚动更新必填,更新间隔 * @return UpdateIvl 滚动更新必填,更新间隔 */ int64_t GetUpdateIvl() const; /** * 设置滚动更新必填,更新间隔 * @param UpdateIvl 滚动更新必填,更新间隔 */ void SetUpdateIvl(const int64_t& _updateIvl); /** * 判断参数 UpdateIvl 是否已赋值 * @return UpdateIvl 是否已赋值 */ bool UpdateIvlHasBeenSet() const; /** * 获取初始分配的 CPU 核数,对应 K8S request * @return CpuRequest 初始分配的 CPU 核数,对应 K8S request */ std::string GetCpuRequest() const; /** * 设置初始分配的 CPU 核数,对应 K8S request * @param CpuRequest 初始分配的 CPU 核数,对应 K8S request */ void SetCpuRequest(const std::string& _cpuRequest); /** * 判断参数 CpuRequest 是否已赋值 * @return CpuRequest 是否已赋值 */ bool CpuRequestHasBeenSet() const; /** * 获取初始分配的内存 MiB 数,对应 K8S request * @return MemRequest 初始分配的内存 MiB 数,对应 K8S request */ std::string GetMemRequest() const; /** * 设置初始分配的内存 MiB 数,对应 K8S request * @param MemRequest 初始分配的内存 MiB 数,对应 K8S request */ void SetMemRequest(const std::string& _memRequest); /** * 判断参数 MemRequest 是否已赋值 * @return MemRequest 是否已赋值 */ bool MemRequestHasBeenSet() const; private: /** * 分组所属应用ID */ std::string m_applicationId; bool m_applicationIdHasBeenSet; /** * 分组所属命名空间ID */ std::string m_namespaceId; bool m_namespaceIdHasBeenSet; /** * 分组名称字段,长度1~60,字母或下划线开头,可包含字母数字下划线 */ std::string m_groupName; bool m_groupNameHasBeenSet; /** * 实例数量 */ int64_t m_instanceNum; bool m_instanceNumHasBeenSet; /** * 0:公网 1:集群内访问 2:NodePort */ int64_t m_accessType; bool m_accessTypeHasBeenSet; /** * 数组对象,见下方定义 */ std::vector<ProtocolPort> m_protocolPorts; bool m_protocolPortsHasBeenSet; /** * 集群ID */ std::string m_clusterId; bool m_clusterIdHasBeenSet; /** * 最大分配 CPU 核数,对应 K8S limit */ std::string m_cpuLimit; bool m_cpuLimitHasBeenSet; /** * 最大分配内存 MiB 数,对应 K8S limit */ std::string m_memLimit; bool m_memLimitHasBeenSet; /** * 分组备注字段,长度应不大于200字符 */ std::string m_groupComment; bool m_groupCommentHasBeenSet; /** * 更新方式:0:快速更新 1:滚动更新 */ int64_t m_updateType; bool m_updateTypeHasBeenSet; /** * 滚动更新必填,更新间隔 */ int64_t m_updateIvl; bool m_updateIvlHasBeenSet; /** * 初始分配的 CPU 核数,对应 K8S request */ std::string m_cpuRequest; bool m_cpuRequestHasBeenSet; /** * 初始分配的内存 MiB 数,对应 K8S request */ std::string m_memRequest; bool m_memRequestHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_TSF_V20180326_MODEL_CREATECONTAINGROUPREQUEST_H_
33.26087
91
0.399308
[ "vector", "model" ]
6a990d16b5001a123d87af6d02e48ffbbb1e60f2
4,129
h
C
tools/vssdk_tools/Inc/vapiemp.h
ppittle/pMixins
07642d43d0014f65cc9ca058cd08019cfe7a071e
[ "Apache-2.0" ]
16
2015-01-06T10:24:44.000Z
2020-11-11T07:34:39.000Z
tools/vssdk_tools/Inc/vapiemp.h
ppittle/pMixins
07642d43d0014f65cc9ca058cd08019cfe7a071e
[ "Apache-2.0" ]
8
2015-01-05T15:45:50.000Z
2018-10-25T00:10:09.000Z
tools/vssdk_tools/Inc/vapiemp.h
ppittle/pMixins
07642d43d0014f65cc9ca058cd08019cfe7a071e
[ "Apache-2.0" ]
5
2015-06-03T14:03:03.000Z
2021-02-14T19:08:38.000Z
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.00.0603 */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __vapiemp_h__ #define __vapiemp_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __ISetVsWeb_FWD_DEFINED__ #define __ISetVsWeb_FWD_DEFINED__ typedef interface ISetVsWeb ISetVsWeb; #endif /* __ISetVsWeb_FWD_DEFINED__ */ #ifndef __CVapiEMPDataSource_FWD_DEFINED__ #define __CVapiEMPDataSource_FWD_DEFINED__ #ifdef __cplusplus typedef class CVapiEMPDataSource CVapiEMPDataSource; #else typedef struct CVapiEMPDataSource CVapiEMPDataSource; #endif /* __cplusplus */ #endif /* __CVapiEMPDataSource_FWD_DEFINED__ */ /* header files for imported files */ #include "objidl.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_vapiemp_0000_0000 */ /* [local] */ #pragma once extern RPC_IF_HANDLE __MIDL_itf_vapiemp_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_vapiemp_0000_0000_v0_0_s_ifspec; #ifndef __ISetVsWeb_INTERFACE_DEFINED__ #define __ISetVsWeb_INTERFACE_DEFINED__ /* interface ISetVsWeb */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ISetVsWeb; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("6B33DBD9-1DDD-11d3-85CF-00A0C9CFCC16") ISetVsWeb : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE SetVsWeb( /* [in] */ __RPC__in_opt IUnknown *pIUnknown) = 0; }; #else /* C style interface */ typedef struct ISetVsWebVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( __RPC__in ISetVsWeb * This, /* [in] */ __RPC__in REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( __RPC__in ISetVsWeb * This); ULONG ( STDMETHODCALLTYPE *Release )( __RPC__in ISetVsWeb * This); HRESULT ( STDMETHODCALLTYPE *SetVsWeb )( __RPC__in ISetVsWeb * This, /* [in] */ __RPC__in_opt IUnknown *pIUnknown); END_INTERFACE } ISetVsWebVtbl; interface ISetVsWeb { CONST_VTBL struct ISetVsWebVtbl *lpVtbl; }; #ifdef COBJMACROS #define ISetVsWeb_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ISetVsWeb_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ISetVsWeb_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ISetVsWeb_SetVsWeb(This,pIUnknown) \ ( (This)->lpVtbl -> SetVsWeb(This,pIUnknown) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ISetVsWeb_INTERFACE_DEFINED__ */ #ifndef __VseeVersioningEnlistmentManagerProxy_LIBRARY_DEFINED__ #define __VseeVersioningEnlistmentManagerProxy_LIBRARY_DEFINED__ /* library VseeVersioningEnlistmentManagerProxy */ /* [uuid] */ EXTERN_C const IID LIBID_VseeVersioningEnlistmentManagerProxy; EXTERN_C const CLSID CLSID_CVapiEMPDataSource; #ifdef __cplusplus class DECLSPEC_UUID("6856262f-19d4-4090-a0cd-a486a148709c") CVapiEMPDataSource; #endif #endif /* __VseeVersioningEnlistmentManagerProxy_LIBRARY_DEFINED__ */ /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
21.846561
76
0.717123
[ "object" ]
6a9a1dba2e847881182a0196d4d7177f64d17669
6,840
h
C
include/api/input.h
Metadiff/metadiff-core
3b83fb033ed84827f76632c5f03d91e9b657412c
[ "Apache-2.0" ]
11
2016-12-20T07:54:12.000Z
2021-05-31T22:13:06.000Z
include/api/input.h
Metadiff/metadiff-core
3b83fb033ed84827f76632c5f03d91e9b657412c
[ "Apache-2.0" ]
1
2016-11-22T17:53:06.000Z
2016-11-23T18:43:27.000Z
include/api/input.h
Metadiff/metadiff-core
3b83fb033ed84827f76632c5f03d91e9b657412c
[ "Apache-2.0" ]
2
2019-06-18T22:43:35.000Z
2022-01-20T02:25:27.000Z
// // Created by alex on 27/10/16. // #ifndef GRAPH_IR_API_INPUT_H #define GRAPH_IR_API_INPUT_H namespace md{ namespace api { /** @brief Creates an input variable with the same attributes and the one provied * * @param node * @param name * @return */ inline Node tensor_as(Node node, std::string name = ""){ return node.g()->tensor_as(node, name); } // /** @brief Creates a four dimensional variable in the default_graph // * // * @param data_type // * @param shape // * @param name // * @param g // * @return // */ // Node tensor4(DataType data_type, // std::array<SymInt, 4> shape, // std::string name = "Tensor4", // Graph g = default_graph); // // /** @brief Creates a four dimensional variable in the default_graph // * // * @param data_type // * @param shape0 // * @param shape1 // * @param shape2 // * @param shape3 // * @param name // * @param g // * @return // */ // Node tensor4(DataType data_type, // SymInt shape0, // SymInt shape1, // SymInt shape2, // SymInt shape3, // std::string name = "Tensor4", // Graph g = default_graph); // // /** @brief Creates a four dimensional variable in default_graph // * // * @param data_type // * @param name // * @param g // * @return // */ // Node tensor4(DataType data_type, // std::string name = "Tensor4", // Graph g = default_graph); // // /** @brief Creates a three dimensional variable in the default_graph // * // * @param data_type // * @param shape // * @param name // * @param g // * @return // */ // Node tensor3(DataType data_type, // std::array<SymInt, 3> shape, // std::string name = "Tensor3", // Graph g = default_graph); // // /** @brief Creates a three dimensional variable in the default_graph // * // * @param data_type // * @param shape0 // * @param shape1 // * @param shape2 // * @param name // * @param g // * @return // */ // Node tensor3(DataType data_type, // SymInt shape0, // SymInt shape1, // SymInt shape2, // std::string name = "Tensor3", // Graph g = default_graph); // // /** @brief Creates a three dimensional variable in the default_graph // * // * @param data_type // * @param name // * @param g // * @return // */ // Node tensor3(DataType data_type, // std::string name = "Tensor3", // Graph g = default_graph); // // /** @brief Creates a matrix variable in the default_graph // * // * @param data_type // * @param shape // * @param name // * @param g // * @return // */ // Node matrix(DataType data_type, // std::array<SymInt, 2> shape, // std::string name = "Matrix", // Graph g = default_graph); // // /** @brief Creates a matrix variable in the default_graph // * // * @param data_type // * @param shape0 // * @param shape1 // * @param name // * @param g // * @return // */ // Node matrix(DataType data_type, // SymInt shape0, // SymInt shape1, // std::string name = "Matrix", // Graph g = default_graph); // // /** @brief Creates a matrix variable in the default_graph // * // * @param data_type // * @param name // * @param g // * @return // */ // Node matrix(DataType data_type, // std::string name = "Matrix", // Graph g = default_graph); // // /** @brief Creates a square matrix variable in the default_graph // * // * @param data_type // * @param shape // * @param name // * @param g // * @return // */ // Node square_matrix(DataType data_type, // SymInt shape, // std::string name = "Matrix", // Graph g = default_graph); // // /** @brief Creates a row vector variable in the default_graph // * // * @param data_type // * @param shape // * @param name // * @param g // * @return // */ // Node vector(DataType data_type, // SymInt shape, // std::string name = "Vector", // Graph g = default_graph); // // /** @brief Creates a row vector variable in the default_graph // * // * @param data_type // * @param name // * @param g // * @return // */ // Node vector(DataType data_type, // std::string name = "Vector", // Graph g = default_graph); // // /** @brief Creates a scalar variable in the default_graph // * // * @param data_type // * @param name // * @param g // * @return // */ // Node scalar(DataType data_type, // std::string name = "Scalar", // Graph g = default_graph); /** @brief Creates a new symbolic integer * * @return */ inline SymInt new_sym(std::string name = ""){ if(name != "") { return sym::variable<std::string, int64_t, uint8_t>(name); } else { // Generate random name auto len = 5; std::string random_name; random_name.reserve(len + 4); random_name += "__"; static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; for (int i = 0; i < len; ++i) { random_name += alphanum[rand() % (sizeof(alphanum) - 1)]; } random_name += "__"; return sym::variable<std::string, int64_t, uint8_t>(random_name); } } } } #endif //GRAPH_IR_API_INPUT_H
31.520737
89
0.437135
[ "shape", "vector" ]
6aa7a4d07d1581a660074b457e773f4d7a545921
1,426
h
C
include/SpatiaLiteCpp/LineString.h
dpmcmlxxvi/SpatiaLiteCpp
2f93e18a8b996a499a4fc14754f7ac38cdce3fba
[ "MIT" ]
8
2016-07-04T22:56:59.000Z
2021-12-01T15:16:31.000Z
include/SpatiaLiteCpp/LineString.h
philipchang/SpatiaLiteCpp
2f93e18a8b996a499a4fc14754f7ac38cdce3fba
[ "MIT" ]
6
2016-07-26T02:49:17.000Z
2019-06-10T22:45:08.000Z
include/SpatiaLiteCpp/LineString.h
philipchang/SpatiaLiteCpp
2f93e18a8b996a499a4fc14754f7ac38cdce3fba
[ "MIT" ]
5
2016-07-26T02:22:52.000Z
2022-01-20T06:31:57.000Z
/** * @file LineString.h * @ingroup SpatiaLiteCpp * @brief Main LineString class. * @license MIT License (http://opensource.org/licenses/MIT) * @copyright Copyright (c) 2015 Daniel Pulido (dpmcmlxxvi@gmail.com) */ #pragma once #include "SpatiaLiteCpp/Buffer.hpp" extern "C" { #include "sqlite3.h" #include "spatialite/gaiageo.h" } namespace SpatiaLite { // Forward declarations class Blob; /** * Line string buffer data type */ typedef gaiaLinestringPtr LineStringType; /** * @brief RAII management of a gaiaLinestringPtr. */ class SPATIALITECPP_ABI LineString : public Buffer<LineStringType> { public: /** * @brief Takes ownership of an existing line string pointer * @param[in] line Existing line pointer */ explicit LineString(LineStringType line); /** * @brief Create new line string from two points * @param[in] geometry1 Point #1 * @param[in] geometry2 Point #2 * @returns New pointer of line string geometry blob * @throws std::runtime_error on failure * @warning Caller must delete pointer. Should be owned by a BlobPtr. */ static SpatiaLite::Blob * makeLine(gaiaGeomCollPtr geometry1, gaiaGeomCollPtr geometry2); }; }
25.017544
78
0.596774
[ "geometry" ]
6aaad9d5e44974314563b89a7b4005c08898458c
12,572
h
C
include/internal/HMStorageHostGroupMDBM.h
varsameer/NetCHASM
3071241ce0d2cddc077e5e7e1b957677d733ae76
[ "Apache-2.0" ]
13
2019-06-06T01:14:30.000Z
2022-03-03T05:57:51.000Z
include/internal/HMStorageHostGroupMDBM.h
varsameer/NetCHASM
3071241ce0d2cddc077e5e7e1b957677d733ae76
[ "Apache-2.0" ]
7
2019-07-23T18:31:20.000Z
2021-05-26T12:57:34.000Z
include/internal/HMStorageHostGroupMDBM.h
varsameer/NetCHASM
3071241ce0d2cddc077e5e7e1b957677d733ae76
[ "Apache-2.0" ]
12
2019-06-27T13:58:03.000Z
2021-12-23T07:43:06.000Z
// Copyright 2019, Oath Inc. // Licensed under the terms of the Apache 2.0 license. See LICENSE file in the root of the distribution for licensing details. #ifndef HMSTORAGEHOSTGROUPMDBM_H_ #define HMSTORAGEHOSTGROUPMDBM_H_ #include <mdbm.h> #include <mdbm_handle_pool.h> #include "HMStorage.h" #include "HMAuxCache.h" #include "HMStorageHostGroup.h" //! The default MDBM locking scheme to use. #define MDBM_DEFAULT_LOCKING MDBM_RW_LOCKS //! The GLOBAL MDBM locking scheme to use. #define MDBM_GLOBAL_LOCKING 0x0 //! The default open flags for the MDBM database. #define MDBM_OPEN_FLAGS (MDBM_CREATE_V3 | MDBM_LARGE_OBJECTS) //! The default MDBM path in NetCHASM #define DEFAULT_DBNAME "/home/y/var/run/netchasm.mdbm" //! The prefix to use for the config data in the MDBM key. const std::string HM_MDBM_CONFIG = "hm:config"; //! The prefix to use for the group names in the MDBM key. const std::string HM_MDBM_GROUP_NAMES = "hm:groups"; //! The prefix to use for the group information in the MDBM key. const std::string HM_MDBM_GROUP_PREFIX = "hm:group:"; //! The prefix to use for the health check information in the MDBM key. const std::string HM_MDBM_CHECK_PREFIX = "hm:check:"; //! The prefix to use for the aux info information in the MDBM key. const std::string HM_MDBM_AUX_PREFIX = "hm:aux:"; //! Convenience class to track an MDBM handle. /*! Convenience class to track and MDBM handle. Wraps all the locking/unlocking functionality for all locking types. Automatically cleans up the handle upon shutdown for smart pointer use. The locks are auto-aquired for the store and delete operations. The lock is auto release when the handle goes out of scope for the handle. Warning the m_kv retains a read lock during read operations until object destruction. Thus, the data should be copied immediately to avoid lock contention. */ class MDBMHandle { public: MDBMHandle(uint32_t lockScheme) : m_handle(nullptr), m_mdbmPool(nullptr), m_locked(false), m_lockScheme(lockScheme) {} ~MDBMHandle(); //! Initialize the handle using the given MDBM pool. /*! Initialize the handle using the given MDBM pool. \param a pointer to the MDBM pool to use to get the handle. \return true if the handle is ready for operations. */ bool init(mdbm_pool_t* pool); //! Lock the handle for an MDBM operation. /*! Lock the handle for an MDBM operation. Wraps the lock/unlock logic for the given lock strategy passed on construction. \param true if the handle is read only. \return true if the lock was aquired. */ bool lock(bool readOnly); //! Unlock the handle. /*! Unlock the handle. \return true if the handle is unlocked. */ bool unlock(); //! Store the data to MDBM. /*! Store the data to MDBM as stored in the m_kv variable. m_kv.key contains the key and m_kv.data is the pointer to the data to store. \return true if the data was stored. */ bool mdbmStore(); //! Get the data from MDBM. /*! Get the data drom MDBM and store the data in m_kv.value. Expects the key to be prefilled in m_kv.key. Locks the database until the unlock is called or the handle goes out of scope. The m_kv is no longer accessible after the database is unlocked. \return true if the data was fetched. */ bool mdbmFetch(); //! Remove the data from MDBM. /*! Remove the data from key m_kv.key from the MDBM database. \return true indicating the data was deleted. */ bool mdbmRemove(); //! Delete all data from the MDBM database. /*! Delete all the data from the MDBM database. \return true if the data was deleted. */ bool mdbmClear(); kvpair m_kv; private: MDBM* m_handle; mdbm_pool_t* m_mdbmPool; bool m_locked; uint32_t m_lockScheme; }; //! Convenience function to wrap the MDBM pool. /*! Convenience function to wrap the MDBM pool. Handles shutting down the MDBM pool on destruction. */ class MDBMPool { public: MDBMPool() : m_mdbm(nullptr), m_mdbmPool(nullptr), m_lockScheme(MDBM_DEFAULT_LOCKING) {} MDBMPool(HM_STORAGE_LOCK_POLICY defaultLocking) : m_mdbm(nullptr), m_mdbmPool(nullptr) { switch (defaultLocking) { case HM_STORAGE_GLOBAL_LOCKS: m_lockScheme = MDBM_GLOBAL_LOCKING; break; case HM_STORAGE_RW_LOCKS: m_lockScheme = MDBM_RW_LOCKS; break; case HM_STORAGE_PARTITION_LOCKS: m_lockScheme = MDBM_PARTITIONED_LOCKS; break; }; } ~MDBMPool(); //! Check to see if the MDBM pool is ready. /*! Check to see if the MDBM pool is ready. \return true if the MDBM pool is ready to use. */ bool isInit() { return m_mdbm != nullptr && m_mdbmPool != nullptr; } //! Create a new MDBM pool. /*! Creeat a new MDBM pool. \param the path to the MDBM file on the disk. \param true if the MDBM pool should be read only. */ bool init(std::string& mdbmPath, bool readOnly); //! Get a new Handle to the MDBM pool. /*! Get a new Handle to the MDBM pool. \return a unique pointer to an MDBM handle read for operations. */ std::unique_ptr<MDBMHandle> getHandle(); private: MDBM* m_mdbm; mdbm_pool_t* m_mdbmPool; uint32_t m_lockScheme; }; //! Main class to support storing information to an MDBM backend using the host group as the keys. class HMStorageHostGroupMDBM : public HMStorageHostGroup { public: HMStorageHostGroupMDBM(std::string filename, HMDataHostGroupMap* hostGroupMap, HMDNSCache* dnsCache) : HMStorageHostGroup(hostGroupMap, dnsCache), m_mdbmPath(filename), m_openFlags(MDBM_OPEN_FLAGS) {} ~HMStorageHostGroupMDBM(){ closeStore(); } //! Clear the backend datastore. /*! clear the backend datastore and any local caches in the store class. \return true if the clear was a success. */ bool clearBackend(); //! Store the config info into the data store. /*! Store the config info into the data store. \param HMConfigInfo structure \return true on success. */ bool storeConfigInfo(const HMConfigInfo& configInfo); //! Get the config info from the data store. /*! Get the config info int the data store. \param HMConfigInfo structure \return true if the passed structure has the config info from the data store. */ bool getConfigInfo(HMConfigInfo& configInfo); //! Get all the host group names from the stored configuration info. /*! Get all the host group names from the stored configuration info. \param the set to store the group names from the backend. \return true if the set contains the host group names. */ bool getHostGroupNames(std::set<std::string>& groupNames); //! Get the host group info from the backend for a given host group name. /*! Get the host group info from the backend for a given host group name. \param the host group name to lookup the host group info. \param the HMDataHostGroup class to fill with the host group info. \return true if the host group info is in the HMDataHostGroup. */ bool getGroupInfo(const std::string& hostGroupName, HMDataHostGroup& hostGroup); protected: //! Internal function to handle opening the database and initializing the data structures. /*! Internal function to handle opening the database and initializing the data structures. \return true if the datastore was opened successfully. */ bool openBackend(); //! Internal function to handle closing the backend storage. bool closeBackend(); // Internal function to get all the host group names. /*! Internal function to get all the host group names. \param the set of all host group names. \return true if the host group names were stored successfully. */ bool storeHostGroupNames(std::set<std::string>& groupNames); // Internal function to store the group info per host group. /*! Internal function to store the group info per host group. \param the host group name. \param the host group info. \return true if the host group info was stored successfully. */ bool storeGroupInfo(const std::string& hostGroupName, HMDataHostGroup& hostGroup); // Internal function to remove the group info per host group. /*! Internal function to remove the group info per host group. \param the host group name. \return true if the host group info was removed successfully. */ bool removeGroupInfo(const std::string& hostGroupName); // Internal function to store the host group results. /*! Internal function to store the host group results to the backend. Function assumes the host group results are in the cache. \param the host group to store. \return true if the host group was stored successfully. */ bool storeHostGroupCheckResults(const std::string& hostGroup); // Internal function to get the check results from the backend for the given group. /*! Internal function to get the check results from the backend for the given group. Function stores the results into the local cache. \param the host group to get. \return true if the host group was retrieved successfully. */ bool getHostGroupCheckResults(const std::string& hostGroup); // Internal function to get the check results from the backend for the given group. /*! Internal function to get the check results from the backend for the given group. Function stores the results into the passed vector. The internal cache is not updated. \param the host group to get. \param the vector to hold the HMGroupCheckResults. \return true if the host group was retrieved successfully. */ bool getHostGroupCheckResults(const std::string& hostGroup, std::vector<HMGroupCheckResult>& results); // Internal function to remove the host group from the backend. /*! Internal function to remove the host group from the backend. \param the host group to remove. \return true if the host group was removed successfully. */ bool removeHostGroupCheckResults(const std::string& hostGroupName); // Internal function to store the Aux info. /*! Internal function to store the Aux info to the backend. Function assumes the Aux info is in the cache. \param the host group to store. \return true if the Aux info was stored successfully. */ bool storeHostGroupAuxInfo(const std::string& hostGroup); // Internal function to get the Aux info from the backend for the given group. /*! Internal function to get the Aux info from the backend for the given group. Function stores the results into the local cache. \param the host group to get. \return true if the Aux info was retrieved successfully. */ bool getHostGroupGroupAuxInfo(const std::string& hostGroup); // Internal function to get the Aux info from the backend for the given group. /*! Internal function to get the Aux info from the backend for the given group. Function stores the results into the passed vector. The internal cache is not updated. \param the host group to get. \param a vector to hold the HMGroupResults for the host group. \return true if the Aux info was retrieved successfully. */ bool getHostGroupGroupAuxInfo(const std::string& hostGroup, std::vector<HMGroupAuxResult>& results); // Internal function to remove the Aux info from the backend. /*! Internal function to remove the Aux info from the backend. \param the host group to remove. \return true if the host group was removed successfully. */ bool removeHostGroupGroupAuxInfo(const std::string& hostGroup); private: std::string m_mdbmPath; uint32_t m_openFlags; std::unique_ptr<MDBMPool> m_pool; }; #endif /* HMSTORAGEHOSTGROUPYFORMDBM_H_ */
36.126437
126
0.674276
[ "object", "vector" ]
6aaf907e65b22d43c7536450d3e4ba68d2c8310b
12,236
h
C
Include/10.0.15063.0/winrt/windows.media.core.preview.h
sezero/windows-sdk-headers
e8e9d4d50769ded01a2df905c6bf4355eb3fa8b5
[ "MIT" ]
5
2020-05-29T06:22:17.000Z
2021-11-28T08:21:38.000Z
Include/10.0.15063.0/winrt/windows.media.core.preview.h
sezero/windows-sdk-headers
e8e9d4d50769ded01a2df905c6bf4355eb3fa8b5
[ "MIT" ]
null
null
null
Include/10.0.15063.0/winrt/windows.media.core.preview.h
sezero/windows-sdk-headers
e8e9d4d50769ded01a2df905c6bf4355eb3fa8b5
[ "MIT" ]
5
2020-05-30T04:15:11.000Z
2021-11-28T08:48:56.000Z
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.01.0622 */ /* @@MIDL_FILE_HEADING( ) */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __windows2Emedia2Ecore2Epreview_h__ #define __windows2Emedia2Ecore2Epreview_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef ____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics; #ifdef __cplusplus namespace ABI { namespace Windows { namespace Media { namespace Core { namespace Preview { interface ISoundLevelBrokerStatics; } /* end namespace */ } /* end namespace */ } /* end namespace */ } /* end namespace */ } /* end namespace */ #endif /* __cplusplus */ #endif /* ____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_FWD_DEFINED__ */ /* header files for imported files */ #include "inspectable.h" #include "AsyncInfo.h" #include "EventToken.h" #include "Windows.Foundation.h" #include "Windows.Media.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0000 */ /* [local] */ #ifdef __cplusplus } /*extern "C"*/ #endif #include <windows.foundation.collections.h> #ifdef __cplusplus extern "C" { #endif interface IInspectable; /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0000 */ /* [local] */ extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0000_v0_0_s_ifspec; /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview2Eidl_0000_4658 */ /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview2Eidl_0000_4658 */ extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview2Eidl_0000_4658_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview2Eidl_0000_4658_v0_0_s_ifspec; /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0001 */ /* [local] */ #ifndef DEF___FIEventHandler_1_IInspectable_USE #define DEF___FIEventHandler_1_IInspectable_USE #if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME) } /*extern "C"*/ namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("c50898f6-c536-5f47-8583-8b2c2438a13b")) IEventHandler<IInspectable*> : IEventHandler_impl<IInspectable*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.EventHandler`1<Object>"; } }; typedef IEventHandler<IInspectable*> __FIEventHandler_1_IInspectable_t; #define ____FIEventHandler_1_IInspectable_FWD_DEFINED__ #define __FIEventHandler_1_IInspectable ABI::Windows::Foundation::__FIEventHandler_1_IInspectable_t /* ABI */ } /* Windows */ } /* Foundation */ } extern "C" { #endif //__cplusplus #endif /* DEF___FIEventHandler_1_IInspectable_USE */ #if defined(__cplusplus) } #endif // defined(__cplusplus) #include <Windows.Foundation.h> #if !defined(__windows2Emedia_h__) #include <Windows.Media.h> #endif // !defined(__windows2Emedia_h__) #if defined(__cplusplus) extern "C" { #endif // defined(__cplusplus) #if !defined(__cplusplus) #if !defined(__cplusplus) typedef enum __x_ABI_CWindows_CMedia_CSoundLevel __x_ABI_CWindows_CMedia_CSoundLevel; #endif /* end if !defined(__cplusplus) */ #endif #if !defined(____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_INTERFACE_DEFINED__) extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Core_Preview_ISoundLevelBrokerStatics[] = L"Windows.Media.Core.Preview.ISoundLevelBrokerStatics"; #endif /* !defined(____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_INTERFACE_DEFINED__) */ /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0001 */ /* [local] */ #ifdef __cplusplus } /* end extern "C" */ namespace ABI { namespace Windows { namespace Media { typedef enum SoundLevel SoundLevel; } /* end namespace */ } /* end namespace */ } /* end namespace */ extern "C" { #endif extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0001_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0001_v0_0_s_ifspec; #ifndef ____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_INTERFACE_DEFINED__ #define ____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_INTERFACE_DEFINED__ /* interface __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics */ /* [uuid][object] */ /* interface ABI::Windows::Media::Core::Preview::ISoundLevelBrokerStatics */ /* [uuid][object] */ EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics; #if defined(__cplusplus) && !defined(CINTERFACE) } /* end extern "C" */ namespace ABI { namespace Windows { namespace Media { namespace Core { namespace Preview { MIDL_INTERFACE("6A633961-DBED-464C-A09A-33412F5CAA3F") ISoundLevelBrokerStatics : public IInspectable { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_SoundLevel( /* [out][retval] */ __RPC__out ABI::Windows::Media::SoundLevel *value) = 0; virtual HRESULT STDMETHODCALLTYPE add_SoundLevelChanged( /* [in] */ __RPC__in_opt __FIEventHandler_1_IInspectable *handler, /* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0; virtual HRESULT STDMETHODCALLTYPE remove_SoundLevelChanged( /* [in] */ EventRegistrationToken token) = 0; }; extern const __declspec(selectany) IID & IID_ISoundLevelBrokerStatics = __uuidof(ISoundLevelBrokerStatics); } /* end namespace */ } /* end namespace */ } /* end namespace */ } /* end namespace */ } /* end namespace */ extern "C" { #else /* C style interface */ typedef struct __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStaticsVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [in] */ __RPC__in REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This); ULONG ( STDMETHODCALLTYPE *Release )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This); HRESULT ( STDMETHODCALLTYPE *GetIids )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [out] */ __RPC__out ULONG *iidCount, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids); HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [out] */ __RPC__deref_out_opt HSTRING *className); HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [out] */ __RPC__out TrustLevel *trustLevel); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_SoundLevel )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [out][retval] */ __RPC__out __x_ABI_CWindows_CMedia_CSoundLevel *value); HRESULT ( STDMETHODCALLTYPE *add_SoundLevelChanged )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [in] */ __RPC__in_opt __FIEventHandler_1_IInspectable *handler, /* [out][retval] */ __RPC__out EventRegistrationToken *token); HRESULT ( STDMETHODCALLTYPE *remove_SoundLevelChanged )( __RPC__in __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics * This, /* [in] */ EventRegistrationToken token); END_INTERFACE } __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStaticsVtbl; interface __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics { CONST_VTBL struct __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStaticsVtbl *lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_GetIids(This,iidCount,iids) \ ( (This)->lpVtbl -> GetIids(This,iidCount,iids) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_GetRuntimeClassName(This,className) \ ( (This)->lpVtbl -> GetRuntimeClassName(This,className) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_GetTrustLevel(This,trustLevel) \ ( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_get_SoundLevel(This,value) \ ( (This)->lpVtbl -> get_SoundLevel(This,value) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_add_SoundLevelChanged(This,handler,token) \ ( (This)->lpVtbl -> add_SoundLevelChanged(This,handler,token) ) #define __x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_remove_SoundLevelChanged(This,token) \ ( (This)->lpVtbl -> remove_SoundLevelChanged(This,token) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* ____x_ABI_CWindows_CMedia_CCore_CPreview_CISoundLevelBrokerStatics_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0002 */ /* [local] */ #ifndef RUNTIMECLASS_Windows_Media_Core_Preview_SoundLevelBroker_DEFINED #define RUNTIMECLASS_Windows_Media_Core_Preview_SoundLevelBroker_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Core_Preview_SoundLevelBroker[] = L"Windows.Media.Core.Preview.SoundLevelBroker"; #endif /* interface __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0002 */ /* [local] */ extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0002_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Ecore2Epreview_0000_0002_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
34.083565
184
0.731775
[ "object" ]
6ab396dd295ce4b760a21215f4ca18e981fb7e83
3,826
h
C
DBTest/UIView+Animation.h
NicofnCHINA/DBTest
4e68676e5c694581baac7775360e009c770a719d
[ "MIT" ]
1
2019-08-23T03:40:39.000Z
2019-08-23T03:40:39.000Z
DBTest/UIView+Animation.h
NicofnCHINA/DBTest
4e68676e5c694581baac7775360e009c770a719d
[ "MIT" ]
null
null
null
DBTest/UIView+Animation.h
NicofnCHINA/DBTest
4e68676e5c694581baac7775360e009c770a719d
[ "MIT" ]
null
null
null
// // UIView+Animation.h // CoolUIViewAnimations // // Created by Peter de Tagyos on 12/10/11. // Copyright (c) 2011 PT Software Solutions. All rights reserved. // #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger, ShakeDirection) { ShakeDirectionHorizontal = 0, ShakeDirectionVertical }; float radiansForDegrees(int degrees); @interface UIView (Animation) // Moves - (void)moveTo:(CGPoint)destination duration:(float)secs option:(UIViewAnimationOptions)option; - (void)moveTo:(CGPoint)destination duration:(float)secs option:(UIViewAnimationOptions)option delegate:(id)delegate callback:(SEL)method; - (void)raceTo:(CGPoint)destination withSnapBack:(BOOL)withSnapBack; - (void)raceTo:(CGPoint)destination withSnapBack:(BOOL)withSnapBack delegate:(id)delegate callback:(SEL)method; // Transforms - (void)rotate:(int)degrees secs:(float)secs delegate:(id)delegate callback:(SEL)method; - (void)scale:(float)secs x:(float)scaleX y:(float)scaleY delegate:(id)delegate callback:(SEL)method; - (void)spinClockwise:(float)secs; - (void)spinCounterClockwise:(float)secs; // Transitions - (void)curlDown:(float)secs; - (void)curlUpAndAway:(float)secs; - (void)drainAway:(float)secs; // Effects - (void)changeAlpha:(float)newAlpha secs:(float)secs; - (void)pulse:(float)secs continuously:(BOOL)continuously; //add subview - (void)addSubviewWithFadeAnimation:(UIView *)subview; /* 移动窗口弹一下的动画 */ - (void)bounceAnima; /**----------------------------------------------------------------------------- * @name UIView+Animation * ----------------------------------------------------------------------------- */ /** 抖动视图 */ - (void)shake; /** 抖动视图 * * Shake the view a given number of times * * @param times The number of shakes * @param delta The width of the shake */ - (void)shake:(int)times withDelta:(CGFloat)delta; /** Shake the UIView * * Shake the view a given number of times * * @param times The number of shakes * @param delta The width of the shake * @param handler A block object to be executed when the shake sequence ends */ - (void)shake:(int)times withDelta:(CGFloat)delta completion:(void((^)(void)))handler; /** Shake the UIView at a custom speed * * Shake the view a given number of times with a given speed * * @param times The number of shakes * @param delta The width of the shake * @param interval The duration of one shake */ - (void)shake:(int)times withDelta:(CGFloat)delta speed:(NSTimeInterval)interval; /** Shake the UIView at a custom speed * * Shake the view a given number of times with a given speed * * @param times The number of shakes * @param delta The width of the shake * @param interval The duration of one shake * @param handler A block object to be executed when the shake sequence ends */ - (void)shake:(int)times withDelta:(CGFloat)delta speed:(NSTimeInterval)interval completion:(void((^)(void)))handler; /** Shake the UIView at a custom speed * * Shake the view a given number of times with a given speed * * @param times The number of shakes * @param delta The width of the shake * @param interval The duration of one shake * @param shakeDirection of the shake */ - (void)shake:(int)times withDelta:(CGFloat)delta speed:(NSTimeInterval)interval shakeDirection:(ShakeDirection)shakeDirection; /** Shake the UIView at a custom speed * * Shake the view a given number of times with a given speed, with a completion handler * * @param times The number of shakes * @param delta The width of the shake * @param interval The duration of one shake * @param shakeDirection of the shake * @param completion to be called when the view is done shaking */ - (void)shake:(int)times withDelta:(CGFloat)delta speed:(NSTimeInterval)interval shakeDirection:(ShakeDirection)shakeDirection completion:(void(^)(void))completion; @end
31.619835
164
0.70805
[ "object" ]
6ab63d7772095aa25f5bb6db80c5172712d7ca9b
114,713
c
C
sdk-6.5.20/libs/sdklt/phymod/chip/blackhawk/tier1/blackhawk_tsc_internal.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/phymod/chip/blackhawk/tier1/blackhawk_tsc_internal.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/phymod/chip/blackhawk/tier1/blackhawk_tsc_internal.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/*********************************************************************************** *********************************************************************************** * File Name : blackhawk_tsc_internal.c * * Created On : 13/02/2014 * * Created By : Justin Gaither * * Description : APIs for Serdes IPs * * Revision : * * * * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. * * No portions of this material may be reproduced in any form without * * the written permission of: * * Broadcom Corporation * * 5300 California Avenue * * Irvine, CA 92617 * * * * All information contained in this document is Broadcom Corporation * * company private proprietary, and trade secret. * */ /** @file blackhawk_tsc_internal.c * Implementation of API functions */ #include <phymod/phymod_system.h> #include "blackhawk_tsc_internal.h" #include "blackhawk_tsc_internal_error.h" #include "blackhawk_tsc_access.h" #include "blackhawk_tsc_common.h" #include "blackhawk_tsc_config.h" #include "blackhawk_tsc_functions.h" #include "blackhawk_tsc_select_defns.h" #include "blackhawk_tsc_prbs.h" #include "blackhawk_tsc_debug_functions.h" /* If SERDES_EVAL is defined, then is_ate_log_enabled() is queried to *\ \* know whether to log ATE. blackhawk_tsc_access.h provides that function. */ uint32_t blackhawk_tsc_INTERNAL_mult_with_overflow_check(uint32_t a, uint32_t b, uint8_t *of) { uint16_t c,d; uint32_t r,s; if (a > b) return blackhawk_tsc_INTERNAL_mult_with_overflow_check(b, a, of); *of = 0; c = b >> 16; d = UINT16_MAX & b; r = a * c; s = a * d; if (r > UINT16_MAX) *of = 1; r <<= 16; return (s + r); } #ifdef SERDES_MULTI_INFO_TABLE_EN srds_info_t blackhawk_tsc_info[NUM_SERDES_INFO_TABLES]; #endif srds_info_t *blackhawk_tsc_INTERNAL_get_blackhawk_tsc_info_ptr_with_check(srds_access_t *sa__) { err_code_t err_code = ERR_CODE_NONE; srds_info_t * blackhawk_tsc_info_ptr = blackhawk_tsc_INTERNAL_get_blackhawk_tsc_info_ptr(sa__); #ifdef PHYMOD_SUPPORT if ( blackhawk_tsc_info_ptr == NULL ) { blackhawk_tsc_init_blackhawk_tsc_info(sa__); } else if (blackhawk_tsc_info_ptr->signature != SRDS_INFO_SIGNATURE) { blackhawk_tsc_init_blackhawk_tsc_info(sa__); } #endif /* PHYMOD_SUPPORT */ /* coverity[forward_null] */ /* coverity[var_deref_op] */ if (blackhawk_tsc_info_ptr->signature != SRDS_INFO_SIGNATURE) { err_code = blackhawk_tsc_init_blackhawk_tsc_info(sa__); if (err_code != ERR_CODE_NONE){ EFUN_PRINTF(("ERROR: %s Failed: 0x%04X \n", API_FUNCTION_NAME, err_code)); return 0; } } return blackhawk_tsc_info_ptr; } err_code_t blackhawk_tsc_INTERNAL_match_ucode_from_info(srds_access_t *sa__) { uint16_t ucode_version_major; uint8_t ucode_version_minor; uint32_t ucode_version; srds_info_t * blackhawk_tsc_info_ptr = blackhawk_tsc_INTERNAL_get_blackhawk_tsc_info_ptr(sa__); CHECK_AND_RETURN_IF_NULL(blackhawk_tsc_info_ptr, ERR_CODE_INVALID_INFO_TABLE_ADDR); ESTM(ucode_version_major = rdcv_common_ucode_version()); ESTM(ucode_version_minor = rdcv_common_ucode_minor_version()); ucode_version = (ucode_version_major << 8) | ucode_version_minor; if (ucode_version == blackhawk_tsc_info_ptr->ucode_version) { return(ERR_CODE_NONE); } else { EFUN_PRINTF(("ERROR: ucode version of the current thread not matching with stored blackhawk_tsc_info->ucode_version, Expected 0x%08X, but received 0x%08X.\n", blackhawk_tsc_info_ptr->ucode_version, ucode_version)); return(ERR_CODE_UCODE_VERIFY_FAIL); } } err_code_t blackhawk_tsc_INTERNAL_verify_blackhawk_tsc_info(srds_info_t *blackhawk_tsc_info_ptr, srds_access_t *sa__) { err_code_t err_code = ERR_CODE_NONE; CHECK_AND_RETURN_IF_NULL(blackhawk_tsc_info_ptr, ERR_CODE_INVALID_INFO_TABLE_ADDR); if (blackhawk_tsc_info_ptr->signature != SRDS_INFO_SIGNATURE) { EFUN_PRINTF(("ERROR: Mismatch in blackhawk_tsc_info signature. Expected 0x%08X, but received 0x%08X.\n", SRDS_INFO_SIGNATURE, blackhawk_tsc_info_ptr->signature)); return (blackhawk_tsc_error(sa__, ERR_CODE_INFO_TABLE_ERROR)); } err_code = blackhawk_tsc_INTERNAL_match_ucode_from_info(sa__); if (err_code != ERR_CODE_NONE) { /* ucode version mismatch */ return(ERR_CODE_MICRO_INIT_NOT_DONE); } return (ERR_CODE_NONE); } int blackhawk_tsc_osr_mode_enum_to_int_x1000(uint8_t osr_mode) { switch(osr_mode) { case BLACKHAWK_TSC_OSX1: return 1000; case BLACKHAWK_TSC_OSX2: return 2000; case BLACKHAWK_TSC_OSX4: return 4000; case BLACKHAWK_TSC_OSX8: return 8000; case BLACKHAWK_TSC_OSX16P5: return 16500; case BLACKHAWK_TSC_OSX20P625: return 20625; case BLACKHAWK_TSC_OSX16: return 16000; case BLACKHAWK_TSC_OSX32: return 32000; case BLACKHAWK_TSC_OSX21P25: return 21250; #ifdef wr_ams_rx_rxclk_div2p5 case BLACKHAWK_TSC_OSX2P5: return 2500; #endif default: return 1000; } } err_code_t blackhawk_tsc_INTERNAL_get_num_bits_per_ms(srds_access_t *sa__, uint32_t *num_bits_per_ms) { uint8_t osr_mode = 0; #if defined(rd_rx_pam4_mode) uint8_t pam4_mode = 0; #endif uint8_t pll_select = 0, prev_pll = 0; struct blackhawk_tsc_uc_core_config_st core_config = {{0}}; { blackhawk_tsc_osr_mode_st osr_mode_st; ENULL_MEMSET(&osr_mode_st, 0, sizeof(blackhawk_tsc_osr_mode_st)); EFUN(blackhawk_tsc_INTERNAL_get_osr_mode(sa__, &osr_mode_st)); osr_mode = osr_mode_st.rx; } #if defined(rd_rx_pam4_mode) ESTM(pam4_mode = rd_rx_pam4_mode()); #endif #if defined(rd_rx_pll_select) ESTM(prev_pll = blackhawk_tsc_get_pll_idx(sa__)); ESTM(pll_select = rd_rx_pll_select()); EFUN(blackhawk_tsc_set_pll_idx(sa__,pll_select)); #endif EFUN(blackhawk_tsc_get_uc_core_config(sa__, &core_config)); *num_bits_per_ms = (((uint32_t)core_config.vco_rate_in_Mhz * 100000UL) / blackhawk_tsc_osr_mode_enum_to_int_x1000(osr_mode))*10; #if defined(rd_rx_pam4_mode) if(pam4_mode > 0) *num_bits_per_ms <<= 1; #endif EFUN(blackhawk_tsc_set_pll_idx(sa__,prev_pll)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_display_BER(srds_access_t *sa__, uint16_t time_ms) { char string[10]; EFUN(blackhawk_tsc_INTERNAL_get_BER_string(sa__,time_ms,string)); USR_PRINTF(("%s",string)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_BER_string(srds_access_t *sa__, uint16_t time_ms, char *string) { char string2[3]; struct ber_data_st ber_data_local; ENULL_MEMSET(&ber_data_local, 0, sizeof(ber_data_local)); if(string == NULL) { return(ERR_CODE_BAD_PTR_OR_INVALID_INPUT); } EFUN(blackhawk_tsc_INTERNAL_get_BER_data(sa__, time_ms, &ber_data_local, USE_HW_TIMERS)); if(ber_data_local.prbs_chk_en == 0) { USR_STRCPY(string,""); return(ERR_CODE_NONE); } else { USR_STRCPY(string2," "); } if((COMPILER_64_HI(ber_data_local.num_errs) == 0) && (COMPILER_64_LO(ber_data_local.num_errs) < 3) && (ber_data_local.lcklost == 0)) { /* lcklost = 0 */ USR_STRNCAT(string2,"<",2); COMPILER_64_SET(ber_data_local.num_errs, 0, 3); } else { USR_STRNCAT(string2," ",2); } if(ber_data_local.lcklost == 1) { /* lcklost = 1 */ USR_STRCPY(string," !Lock "); } else { /* lcklost = 0 */ uint16_t x=0,y=0,z=0,srds_div; if(COMPILER_64_GE(ber_data_local.num_errs, ber_data_local.num_bits)) { x = 1;y=0;z=0; }else { uint64_t temp_dividend; uint64_t temp_divisor; while(1) { COMPILER_64_COPY(temp_dividend, ber_data_local.num_errs); COMPILER_64_SHL(temp_dividend, 1); COMPILER_64_ADD_64(temp_dividend, ber_data_local.num_bits); COMPILER_64_COPY(temp_divisor, ber_data_local.num_bits); COMPILER_64_SHL(temp_divisor, 1); COMPILER_64_UDIV_64(temp_dividend, temp_divisor); srds_div = (uint16_t) COMPILER_64_LO( temp_dividend ); if(srds_div>=10) { break; } COMPILER_64_UMUL_32(ber_data_local.num_errs, 10); z=z+1; } if(srds_div>=100) { srds_div = srds_div/10; z=z-1; } x=srds_div/10; y = srds_div - 10*x; z=z-1; } USR_SPRINTF(string,"%s%d.%1de-%02d",string2,x,y,z); } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_BER_data(srds_access_t *sa__, uint16_t time_ms, struct ber_data_st *ber_data, enum blackhawk_tsc_prbs_chk_timer_selection_enum timer_sel) { uint8_t lcklost = 0; uint32_t err_cnt= 0; const uint8_t ITER_MAX=10; uint8_t iter=0 ; if(ber_data == NULL) { return(ERR_CODE_BAD_PTR_OR_INVALID_INPUT); } ESTM(ber_data->prbs_chk_en = rd_prbs_chk_en()); if(ber_data->prbs_chk_en == 0) return(ERR_CODE_NONE); /* hardware timer's limitation - 448ms Max */ if((time_ms <= PRBS_MAX_HW_TIMER_TIMEOUT) && (timer_sel == USE_HW_TIMERS)) { uint8_t prbs_chk_mode_bak = 0; uint32_t num_bits_per_ms=0; uint16_t time_ms_adjusted = 0; uint8_t prbs_chk_lock = 0; struct prbs_chk_hw_timer_ctrl_st prbs_chk_hw_timer_ctrl_bak; USR_MEMSET(&prbs_chk_hw_timer_ctrl_bak, 0, sizeof(struct prbs_chk_hw_timer_ctrl_st)); /* STEP 1: save prbs chk mode */ ESTM(prbs_chk_mode_bak = rd_prbs_chk_mode()); /* STEP 2: force prbs mode 2, initial seed without hysteresis */ /* ??????????????????? */ EFUN(wr_prbs_chk_mode(PRBS_INITIAL_SEED_NO_HYSTERESIS)); /* STEP 3: save prbs hardware timer config registers */ EFUN(blackhawk_tsc_get_prbs_chk_hw_timer_ctrl(sa__, &prbs_chk_hw_timer_ctrl_bak)); /* STEP 4: Configure hardware timer to count prbs errors */ EFUN(blackhawk_tsc_config_prbs_chk_hw_timer(sa__, time_ms, &time_ms_adjusted)); /* STEP 5: Clear prbs error counters and lock lost status */ EFUN(blackhawk_tsc_prbs_err_count_state(sa__, &err_cnt,&lcklost)); /* clear error counters */ /* STEP 6: toggle checker enable to start hardware timers and error counters */ EFUN(blackhawk_tsc_prbs_chk_en_toggle(sa__)); /* STEP 7: Confirm that prbs lock was achieved */ ESTM(prbs_chk_lock = rd_prbs_chk_lock()); if(!prbs_chk_lock) { /* If prbs lock was not achieved, set lcklost = 1 and skip the wait for error accumulation */ ber_data->lcklost = 1; } else { /* STEP 8: wait time_ms for hardware timeout */ EFUN(USR_DELAY_MS(time_ms_adjusted)); /* STEP 9: Poll prbs_chk_lock to make sure timers expired */ do { EFUN(USR_DELAY_MS(1)); ESTM(prbs_chk_lock = rd_prbs_chk_lock()); iter++; } while(prbs_chk_lock && iter<ITER_MAX); if(prbs_chk_lock) { /* timer hasn't expired or it expired and lock didn't go away */ ber_data->lcklost = 1; return ERR_CODE_PRBS_CHK_HW_TIMERS_NOT_EXPIRED; } /* STEP 10: Read error counters */ EFUN(blackhawk_tsc_prbs_err_count_state(sa__, &err_cnt,&lcklost)); /* STEP 11: Update the BER data structure */ EFUN(blackhawk_tsc_INTERNAL_get_num_bits_per_ms(sa__,&num_bits_per_ms)); COMPILER_64_SET(ber_data->num_bits, 0, num_bits_per_ms); COMPILER_64_UMUL_32(ber_data->num_bits, time_ms_adjusted); COMPILER_64_SET(ber_data->num_errs, 0, err_cnt); /* ber_data->num_bits = (uint64_t)num_bits_per_ms*(uint64_t)time_ms_adjusted; ber_data->num_errs = err_cnt; */ ber_data->lcklost = 0; } /* STEP 12: restore prbs hardware timer config registers */ EFUN(blackhawk_tsc_set_prbs_chk_hw_timer_ctrl(sa__, &prbs_chk_hw_timer_ctrl_bak)); /* STEP 13: Restore prbs check mode */ EFUN(wr_prbs_chk_mode(prbs_chk_mode_bak)); } else { UNUSED(timer_sel); EFUN(USR_DELAY_MS(time_ms)); EFUN(blackhawk_tsc_prbs_err_count_state(sa__, &err_cnt,&lcklost)); ber_data->lcklost = lcklost; if(ber_data->lcklost == 0) { uint32_t num_bits_per_ms=0; EFUN(blackhawk_tsc_INTERNAL_get_num_bits_per_ms(sa__,&num_bits_per_ms)); COMPILER_64_SET(ber_data->num_bits, 0, num_bits_per_ms); COMPILER_64_UMUL_32(ber_data->num_bits, time_ms); COMPILER_64_SET(ber_data->num_errs, 0, err_cnt); /* ber_data->num_bits = (uint64_t)num_bits_per_ms*(uint64_t)time_ms; ber_data->num_errs = err_cnt; */ ESTM(lcklost = rd_prbs_chk_lock_lost_lh()); } } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_prbs_timeout_count_from_time(uint16_t time_ms, uint16_t * time_ms_adjusted, struct prbs_chk_hw_timer_ctrl_st * const prbs_chk_hw_timer_ctrl ) { uint8_t timeout_value; uint8_t iter = 0; if(time_ms > PRBS_HW_LUT_MAX_MINUS_1) { UNUSED(timeout_value); *time_ms_adjusted = PRBS_MAX_HW_TIMER_TIMEOUT; return ERR_CODE_NONE; } *time_ms_adjusted = time_ms; if(time_ms < 8) { /* Linear */ timeout_value = (uint8_t)time_ms; } else { for(iter=8; iter>2; iter--) { if((time_ms>>iter)&0x1) break; } timeout_value = ((iter-1)<<2) + ((time_ms>>(iter-2))&(0x3)); if((time_ms-((time_ms>>(iter-2))<<(iter-2)))>0) { /* time_ms is not found in the map, using a possible value larger than provided */ timeout_value = timeout_value + 1; *time_ms_adjusted = ((1<<(((timeout_value)>>2)+1)) + (((timeout_value)&3)*(1<<(((timeout_value)>>2)-1)))); } } prbs_chk_hw_timer_ctrl->prbs_chk_en_timeout = timeout_value; prbs_chk_hw_timer_ctrl->prbs_chk_en_timer_mode = 0x3; /* 1ms unit */ return ERR_CODE_NONE; } int16_t blackhawk_tsc_INTERNAL_ladder_setting_to_mV(srds_access_t *sa__, int8_t ctrl, uint8_t range_250) { uint16_t absv; /* Absolute value of ctrl */ int16_t nlmv; /* Non-linear value */ /* Get absolute value */ absv = SRDS_ABS(ctrl); { UNUSED(range_250); nlmv = absv*263/127; } /* Add sign and return */ return( (ctrl>=0) ? nlmv : -nlmv); } err_code_t blackhawk_tsc_INTERNAL_pam4_to_bin(srds_access_t *sa__, char var, char bin[]) { if(!bin) { return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } switch (var) { case '0': ENULL_STRCPY(bin,"00"); break; case '1': ENULL_STRCPY(bin,"01"); break; case '2': ENULL_STRCPY(bin,"11"); /* To account for PAM4 Gray coding */ break; case '3': ENULL_STRCPY(bin,"10"); /* To account for PAM4 Gray coding */ break; case '_': ENULL_STRCPY(bin,""); break; default : ENULL_STRCPY(bin,""); EFUN_PRINTF(("ERROR: Invalid PAM4 format Pattern\n")); return (blackhawk_tsc_error(sa__, ERR_CODE_CFG_PATT_INVALID_PAM4)); } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_compute_bin(srds_access_t *sa__, char var, char bin[]) { if(!bin) { return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } switch (var) { case '0': ENULL_STRCPY(bin,"0000"); break; case '1': ENULL_STRCPY(bin,"0001"); break; case '2': ENULL_STRCPY(bin,"0010"); break; case '3': ENULL_STRCPY(bin,"0011"); break; case '4': ENULL_STRCPY(bin,"0100"); break; case '5': ENULL_STRCPY(bin,"0101"); break; case '6': ENULL_STRCPY(bin,"0110"); break; case '7': ENULL_STRCPY(bin,"0111"); break; case '8': ENULL_STRCPY(bin,"1000"); break; case '9': ENULL_STRCPY(bin,"1001"); break; case 'a': case 'A': ENULL_STRCPY(bin,"1010"); break; case 'b': case 'B': ENULL_STRCPY(bin,"1011"); break; case 'c': case 'C': ENULL_STRCPY(bin,"1100"); break; case 'd': case 'D': ENULL_STRCPY(bin,"1101"); break; case 'e': case 'E': ENULL_STRCPY(bin,"1110"); break; case 'f': case 'F': ENULL_STRCPY(bin,"1111"); break; case '_': ENULL_STRCPY(bin,""); break; default : ENULL_STRCPY(bin,""); EFUN_PRINTF(("ERROR: Invalid Hexadecimal Pattern\n")); return (blackhawk_tsc_error(sa__, ERR_CODE_CFG_PATT_INVALID_HEX)); } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_compute_hex(srds_access_t *sa__, char bin[],uint8_t *hex) { if(!hex) { return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } if (!USR_STRCMP(bin,"0000")) { *hex = 0x0; } else if (!USR_STRCMP(bin,"0001")) { *hex = 0x1; } else if (!USR_STRCMP(bin,"0010")) { *hex = 0x2; } else if (!USR_STRCMP(bin,"0011")) { *hex = 0x3; } else if (!USR_STRCMP(bin,"0100")) { *hex = 0x4; } else if (!USR_STRCMP(bin,"0101")) { *hex = 0x5; } else if (!USR_STRCMP(bin,"0110")) { *hex = 0x6; } else if (!USR_STRCMP(bin,"0111")) { *hex = 0x7; } else if (!USR_STRCMP(bin,"1000")) { *hex = 0x8; } else if (!USR_STRCMP(bin,"1001")) { *hex = 0x9; } else if (!USR_STRCMP(bin,"1010")) { *hex = 0xA; } else if (!USR_STRCMP(bin,"1011")) { *hex = 0xB; } else if (!USR_STRCMP(bin,"1100")) { *hex = 0xC; } else if (!USR_STRCMP(bin,"1101")) { *hex = 0xD; } else if (!USR_STRCMP(bin,"1110")) { *hex = 0xE; } else if (!USR_STRCMP(bin,"1111")) { *hex = 0xF; } else { EFUN_PRINTF(("ERROR: Invalid Binary to Hex Conversion\n")); *hex = 0x0; return (blackhawk_tsc_error(sa__, ERR_CODE_CFG_PATT_INVALID_BIN2HEX)); } return (ERR_CODE_NONE); } uint8_t blackhawk_tsc_INTERNAL_stop_micro(srds_access_t *sa__, uint8_t graceful, err_code_t *err_code_p) { uint8_t stop_state = 0; if(!err_code_p) { return(0xFF); } /* Log current micro stop status */ EPSTM2((stop_state = rdv_usr_sts_micro_stopped()),0xFF); /* Stop micro only if micro is not stopped currently */ if (!(stop_state & 0x7F)) { if (graceful) { EPFUN2((blackhawk_tsc_stop_rx_adaptation(sa__, 1)),0xFF); } else { EPFUN2((blackhawk_tsc_pmd_uc_control(sa__, CMD_UC_CTRL_STOP_IMMEDIATE,GRACEFUL_STOP_TIME)),0xFF); } } /* Return the previous micro stop status */ return(stop_state); } /********************************************************/ /* Global RAM access through Micro Register Interface */ /********************************************************/ /* Micro Global RAM Byte Read */ uint8_t blackhawk_tsc_INTERNAL_rdb_uc_var(srds_access_t *sa__, err_code_t *err_code_p, uint16_t addr) { uint8_t rddata; if(!err_code_p) { return(0); } EPSTM(rddata = blackhawk_tsc_rdb_uc_ram(sa__, err_code_p, addr)); /* Use Micro register interface for reading RAM */ return (rddata); } /* Micro Global RAM Word Read */ uint16_t blackhawk_tsc_INTERNAL_rdw_uc_var(srds_access_t *sa__, err_code_t *err_code_p, uint16_t addr) { uint16_t rddata; if(!err_code_p) { return(0); } if (addr%2 != 0) { /* Validate even address */ *err_code_p = ERR_CODE_INVALID_RAM_ADDR; USR_PRINTF(("Error incorrect addr x%04x\n",addr)); return (0); } EPSTM(rddata = blackhawk_tsc_rdw_uc_ram(sa__, err_code_p, (addr))); /* Use Micro register interface for reading RAM */ return (rddata); } /* Micro Global RAM Byte Write */ err_code_t blackhawk_tsc_INTERNAL_wrb_uc_var(srds_access_t *sa__, uint16_t addr, uint8_t wr_val) { return (blackhawk_tsc_wrb_uc_ram(sa__, addr, wr_val)); /* Use Micro register interface for writing RAM */ } /* Micro Global RAM Word Write */ err_code_t blackhawk_tsc_INTERNAL_wrw_uc_var(srds_access_t *sa__, uint16_t addr, uint16_t wr_val) { if (addr%2 != 0) { /* Validate even address */ USR_PRINTF(("Error incorrect addr x%04x\n",addr)); return (blackhawk_tsc_error(sa__, ERR_CODE_INVALID_RAM_ADDR)); } return (blackhawk_tsc_wrw_uc_ram(sa__, addr, wr_val)); /* Use Micro register interface for writing RAM */ } /***********************/ /* Event Log Display */ /***********************/ err_code_t blackhawk_tsc_INTERNAL_event_log_dump_callback(void *arg, uint8_t byte_count, uint16_t data) { blackhawk_tsc_INTERNAL_event_log_dump_state_t * const state_ptr = (blackhawk_tsc_INTERNAL_event_log_dump_state_t *)arg; const uint8_t bytes_per_row=16; if (byte_count == 0) { if (state_ptr->line_start_index != state_ptr->index) { EFUN_PRINTF(("%*s %d\n", 4*(bytes_per_row - state_ptr->index + state_ptr->line_start_index), "", state_ptr->line_start_index)); } return (ERR_CODE_NONE); } if (byte_count == 1) { /* There is a trailing byte in the event log. * The simplest way to handle it is to print out a whole word, but mask * the invalid upper byte. */ data &= 0xFF; } EFUN_PRINTF((" 0x%04x", ((data & 0xFF) << 8) | (data >> 8))); state_ptr->index += 2; if (state_ptr->index % bytes_per_row == 0) { EFUN_PRINTF((" %d\n", state_ptr->line_start_index)); state_ptr->line_start_index = state_ptr->index; } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_read_event_log_with_callback(srds_access_t *sa__, uint8_t micro_num, uint8_t bypass_micro, void *arg, err_code_t (*callback)(void *, uint8_t, uint16_t)) { uint16_t rd_idx; uint8_t current_lane; srds_info_t * blackhawk_tsc_info_ptr = blackhawk_tsc_INTERNAL_get_blackhawk_tsc_info_ptr_with_check(sa__); #ifdef PHYMOD_SUPPORT if ( blackhawk_tsc_info_ptr == NULL ) { blackhawk_tsc_init_blackhawk_tsc_info(sa__); } else if (blackhawk_tsc_info_ptr->signature != SRDS_INFO_SIGNATURE) { blackhawk_tsc_init_blackhawk_tsc_info(sa__); } #endif /* PHYMOD_SUPPORT */ EFUN(blackhawk_tsc_INTERNAL_verify_blackhawk_tsc_info(blackhawk_tsc_info_ptr, sa__)); if (micro_num >= blackhawk_tsc_info_ptr->micro_count) { return (blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } /* Read Current lane so that it can be restored at the end of function */ current_lane = blackhawk_tsc_get_lane(sa__); /* Blackhawk has 2 lanes per micro, set lane appropriate for the desired micro */ EFUN(blackhawk_tsc_set_lane(sa__,micro_num<<1)); EFUN_PRINTF(("\n\n********************************************\n")); EFUN_PRINTF(( "**** SERDES UC TRACE MEMORY DUMP ***********\n")); EFUN_PRINTF(( "********************************************\n")); if (bypass_micro) { ESTM(rd_idx = rducv_trace_mem_wr_idx()); if (blackhawk_tsc_info_ptr->trace_memory_descending_writes) { ++rd_idx; if (rd_idx >= blackhawk_tsc_info_ptr->trace_mem_ram_size) { rd_idx = 0; } } else { if (rd_idx == 0) { rd_idx = blackhawk_tsc_info_ptr->trace_mem_ram_size; } --rd_idx; } } else { /* Start Read to stop uC logging and read the word at last event written by uC */ EFUN(blackhawk_tsc_pmd_uc_cmd(sa__, CMD_EVENT_LOG_READ, CMD_EVENT_LOG_READ_START, GRACEFUL_STOP_TIME)); ESTM(rd_idx = rducv_trace_mem_rd_idx()); } EFUN_PRINTF(( "\n DEBUG INFO: trace memory read index = 0x%04x\n", rd_idx)); EFUN_PRINTF((" DEBUG INFO: trace memory size = 0x%04x\n\n", blackhawk_tsc_info_ptr->trace_mem_ram_size)); if (blackhawk_tsc_info_ptr->trace_memory_descending_writes) { /* Micro writes trace memory using descending addresses. * So read using ascending addresses using block read */ EFUN(blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram(sa__, blackhawk_tsc_info_ptr->trace_mem_ram_base + blackhawk_tsc_info_ptr->grp_ram_size*micro_num, blackhawk_tsc_info_ptr->trace_mem_ram_size, rd_idx, blackhawk_tsc_info_ptr->trace_mem_ram_size, arg, callback)); } else { /* Micro writes trace memory using descending addresses. * So read using ascending addresses using block read */ EFUN(blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram_descending(sa__, blackhawk_tsc_info_ptr->trace_mem_ram_base + blackhawk_tsc_info_ptr->grp_ram_size*micro_num, blackhawk_tsc_info_ptr->trace_mem_ram_size, rd_idx, blackhawk_tsc_info_ptr->trace_mem_ram_size, arg, callback)); } if (!bypass_micro) { /* Read Done to resume logging */ EFUN(blackhawk_tsc_pmd_uc_cmd(sa__, CMD_EVENT_LOG_READ, CMD_EVENT_LOG_READ_DONE, 50)); } EFUN(blackhawk_tsc_set_lane(sa__,current_lane)); return(ERR_CODE_NONE); } #ifdef TO_FLOATS /* convert uint32_t to float8 */ float8_t blackhawk_tsc_INTERNAL_int32_to_float8(uint32_t input) { int8_t cnt; uint8_t output; if(input == 0) { return(0); } else if(input == 1) { return(0xe0); } else { cnt = 0; input = input & 0x7FFFFFFF; /* get rid of MSB which may be lock indicator */ do { input = input << 1; cnt++; } while ((input & 0x80000000) == 0); output = (uint8_t)((input & 0x70000000)>>23)+(31 - cnt%32); return(output); } } #endif /* convert float8 to uint32_t */ uint32_t blackhawk_tsc_INTERNAL_float8_to_int32(float8_t input) { uint32_t x; if(input == 0) return(0); x = (input>>5) + 8; if((input & 0x1F) < 3) { return(x>>(3-(input & 0x1f))); } return(x<<((input & 0x1F)-3)); } /* Convert uint8 to 8-bit gray code */ uint8_t blackhawk_tsc_INTERNAL_uint8_to_gray(uint8_t input) { return input ^ (input >> 1); } /* Convert 8-bit gray code to uint8 */ uint8_t blackhawk_tsc_INTERNAL_gray_to_uint8(uint8_t input) { input = input ^ (input >> 4); input = input ^ (input >> 2); input = input ^ (input >> 1); return input; } /* Convert seconds to hr:min:sec */ uint8_t blackhawk_tsc_INTERNAL_seconds_to_displayformat(uint32_t seconds, uint8_t *hrs, uint8_t *mins, uint8_t *secs) { *hrs = (seconds / 3600); seconds = (seconds % 3600); *mins = (seconds / 60); *secs = (seconds % 60); return(ERR_CODE_NONE); } /* convert float12 to uint32 */ uint32_t blackhawk_tsc_INTERNAL_float12_to_uint32(uint8_t input, uint8_t multi) { return(((uint32_t)input)<<multi); } err_code_t blackhawk_tsc_INTERNAL_set_rx_pf_main(srds_access_t *sa__, uint8_t val) { if (val > 31) { return (blackhawk_tsc_error(sa__, ERR_CODE_PF_INVALID)); } EFUN(WR_RX_PF_CTRL(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_pf_main(srds_access_t *sa__, uint8_t *val) { ESTM(*val = RD_RX_PF_CTRL()); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_pf2(srds_access_t *sa__, uint8_t val) { if (val > 7) { return (blackhawk_tsc_error(sa__, ERR_CODE_PF_INVALID)); } EFUN(WR_RX_PF2_CTRL(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_pf2(srds_access_t *sa__, uint8_t *val) { ESTM(*val = RD_RX_PF2_CTRL()); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_pf3(srds_access_t *sa__, uint8_t val) { if (val > 15) { return (blackhawk_tsc_error(sa__, ERR_CODE_PF_INVALID)); } EFUN(wr_ams_rx_pf3_ctrl(blackhawk_tsc_INTERNAL_uint8_to_gray(val))); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_pf3(srds_access_t *sa__, uint8_t *val) { ESTM(*val = blackhawk_tsc_INTERNAL_gray_to_uint8(rd_ams_rx_pf3_ctrl())); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_vga(srds_access_t *sa__, uint8_t val) { EFUN(blackhawk_tsc_INTERNAL_check_uc_lane_stopped(sa__)); /* make sure uC is stopped to avoid race conditions */ if (val > RX_VGA_CTRL_VAL_MAX) { return (blackhawk_tsc_error(sa__, ERR_CODE_VGA_INVALID)); } #if defined(RX_VGA_CTRL_VAL_MIN) && (RX_VGA_CTRL_VAL_MIN > 0) if (val < RX_VGA_CTRL_VAL_MIN) { return (blackhawk_tsc_error(sa__, ERR_CODE_VGA_INVALID)); } #endif EFUN(wr_rx_vga_val(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_vga(srds_access_t *sa__, uint8_t *val) { ESTM(*val = rd_rx_vga_status()); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe1(srds_access_t *sa__, int8_t val) { enum blackhawk_tsc_rx_pam_mode_enum pam_mode = NRZ; EFUN(blackhawk_tsc_INTERNAL_get_rx_pam_mode(sa__, &pam_mode)); if(pam_mode != NRZ) { EFUN_PRINTF(("ERROR: RX DFE1 is only available in NRZ mode\n")); return(ERR_CODE_INVALID_RX_PAM_MODE); } EFUN(blackhawk_tsc_INTERNAL_check_uc_lane_stopped(sa__)); /* make sure uC is stopped to avoid race conditions */ EFUN(wr_rx_afe_override_sel(1)); /* Select data23 slicer */ EFUN(wr_rx_afe_override_val(val)); EFUN(wr_rx_afe_override_write(1)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe1(srds_access_t *sa__, int8_t *val) { { enum blackhawk_tsc_rx_pam_mode_enum pam_mode = NRZ; EFUN(blackhawk_tsc_INTERNAL_get_rx_pam_mode(sa__, &pam_mode)); if(pam_mode != NRZ) { EFUN_PRINTF(("ERROR: RX DFE1 is only available in NRZ mode (core %d lane %d)\n",blackhawk_tsc_get_core(sa__),blackhawk_tsc_get_lane(sa__))); return(ERR_CODE_INVALID_RX_PAM_MODE); } } ESTM(*val = (int8_t)rd_rx_data23_status()); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe2(srds_access_t *sa__, int8_t val) { if ((val > 15) || (val < -15)) { USR_PRINTF(("Exceeded range of DFE tap limit = 15, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rx_afe_override_sel(6)); EFUN(wr_rxa_dfe_tap2_val(val)); EFUN(wr_rxa_dfe_tap2_write(1)); EFUN(wr_rxb_dfe_tap2_val(val)); EFUN(wr_rxb_dfe_tap2_write(1)); EFUN(wr_rxc_dfe_tap2_val(val)); EFUN(wr_rxc_dfe_tap2_write(1)); EFUN(wr_rxd_dfe_tap2_val(val)); EFUN(wr_rxd_dfe_tap2_write(1)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe2(srds_access_t *sa__, int8_t *val) { ESTM(*val = ((rd_rxa_dfe_tap2_status() + rd_rxb_dfe_tap2_status() + rd_rxc_dfe_tap2_status() + rd_rxd_dfe_tap2_status())>>2)); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe3(srds_access_t *sa__, int8_t val) { if ((val > 15) || (val < -15)) { USR_PRINTF(("Exceeded range of DFE tap limit = 15, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rx_afe_override_sel(6)); EFUN(wr_rxa_dfe_tap3_val(val)); EFUN(wr_rxa_dfe_tap3_write(1)); EFUN(wr_rxb_dfe_tap3_val(val)); EFUN(wr_rxb_dfe_tap3_write(1)); EFUN(wr_rxc_dfe_tap3_val(val)); EFUN(wr_rxc_dfe_tap3_write(1)); EFUN(wr_rxd_dfe_tap3_val(val)); EFUN(wr_rxd_dfe_tap3_write(1)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe3(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap3_status() + rd_rxb_dfe_tap3_status() + rd_rxc_dfe_tap3_status() + rd_rxd_dfe_tap3_status())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe4(srds_access_t *sa__, int8_t val) { if ((val > 15) || (val < -15)) { USR_PRINTF(("Exceeded range of DFE tap limit = 15, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap4(val)); EFUN(wr_rxb_dfe_tap4(val)); EFUN(wr_rxc_dfe_tap4(val)); EFUN(wr_rxd_dfe_tap4(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe4(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap4() + rd_rxb_dfe_tap4() + rd_rxc_dfe_tap4() + rd_rxd_dfe_tap4())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe5(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap5(val)); EFUN(wr_rxb_dfe_tap5(val)); EFUN(wr_rxc_dfe_tap5(val)); EFUN(wr_rxd_dfe_tap5(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe5(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap5() + rd_rxb_dfe_tap5() + rd_rxc_dfe_tap5() + rd_rxd_dfe_tap5())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe6(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap6(val)); EFUN(wr_rxb_dfe_tap6(val)); EFUN(wr_rxc_dfe_tap6(val)); EFUN(wr_rxd_dfe_tap6(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe6(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap6() + rd_rxb_dfe_tap6() + rd_rxc_dfe_tap6() + rd_rxd_dfe_tap6())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe7(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap7(val)); EFUN(wr_rxb_dfe_tap7(val)); EFUN(wr_rxc_dfe_tap7(val)); EFUN(wr_rxd_dfe_tap7(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe7(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap7() + rd_rxb_dfe_tap7() + rd_rxc_dfe_tap7() + rd_rxd_dfe_tap7())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe8(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap8(val)); EFUN(wr_rxb_dfe_tap8(val)); EFUN(wr_rxc_dfe_tap8(val)); EFUN(wr_rxd_dfe_tap8(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe8(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap8() + rd_rxb_dfe_tap8() + rd_rxc_dfe_tap8() + rd_rxd_dfe_tap8())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe9(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap9(val)); EFUN(wr_rxb_dfe_tap9(val)); EFUN(wr_rxc_dfe_tap9(val)); EFUN(wr_rxd_dfe_tap9(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe9(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap9() + rd_rxb_dfe_tap9() + rd_rxc_dfe_tap9() + rd_rxd_dfe_tap9())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe10(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap10(val)); EFUN(wr_rxb_dfe_tap10(val)); EFUN(wr_rxc_dfe_tap10(val)); EFUN(wr_rxd_dfe_tap10(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe10(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap10() + rd_rxb_dfe_tap10() + rd_rxc_dfe_tap10() + rd_rxd_dfe_tap10())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe11(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap11(val)); EFUN(wr_rxb_dfe_tap11(val)); EFUN(wr_rxc_dfe_tap11(val)); EFUN(wr_rxd_dfe_tap11(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe11(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap11() + rd_rxb_dfe_tap11() + rd_rxc_dfe_tap11() + rd_rxd_dfe_tap11())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe12(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap12(val)); EFUN(wr_rxb_dfe_tap12(val)); EFUN(wr_rxc_dfe_tap12(val)); EFUN(wr_rxd_dfe_tap12(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe12(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap12() + rd_rxb_dfe_tap12() + rd_rxc_dfe_tap12() + rd_rxd_dfe_tap12())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe13(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap13(val)); EFUN(wr_rxb_dfe_tap13(val)); EFUN(wr_rxc_dfe_tap13(val)); EFUN(wr_rxd_dfe_tap13(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe13(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap13() + rd_rxb_dfe_tap13() + rd_rxc_dfe_tap13() + rd_rxd_dfe_tap13())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe14(srds_access_t *sa__, int8_t val) { if ((val > 7) || (val < -7)) { USR_PRINTF(("Exceeded range of DFE tap limit = 7, request %d\n",val)); return (blackhawk_tsc_error(sa__, ERR_CODE_DFE_TAP)); } EFUN(wr_rxa_dfe_tap14(val)); EFUN(wr_rxb_dfe_tap14(val)); EFUN(wr_rxc_dfe_tap14(val)); EFUN(wr_rxd_dfe_tap14(val)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe14(srds_access_t *sa__, int8_t *val) { ESTM(*val = (rd_rxa_dfe_tap14() + rd_rxb_dfe_tap14() + rd_rxc_dfe_tap14() + rd_rxd_dfe_tap14())>>2); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_ip_version_check(srds_access_t *sa__, uint8_t *i_am_b0) { uint8_t ams_tx_version_id = 0; ESTM(ams_tx_version_id = rd_ams_tx_version_id()); *i_am_b0 = ams_tx_version_id == 0xC0; return ERR_CODE_NONE; } err_code_t blackhawk_tsc_INTERNAL_load_txfir_taps(srds_access_t *sa__){ EFUN(wr_txfir_tap_load(1)); /* Load the tap coefficients into TXFIR. */ return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_set_tx_tap(srds_access_t *sa__, uint8_t tap_num, int16_t val) { switch (tap_num) { case 0: EFUN(wr_txfir_tap0_coeff (val)); break; case 1: EFUN(wr_txfir_tap1_coeff (val)); break; case 2: EFUN(wr_txfir_tap2_coeff (val)); break; case 3: EFUN(wr_txfir_tap3_coeff (val)); break; case 4: EFUN(wr_txfir_tap4_coeff (val)); break; case 5: EFUN(wr_txfir_tap5_coeff (val)); break; case 6: EFUN(wr_txfir_tap6_coeff ((uint8_t)val)); break; case 7: EFUN(wr_txfir_tap7_coeff ((uint8_t)val)); break; case 8: EFUN(wr_txfir_tap8_coeff ((uint8_t)val)); break; case 9: EFUN(wr_txfir_tap9_coeff ((uint8_t)val)); break; case 10: EFUN(wr_txfir_tap10_coeff((uint8_t)val)); break; case 11: EFUN(wr_txfir_tap11_coeff((uint8_t)val)); break; default: return (blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_tx_tap(srds_access_t *sa__, uint8_t tap_num, int16_t *val) { switch (tap_num) { case 0: ESTM(*val = rd_txfir_tap0_coeff ()); break; case 1: ESTM(*val = rd_txfir_tap1_coeff ()); break; case 2: ESTM(*val = rd_txfir_tap2_coeff ()); break; case 3: ESTM(*val = rd_txfir_tap3_coeff ()); break; case 4: ESTM(*val = rd_txfir_tap4_coeff ()); break; case 5: ESTM(*val = rd_txfir_tap5_coeff ()); break; case 6: ESTM(*val = rd_txfir_tap6_coeff ()); break; case 7: ESTM(*val = rd_txfir_tap7_coeff ()); break; case 8: ESTM(*val = rd_txfir_tap8_coeff ()); break; case 9: ESTM(*val = rd_txfir_tap9_coeff ()); break; case 10: ESTM(*val = rd_txfir_tap10_coeff()); break; case 11: ESTM(*val = rd_txfir_tap11_coeff()); break; default: return (blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_core_clkgate(srds_access_t *sa__, uint8_t enable) { UNUSED(sa__); if (enable) { } else { } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_lane_clkgate(srds_access_t *sa__, uint8_t enable) { if (enable) { /* Use frc/frc_val to force all RX and TX clk_vld signals to 0 */ EFUN(wr_pmd_rx_clk_vld_frc_val(0x0)); EFUN(wr_pmd_rx_clk_vld_frc(0x1)); EFUN(wr_pmd_tx_clk_vld_frc_val(0x0)); EFUN(wr_pmd_tx_clk_vld_frc(0x1)); /* Use frc_on to force clkgate */ EFUN(wr_ln_rx_s_clkgate_frc_on(0x1)); EFUN(wr_ln_tx_s_clkgate_frc_on(0x1)); } else { EFUN(wr_pmd_rx_clk_vld_frc_val(0x0)); EFUN(wr_pmd_rx_clk_vld_frc(0x0)); EFUN(wr_pmd_tx_clk_vld_frc_val(0x0)); EFUN(wr_pmd_tx_clk_vld_frc(0x0)); EFUN(wr_ln_rx_s_clkgate_frc_on(0x0)); EFUN(wr_ln_tx_s_clkgate_frc_on(0x0)); } return (ERR_CODE_NONE); } /*-----------------------------------------------*/ /* Get dynamic eye margin estimation values */ /*-----------------------------------------------*/ err_code_t blackhawk_tsc_INTERNAL_get_eye_margin_est(srds_access_t *sa__, uint16_t *left_eye_mUI, uint16_t *right_eye_mUI, uint16_t *upper_eye_mV, uint16_t *lower_eye_mV) { uint8_t ladder_range = 0; ESTM(*left_eye_mUI = blackhawk_tsc_INTERNAL_eye_to_mUI(sa__, rdv_usr_sts_heye_left())); ESTM(*right_eye_mUI = blackhawk_tsc_INTERNAL_eye_to_mUI(sa__, rdv_usr_sts_heye_right())); ESTM(*upper_eye_mV = blackhawk_tsc_INTERNAL_eye_to_mV(sa__, rdv_usr_sts_veye_upper(), ladder_range)); ESTM(*lower_eye_mV = blackhawk_tsc_INTERNAL_eye_to_mV(sa__, rdv_usr_sts_veye_lower(), ladder_range)); return (ERR_CODE_NONE); } /*----------------------------------------------------*/ /* Get dynamic eye margin estimation values (PAM) */ /*----------------------------------------------------*/ err_code_t blackhawk_tsc_INTERNAL_get_pam_eye_margin_est(srds_access_t *sa__, eye_margin_t *eye_margin) { uint8_t ladder_range = 0; uint8_t i; for(i=0; i<NUM_PAM_EYES; i++) { ESTM(eye_margin->left_eye_mUI [i] = blackhawk_tsc_INTERNAL_eye_to_mUI(sa__, rdv_usr_sts_pam_heye_left(i))); ESTM(eye_margin->right_eye_mUI[i] = blackhawk_tsc_INTERNAL_eye_to_mUI(sa__, rdv_usr_sts_pam_heye_right(i))); ESTM(eye_margin->upper_eye_mV [i] = blackhawk_tsc_INTERNAL_eye_to_mV (sa__, rdv_usr_sts_pam_veye_upper(i), ladder_range)); ESTM(eye_margin->lower_eye_mV [i] = blackhawk_tsc_INTERNAL_eye_to_mV (sa__, rdv_usr_sts_pam_veye_lower(i), ladder_range)); } return (ERR_CODE_NONE); } /*------------------------------------------------------*/ /* Print dynamic eye margin estimation values (PAM) */ /*------------------------------------------------------*/ err_code_t blackhawk_tsc_display_pam_eye_margin_est(srds_access_t *sa__) { int8_t i; eye_margin_t eye_margin; ESTM(blackhawk_tsc_INTERNAL_get_pam_eye_margin_est(sa__, &eye_margin)); EFUN_PRINTF(("Eye margin: L(mUI),R(mUI),U(mV),D(mV)\n")); for(i=NUM_PAM_EYES-1; i>=0; i--) { EFUN_PRINTF(("%s eye: ", i==2?"Upper ":i==1?"Middle":"Lower ")); EFUN_PRINTF(("%6d,%6d,%5d,%5d\n", eye_margin.left_eye_mUI[i], eye_margin.right_eye_mUI[i], eye_margin.upper_eye_mV[i], eye_margin.lower_eye_mV[i])); } return (ERR_CODE_NONE); } uint16_t blackhawk_tsc_INTERNAL_eye_to_mUI(srds_access_t *sa__, uint8_t var) { UNUSED(sa__); /* var is in units of 1/512 th UI, so need to multiply by 1000/512 */ return ((uint16_t)var)*125/64; } uint16_t blackhawk_tsc_INTERNAL_eye_to_mV(srds_access_t *sa__, uint8_t var, uint8_t ladder_range) { /* find nearest two vertical levels */ uint16_t vl = blackhawk_tsc_INTERNAL_ladder_setting_to_mV(sa__, var, ladder_range); return (vl); } err_code_t blackhawk_tsc_INTERNAL_get_osr_mode(srds_access_t *sa__, blackhawk_tsc_osr_mode_st *imode) { blackhawk_tsc_osr_mode_st mode; ENULL_MEMSET(&mode, 0, sizeof(blackhawk_tsc_osr_mode_st)); if(!imode) return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); ESTM(mode.tx = rd_tx_osr_mode()); ESTM(mode.rx = rd_rx_osr_mode()); mode.tx_rx = 255; #ifdef wr_ams_rx_rxclk_div2p5 /* Analog 2p5 OSR mode */ { uint8_t osr_2p5, osr_2p5_pwrup; ESTM(osr_2p5 = rd_ams_tx_txclk_div2p5()); ESTM(osr_2p5_pwrup = rd_ams_tx_txclk_div2p5_pwrup()); if ((mode.tx == BLACKHAWK_TSC_OSX1) && (osr_2p5 == 1) && (osr_2p5_pwrup == 1)) { mode.tx = BLACKHAWK_TSC_OSX2P5; } ESTM(osr_2p5 = rd_ams_rx_rxclk_div2p5()); ESTM(osr_2p5_pwrup = rd_ams_rx_rxclk_div2p5_pwrup()); if ((mode.rx == BLACKHAWK_TSC_OSX1) && (osr_2p5 == 1) && (osr_2p5_pwrup == 1)) { mode.rx = BLACKHAWK_TSC_OSX2P5; } } #endif *imode = mode; return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_get_rx_pam_mode(srds_access_t *sa__, enum blackhawk_tsc_rx_pam_mode_enum *pmode) { uint8_t rx_pam4_mode, rx_pam4_es_mode; ESTM(rx_pam4_mode = rd_rx_pam4_mode()); ESTM(rx_pam4_es_mode = rd_rx_pam4_er_mode()); if (rx_pam4_mode == 0) { *pmode = NRZ; } else if (rx_pam4_mode == 1) { *pmode = (rx_pam4_es_mode) ? PAM4_ES : PAM4_NS; } else { return(blackhawk_tsc_error(sa__, ERR_CODE_INVALID_RX_PAM_MODE)); } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_decode_br_os_mode(srds_access_t *sa__, uint8_t *br_pd_en){ enum blackhawk_tsc_rx_pam_mode_enum pam_mode = NRZ; uint8_t os_pattern_enhanced=0, os_all_edges=0; ESTM(os_pattern_enhanced = rd_os_pattern_enhanced()); ESTM(os_all_edges = rd_os_all_edges()); EFUN(blackhawk_tsc_INTERNAL_get_rx_pam_mode(sa__, &pam_mode)); if(pam_mode == NRZ) { ESTM(*br_pd_en = rd_br_pd_en()); } else { *br_pd_en = (uint8_t)(!((!os_pattern_enhanced) & os_all_edges)); } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_pmd_lock_status(srds_access_t *sa__, uint8_t *pmd_lock, uint8_t *pmd_lock_chg) { uint16_t rddata; #if defined(reg_rd_TLB_RX_RXDBG_PMD_RX_LOCK_STATUS) ESTM(rddata = reg_rd_TLB_RX_RXDBG_PMD_RX_LOCK_STATUS()); ESTM(*pmd_lock = ex_TLB_RX_RXDBG_PMD_RX_LOCK_STATUS__dbg_pmd_rx_lock(rddata)); ESTM(*pmd_lock_chg = ex_TLB_RX_RXDBG_PMD_RX_LOCK_STATUS__dbg_pmd_rx_lock_change(rddata)); #elif defined(reg_rd_TLB_RX_DBG_PMD_RX_LOCK_STATUS) ESTM(rddata = reg_rd_TLB_RX_DBG_PMD_RX_LOCK_STATUS()); ESTM(*pmd_lock = ex_TLB_RX_DBG_PMD_RX_LOCK_STATUS__dbg_pmd_rx_lock(rddata)); ESTM(*pmd_lock_chg = ex_TLB_RX_DBG_PMD_RX_LOCK_STATUS__dbg_pmd_rx_lock_change(rddata)); #else #error "Unknown core for blackhawk_tsc_INTERNAL_pmd_lock_status()" #endif return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_sigdet_status(srds_access_t *sa__, uint8_t *sig_det, uint8_t *sig_det_chg) { uint16_t rddata; ESTM(rddata = reg_rd_SIGDET_SDSTATUS_0()); ESTM(*sig_det = ex_SIGDET_SDSTATUS_0__signal_detect(rddata)); ESTM(*sig_det_chg = ex_SIGDET_SDSTATUS_0__signal_detect_change(rddata)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_pll_lock_status(srds_access_t *sa__, uint8_t *pll_lock, uint8_t *pll_lock_chg) { uint16_t rddata; ESTM(rddata = reg_rdc_PLL_CAL_COM_CTL_STATUS_0()); ESTM(*pll_lock = exc_PLL_CAL_COM_CTL_STATUS_0__pll_lock(rddata)); ESTM(*pll_lock_chg = exc_PLL_CAL_COM_CTL_STATUS_0__pll_lock_lh_ll(rddata)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_read_lane_state(srds_access_t *sa__, blackhawk_tsc_lane_state_st *istate) { blackhawk_tsc_lane_state_st state; ENULL_MEMSET(&state, 0, sizeof(blackhawk_tsc_lane_state_st)); if(!istate) return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); EFUN(blackhawk_tsc_INTERNAL_pmd_lock_status(sa__,&state.rx_lock, &state.rx_lock_chg)); { err_code_t err_code = 0; state.stop_state = blackhawk_tsc_INTERNAL_stop_micro(sa__,state.rx_lock,&err_code); if(err_code) USR_PRINTF(("WARNING: Unable to stop microcontroller, following data is suspect\n")); } { blackhawk_tsc_osr_mode_st osr_mode; ENULL_MEMSET(&osr_mode, 0, sizeof(blackhawk_tsc_osr_mode_st)); EFUN(blackhawk_tsc_INTERNAL_get_osr_mode(sa__, &osr_mode)); state.osr_mode = osr_mode; } { enum blackhawk_tsc_rx_pam_mode_enum pam_mode = NRZ; EFUN(blackhawk_tsc_INTERNAL_get_rx_pam_mode(sa__, &pam_mode)); state.rx_pam_mode = (uint8_t)pam_mode; } { struct blackhawk_tsc_uc_lane_config_st lane_cfg; EFUN(blackhawk_tsc_get_uc_lane_cfg(sa__, &lane_cfg)); state.ucv_config = lane_cfg.word; } ESTM(state.ucv_status = rdv_status_byte()); ESTM(state.reset_state = rd_rx_lane_dp_reset_state()); ESTM(state.tx_reset_state = rd_tx_lane_dp_reset_state()); ESTM(state.tx_pll_select = rd_tx_pll_select()); ESTM(state.rx_pll_select = rd_rx_pll_select()); EFUN(blackhawk_tsc_INTERNAL_sigdet_status(sa__,&state.sig_det, &state.sig_det_chg)); ESTM(state.rx_ppm = rd_cdr_integ_reg()/84); { int8_t reg_data; ESTM(reg_data = rdv_usr_sts_phase_hoffset()); state.clk90 = reg_data; } EFUN(blackhawk_tsc_INTERNAL_decode_br_os_mode(sa__, &state.br_pd_en)); /* drop the MSB, the result is actually valid modulo 128 */ /* Also flip the sign to account for d-m1, versus m1-d */ EFUN(blackhawk_tsc_read_rx_afe(sa__, RX_AFE_PF, &state.pf_main)); state.pf_hiz = 0; EFUN(blackhawk_tsc_read_rx_afe(sa__, RX_AFE_PF2, &state.pf2_ctrl)); EFUN(blackhawk_tsc_read_rx_afe(sa__, RX_AFE_PF3, &state.pf3_ctrl)); ESTM(state.bwr_ctrl = rdv_afe_bw_adjust()); EFUN(blackhawk_tsc_read_rx_afe(sa__, RX_AFE_VGA, &state.vga)); ESTM(state.dc_offset = rd_dc_offset_bin()); ESTM(state.p1_lvl = rdv_usr_main_tap_est()/32); state.p1_lvl = blackhawk_tsc_INTERNAL_ladder_setting_to_mV(sa__, (int8_t)state.p1_lvl, 0); if (state.rx_pam_mode == NRZ) { ESTM(state.m1_lvl = rd_rx_phase02_status()); state.m1_lvl = blackhawk_tsc_INTERNAL_ladder_setting_to_mV(sa__, (int8_t)state.m1_lvl, 0); state.usr_status_eq_debug1 = 0; state.afe_bw = 0; } else { ESTM(state.m1_lvl = rdv_usr_ctrl_pam4_chn_loss()); ESTM(state.usr_status_eq_debug1 = rdv_usr_status_eq_debug1()); { uint16_t ucode_version_major; uint8_t ucode_version_minor; /*Extracting the major version number*/ ESTM(ucode_version_major = rdcv_common_ucode_version() & 0xFFF); ESTM(ucode_version_minor = rdcv_common_ucode_minor_version()); if ((ucode_version_major == 0x2) && (ucode_version_minor >= 0x3) && (ucode_version_minor < 0x8)) { uint8_t afe_bw_dbg0, afe_bw_dbg1; uint8_t afe_bw[4] = {1, 2, 0, 3}; ESTM(afe_bw_dbg0 = rdv_afe_bw_dbg_0()); ESTM(afe_bw_dbg1 = rdv_afe_bw_dbg_1()); afe_bw_dbg0 &= 0x01; afe_bw_dbg1 &= 0x01; state.afe_bw = afe_bw[((afe_bw_dbg0 << 1) | afe_bw_dbg1)]; } else if (((ucode_version_major == 0x2) && (ucode_version_minor >= 0x8)) || (ucode_version_major > 0x2)) { /*tag D002_08 has the changes to afe_bw calculation along with trunk before branching for tag D002_08*/ ESTM(state.afe_bw = rdv_afe_bw_dbg_0()); } else { state.afe_bw = 0xFF; /* assign to a invalid value. */ } } } ESTM(state.blind_ctle_ctrl = rdv_usr_status_eq_debug3()); ESTM(state.blind_ctle_trnsum = rdv_usr_status_eq_debug14()); if ((state.blind_ctle_ctrl == 0) && (state.blind_ctle_trnsum < 0)) { state.afe_bw_metric = state.blind_ctle_trnsum; } else { state.afe_bw_metric = state.blind_ctle_ctrl; } ESTM(state.tp_metric_prec1 = rdv_usr_status_tp_metric_1()); if (state.rx_pam_mode == NRZ) { EFUN(blackhawk_tsc_INTERNAL_get_rx_dfe1(sa__, &state.dfe1)); } EFUN(blackhawk_tsc_INTERNAL_get_rx_dfe2(sa__, &state.dfe2)); EFUN(blackhawk_tsc_INTERNAL_get_rx_dfe3(sa__, &state.dfe3)); EFUN(blackhawk_tsc_INTERNAL_get_rx_dfe4(sa__, &state.dfe4)); EFUN(blackhawk_tsc_INTERNAL_get_rx_dfe5(sa__, &state.dfe5)); EFUN(blackhawk_tsc_INTERNAL_get_rx_dfe6(sa__, &state.dfe6)); /* tx_ppm = register/10.84 */ ESTM(state.tx_ppm = (int16_t)(((int32_t)(rd_tx_pi_integ2_reg()))*3125/32768)); ESTM(state.tx_prec_en = rd_pam4_precoder_en()); ESTM(state.linktrn_en = rd_linktrn_ieee_training_enable()); ESTM(state.txfir_use_pam4_range = rd_txfir_nrz_tap_range_sel() ? 0 : 1); { uint8_t tap_num; for (tap_num=0; tap_num<12; ++tap_num) { EFUN(blackhawk_tsc_INTERNAL_get_tx_tap(sa__, tap_num, &state.txfir.tap[tap_num])); } } EFUN(blackhawk_tsc_INTERNAL_get_eye_margin_est(sa__, &state.heye_left, &state.heye_right, &state.veye_upper, &state.veye_lower)); ESTM(state.link_time = (((uint32_t)rdv_usr_sts_link_time())*8)/10); /* convert from 80us to 0.1 ms units */ { /* read lock status at end and combine them to handle transient cases */ uint8_t rx_lock_at_end=0, rx_lock_chg_at_end=0; EFUN(blackhawk_tsc_INTERNAL_pmd_lock_status(sa__,&rx_lock_at_end, &rx_lock_chg_at_end)); if (state.rx_lock != rx_lock_at_end) { USR_PRINTF(("rx_lock has changed while reading the lane state rx_lock_start=%d, rx_lock_chg_start=%d, rx_lock_at_end=%d, rx_lock_chg_at_end=%d\n", state.rx_lock, state.rx_lock_chg, rx_lock_at_end, rx_lock_chg_at_end)); } state.rx_lock &= rx_lock_at_end; state.rx_lock_chg |= rx_lock_chg_at_end; } if (!state.stop_state || (state.stop_state == 0xFF)) { /* manually check error code instead of EFUN*/ { err_code_t resume_status = ERR_CODE_NONE; resume_status = blackhawk_tsc_stop_rx_adaptation(sa__, 0); if (resume_status) { USR_PRINTF(("WARNING: Resuming micro after lane state capture failed \n")); } } } *istate = state; return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_display_lane_state_no_newline(srds_access_t *sa__) { uint16_t lane_idx; blackhawk_tsc_lane_state_st state; const char* e2s_osr_mode_enum[14] = { "x1 ", "x2 ", "x4 ", "ERR ", "x21.2", "x8 ", "ERR ", "ERR ", "x16.5", "x16 ", "ERR ", "ERR ", "x20.6", "x32 " }; const char* e2s_tx_osr_mode_enum[14] = { "x1", "x2", "x4", "ER", "xL", "x8", "ER", "ER", "xH", "xG", "ER", "ER", "xK", "xW" }; const char* e2s_rx_pam_mode_enum_2[3] = { "NRZ", "P4N", "P4E" }; ENULL_MEMSET(&state, 0, sizeof(blackhawk_tsc_lane_state_st)); EFUN(blackhawk_tsc_INTERNAL_read_lane_state(sa__, &state)); lane_idx = blackhawk_tsc_get_lane(sa__); EFUN_PRINTF(("%2d ", lane_idx)); if(state.osr_mode.tx_rx != 255) { char *s; s = (char *)e2s_osr_mode_enum[state.osr_mode.tx_rx]; EFUN_PRINTF(("(%2s%s, 0x%04x, 0x%02x ,", (state.br_pd_en) ? "BR" : "OS", s, state.ucv_config,state.ucv_status)); } else { char *s; char *r; s = (char *)e2s_tx_osr_mode_enum[state.osr_mode.tx]; r = (char *)e2s_tx_osr_mode_enum[state.osr_mode.rx]; { char *t; uint8_t tx, rx; t = (char *)e2s_rx_pam_mode_enum_2[state.rx_pam_mode]; ESTM(tx = rd_tx_pam4_mode()); ESTM(rx = rd_rx_pam4_mode()); EFUN_PRINTF(("(%3s%s,%2s%s:%s, 0x%04x, 0x%02x ,", t,(tx == rx) ? " ": "~", (state.br_pd_en) ? "BR" : "OS", s,r, state.ucv_config,state.ucv_status)); } } EFUN_PRINTF((" %01x,%01x, %01x, %1d,%1d)",state.tx_reset_state,state.reset_state,state.stop_state,state.tx_pll_select,state.rx_pll_select)); EFUN_PRINTF((" %1d%s", state.sig_det, state.sig_det_chg ? "*" : " ")); EFUN_PRINTF((" %1d%s", state.rx_lock, state.rx_lock_chg ? "*" : " ")); EFUN_PRINTF(("%4d ", state.rx_ppm)); EFUN_PRINTF((" %3d ", state.clk90)); EFUN_PRINTF((" %2d,%1d,%2d,%2d", state.pf_main, state.pf2_ctrl, state.pf3_ctrl, state.bwr_ctrl)); EFUN_PRINTF((" %2d ", state.vga)); EFUN_PRINTF(("%3d ", state.dc_offset)); EFUN_PRINTF(("%3d ", state.p1_lvl)); if (state.afe_bw == 0xFF) { /* afe_bw calculation is not supported in this microcode version and so invalid value 0xFF*/ EFUN_PRINTF(("(%4d,%+5d, x,%3d,%3d)", state.m1_lvl, /* pam4 _chn_loss */ state.afe_bw_metric, state.usr_status_eq_debug1, state.tp_metric_prec1)); } else { EFUN_PRINTF(("(%4d,%+5d,%2d,%3d,%3d)", state.m1_lvl, /* pam4 _chn_loss */ state.afe_bw_metric, state.afe_bw, state.usr_status_eq_debug1, state.tp_metric_prec1)); } if (state.rx_pam_mode == NRZ) { EFUN_PRINTF(("%3d,%3d,%3d,%3d,%3d,%3d", state.dfe1, state.dfe2, state.dfe3, state.dfe4, state.dfe5, state.dfe6)); } else { EFUN_PRINTF((" x ,%3d,%3d,%3d,%3d,%3d", state.dfe2, state.dfe3, state.dfe4, state.dfe5, state.dfe6)); } EFUN_PRINTF((" %4d ", state.tx_ppm)); { uint8_t enable_6taps; if (state.tx_prec_en) { EFUN_PRINTF((" P")); } else { EFUN_PRINTF((" ")); } if(state.linktrn_en) { EFUN_PRINTF(("T")); } else { EFUN_PRINTF((" ")); } ESTM(enable_6taps = rd_txfir_tap_en()); if (!enable_6taps) { EFUN_PRINTF((" x ,%3d,%3d,%3d, x , x ", state.txfir.tap[0], state.txfir.tap[1], state.txfir.tap[2])); } else { EFUN_PRINTF(("%3d,%3d,%3d,%3d,%3d,%3d ", state.txfir.tap[0], state.txfir.tap[1], state.txfir.tap[2], state.txfir.tap[3], state.txfir.tap[4], state.txfir.tap[5])); } } EFUN_PRINTF((" %3d,%3d,%3d,%3d ", state.heye_left, state.heye_right, state.veye_upper, state.veye_lower)); /* Check to see if link_time is max value after 80us to 0.1msec unit conversion */ if (state.link_time == 0xCCCC) { EFUN_PRINTF((" >%4d.%01d", state.link_time/10, state.link_time%10)); EFUN_PRINTF((" ")); } else { EFUN_PRINTF((" %4d.%01d", state.link_time/10, state.link_time%10)); EFUN_PRINTF((" ")); } EFUN(blackhawk_tsc_INTERNAL_display_BER(sa__,100)); return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_read_core_state(srds_access_t *sa__, blackhawk_tsc_core_state_st *istate) { blackhawk_tsc_core_state_st state; struct blackhawk_tsc_uc_core_config_st core_cfg; ENULL_MEMSET(&state, 0, sizeof(blackhawk_tsc_core_state_st)); ENULL_MEMSET(&core_cfg, 0, sizeof(struct blackhawk_tsc_uc_core_config_st)); if(!istate) return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); EFUN(blackhawk_tsc_get_uc_core_config(sa__, &core_cfg)); { uint8_t rescal_frc; ESTM(rescal_frc = rdc_rescal_frc()); if (1 == rescal_frc) { /* rescal_frc_val is read, since the rescal value is overriden. */ ESTM(state.rescal = rdc_rescal_frc_val()); } else { ESTM(state.rescal = rd_ams_tx_ana_rescal()); } } ESTM(state.core_reset = rdc_core_dp_reset_state()); ESTM(state.uc_active = rdc_uc_active()); ESTM(state.comclk_mhz = rdc_heartbeat_count_1us()); ESTM(state.pll_pwrdn = rdc_pll_pwrdn_or()); ESTM(state.ucode_version = rdcv_common_ucode_version()); EFUN(blackhawk_tsc_version(sa__, &state.api_version)); ESTM(state.ucode_minor_version = rdcv_common_ucode_minor_version()); ESTM(state.afe_hardware_version = rdcv_afe_hardware_version()); ESTM(state.temp_idx = rdcv_temp_idx()); { int16_t die_temp = 0; EFUN(blackhawk_tsc_read_die_temperature(sa__, &die_temp)); state.die_temp = die_temp; } ESTM(state.avg_tmon = _bin_to_degC(rdcv_avg_tmon_reg13bit()>>3)); state.vco_rate_mhz = (uint16_t)core_cfg.vco_rate_in_Mhz; ESTM(state.analog_vco_range = rdc_ams_pll_range()); EFUN(blackhawk_tsc_INTERNAL_measure_pll_comp_thresh(sa__, &state.pll_comp_thresh)); EFUN(blackhawk_tsc_INTERNAL_read_pll_div(sa__, &state.pll_div)); EFUN(blackhawk_tsc_INTERNAL_pll_lock_status(sa__, &state.pll_lock, &state.pll_lock_chg)); ESTM(state.core_status = rdcv_status_byte()); ESTM(state.refclk_doubler = rdc_ams_pll_refclk_doubler()); *istate = state; return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_measure_pll_comp_thresh(srds_access_t *sa__, int16_t *thresh) { uint8_t pll_comp_thresh=0; uint8_t pll_low=0; uint8_t pll_comp_thresh_bak; if(!thresh) return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); ESTM(pll_comp_thresh_bak = rdc_ams_pll_comp_thresh()); for(pll_comp_thresh = 0; pll_comp_thresh < 8; pll_comp_thresh++) { EFUN(wrc_ams_pll_comp_thresh(pll_comp_thresh)); ESTM(pll_low = rdc_ams_pll_low()); if(pll_low == 1) break; } EFUN(wrc_ams_pll_comp_thresh(pll_comp_thresh_bak)); *thresh = ((pll_comp_thresh==0) ? 0 : (-50*pll_comp_thresh - 50)); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_display_core_state_no_newline(srds_access_t *sa__) { blackhawk_tsc_core_state_st state; blackhawk_tsc_core_state_st state_pll1; ENULL_MEMSET(&state_pll1, 0, sizeof(state_pll1)); ENULL_MEMSET(&state , 0, sizeof(state )); { uint8_t pll_orig; ESTM(pll_orig = blackhawk_tsc_get_pll_idx(sa__)); EFUN(blackhawk_tsc_set_pll_idx(sa__, 0)); EFUN(blackhawk_tsc_INTERNAL_read_core_state(sa__, &state)); EFUN(blackhawk_tsc_set_pll_idx(sa__, 1)); EFUN(blackhawk_tsc_INTERNAL_read_core_state(sa__, &state_pll1)); EFUN(blackhawk_tsc_set_pll_idx(sa__, pll_orig)); } if ((state.avg_tmon<-50)||(state.avg_tmon>135)) { EFUN_PRINTF(("\n*** WARNING: Core die temperature (LIVE_TEMP) out of bounds -50C to 130C\n")); } if ((state.rescal < 6) || (state.rescal > 13)) { EFUN_PRINTF(("\n*** WARNING: RESCAL value is out of bounds 6 to 13\n")); } if ((state_pll1.rescal < 6) || (state_pll1.rescal > 13)) { EFUN_PRINTF(("\n*** WARNING: RESCAL PLL1 value is out of bounds 6 to 13\n")); } EFUN_PRINTF((" %02d " , blackhawk_tsc_get_core(sa__))); EFUN_PRINTF((" %x,%x,%02x " , state.core_reset, state_pll1.core_reset, state.core_status)); EFUN_PRINTF((" %1d,%1d " , state.pll_pwrdn,state_pll1.pll_pwrdn)); EFUN_PRINTF((" %1d " , state.uc_active)); EFUN_PRINTF((" %3d.%2dMHz" , (state.comclk_mhz/4),((state.comclk_mhz%4)*25))); /* comclk in Mhz = heartbeat_count_1us / 4 */ EFUN_PRINTF((" %4X_%02X " , state.ucode_version, state.ucode_minor_version)); EFUN_PRINTF((" %06X " , state.api_version)); EFUN_PRINTF((" 0x%02x " , state.afe_hardware_version)); EFUN_PRINTF((" %3dC " , state.die_temp)); EFUN_PRINTF((" (%02d)%3dC " , state.temp_idx, state.avg_tmon)); EFUN_PRINTF((" 0x%02x " , state.rescal)); EFUN_PRINTF((" %2d.%03d,%2d.%03dGHz ", (state .vco_rate_mhz / 1000), (state .vco_rate_mhz % 1000), (state_pll1.vco_rate_mhz / 1000), (state_pll1.vco_rate_mhz % 1000))); EFUN_PRINTF((" %03d,%03d " , state .analog_vco_range, state_pll1.analog_vco_range)); EFUN(blackhawk_tsc_INTERNAL_display_pll_to_divider(sa__, state .pll_div)); EFUN_PRINTF((",")); EFUN(blackhawk_tsc_INTERNAL_display_pll_to_divider(sa__, state_pll1.pll_div)); EFUN_PRINTF((" %01d%s," , state.pll_lock, state.pll_lock_chg ? "*" : " ")); EFUN_PRINTF((" %01d%s" , state_pll1.pll_lock, state_pll1.pll_lock_chg ? "*" : " ")); EFUN_PRINTF((" %+4dmV,%+4dmV " , state.pll_comp_thresh,state_pll1.pll_comp_thresh)); return (ERR_CODE_NONE); } /* returns 000111 (7 = 8-1), for n = 3 */ #define BFMASK(n) ((1<<((n)))-1) err_code_t blackhawk_tsc_INTERNAL_update_uc_lane_config_st(struct blackhawk_tsc_uc_lane_config_st *st) { uint16_t in = st->word; st->field.lane_cfg_from_pcs = in & BFMASK(1); in >>= 1; st->field.an_enabled = in & BFMASK(1); in >>= 1; st->field.dfe_on = in & BFMASK(1); in >>= 1; st->field.dfe_lp_mode = in & BFMASK(1); in >>= 1; st->field.force_brdfe_on = in & BFMASK(1); in >>= 1; st->field.media_type = in & BFMASK(2); in >>= 2; st->field.unreliable_los = in & BFMASK(1); in >>= 1; st->field.scrambling_dis = in & BFMASK(1); in >>= 1; st->field.cl72_auto_polarity_en = in & BFMASK(1); in >>= 1; st->field.cl72_restart_timeout_en = in & BFMASK(1); in >>= 1; st->field.force_es = in & BFMASK(1); in >>= 1; st->field.force_ns = in & BFMASK(1); in >>= 1; st->field.lp_has_prec_en = in & BFMASK(1); in >>= 1; st->field.force_pam4_mode = in & BFMASK(1); in >>= 1; st->field.force_nrz_mode = in & BFMASK(1); in >>= 1; return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_functions_st(struct blackhawk_tsc_usr_ctrl_disable_functions_st *st) { uint16_t in = st->word; st->field.pf_adaptation = in & BFMASK(1); in >>= 1; st->field.pf2_adaptation = in & BFMASK(1); in >>= 1; st->field.pf3_adaptation = in & BFMASK(1); in >>= 1; st->field.dc_adaptation = in & BFMASK(1); in >>= 1; st->field.vga_adaptation = in & BFMASK(1); in >>= 1; st->field.slicer_voffset_tuning = in & BFMASK(1); in >>= 1; st->field.slicer_hoffset_tuning = in & BFMASK(1); in >>= 1; st->field.phase_offset_adaptation = in & BFMASK(1); in >>= 1; st->field.eye_adaptation = in & BFMASK(1); in >>= 1; st->field.all_adaptation = in & BFMASK(1); in >>= 1; st->field.deq_adaptation = in & BFMASK(1); in >>= 1; st->field.pam_eye_margin_estimation = in & BFMASK(1); in >>= 1; st->field.reserved = in & BFMASK(4); return ERR_CODE_NONE; } err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_dfe_functions_st(struct blackhawk_tsc_usr_ctrl_disable_dfe_functions_st *st) { uint8_t in = st->byte; st->field.dfe_tap1_adaptation = in & BFMASK(1); in >>= 1; st->field.dfe_fx_taps_adaptation = in & BFMASK(1); in >>= 1; st->field.dfe_fl_taps_adaptation = in & BFMASK(1); in >>= 1; st->field.dfe_dcd_adaptation = in & BFMASK(1); in >>= 1; return ERR_CODE_NONE; } /* word to fields, for display */ err_code_t blackhawk_tsc_INTERNAL_update_uc_core_config_st(struct blackhawk_tsc_uc_core_config_st *st) { uint16_t in = st->word; st->field.vco_rate = in & BFMASK(8); in >>= 8; st->field.core_cfg_from_pcs = in & BFMASK(1); in >>= 1; st->field.reserved = in & BFMASK(7); st->vco_rate_in_Mhz = VCO_RATE_TO_MHZ(st->field.vco_rate); return ERR_CODE_NONE; } /* fields to word, to write into uC RAM */ err_code_t blackhawk_tsc_INTERNAL_update_uc_core_config_word(struct blackhawk_tsc_uc_core_config_st *st) { uint16_t in = 0; in <<= 7; in |= 0/*st->field.reserved*/ & BFMASK(7); in <<= 1; in |= st->field.core_cfg_from_pcs & BFMASK(1); in <<= 8; in |= st->field.vco_rate & BFMASK(8); st->word = in; return ERR_CODE_NONE; } err_code_t blackhawk_tsc_INTERNAL_update_uc_lane_config_word(struct blackhawk_tsc_uc_lane_config_st *st) { uint16_t in = 0; in <<= 1; in |= st->field.force_nrz_mode & BFMASK(1); in <<= 1; in |= st->field.force_pam4_mode & BFMASK(1); in <<= 1; in |= st->field.lp_has_prec_en & BFMASK(1); in <<= 1; in |= st->field.force_ns & BFMASK(1); in <<= 1; in |= st->field.force_es & BFMASK(1); in <<= 1; in |= st->field.cl72_restart_timeout_en & BFMASK(1); in <<= 1; in |= st->field.cl72_auto_polarity_en & BFMASK(1); in <<= 1; in |= st->field.scrambling_dis & BFMASK(1); in <<= 1; in |= st->field.unreliable_los & BFMASK(1); in <<= 2; in |= st->field.media_type & BFMASK(2); in <<= 1; in |= st->field.force_brdfe_on & BFMASK(1); in <<= 1; in |= st->field.dfe_lp_mode & BFMASK(1); in <<= 1; in |= st->field.dfe_on & BFMASK(1); in <<= 1; in |= st->field.an_enabled & BFMASK(1); in <<= 1; in |= st->field.lane_cfg_from_pcs & BFMASK(1); st->word = in; return ERR_CODE_NONE; } err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_functions_byte(struct blackhawk_tsc_usr_ctrl_disable_functions_st *st) { uint16_t in = 0; in <<= 5; in |= 0/*st->field.reserved*/ & BFMASK(4); in <<= 1; in |= st->field.pam_eye_margin_estimation & BFMASK(1); in <<= 1; in |= st->field.deq_adaptation & BFMASK(1); in <<= 1; in |= st->field.all_adaptation & BFMASK(1); in <<= 1; in |= st->field.eye_adaptation & BFMASK(1); in <<= 1; in |= st->field.phase_offset_adaptation & BFMASK(1); in <<= 1; in |= st->field.slicer_hoffset_tuning & BFMASK(1); in <<= 1; in |= st->field.slicer_voffset_tuning & BFMASK(1); in <<= 1; in |= st->field.vga_adaptation & BFMASK(1); in <<= 1; in |= st->field.dc_adaptation & BFMASK(1); in <<= 1; in |= st->field.pf3_adaptation & BFMASK(1); in <<= 1; in |= st->field.pf2_adaptation & BFMASK(1); in <<= 1; in |= st->field.pf_adaptation & BFMASK(1); st->word = in; return ERR_CODE_NONE; } err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_dfe_functions_byte(struct blackhawk_tsc_usr_ctrl_disable_dfe_functions_st *st) { uint8_t in = 0; in <<= 1; in |= st->field.dfe_dcd_adaptation & BFMASK(1); in <<= 1; in |= st->field.dfe_fl_taps_adaptation & BFMASK(1); in <<= 1; in |= st->field.dfe_fx_taps_adaptation & BFMASK(1); in <<= 1; in |= st->field.dfe_tap1_adaptation & BFMASK(1); st->byte = in; return ERR_CODE_NONE; } #undef BFMASK err_code_t blackhawk_tsc_INTERNAL_check_uc_lane_stopped(srds_access_t *sa__) { uint8_t is_micro_stopped; ESTM(is_micro_stopped = rdv_usr_sts_micro_stopped() || (rd_rx_lane_dp_reset_state() > 0)); if (!is_micro_stopped) { return(blackhawk_tsc_error(sa__, ERR_CODE_UC_NOT_STOPPED)); } else { return(ERR_CODE_NONE); } } err_code_t blackhawk_tsc_INTERNAL_calc_patt_gen_mode_sel(srds_access_t *sa__, uint8_t *mode_sel, uint8_t *zero_pad_len, uint8_t patt_length) { if(!mode_sel) { return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } if(!zero_pad_len) { return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } /* Select the correct Pattern generator Mode depending on Pattern length */ if (!(140 % patt_length)) { *mode_sel = 6; *zero_pad_len = 100; } else if (!(160 % patt_length)) { *mode_sel = 5; *zero_pad_len = 80; } else if (!(180 % patt_length)) { *mode_sel = 4; *zero_pad_len = 60; } else if (!(200 % patt_length)) { *mode_sel = 3; *zero_pad_len = 40; } else if (!(220 % patt_length)) { *mode_sel = 2; *zero_pad_len = 20; } else if (!(240 % patt_length)) { *mode_sel = 1; *zero_pad_len = 0; } else { EFUN_PRINTF(("ERROR: Unsupported Pattern Length\n")); return (blackhawk_tsc_error(sa__, ERR_CODE_CFG_PATT_INVALID_PATT_LENGTH)); } return(ERR_CODE_NONE); } /*-----------------------------------------*/ /* Write Core Config variables to uC RAM */ /*-----------------------------------------*/ err_code_t blackhawk_tsc_INTERNAL_set_uc_core_config(srds_access_t *sa__, struct blackhawk_tsc_uc_core_config_st struct_val) { { uint8_t reset_state; ESTM(reset_state = rdc_core_dp_reset_state()); if(reset_state < 7) { EFUN_PRINTF(("ERROR: blackhawk_tsc_INTERNAL_set_uc_core_config(..) called without core_dp_s_rstb=0\n")); return (blackhawk_tsc_error(sa__, ERR_CODE_CORE_DP_NOT_RESET)); } } if(struct_val.vco_rate_in_Mhz > 0) { struct_val.field.vco_rate = MHZ_TO_VCO_RATE(struct_val.vco_rate_in_Mhz); } EFUN(blackhawk_tsc_INTERNAL_update_uc_core_config_word(&struct_val)); switch (blackhawk_tsc_get_pll_idx(sa__)) { case 0: EFUN(reg_wrc_CORE_PLL_COM_PLL_UC_CORE_CONFIG(struct_val.word)); break; case 1: EFUN(reg_wrc_CORE_PLL_COM_PLL_UC_CORE_CONFIG(struct_val.word)); break; default: EFUN(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); break; } return (ERR_CODE_NONE); } /*---------------------*/ /* PLL Configuration */ /*---------------------*/ /** Extract the refclk frequency in Hz, based on a blackhawk_tsc_pll_refclk_enum value. */ err_code_t _blackhawk_tsc_get_refclk_in_hz(srds_access_t *sa__, enum blackhawk_tsc_pll_refclk_enum refclk, uint32_t *refclk_in_hz) { switch (refclk) { case BLACKHAWK_TSC_PLL_REFCLK_100MHZ: *refclk_in_hz = 100000000; break; case BLACKHAWK_TSC_PLL_REFCLK_106P25MHZ: *refclk_in_hz = 106250000; break; case BLACKHAWK_TSC_PLL_REFCLK_122P88MHZ: *refclk_in_hz = 122880000; break; case BLACKHAWK_TSC_PLL_REFCLK_125MHZ: *refclk_in_hz = 125000000; break; case BLACKHAWK_TSC_PLL_REFCLK_145P947802MHZ: *refclk_in_hz = 145947802; break; case BLACKHAWK_TSC_PLL_REFCLK_155P52MHZ: *refclk_in_hz = 155520000; break; case BLACKHAWK_TSC_PLL_REFCLK_156P25MHZ: *refclk_in_hz = 156250000; break; case BLACKHAWK_TSC_PLL_REFCLK_159P375MHZ: *refclk_in_hz = 159375000; break; case BLACKHAWK_TSC_PLL_REFCLK_161P1328125MHZ: *refclk_in_hz = 161132813; break; case BLACKHAWK_TSC_PLL_REFCLK_166P67MHZ: *refclk_in_hz = 166670000; break; case BLACKHAWK_TSC_PLL_REFCLK_166P7974882MHZ: *refclk_in_hz = 166797488; break; case BLACKHAWK_TSC_PLL_REFCLK_167P38MHZ: *refclk_in_hz = 167380000; break; case BLACKHAWK_TSC_PLL_REFCLK_167P4107143MHZ: *refclk_in_hz = 167410714; break; case BLACKHAWK_TSC_PLL_REFCLK_174P703125MHZ: *refclk_in_hz = 174703125; break; case BLACKHAWK_TSC_PLL_REFCLK_212P5MHZ: *refclk_in_hz = 212500000; break; case BLACKHAWK_TSC_PLL_REFCLK_311p04: *refclk_in_hz = 311040000; break; case BLACKHAWK_TSC_PLL_REFCLK_312P5MHZ: *refclk_in_hz = 312500000; break; case BLACKHAWK_TSC_PLL_REFCLK_425MHZ: *refclk_in_hz = 425000000; break; case BLACKHAWK_TSC_PLL_REFCLK_534MHZ: *refclk_in_hz = 534000000; break; case BLACKHAWK_TSC_PLL_REFCLK_705MHZ: *refclk_in_hz = 705000000; break; case BLACKHAWK_TSC_PLL_REFCLK_175MHZ: *refclk_in_hz = 175000000; break; case BLACKHAWK_TSC_PLL_REFCLK_400MHZ: *refclk_in_hz = 400000000; break; case BLACKHAWK_TSC_PLL_REFCLK_266P67MHZ: *refclk_in_hz = 266670000; break; case BLACKHAWK_TSC_PLL_REFCLK_156P637MHZ: *refclk_in_hz = 156637000; break; case BLACKHAWK_TSC_PLL_REFCLK_157P844MHZ: *refclk_in_hz = 157844000; break; case BLACKHAWK_TSC_PLL_REFCLK_158P51MHZ: *refclk_in_hz = 158510000; break; case BLACKHAWK_TSC_PLL_REFCLK_162P9485MHZ: *refclk_in_hz = 162948500; break; case BLACKHAWK_TSC_PLL_REFCLK_167P331MHZ: *refclk_in_hz = 167331000; break; case BLACKHAWK_TSC_PLL_REFCLK_168P04MHZ: *refclk_in_hz = 168040000; break; case BLACKHAWK_TSC_PLL_REFCLK_169P40905086MHZ: *refclk_in_hz = 169409051; break; case BLACKHAWK_TSC_PLL_REFCLK_173P37MHZ: *refclk_in_hz = 173370000; break; default: EFUN_PRINTF(("ERROR: Unknown refclk frequency: 0x%08X\n", (uint32_t)refclk)); *refclk_in_hz = 0xFFFFFFFF; return (blackhawk_tsc_error(sa__, ERR_CODE_REFCLK_FREQUENCY_INVALID)); } return (ERR_CODE_NONE); } /** Identify the ratio: * * (numerator / denominator) = (1000 / divisor) * * such that this has as little rounding error as possible: * * refclk_freq_hz = numerator * round(vco_freq_khz / denominator) * * This will yield the most accurate refclk_freq_hz. * Common values of vco_freq_khz are considered in this. */ static err_code_t _blackhawk_tsc_get_divisor_ratio(srds_access_t *sa__, enum blackhawk_tsc_pll_div_enum srds_div, uint16_t *numerator, uint16_t *denominator) { switch (srds_div) { case BLACKHAWK_TSC_PLL_DIV_66: *denominator = 33; *numerator = 500; break; case BLACKHAWK_TSC_PLL_DIV_67: *denominator = 67; *numerator = 1000; break; case BLACKHAWK_TSC_PLL_DIV_70: *denominator = 7; *numerator = 100; break; case BLACKHAWK_TSC_PLL_DIV_72: *denominator = 9; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_76: *denominator = 19; *numerator = 250; break; case BLACKHAWK_TSC_PLL_DIV_73P6: *denominator = 46; *numerator = 625; break; case BLACKHAWK_TSC_PLL_DIV_79P2: *denominator = 99; *numerator = 1250; break; case BLACKHAWK_TSC_PLL_DIV_80: *denominator = 2; *numerator = 25; break; case BLACKHAWK_TSC_PLL_DIV_82P5: *denominator = 33; *numerator = 400; break; case BLACKHAWK_TSC_PLL_DIV_84: *denominator = 21; *numerator = 250; break; case BLACKHAWK_TSC_PLL_DIV_85: *denominator = 17; *numerator = 200; break; case BLACKHAWK_TSC_PLL_DIV_87P5: *denominator = 7; *numerator = 80; break; case BLACKHAWK_TSC_PLL_DIV_89P6: *denominator = 56; *numerator = 625; break; case BLACKHAWK_TSC_PLL_DIV_90: *denominator = 9; *numerator = 100; break; case BLACKHAWK_TSC_PLL_DIV_96: *denominator = 12; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_100: *denominator = 1; *numerator = 10; break; case BLACKHAWK_TSC_PLL_DIV_120: *denominator = 3; *numerator = 25; break; case BLACKHAWK_TSC_PLL_DIV_127P401984: *denominator = 179; *numerator = 1405; break; case BLACKHAWK_TSC_PLL_DIV_128: *denominator = 16; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_132: *denominator = 33; *numerator = 250; break; case BLACKHAWK_TSC_PLL_DIV_134: *denominator = 67; *numerator = 500; break; case BLACKHAWK_TSC_PLL_DIV_140: *denominator = 7; *numerator = 50; break; case BLACKHAWK_TSC_PLL_DIV_144: *denominator = 18; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_147P2: *denominator = 92; *numerator = 625; break; case BLACKHAWK_TSC_PLL_DIV_148: *denominator = 37; *numerator = 250; break; case BLACKHAWK_TSC_PLL_DIV_152: *denominator = 19; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_158P4: *denominator = 99; *numerator = 625; break; case BLACKHAWK_TSC_PLL_DIV_160: *denominator = 4; *numerator = 25; break; case BLACKHAWK_TSC_PLL_DIV_165: *denominator = 33; *numerator = 200; break; case BLACKHAWK_TSC_PLL_DIV_168: *denominator = 21; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_170: *denominator = 17; *numerator = 100; break; case BLACKHAWK_TSC_PLL_DIV_175: *denominator = 7; *numerator = 40; break; case BLACKHAWK_TSC_PLL_DIV_180: *denominator = 9; *numerator = 50; break; case BLACKHAWK_TSC_PLL_DIV_184: *denominator = 23; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_192: *denominator = 24; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_198: *denominator = 99; *numerator = 500; break; case BLACKHAWK_TSC_PLL_DIV_200: *denominator = 1; *numerator = 5; break; case BLACKHAWK_TSC_PLL_DIV_224: *denominator = 28; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_240: *denominator = 6; *numerator = 25; break; case BLACKHAWK_TSC_PLL_DIV_264: *denominator = 33; *numerator = 125; break; case BLACKHAWK_TSC_PLL_DIV_280: *denominator = 7; *numerator = 25; break; case BLACKHAWK_TSC_PLL_DIV_330: *denominator = 33; *numerator = 100; break; case BLACKHAWK_TSC_PLL_DIV_350: *denominator = 7; *numerator = 20; break; default: EFUN_PRINTF(("ERROR: Unknown divider value: 0x%08X\n", (uint32_t)srds_div)); *numerator = 0; *denominator = 0; return (blackhawk_tsc_error(sa__, ERR_CODE_PLL_DIV_INVALID)); } return (ERR_CODE_NONE); } /** Get the Refclk frequency in Hz, based on the blackhawk_tsc_pll_div_enum value and VCO frequency. */ static err_code_t _blackhawk_tsc_get_refclk_from_div_vco(srds_access_t *sa__, uint32_t *refclk_freq_hz, enum blackhawk_tsc_pll_div_enum srds_div, uint32_t vco_freq_khz, enum blackhawk_tsc_pll_option_enum pll_option) { uint16_t numerator, denominator; EFUN(_blackhawk_tsc_get_divisor_ratio(sa__, srds_div, &numerator, &denominator)); *refclk_freq_hz = ((vco_freq_khz+(denominator>>1)) / denominator) * numerator; if (pll_option == BLACKHAWK_TSC_PLL_OPTION_REFCLK_DOUBLER_EN) *refclk_freq_hz /= 2; if (pll_option == BLACKHAWK_TSC_PLL_OPTION_REFCLK_DIV2_EN) *refclk_freq_hz *= 2; if (pll_option == BLACKHAWK_TSC_PLL_OPTION_REFCLK_DIV4_EN) *refclk_freq_hz *= 4; return (ERR_CODE_NONE); } /** Get the VCO frequency in kHz, based on the reference clock frequency and blackhawk_tsc_pll_div_enum value. */ err_code_t blackhawk_tsc_INTERNAL_get_vco_from_refclk_div(srds_access_t *sa__, uint32_t refclk_freq_hz, enum blackhawk_tsc_pll_div_enum srds_div, uint32_t *vco_freq_khz, enum blackhawk_tsc_pll_option_enum pll_option) { uint16_t numerator, denominator; EFUN(_blackhawk_tsc_get_divisor_ratio(sa__, srds_div, &numerator, &denominator)); if (pll_option == BLACKHAWK_TSC_PLL_OPTION_REFCLK_DOUBLER_EN) refclk_freq_hz *= 2; if (pll_option == BLACKHAWK_TSC_PLL_OPTION_REFCLK_DIV2_EN) refclk_freq_hz /= 2; if (pll_option == BLACKHAWK_TSC_PLL_OPTION_REFCLK_DIV4_EN) refclk_freq_hz /= 4; *vco_freq_khz = ((refclk_freq_hz + (numerator>>1)) / numerator) * denominator; return (ERR_CODE_NONE); } /* Boundaries for allowed VCO frequency */ # define SERDES_VCO_FREQ_KHZ_MIN (15000000) # define SERDES_VCO_FREQ_KHZ_MAX (30000000) /* Allowed tolerance in resultant VCO frequency when auto-determining divider value */ # define SERDES_VCO_FREQ_KHZ_TOLERANCE (2000) /* The allowed PLL divider values */ static const enum blackhawk_tsc_pll_div_enum _blackhawk_tsc_div_candidates[] = { BLACKHAWK_TSC_PLL_DIV_66, BLACKHAWK_TSC_PLL_DIV_67, BLACKHAWK_TSC_PLL_DIV_70, BLACKHAWK_TSC_PLL_DIV_72, BLACKHAWK_TSC_PLL_DIV_76, BLACKHAWK_TSC_PLL_DIV_73P6, BLACKHAWK_TSC_PLL_DIV_79P2, BLACKHAWK_TSC_PLL_DIV_80, BLACKHAWK_TSC_PLL_DIV_82P5, BLACKHAWK_TSC_PLL_DIV_84, BLACKHAWK_TSC_PLL_DIV_85, BLACKHAWK_TSC_PLL_DIV_87P5, BLACKHAWK_TSC_PLL_DIV_89P6, BLACKHAWK_TSC_PLL_DIV_90, BLACKHAWK_TSC_PLL_DIV_96, BLACKHAWK_TSC_PLL_DIV_100, BLACKHAWK_TSC_PLL_DIV_120, BLACKHAWK_TSC_PLL_DIV_127P401984, BLACKHAWK_TSC_PLL_DIV_128, BLACKHAWK_TSC_PLL_DIV_132, BLACKHAWK_TSC_PLL_DIV_134, BLACKHAWK_TSC_PLL_DIV_140, BLACKHAWK_TSC_PLL_DIV_144, BLACKHAWK_TSC_PLL_DIV_147P2, BLACKHAWK_TSC_PLL_DIV_148, BLACKHAWK_TSC_PLL_DIV_152, BLACKHAWK_TSC_PLL_DIV_158P4, BLACKHAWK_TSC_PLL_DIV_160, BLACKHAWK_TSC_PLL_DIV_165, BLACKHAWK_TSC_PLL_DIV_168, BLACKHAWK_TSC_PLL_DIV_170, BLACKHAWK_TSC_PLL_DIV_175, BLACKHAWK_TSC_PLL_DIV_180, BLACKHAWK_TSC_PLL_DIV_184, BLACKHAWK_TSC_PLL_DIV_192, BLACKHAWK_TSC_PLL_DIV_198, BLACKHAWK_TSC_PLL_DIV_200, BLACKHAWK_TSC_PLL_DIV_224, BLACKHAWK_TSC_PLL_DIV_240, BLACKHAWK_TSC_PLL_DIV_264, BLACKHAWK_TSC_PLL_DIV_280, BLACKHAWK_TSC_PLL_DIV_330, BLACKHAWK_TSC_PLL_DIV_350 }; static const uint8_t _blackhawk_tsc_div_candidates_count = sizeof(_blackhawk_tsc_div_candidates) / sizeof(_blackhawk_tsc_div_candidates[0]); static err_code_t _blackhawk_tsc_check_div(srds_access_t *sa__, enum blackhawk_tsc_pll_div_enum srds_div) { uint8_t i, found = 0; for (i=0; i<_blackhawk_tsc_div_candidates_count; i++) { found |= srds_div == _blackhawk_tsc_div_candidates[i]; } if (!found) { EFUN_PRINTF(("ERROR: Invalid divider value: 0x%08X\n", (uint32_t)srds_div)); return (blackhawk_tsc_error(sa__, ERR_CODE_PLL_DIV_INVALID)); } return (ERR_CODE_NONE); } static err_code_t _blackhawk_tsc_check_vco_freq_khz(srds_access_t *sa__, uint32_t vco_freq_khz) { if (vco_freq_khz < SERDES_VCO_FREQ_KHZ_MIN - SERDES_VCO_FREQ_KHZ_TOLERANCE) { EFUN_PRINTF(("ERROR: VCO frequency too low: %d kHz is lower than minimum (%d kHz)\n", vco_freq_khz, SERDES_VCO_FREQ_KHZ_MIN)); return (blackhawk_tsc_error(sa__, ERR_CODE_VCO_FREQUENCY_INVALID)); } if (vco_freq_khz > SERDES_VCO_FREQ_KHZ_MAX + SERDES_VCO_FREQ_KHZ_TOLERANCE) { EFUN_PRINTF(("ERROR: VCO frequency too high: %d kHz is higher than maximum (%d kHz)\n", vco_freq_khz, SERDES_VCO_FREQ_KHZ_MAX)); return (blackhawk_tsc_error(sa__, ERR_CODE_VCO_FREQUENCY_INVALID)); } return (ERR_CODE_NONE); } /** Find the entry out of _blackhawk_tsc_div_candidates that is closest to matching refclk_freq_hz and vco_freq_khz. */ static err_code_t _blackhawk_tsc_get_div(srds_access_t *sa__, uint32_t refclk_freq_hz, uint32_t vco_freq_khz, enum blackhawk_tsc_pll_div_enum *srds_div, enum blackhawk_tsc_pll_option_enum pll_option) { int32_t vco_freq_khz_min_error = 0x7FFFFFFF; uint8_t i; for (i=0; i<_blackhawk_tsc_div_candidates_count; i++) { uint32_t actual_vco_freq_khz = 0; int32_t vco_freq_khz_error; EFUN(blackhawk_tsc_INTERNAL_get_vco_from_refclk_div(sa__, refclk_freq_hz, _blackhawk_tsc_div_candidates[i], &actual_vco_freq_khz, pll_option)); vco_freq_khz_error = vco_freq_khz - actual_vco_freq_khz; vco_freq_khz_error = SRDS_ABS(vco_freq_khz_error); if (vco_freq_khz_min_error > vco_freq_khz_error) { vco_freq_khz_min_error = vco_freq_khz_error; *srds_div = _blackhawk_tsc_div_candidates[i]; } } if (vco_freq_khz_min_error == -1) { return (blackhawk_tsc_error(sa__, ERR_CODE_CONFLICTING_PARAMETERS)); } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_resolve_pll_parameters(srds_access_t *sa__, enum blackhawk_tsc_pll_refclk_enum refclk, uint32_t *refclk_freq_hz, enum blackhawk_tsc_pll_div_enum *srds_div, uint32_t *vco_freq_khz, enum blackhawk_tsc_pll_option_enum pll_option) { /* Parameter value and consistency checks */ const uint8_t given_param_count = (((refclk == BLACKHAWK_TSC_PLL_REFCLK_UNKNOWN) ? 0 : 1) + ((*srds_div == BLACKHAWK_TSC_PLL_DIV_UNKNOWN) ? 0 : 1) + ((*vco_freq_khz == 0) ? 0 : 1)); const uint32_t original_vco_freq_khz = *vco_freq_khz; enum blackhawk_tsc_pll_div_enum auto_div = BLACKHAWK_TSC_PLL_DIV_UNKNOWN; char*pll_option_e2s[] = {"no", "refclk_x2", "refclk_div2", "refclk_div4"}; COMPILER_REFERENCE(pll_option_e2s); /* Verify that at least two of the three parameters is given. */ if (given_param_count < 2) { return (blackhawk_tsc_error(sa__, ERR_CODE_INSUFFICIENT_PARAMETERS)); } /* Skip verification if option is selected. Error if all parameters not given. */ if ((pll_option & BLACKHAWK_TSC_PLL_OPTION_DISABLE_VERIFY) == BLACKHAWK_TSC_PLL_OPTION_DISABLE_VERIFY) { if (given_param_count < 3) { return (blackhawk_tsc_error(sa__, ERR_CODE_INSUFFICIENT_PARAMETERS)); } else { EFUN(_blackhawk_tsc_get_refclk_in_hz(sa__, refclk, refclk_freq_hz)); return(ERR_CODE_NONE); } } pll_option = (enum blackhawk_tsc_pll_option_enum)(pll_option & BLACKHAWK_TSC_PLL_OPTION_REFCLK_MASK); /* The refclk value is checked in various functions below. */ /* Verify that the requested div value is allowed. */ if (*srds_div != BLACKHAWK_TSC_PLL_DIV_UNKNOWN) { EFUN(_blackhawk_tsc_check_div(sa__, *srds_div)); } /* Verify that the requested VCO frequency is allowed. */ if (*vco_freq_khz != 0) { EFUN(_blackhawk_tsc_check_vco_freq_khz(sa__, *vco_freq_khz)); } if (refclk == BLACKHAWK_TSC_PLL_REFCLK_UNKNOWN) { /* Determine refclk from vco frequency and div */ EFUN(_blackhawk_tsc_get_refclk_from_div_vco(sa__, refclk_freq_hz, *srds_div, *vco_freq_khz, pll_option)); } else { EFUN(_blackhawk_tsc_get_refclk_in_hz(sa__, refclk, refclk_freq_hz)); } if (*vco_freq_khz == 0) { /* Determine VCO frequency from refclk and divider */ EFUN(blackhawk_tsc_INTERNAL_get_vco_from_refclk_div(sa__, *refclk_freq_hz, *srds_div, vco_freq_khz, pll_option)); } /* Determine divider from vco frequency and refclk. * This is done even if the div was provided, because if it is, * we still want to check whether the parameters are conflicting. */ EFUN(_blackhawk_tsc_get_div(sa__, *refclk_freq_hz, *vco_freq_khz, &auto_div, pll_option)); if (*srds_div == BLACKHAWK_TSC_PLL_DIV_UNKNOWN) { /* Use the auto-determined divider value, since the divider was not supplied. */ *srds_div = auto_div; /* Determine resultant VCO frequency from refclk and divider */ EFUN(blackhawk_tsc_INTERNAL_get_vco_from_refclk_div(sa__, *refclk_freq_hz, *srds_div, vco_freq_khz, pll_option)); } /* Verify the resultant VCO frequency */ EFUN(_blackhawk_tsc_check_vco_freq_khz(sa__, *vco_freq_khz)); /* Verify that the requested VCO frequency is delivered. */ if ((original_vco_freq_khz != 0) && ((*vco_freq_khz < original_vco_freq_khz - SERDES_VCO_FREQ_KHZ_TOLERANCE) || (*vco_freq_khz > original_vco_freq_khz + SERDES_VCO_FREQ_KHZ_TOLERANCE))) { EFUN_PRINTF(("ERROR: Could not achieve requested VCO frequency of %d kHz.\n Refclk is %d Hz, %s option enabled, and auto-determined divider is 0x%08X, yielding a VCO frequency of %d kHz.\n", original_vco_freq_khz, *refclk_freq_hz, pll_option_e2s[pll_option], *srds_div, *vco_freq_khz)); return (blackhawk_tsc_error(sa__, ERR_CODE_VCO_FREQUENCY_INVALID)); } /* Verify the auto-determined divider value. */ if (auto_div != *srds_div) { EFUN_PRINTF(("ERROR: Conflicting PLL parameters: refclk is %d Hz, %s option enabled, divider is 0x%08X, and VCO frequency is %d kHz.\n Expected divider is 0x%08X\n", *refclk_freq_hz, pll_option_e2s[pll_option], *srds_div, *vco_freq_khz, auto_div)); return (blackhawk_tsc_error(sa__, ERR_CODE_CONFLICTING_PARAMETERS)); } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_display_pll_to_divider(srds_access_t *sa__, uint32_t srds_div) { /* Adjust these to increase or decrease the number of digits to the right * of the decimal point. */ const uint8_t decimal_digits = 4; const uint32_t ten_to_the_decimal_digits = 10000; /* 10**decimal_digits */ /* Not a const, because of carry logic below. */ uint16_t div_integer = SRDS_INTERNAL_GET_PLL_DIV_INTEGER(srds_div); if (SRDS_INTERNAL_IS_PLL_DIV_FRACTIONAL(srds_div)) { /* fraction_num will have this many bits (ending at bit 0). */ const uint8_t fraction_num_width = 28; const uint32_t fraction_num = SRDS_INTERNAL_GET_PLL_DIV_FRACTION_NUM(srds_div, fraction_num_width); /* Identify the number that, when printed with left-padded zeros, * becomes the digits to the right of the decimal point. * * This value can be obtained by dividing fraction_num by: * * (2^fraction_num_width)/(10^decimal_digits) */ const uint32_t divisor = (((1 << fraction_num_width) + (ten_to_the_decimal_digits>>1)) / ten_to_the_decimal_digits); uint32_t fraction_as_int = (fraction_num + (divisor>>1)) / divisor; /* In case the rounding above caused the fractional portion to overflow * (e.g. 4.9999999999 becomes 5.0000), implement the carry into the * integer portion. */ if (fraction_as_int >= ten_to_the_decimal_digits) { fraction_as_int -= ten_to_the_decimal_digits; ++div_integer; } EFUN_PRINTF(("%3d.%0*d", div_integer, decimal_digits, fraction_as_int)); } else { const uint8_t left_spaces = (decimal_digits + 1) >> 1; COMPILER_REFERENCE(left_spaces); EFUN_PRINTF(("%*s%3d%*s", left_spaces, "", div_integer, decimal_digits - left_spaces + 1, "")); } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_print_uc_dsc_error(srds_access_t *sa__, enum srds_pmd_uc_cmd_enum cmd) { uint32_t supp_info; ESTM(supp_info = (rd_uc_dsc_supp_info()) & 0xFF); switch (SUPP_INFO_TO_ERROR_CODE(supp_info)) { case UC_CMD_ERROR_INVALID_COMMAND: ESTM_PRINTF(("ERROR : UC reported invalid command %d. (other_info = 0x%X)\n", cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); break; case UC_CMD_ERROR_BUSY: ESTM_PRINTF(("ERROR : UC reported busy for command %d. (other_info = 0x%X)\n", cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); break; case UC_CMD_ERROR_GET_EYE_SAMPLE_ERROR: ESTM_PRINTF(("ERROR : UC reported error in getting eye sample. (command %d, other_info = 0x%X)\n", cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); break; case UC_CMD_ERROR_PRBS_NOT_LOCKED: ESTM_PRINTF(("ERROR : UC reported PRBS not locked. (command %d, other_info = 0x%X)\n", cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); break; case UC_CMD_ERROR_COMMAND_IN_PROGRESS: ESTM_PRINTF(("ERROR : UC reported command already in progress. (command %d, other_info = 0x%X)\n", cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); break; case UC_CMD_ERROR_INVALID_MODE: ESTM_PRINTF(("ERROR : UC reported invalid mode for command %d. (other_info = 0x%X)\n", cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); break; default: ESTM_PRINTF(("ERROR : UC reported unknown error 0x%X for command %d. (other_info = 0x%X)\n", SUPP_INFO_TO_ERROR_CODE(supp_info), cmd, SUPP_INFO_TO_OTHER_INFO(supp_info))); } /* Cleanup cmd register */ EFUN(reg_wr_DSC_A_DSC_UC_CTRL(0x80)); EFUN(wr_uc_dsc_data(0)); return(ERR_CODE_NONE); } /******************************************/ /* Serdes Register field Poll functions */ /******************************************/ #ifndef CUSTOM_REG_POLLING /* poll for microcontroller to populate the dsc_data register */ err_code_t blackhawk_tsc_INTERNAL_poll_diag_done(srds_access_t *sa__, uint16_t *status, uint32_t timeout_ms) { uint8_t loop; if(!status) { return(blackhawk_tsc_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } for(loop=0;loop < 100; loop++) { ESTM(*status=rdv_usr_diag_status()); if((*status & 0x8000) > 0) { return(ERR_CODE_NONE); } if(loop>10) { EFUN(USR_DELAY_US(10*timeout_ms)); } } return(blackhawk_tsc_error(sa__, ERR_CODE_DIAG_TIMEOUT)); } /** Poll for field "uc_dsc_ready_for_cmd" = 1 [Return Val => Error_code (0 = Polling Pass)] */ err_code_t blackhawk_tsc_INTERNAL_poll_uc_dsc_ready_for_cmd_equals_1(srds_access_t *sa__, uint32_t timeout_ms, enum srds_pmd_uc_cmd_enum cmd) { /* read quickly for 10 tries */ uint16_t loop; uint16_t reset_state; for (loop = 0; loop < 100; loop++) { uint16_t rddata; ESTM(rddata = reg_rd_DSC_A_DSC_UC_CTRL()); if (rddata & 0x0080) { /* bit 7 is uc_dsc_ready_for_cmd */ if (rddata & 0x0040) { /* bit 6 is uc_dsc_error_found */ EFUN(blackhawk_tsc_INTERNAL_print_uc_dsc_error(sa__, cmd)); return(blackhawk_tsc_error(sa__, ERR_CODE_UC_CMD_RETURN_ERROR)); } return (ERR_CODE_NONE); } if(loop>10) { EFUN(USR_DELAY_US(10*timeout_ms)); } } /* Check if ln_s_rstb is asserted by looking at the reset state, the give a warning and display the commands*/ ESTM(reset_state = rd_lane_dp_reset_state()); if (reset_state & 0x0007) { EFUN_PRINTF(("DSC ready for command is not working; SerDes is probably reset!\n")); return (ERR_CODE_NONE); } { EFUN_PRINTF(("%s ERROR : DSC ready for command is not working, applying workaround and getting debug info !\n", API_FUNCTION_NAME)); /* print the triage info and reset the cmd interface */ blackhawk_tsc_INTERNAL_print_triage_info(sa__, ERR_CODE_UC_CMD_POLLING_TIMEOUT, 1, 1, __LINE__); /* artifically terminate the command to re-enable the command interface */ EFUN(wr_uc_dsc_ready_for_cmd(0x1)); } return (ERR_CODE_UC_CMD_POLLING_TIMEOUT); } /* Poll for field "dsc_state" = DSC_STATE_UC_TUNE [Return Val => Error_code (0 = Polling Pass)] */ err_code_t blackhawk_tsc_INTERNAL_poll_dsc_state_equals_uc_tune(srds_access_t *sa__, uint32_t timeout_ms) { uint16_t loop; uint16_t dsc_state; /* poll 10 times to avoid longer delays later */ for (loop = 0; loop < 100; loop++) { ESTM(dsc_state = rd_dsc_state()); if (dsc_state == DSC_STATE_UC_TUNE) { return (ERR_CODE_NONE); } if(loop>10) { EFUN(USR_DELAY_US(10*timeout_ms)); } } ESTM_PRINTF(("DSC_STATE = %d\n", rd_dsc_state())); return (blackhawk_tsc_error(sa__, ERR_CODE_POLLING_TIMEOUT)); /* Error Code for polling timeout */ } /* Poll for field "micro_ra_initdone" = 1 [Return Val => Error_code (0 = Polling Pass)] */ err_code_t blackhawk_tsc_INTERNAL_poll_micro_ra_initdone(srds_access_t *sa__, uint32_t timeout_ms) { uint16_t loop; uint8_t result; for (loop = 0; loop <= 100; loop++) { ESTM(result = rdc_micro_ra_initdone()); if (result) { return (ERR_CODE_NONE); } EFUN(USR_DELAY_US(10*timeout_ms)); } return (blackhawk_tsc_error(sa__, ERR_CODE_POLLING_TIMEOUT)); /* Error Code for polling timeout */ } #endif /* CUSTOM_REG_POLLING */ int8_t blackhawk_tsc_INTERNAL_afe_slicer_offset_mapping(int8_t x) { if (x>=0) return(x^((x&2)>>1)); /* XOR bit 0 with bit 1 */ else return(-blackhawk_tsc_INTERNAL_afe_slicer_offset_mapping(-x)); } uint8_t blackhawk_tsc_INTERNAL_is_big_endian(void) { uint32_t one_u32 = 0x01000000; char * ptr = (char *)(&one_u32); const uint8_t big_endian = (ptr[0] == 1); return big_endian; } int blackhawk_tsc_INTERNAL_get_endian_offset(uint8_t *addr) { const int endian_const = 1; return ((*(char*)&endian_const) == 0) ? ( (((USR_UINTPTR)(addr))%4 == 0) ? 3 : (((USR_UINTPTR)(addr))%4 == 1) ? 1 : (((USR_UINTPTR)(addr))%4 == 2) ? -1 : (((USR_UINTPTR)(addr))%4 == 3) ? -3 : 0) : 0; } err_code_t blackhawk_tsc_INTERNAL_rdblk_callback(void *arg, uint8_t byte_count, uint16_t data) { srds_access_t *sa__; blackhawk_tsc_INTERNAL_rdblk_callback_arg_t * const cast_arg = (blackhawk_tsc_INTERNAL_rdblk_callback_arg_t *)arg; int endian_offset = 0; sa__ = cast_arg->sa; ESTM(endian_offset = blackhawk_tsc_INTERNAL_get_endian_offset(cast_arg->mem_ptr)); *(cast_arg->mem_ptr + endian_offset) = data & 0xFF; cast_arg->mem_ptr++; if (byte_count == 2) { ESTM(endian_offset = blackhawk_tsc_INTERNAL_get_endian_offset(cast_arg->mem_ptr)); *(cast_arg->mem_ptr + endian_offset) = data >> 8; cast_arg->mem_ptr++; } return (ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram(srds_access_t *sa__, uint32_t block_addr, uint16_t block_size, uint16_t start_offset, uint16_t cnt, void *arg, err_code_t (*callback)(void *, uint8_t, uint16_t)) { uint32_t read_val = 0; uint8_t defecit = 0; uint32_t addr = block_addr + start_offset; if (cnt == 0) { return (ERR_CODE_NONE); } /* Check for bad start offset and block size. */ if (start_offset >= block_size) { return (ERR_CODE_BAD_PTR_OR_INVALID_INPUT); } while (cnt > 0) { /* Determine how many bytes to read before wrapping back to start of block. */ uint16_t block_cnt = SRDS_MIN(cnt, block_addr + block_size - addr); cnt -= block_cnt; /* Set up the word reads. */ EFUN(wrc_micro_autoinc_rdaddr_en(1)); EFUN(wrc_micro_ra_rddatasize(0x1)); /* Select 16bit read datasize */ EFUN(wrc_micro_ra_rdaddr_msw(addr >> 16)); /* Upper 16bits of RAM address to be read */ EFUN(wrc_micro_ra_rdaddr_lsw(addr & 0xFFFE)); /* Lower 16bits of RAM address to be read */ /* Read the leading byte, if starting at an odd address. */ if ((addr & 1) == 1) { ESTM(read_val |= ((rdc_micro_ra_rddata_lsw() >> 8) << defecit)); if (defecit == 8) { EFUN(callback(arg, 2, (uint16_t)read_val)); read_val = 0; } /* We just read a byte. This toggles the defecit from 0 to 8 or from 8 to 0. */ defecit ^= 8; --block_cnt; } /* Read the whole words, and call the callback with two bytes at a time. */ while (block_cnt >= 2) { ESTM(read_val |= (rdc_micro_ra_rddata_lsw() << defecit)); EFUN(callback(arg, 2, (uint16_t)read_val)); read_val >>= 16; /* We just read two bytes. This preserves whatever defecit (8 or 0) is there. */ block_cnt -= 2; } /* Read the trailing byte, if leftover after reading whole words. */ if (block_cnt > 0) { ESTM(read_val |= ((rdc_micro_ra_rddata_lsw() & 0xFF) << defecit)); if (defecit == 8) { EFUN(callback(arg, 2, (uint16_t)read_val)); read_val = 0; } /* We just read a byte. This toggles the defecit from 0 to 8 or from 8 to 0. */ defecit ^= 8; } addr = block_addr; } /* If a final byte is left behind, then call the callback with it. */ if (defecit > 0) { EFUN(callback(arg, 1, (uint16_t)read_val)); } return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram_descending(srds_access_t *sa__, uint32_t block_addr, uint16_t block_size, uint16_t start_offset, uint16_t cnt, void *arg, err_code_t (*callback)(void *, uint8_t, uint16_t)) { uint32_t read_val = 0; uint8_t defecit = 0; uint32_t addr = block_addr + start_offset; uint16_t configured_addr_msw = (addr >> 16) + 1; if (cnt == 0) { return (ERR_CODE_NONE); } /* Check for bad start offset and block size. */ if (start_offset >= block_size) { return (ERR_CODE_BAD_PTR_OR_INVALID_INPUT); } EFUN(wrc_micro_autoinc_rdaddr_en(0)); EFUN(wrc_micro_ra_rddatasize(0x1)); /* Select 16bit read datasize */ while (cnt > 0) { /* Determine how many bytes to read before wrapping back to end of block. */ uint16_t block_cnt = SRDS_MIN(cnt, start_offset+1); cnt -= block_cnt; while (block_cnt > 0) { const uint16_t addr_msw = addr >> 16; uint16_t read_val2; if (addr_msw != configured_addr_msw) { EFUN(wrc_micro_ra_rdaddr_msw(addr_msw)); /* Upper 16bits of RAM address to be read */ configured_addr_msw = addr_msw; } EFUN(wrc_micro_ra_rdaddr_lsw(addr & 0xFFFE)); /* Lower 16bits of RAM address to be read */ ESTM(read_val2 = rdc_micro_ra_rddata_lsw()); if (((addr & 1) == 1) && (block_cnt >= 2)) { /* Reading two bytes. Since we're reading in descending address order, they * will be reversed before they are sent out. */ read_val |= ((((read_val2 & 0xFF) << 8) | (read_val2 >> 8)) << defecit); EFUN(callback(arg, 2, (uint16_t)read_val)); read_val >>= 16; /* We just read two bytes. This preserves whatever defecit (8 or 0) is there. */ block_cnt -= 2; addr -= 2; } else { if ((addr & 1) == 1) { /* Reading upper byte of word. */ read_val |= ((read_val2 >> 8) << defecit); } else { /* Reading lower byte of word. */ read_val |= ((read_val2 & 0xFF) << defecit); } if (defecit == 8) { EFUN(callback(arg, 2, (uint16_t)read_val)); read_val = 0; } /* We just read a byte. This toggles the defecit from 0 to 8 or from 8 to 0. */ defecit ^= 8; --block_cnt; --addr; } } addr = block_addr + block_size - 1; start_offset = block_size - 1; } /* If a final byte is left behind, then call the callback with it. */ if (defecit > 0) { EFUN(callback(arg, 1, (uint16_t)read_val)); } return(ERR_CODE_NONE); } uint8_t blackhawk_tsc_INTERNAL_grp_idx_from_lane(uint8_t lane) { return(lane>>1); } err_code_t blackhawk_tsc_INTERNAL_get_lms_thresh_bin(srds_access_t *sa__, int8_t *lms_thresh_bin) { ESTM(*lms_thresh_bin = (int8_t)rd_afe_lms_thresh_bin()); return(ERR_CODE_NONE); } err_code_t blackhawk_tsc_INTERNAL_poll_dbgfb_idx_lock(srds_access_t *sa__, uint8_t timeout_ms) { uint32_t loop, max_loop = 10; uint8_t idx_lock = 0; /* poll for first 10 times and then wait for timeout_ms before polling */ for (loop = 0; loop < max_loop; loop++) { ESTM(idx_lock = rd_dbg_fdbk_idx_lock()); if (idx_lock) { return (ERR_CODE_NONE); } } /* polled for 10 times, wait for timeout_ms right here before polling the register */ EFUN(blackhawk_tsc_delay_us(timeout_ms * 1000)); ESTM(idx_lock = rd_dbg_fdbk_idx_lock()); if (idx_lock) { return (ERR_CODE_NONE); } else { ESTM_PRINTF(("!!!!ERROR!!!! polling for dbgfb idx lock timedout after %d ms \n", timeout_ms)); /* Error Code for polling timeout */ return (blackhawk_tsc_error(sa__, ERR_CODE_POLLING_TIMEOUT)); } } err_code_t blackhawk_tsc_get_dbgfb_summary(srds_access_t *sa__, dbgfb_cfg_st *dbgfb_cfg) { uint32_t d_0_n1, d_0_0, d_0_p1, d_1_n1, d_1_0, d_1_p1; uint32_t pdet, ndet; int32_t tdet; enum blackhawk_tsc_rx_pam_mode_enum pam_mode = NRZ; EFUN(blackhawk_tsc_INTERNAL_get_rx_pam_mode(sa__, &pam_mode)); if (pam_mode == NRZ) { EFUN_PRINTF(("!!!!ERROR!!!! rx_pam_mode is set to NRZ , blackhawk_tsc_get_dbgfb_summary cannot continue\n")); return(ERR_CODE_INVALID_RX_PAM_MODE); } EFUN(wr_dbg_fdbk_en(1)); EFUN(wr_fdbk_counting_mode(0)); EFUN(wr_dbg_fdbk_data_threshold(dbgfb_cfg->y)); EFUN(wr_dbg_fdbk_data_sel(1)); if (dbgfb_cfg->x) { EFUN(wr_inlv_idx(78)); EFUN(wr_dbg_fdbk_idx(dbgfb_cfg->x -1)); EFUN(wr_frc_index_diffprec(1)); EFUN(blackhawk_tsc_INTERNAL_poll_dbgfb_idx_lock(sa__, 100)); EFUN(wr_frc_index_diffprec(0)); EFUN(wr_dbg_fdbk_idx_monitor_en(0)); EFUN(wr_dbg_fdbk_idx_monitor_en(1)); } else { EFUN(wr_dbg_fdbk_idx(1)); EFUN(wr_dbg_fdbk_idx(0)); EFUN(wr_dbg_fdbk_idx_monitor_en(0)); } EFUN(USR_DELAY_US(dbgfb_cfg->time_in_us)); EFUN(wr_dbg_fdbk_en(0)); ESTM(d_1_n1 = rd_dbg_fdbk_counter_0()); ESTM(d_1_0 = rd_dbg_fdbk_counter_1()); ESTM(d_1_p1 = rd_dbg_fdbk_counter_2()); ESTM(d_0_n1 = rd_dbg_fdbk_counter_3()); ESTM(d_0_0 = rd_dbg_fdbk_counter_4()); ESTM(d_0_p1 = rd_dbg_fdbk_counter_5()); tdet = d_1_n1 + d_0_p1-d_0_n1 - d_1_p1; pdet = d_1_n1 + d_1_0 + d_1_p1; ndet = d_0_n1 + d_0_0 + d_0_p1; dbgfb_cfg->data2 = pdet; dbgfb_cfg->data3 = ndet; dbgfb_cfg->data1 = tdet; return ERR_CODE_NONE; } err_code_t blackhawk_tsc_collect_dbgfb_stats(srds_access_t *sa__, uint32_t time_in_us, dbgfb_stats_st *dbgfb_stats) { uint8_t y, x; uint8_t max_y; enum blackhawk_tsc_rx_pam_mode_enum pam_mode = NRZ; uint8_t pam4es_en = 0; dbgfb_cfg_st dbgfb_cfg = {0}; EFUN(blackhawk_tsc_INTERNAL_get_rx_pam_mode(sa__, &pam_mode)); if (pam_mode == NRZ) { EFUN_PRINTF(("!!!!ERROR!!!! rx_pam_mode is set to NRZ , blackhawk_tsc_collect_dbgfb_stats cannot continue\n")); return(ERR_CODE_INVALID_RX_PAM_MODE); } pam4es_en = (pam_mode==PAM4_ES); max_y = pam4es_en ? 6 : 3; /* backup the measure time and pam4es_en info */ dbgfb_stats->time_in_us = time_in_us; dbgfb_stats->pam4es_en = pam4es_en; for (y=0; y < max_y; y++){ for (x = 0; x < _X_; x++){ dbgfb_cfg.y = y; dbgfb_cfg.x = x; dbgfb_cfg.time_in_us = time_in_us; dbgfb_cfg.data1 = 0; dbgfb_cfg.data2 = 0; dbgfb_cfg.data3 = 0; EFUN(blackhawk_tsc_get_dbgfb_summary(sa__, &dbgfb_cfg)); dbgfb_stats->time_in_us = time_in_us; dbgfb_stats->data.data1[x][y] = dbgfb_cfg.data1; dbgfb_stats->data.data2[x][y] = dbgfb_cfg.data2; dbgfb_stats->data.data3[x][y] = dbgfb_cfg.data3; dbgfb_stats->data.data4[x][y] = dbgfb_stats->data.data2[x][y] - dbgfb_stats->data.data3[x][y]; } } return ERR_CODE_NONE; }
40.236058
218
0.646126
[ "3d" ]
6abc8c1dd9c4d81da9d576c8e8519c5d5b2e401c
28,487
h
C
System/Library/PrivateFrameworks/AudioToolboxCore.framework/AudioToolboxCore-Structs.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/AudioToolboxCore.framework/AudioToolboxCore-Structs.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/AudioToolboxCore.framework/AudioToolboxCore-Structs.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:40:57 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/AudioToolboxCore.framework/AudioToolboxCore * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class AUAudioUnit, AUAudioUnit_XPC, NSXPCConnection; typedef struct AudioComponentDescription { unsigned componentType; unsigned componentSubType; unsigned componentManufacturer; unsigned componentFlags; unsigned componentFlagsMask; } AudioComponentDescription; typedef struct AUOOPRenderingServerUser { /*function pointer*/void* _vptr$CAPrint; unsigned mSerialNum; AUAudioUnit* mAUAudioUnit; /*^block*/id mRetainedRenderBlock; /*^block*/id mRenderBlock; BOOL mCanProcessInPlace; long long mMIDIOutBaseSampleTime; AUEventSchedule mEventSchedule; AUOOPSharedMemory mSharedBuffers; } AUOOPRenderingServerUser; typedef struct optional<AUOOPRenderingServerUser> { /*function pointer*/void* ; char __null_state_; AUOOPRenderingServerUser) __val_; BOOL __engaged_; } optional<AUOOPRenderingServerUser>; typedef struct type { unsigned char __lx[24]; } type; typedef struct _value_func<void ()> { type __buf_; __base<void ()> __f_; } value_func<void ()>; typedef struct function<void ()> { value_func<void ()> __f_; } function<void ()>; typedef struct reply_watchdog_factory { BOOL mDebugging; int mDefaultTimeoutMS; function<void ()> mTimeoutHandler; } reply_watchdog_factory; typedef struct shared_ptr<auoop::WorkgroupMirror> { WorkgroupMirror __ptr_; __shared_weak_count __cntrl_; } shared_ptr<auoop::WorkgroupMirror>; typedef struct _compressed_pair<KVOAggregator::Record *, std::__1::allocator<KVOAggregator::Record> > { Record __value_; } compressed_pair<KVOAggregator::Record *, std::__1::allocator<KVOAggregator::Record> >; typedef struct vector<KVOAggregator::Record, std::__1::allocator<KVOAggregator::Record> > { Record __begin_; Record __end_; compressed_pair<KVOAggregator::Record *, std::__1::allocator<KVOAggregator::Record> > __end_cap_; } vector<KVOAggregator::Record, std::__1::allocator<KVOAggregator::Record> >; typedef struct KVOAggregator { vector<KVOAggregator::Record, std::__1::allocator<KVOAggregator::Record> > mRecords; } KVOAggregator; typedef struct _compressed_pair<CADeprecated::CAMutex *, std::__1::default_delete<CADeprecated::CAMutex> > { CAMutex __value_; } compressed_pair<CADeprecated::CAMutex *, std::__1::default_delete<CADeprecated::CAMutex> >; typedef struct unique_ptr<CADeprecated::CAMutex, std::__1::default_delete<CADeprecated::CAMutex> > { compressed_pair<CADeprecated::CAMutex *, std::__1::default_delete<CADeprecated::CAMutex> > __ptr_; } unique_ptr<CADeprecated::CAMutex, std::__1::default_delete<CADeprecated::CAMutex> >; typedef struct _compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::less<unsigned int>, true> > { unsigned long long __value_; } compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::less<unsigned int>, true> >; typedef struct _tree_end_node<std::__1::__tree_node_base<void *> *> { __tree_node_base<void *> __left_; } tree_end_node<std::__1::__tree_node_base<void *> *>; typedef struct _compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, void *> > > { tree_end_node<std::__1::__tree_node_base<void *> *> __value_; } compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, void *> > >; typedef struct _tree<std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, RemoteAUHandleInfo> > > { __tree_end_node<std::__1::__tree_node_base<void *> *> __begin_node_; compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, void *> > > __pair1_; compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::less<unsigned int>, true> > __pair3_; } tree<std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, RemoteAUHandleInfo> > >; typedef struct map<unsigned int, RemoteAUHandleInfo, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<const unsigned int, RemoteAUHandleInfo> > > { tree<std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, RemoteAUHandleInfo>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, RemoteAUHandleInfo> > > __tree_; } map<unsigned int, RemoteAUHandleInfo, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<const unsigned int, RemoteAUHandleInfo> > >; typedef struct _compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::less<unsigned int>, true> > { unsigned long long __value_; } compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::less<unsigned int>, true> >; typedef struct _compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, AUProcessingBlock>, void *> > > { tree_end_node<std::__1::__tree_node_base<void *> *> __value_; } compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, AUProcessingBlock>, void *> > >; typedef struct _tree<std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, AUProcessingBlock> > > { __tree_end_node<std::__1::__tree_node_base<void *> *> __begin_node_; compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, AUProcessingBlock>, void *> > > __pair1_; compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::less<unsigned int>, true> > __pair3_; } tree<std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, AUProcessingBlock> > >; typedef struct map<unsigned int, AUProcessingBlock, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<const unsigned int, AUProcessingBlock> > > { tree<std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, AUProcessingBlock>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, AUProcessingBlock> > > __tree_; } map<unsigned int, AUProcessingBlock, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<const unsigned int, AUProcessingBlock> > >; typedef struct _compressed_pair<TestAUProcessingBlock *, std::__1::default_delete<TestAUProcessingBlock> > { TestAUProcessingBlock __value_; } compressed_pair<TestAUProcessingBlock *, std::__1::default_delete<TestAUProcessingBlock> >; typedef struct unique_ptr<TestAUProcessingBlock, std::__1::default_delete<TestAUProcessingBlock> > { compressed_pair<TestAUProcessingBlock *, std::__1::default_delete<TestAUProcessingBlock> > __ptr_; } unique_ptr<TestAUProcessingBlock, std::__1::default_delete<TestAUProcessingBlock> >; typedef struct _NSZone* NSZoneRef; typedef struct OpaqueRemoteAudioUnit* OpaqueRemoteAudioUnitRef; typedef struct OpaqueAUPB* OpaqueAUPBRef; typedef struct opaque_pthread_mutex_t { long long __sig; char __opaque[56]; } opaque_pthread_mutex_t; typedef struct recursive_mutex { opaque_pthread_mutex_t __m_; } recursive_mutex; typedef struct OpaqueAudioComponentInstance* OpaqueAudioComponentInstanceRef; typedef struct mach_timebase_info { unsigned numer; unsigned denom; } mach_timebase_info; typedef struct mutex { opaque_pthread_mutex_t __m_; } mutex; typedef struct _compressed_pair<AUProcAndUserData *, std::__1::default_delete<AUProcAndUserData> > { AUProcAndUserData __value_; } compressed_pair<AUProcAndUserData *, std::__1::default_delete<AUProcAndUserData> >; typedef struct unique_ptr<AUProcAndUserData, std::__1::default_delete<AUProcAndUserData> > { compressed_pair<AUProcAndUserData *, std::__1::default_delete<AUProcAndUserData> > __ptr_; } unique_ptr<AUProcAndUserData, std::__1::default_delete<AUProcAndUserData> >; typedef struct _compressed_pair<AUAudioUnit_XPC_PropListener *, std::__1::allocator<AUAudioUnit_XPC_PropListener> > { AUAudioUnit_XPC_PropListener __value_; } compressed_pair<AUAudioUnit_XPC_PropListener *, std::__1::allocator<AUAudioUnit_XPC_PropListener> >; typedef struct vector<AUAudioUnit_XPC_PropListener, std::__1::allocator<AUAudioUnit_XPC_PropListener> > { AUAudioUnit_XPC_PropListener __begin_; AUAudioUnit_XPC_PropListener __end_; compressed_pair<AUAudioUnit_XPC_PropListener *, std::__1::allocator<AUAudioUnit_XPC_PropListener> > __end_cap_; } vector<AUAudioUnit_XPC_PropListener, std::__1::allocator<AUAudioUnit_XPC_PropListener> >; typedef struct shared_ptr<caulk::synchronized<auoop::RenderPipePool, std::__1::recursive_mutex, caulk::empty_atomic_interface<auoop::RenderPipePool> > > { synchronized<auoop::RenderPipePool, std::__1::recursive_mutex, caulk::empty_atomic_interface<auoop::RenderPipePool> > __ptr_; __shared_weak_count __cntrl_; } shared_ptr<caulk::synchronized<auoop::RenderPipePool, std::__1::recursive_mutex, caulk::empty_atomic_interface<auoop::RenderPipePool> > >; typedef struct AUOOPRenderClientUser { AUAudioUnit_XPC* au; NSXPCConnection* xpcConnection; /*^block*/id musicalContextBlock; /*^block*/id transportStateBlock; /*^block*/id MIDIOutputEventBlock; unsigned serviceProcessAUInstanceToken; BOOL isOffline; } AUOOPRenderClientUser; typedef struct _cxx_atomic_impl<bool, std::__1::__cxx_atomic_base_impl<bool> > { AB __a_value; } cxx_atomic_impl<bool, std::__1::__cxx_atomic_base_impl<bool> >; typedef struct atomic<bool> { cxx_atomic_impl<bool, std::__1::__cxx_atomic_base_impl<bool> > __a_; } atomic<bool>; typedef struct RenderPipeUser { PipeSubPool mPipeSubPool; AUOOPRenderClientUser mRenderClientUser; atomic<bool> mInvalidated; } RenderPipeUser; typedef struct optional<auoop::RenderPipeUser> { /*function pointer*/void* ; char __null_state_; RenderPipeUser) __val_; BOOL __engaged_; } optional<auoop::RenderPipeUser>; typedef struct shared_ptr<APComponent> { APComponent __ptr_; __shared_weak_count __cntrl_; } shared_ptr<APComponent>; typedef struct _compressed_pair<std::__1::shared_ptr<APComponent> *, std::__1::allocator<std::__1::shared_ptr<APComponent> > > { shared_ptr<APComponent> __value_; } compressed_pair<std::__1::shared_ptr<APComponent> *, std::__1::allocator<std::__1::shared_ptr<APComponent> > >; typedef struct AudioComponentVector { shared_ptr<APComponent> __begin_; shared_ptr<APComponent> __end_; compressed_pair<std::__1::shared_ptr<APComponent> *, std::__1::allocator<std::__1::shared_ptr<APComponent> > > __end_cap_; BOOL mSorted; } AudioComponentVector; typedef struct OpaqueAudioComponent* OpaqueAudioComponentRef; typedef struct semaphore { unsigned mMachSem; BOOL mOwned; } semaphore; typedef struct _cxx_atomic_impl<int, std::__1::__cxx_atomic_base_impl<int> > { Ai __a_value; } cxx_atomic_impl<int, std::__1::__cxx_atomic_base_impl<int> >; typedef struct RenderContextChangeGenerator { void mLastWorkgroup; /*^block*/id mObserver; } RenderContextChangeGenerator; typedef struct optional<RenderContextChangeGenerator> { /*function pointer*/void* ; char __null_state_; RenderContextChangeGenerator) __val_; BOOL __engaged_; } optional<RenderContextChangeGenerator>; typedef struct TAtomicStack<AURenderEventStruct> { AURenderEventStruct mHead; } TAtomicStack<AURenderEventStruct>; typedef struct AUEventSchedule { AURenderEventAllocator mAllocator; TAtomicStack<AURenderEventStruct> mAddedEventStack; (AURenderEvent) mScheduleHead; AUAudioUnit* mOwningAU; } AUEventSchedule; typedef struct NodeStack { Node mHead; } NodeStack; typedef struct TThreadSafeList<RenderObserver> { NodeStack mActiveList; NodeStack mPendingList; NodeStack mFreeList; } TThreadSafeList<RenderObserver>; typedef struct RenderObserverList { TThreadSafeList<RenderObserver> mObservers; BOOL mTouched; } RenderObserverList; typedef struct atomic<int> { cxx_atomic_impl<int, std::__1::__cxx_atomic_base_impl<int> > __a_; } atomic<int>; typedef struct semaphore_mutex_t<caulk::semaphore> { semaphore mSema; } semaphore_mutex_t<caulk::semaphore>; typedef struct RealtimeState { semaphore_mutex_t<caulk::semaphore> mRenderMutex; RenderObserverList renderObserverList; AUEventSchedule eventSchedule; optional<RenderContextChangeGenerator> contextChangeGenerator; } RealtimeState; typedef struct { unsigned long long field1; id field2; unsigned long long field3; unsigned long long field4[5]; } SCD_Struct_AU58; typedef struct _compressed_pair<BusPropertyObserver *, std::__1::allocator<BusPropertyObserver> > { BusPropertyObserver __value_; } compressed_pair<BusPropertyObserver *, std::__1::allocator<BusPropertyObserver> >; typedef struct vector<BusPropertyObserver, std::__1::allocator<BusPropertyObserver> > { BusPropertyObserver __begin_; BusPropertyObserver __end_; compressed_pair<BusPropertyObserver *, std::__1::allocator<BusPropertyObserver> > __end_cap_; } vector<BusPropertyObserver, std::__1::allocator<BusPropertyObserver> >; typedef struct shared_ptr<AUObserverController> { AUObserverController __ptr_; __shared_weak_count __cntrl_; } shared_ptr<AUObserverController>; typedef struct AURemoteParameterObserver* AURemoteParameterObserverRef; typedef struct _compressed_pair<AddressToParameter *, std::__1::allocator<AddressToParameter> > { AddressToParameter __value_; } compressed_pair<AddressToParameter *, std::__1::allocator<AddressToParameter> >; typedef struct vector<AddressToParameter, std::__1::allocator<AddressToParameter> > { AddressToParameter __begin_; AddressToParameter __end_; compressed_pair<AddressToParameter *, std::__1::allocator<AddressToParameter> > __end_cap_; } vector<AddressToParameter, std::__1::allocator<AddressToParameter> >; typedef struct OpaqueAUPBServer* OpaqueAUPBServerRef; typedef struct _compressed_pair<NSObject<OS_dispatch_semaphore> **, std::__1::allocator<NSObject<OS_dispatch_semaphore> *> > { id __value_; } compressed_pair<NSObject<OS_dispatch_semaphore> **, std::__1::allocator<NSObject<OS_dispatch_semaphore> *> >; typedef struct vector<NSObject<OS_dispatch_semaphore> *, std::__1::allocator<NSObject<OS_dispatch_semaphore> *> > { id __begin_; id __end_; compressed_pair<NSObject<OS_dispatch_semaphore> **, std::__1::allocator<NSObject<OS_dispatch_semaphore> *> > __end_cap_; } vector<NSObject<OS_dispatch_semaphore> *, std::__1::allocator<NSObject<OS_dispatch_semaphore> *> >; typedef struct _compressed_pair<PropertyListener *, std::__1::allocator<PropertyListener> > { PropertyListener __value_; } compressed_pair<PropertyListener *, std::__1::allocator<PropertyListener> >; typedef struct vector<PropertyListener, std::__1::allocator<PropertyListener> > { PropertyListener __begin_; PropertyListener __end_; compressed_pair<PropertyListener *, std::__1::allocator<PropertyListener> > __end_cap_; } vector<PropertyListener, std::__1::allocator<PropertyListener> >; typedef struct _compressed_pair<NewServerListener *, std::__1::allocator<NewServerListener> > { NewServerListener __value_; } compressed_pair<NewServerListener *, std::__1::allocator<NewServerListener> >; typedef struct vector<NewServerListener, std::__1::allocator<NewServerListener> > { NewServerListener __begin_; NewServerListener __end_; compressed_pair<NewServerListener *, std::__1::allocator<NewServerListener> > __end_cap_; } vector<NewServerListener, std::__1::allocator<NewServerListener> >; typedef struct AUListenerBase* AUListenerBaseRef; typedef struct _cxx_atomic_impl<unsigned long long, std::__1::__cxx_atomic_base_impl<unsigned long long> > { AQ __a_value; } cxx_atomic_impl<unsigned long long, std::__1::__cxx_atomic_base_impl<unsigned long long> >; typedef struct atomic<unsigned long long> { cxx_atomic_impl<unsigned long long, std::__1::__cxx_atomic_base_impl<unsigned long long> > __a_; } atomic<unsigned long long>; typedef struct _cxx_atomic_impl<unsigned int, std::__1::__cxx_atomic_base_impl<unsigned int> > { AI __a_value; } cxx_atomic_impl<unsigned int, std::__1::__cxx_atomic_base_impl<unsigned int> >; typedef struct atomic<unsigned int> { cxx_atomic_impl<unsigned int, std::__1::__cxx_atomic_base_impl<unsigned int> > __a_; } atomic<unsigned int>; typedef struct _compressed_pair<AUAudioUnitV2Bridge_Renderer *, std::__1::default_delete<AUAudioUnitV2Bridge_Renderer> > { AUAudioUnitV2Bridge_Renderer __value_; } compressed_pair<AUAudioUnitV2Bridge_Renderer *, std::__1::default_delete<AUAudioUnitV2Bridge_Renderer> >; typedef struct unique_ptr<AUAudioUnitV2Bridge_Renderer, std::__1::default_delete<AUAudioUnitV2Bridge_Renderer> > { compressed_pair<AUAudioUnitV2Bridge_Renderer *, std::__1::default_delete<AUAudioUnitV2Bridge_Renderer> > __ptr_; } unique_ptr<AUAudioUnitV2Bridge_Renderer, std::__1::default_delete<AUAudioUnitV2Bridge_Renderer> >; typedef struct _compressed_pair<unsigned long, std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > { unsigned long long __value_; } compressed_pair<unsigned long, std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> >; typedef struct _compressed_pair<unsigned long, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::hash<long>, true> > { unsigned long long __value_; } compressed_pair<unsigned long, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::hash<long>, true> >; typedef struct _compressed_pair<float, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::equal_to<long>, true> > { float __value_; } compressed_pair<float, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::equal_to<long>, true> >; typedef struct _hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> { __hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> __next_; } hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *>; typedef struct _compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *>, std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> > > { hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> __value_; } compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *>, std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> > >; typedef struct _bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > { compressed_pair<unsigned long, std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > __data_; } bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> >; typedef struct _compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> **, std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > > { __hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> __value_; bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > __value_; } compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> **, std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > >; typedef struct unique_ptr<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *[], std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > > { compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> **, std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > > __ptr_; } unique_ptr<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *[], std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > >; typedef struct _hash_table<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::hash<long>, true>, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::equal_to<long>, true>, std::__1::allocator<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)> > > { unique_ptr<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *[], std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *> *> > > __bucket_list_; compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> *>, std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, void *> > > __p1_; compressed_pair<unsigned long, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::hash<long>, true> > __p2_; compressed_pair<float, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::equal_to<long>, true> > __p3_; } hash_table<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::hash<long>, true>, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::equal_to<long>, true>, std::__1::allocator<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)> > >; typedef struct unordered_map<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long), std::__1::hash<long>, std::__1::equal_to<long>, std::__1::allocator<std::__1::pair<const long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)> > > { hash_table<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::hash<long>, true>, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)>, std::__1::equal_to<long>, true>, std::__1::allocator<std::__1::__hash_value_type<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)> > > __table_; } unordered_map<long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long), std::__1::hash<long>, std::__1::equal_to<long>, std::__1::allocator<std::__1::pair<const long, void ()(unsigned int, const AudioTimeStamp *, unsigned int, long)> > >; typedef struct __FSEventStream* FSEventStreamRef; typedef struct _value_func<void (AudioComponentVector &, AudioComponentVector &)> { type __buf_; __base<void (AudioComponentVector &, AudioComponentVector &)> __f_; } value_func<void (AudioComponentVector &, AudioComponentVector &)>; typedef struct function<void (AudioComponentVector &, AudioComponentVector &)> { value_func<void (AudioComponentVector &, AudioComponentVector &)> __f_; } function<void (AudioComponentVector &, AudioComponentVector &)>; typedef struct ConnectionInfo { NSXPCConnection* mConnection; int mExtUsePermission; BOOL mLinkedSDKRequiresEntitlement; } ConnectionInfo;
63.872197
598
0.777197
[ "vector" ]
6ac55143706362057d45b9abf16126cd0e2992da
9,105
h
C
tke/include/tencentcloud/tke/v20180525/model/ClusterLevelChangeRecord.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
1
2022-01-27T09:27:34.000Z
2022-01-27T09:27:34.000Z
tke/include/tencentcloud/tke/v20180525/model/ClusterLevelChangeRecord.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
null
null
null
tke/include/tencentcloud/tke/v20180525/model/ClusterLevelChangeRecord.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_TKE_V20180525_MODEL_CLUSTERLEVELCHANGERECORD_H_ #define TENCENTCLOUD_TKE_V20180525_MODEL_CLUSTERLEVELCHANGERECORD_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> #include <tencentcloud/core/AbstractModel.h> namespace TencentCloud { namespace Tke { namespace V20180525 { namespace Model { /** * Cluster model adjustment history */ class ClusterLevelChangeRecord : public AbstractModel { public: ClusterLevelChangeRecord(); ~ClusterLevelChangeRecord() = default; void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const; CoreInternalOutcome Deserialize(const rapidjson::Value &value); /** * 获取Record ID * @return ID Record ID */ std::string GetID() const; /** * 设置Record ID * @param ID Record ID */ void SetID(const std::string& _iD); /** * 判断参数 ID 是否已赋值 * @return ID 是否已赋值 */ bool IDHasBeenSet() const; /** * 获取Cluster ID * @return ClusterID Cluster ID */ std::string GetClusterID() const; /** * 设置Cluster ID * @param ClusterID Cluster ID */ void SetClusterID(const std::string& _clusterID); /** * 判断参数 ClusterID 是否已赋值 * @return ClusterID 是否已赋值 */ bool ClusterIDHasBeenSet() const; /** * 获取Status (valid values: `trading`, `upgrading`, `success`, `failed`) * @return Status Status (valid values: `trading`, `upgrading`, `success`, `failed`) */ std::string GetStatus() const; /** * 设置Status (valid values: `trading`, `upgrading`, `success`, `failed`) * @param Status Status (valid values: `trading`, `upgrading`, `success`, `failed`) */ void SetStatus(const std::string& _status); /** * 判断参数 Status 是否已赋值 * @return Status 是否已赋值 */ bool StatusHasBeenSet() const; /** * 获取Status description * @return Message Status description */ std::string GetMessage() const; /** * 设置Status description * @param Message Status description */ void SetMessage(const std::string& _message); /** * 判断参数 Message 是否已赋值 * @return Message 是否已赋值 */ bool MessageHasBeenSet() const; /** * 获取Original model * @return OldLevel Original model */ std::string GetOldLevel() const; /** * 设置Original model * @param OldLevel Original model */ void SetOldLevel(const std::string& _oldLevel); /** * 判断参数 OldLevel 是否已赋值 * @return OldLevel 是否已赋值 */ bool OldLevelHasBeenSet() const; /** * 获取New model * @return NewLevel New model */ std::string GetNewLevel() const; /** * 设置New model * @param NewLevel New model */ void SetNewLevel(const std::string& _newLevel); /** * 判断参数 NewLevel 是否已赋值 * @return NewLevel 是否已赋值 */ bool NewLevelHasBeenSet() const; /** * 获取Trigger type (valid values: `manual`, `auto`) * @return TriggerType Trigger type (valid values: `manual`, `auto`) */ std::string GetTriggerType() const; /** * 设置Trigger type (valid values: `manual`, `auto`) * @param TriggerType Trigger type (valid values: `manual`, `auto`) */ void SetTriggerType(const std::string& _triggerType); /** * 判断参数 TriggerType 是否已赋值 * @return TriggerType 是否已赋值 */ bool TriggerTypeHasBeenSet() const; /** * 获取Start time * @return StartedAt Start time */ std::string GetStartedAt() const; /** * 设置Start time * @param StartedAt Start time */ void SetStartedAt(const std::string& _startedAt); /** * 判断参数 StartedAt 是否已赋值 * @return StartedAt 是否已赋值 */ bool StartedAtHasBeenSet() const; /** * 获取End time * @return EndedAt End time */ std::string GetEndedAt() const; /** * 设置End time * @param EndedAt End time */ void SetEndedAt(const std::string& _endedAt); /** * 判断参数 EndedAt 是否已赋值 * @return EndedAt 是否已赋值 */ bool EndedAtHasBeenSet() const; private: /** * Record ID */ std::string m_iD; bool m_iDHasBeenSet; /** * Cluster ID */ std::string m_clusterID; bool m_clusterIDHasBeenSet; /** * Status (valid values: `trading`, `upgrading`, `success`, `failed`) */ std::string m_status; bool m_statusHasBeenSet; /** * Status description */ std::string m_message; bool m_messageHasBeenSet; /** * Original model */ std::string m_oldLevel; bool m_oldLevelHasBeenSet; /** * New model */ std::string m_newLevel; bool m_newLevelHasBeenSet; /** * Trigger type (valid values: `manual`, `auto`) */ std::string m_triggerType; bool m_triggerTypeHasBeenSet; /** * Start time */ std::string m_startedAt; bool m_startedAtHasBeenSet; /** * End time */ std::string m_endedAt; bool m_endedAtHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_TKE_V20180525_MODEL_CLUSTERLEVELCHANGERECORD_H_
33.229927
116
0.409336
[ "vector", "model" ]
6ac55210050640a9dfe7bd15c870a4e6e43c019d
19,279
c
C
robocape/src/math/discrete_siso_filter.c
gaomeitao/balance-gyrodometry-robot
f7039adc78fbf89442c1881f9d9d2c2b28bf4c76
[ "MIT" ]
1
2020-06-18T05:10:23.000Z
2020-06-18T05:10:23.000Z
robocape/src/math/discrete_siso_filter.c
AbdullahHamdanAldassoukii/autonomous-quadrotor-with-manipulator
fa719d7d49db1072883413316e0ce67fa0da450a
[ "MIT" ]
null
null
null
robocape/src/math/discrete_siso_filter.c
AbdullahHamdanAldassoukii/autonomous-quadrotor-with-manipulator
fa719d7d49db1072883413316e0ce67fa0da450a
[ "MIT" ]
2
2019-12-23T02:39:08.000Z
2020-08-03T06:20:41.000Z
/******************************************************************************* * discrete_siso_filter.c * James Strawson 2016 * * This is a collection of functions for generating and implementing discrete * SISO filters for arbitrary transfer functions. *******************************************************************************/ #include "../robocape.h" #include <stdio.h> #include <math.h> #include <string.h> // for memset /******************************************************************************* * d_filter_t create_filter(int order, float dt, float* num, float* den) * * Allocate memory for a filter of specified order & fill with transfer * function constants. Use enable_saturation immediately after this if you want * to enable automatic saturation. *******************************************************************************/ d_filter_t create_filter(int order, float dt, float* num, float* den){ d_filter_t filter; if(order<1){ printf("ERROR: order must be >=1\n"); return filter; } filter.order = order; filter.gain = 1; filter.newest_input = 0; filter.newest_output = 0; filter.saturation_en = 0; filter.saturation_min = 0; filter.saturation_max = 0; filter.saturation_flag = 0; filter.soft_start_en = 0; filter.soft_start_steps = 0; filter.numerator = create_vector_from_array(order+1, num); filter.denominator = create_vector_from_array(order+1, den); filter.in_buf = create_ring_buf(order+1); filter.out_buf = create_ring_buf(order+1); filter.initialized = 1; filter.step = 0; return filter; } /******************************************************************************* * int destroy_filter(d_filter_t* filter) * * free the memory allocated by the filter's buffers and coefficient vectors. *******************************************************************************/ int destroy_filter(d_filter_t* filter){ if(filter->initialized == 0) return -1; destroy_ring_buf(&(filter->in_buf)); destroy_ring_buf(&(filter->out_buf)); destroy_vector(&(filter->numerator)); destroy_vector(&(filter->denominator)); filter->initialized = 0; return 0; } /******************************************************************************* * d_filter_t create_empty_filter() * * Returns an empty d_filter_t struct initialized to 0 *******************************************************************************/ d_filter_t create_empty_filter(){ d_filter_t out; memset(&out,0,sizeof(d_filter_t)); return out; } /******************************************************************************* * float march_filter(d_filter_t* filter, float new_input) * * March the filter forward in time one step with new input data. * Returns new output which could also be accessed with filter.current_output * If saturation is enabled then the output will automatically be bound by the * min and max values given to enable_saturation. The enable_saturation entry * in the filter struct will also be set to 1 if saturation occurred. *******************************************************************************/ float march_filter(d_filter_t* filter, float new_input){ int i = 0; if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } insert_new_ring_buf_value(&filter->in_buf, new_input); filter->newest_input = new_input; // evaluate the difference equation float new_output = 0; float input_i, output_i; for(i=0; i<=(filter->order); i++){ input_i = get_ring_buf_value(&filter->in_buf,i); new_output += filter->gain * filter->numerator.data[i] * input_i; } for(i=1; i<=(filter->order); i++){ output_i = get_ring_buf_value(&filter->out_buf,i-1); new_output -= filter->denominator.data[i] * output_i; } // scale in case denominator doesn't have a leading 1 new_output = new_output/filter->denominator.data[0]; // soft start limits if(filter->soft_start_en && filter->step < filter->soft_start_steps){ float a=filter->saturation_max*(filter->step/filter->soft_start_steps); float b=filter->saturation_min*(filter->step/filter->soft_start_steps); if(new_output > a) new_output = a; if(new_output < b) new_output = b; } // saturate and set flag if(filter->saturation_en){ if(new_output > filter->saturation_max){ new_output = filter->saturation_max; filter->saturation_flag=1; } else if(new_output < filter->saturation_min){ new_output = filter->saturation_min; filter->saturation_flag=1; } else{ filter->saturation_flag=0; } } // record the output to filter struct and ring buffer filter->newest_output = new_output; insert_new_ring_buf_value(&filter->out_buf, new_output); // increment steps filter->step++; return new_output; } /******************************************************************************* * int reset_filter(d_filter_t* filter) * * resets all inputs and outputs to 0 *******************************************************************************/ int reset_filter(d_filter_t* filter){ reset_ring_buf(&filter->in_buf); reset_ring_buf(&filter->out_buf); filter->newest_input = 0; filter->newest_output = 0; filter->step = 0; return 0; } /******************************************************************************* * int enable_saturation(d_filter_t* filter, float sat_min, float sat_max) * * If saturation is enabled for a specified filter, the filter will automatically * bound the output between min and max. You may ignore this function if you wish * the filter to run unbounded. *******************************************************************************/ int enable_saturation(d_filter_t* filter, float min, float max){ if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } if(min>=max){ printf("ERORR: saturation max must be > min\n"); return -1; } filter->saturation_en = 1; filter->saturation_min = min; filter->saturation_max = max; return 0; } /******************************************************************************* * int enable_soft_start(d_filter_t* filter, float seconds) * * Enables soft start function where the output limit is gradually increased * for the given number of seconds up to the normal saturation value. Saturation * must already be enabled for this to work. *******************************************************************************/ int enable_soft_start(d_filter_t* filter, float seconds){ if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } if(filter->saturation_en != 1){ printf("ERROR: saturation must be enabled to use soft start.\n"); return -1; } filter->soft_start_en = 1; filter->soft_start_steps = seconds/filter->dt; return 0; } /******************************************************************************* * int did_filter_saturate(d_filter_t* filter) * * Returns 1 if the filter saturated the last time step. Returns 0 otherwise. *******************************************************************************/ int did_filter_saturate(d_filter_t* filter){ if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } return filter->saturation_flag; return 0; } /******************************************************************************* * float previous_filter_input(d_filter_t* filter, int steps) * * Returns the input 'steps' back in time. Steps = 0 returns most recent input. *******************************************************************************/ float previous_filter_input(d_filter_t* filter, int steps){ return get_ring_buf_value(&filter->in_buf, steps); } /******************************************************************************* * float previous_filter_output(d_filter_t* filter, int steps) * * Returns the output 'steps' back in time. Steps = 0 returns most recent output. *******************************************************************************/ float previous_filter_output(d_filter_t* filter, int steps){ return get_ring_buf_value(&filter->out_buf, steps); } /******************************************************************************* * float newest_filter_output(d_filter_t* filter) * * Returns the most recent output from the filter. Alternatively the user could * access the value from their d_filter_t_t struct with filter.newest_output *******************************************************************************/ float newest_filter_output(d_filter_t* filter){ return filter->newest_output; } /******************************************************************************* * float newest_filter_input(d_filter_t* filter) * * Returns the most recent input to the filter. Alternatively the user could * access the value from their d_filter_t_t struct with filter.newest_input *******************************************************************************/ float newest_filter_input(d_filter_t* filter){ return filter->newest_input; } /******************************************************************************* * prefill_filter_inputs(d_filter_t* filter, float in) * * fills all previous inputs to the filter as if they had been equal to 'in' * used when initializing filters to non-zero values *******************************************************************************/ int prefill_filter_inputs(d_filter_t* filter, float in){ int i; if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } for(i=0;i<filter->order;i++){ insert_new_ring_buf_value(&(filter->in_buf), in); } filter->newest_input = in; return 0; } /******************************************************************************* * prefill_filter_outputs(d_filter_t* filter, float out) * * fills all previous inputs to the filter as if they had been equal to 'in' * used when initializing filters to non-zero values *******************************************************************************/ int prefill_filter_outputs(d_filter_t* filter, float out){ int i; if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } for(i=0;i<filter->order;i++){ insert_new_ring_buf_value(&(filter->out_buf), out); } filter->newest_output = out; return 0; } /******************************************************************************* * int print_filter_details(d_filter_t* filter) * * Prints the order, numerator, and denominator coefficients for debugging. *******************************************************************************/ int print_filter_details(d_filter_t* filter){ int i; if(filter->initialized != 1){ printf("ERROR: filter not initialized yet\n"); return -1; } printf("\n"); printf("\nOrder: %d\n", filter->order); printf("num: "); for(i=0; i<=filter->order; i++){ printf("%0.3f ", filter->numerator.data[i]); } printf("\n "); for(i=0; i <= filter->order; i++){ printf("-------"); } printf("\nden: "); for(i=0; i <= filter->order; i++){ printf("%0.3f ", filter->denominator.data[i]); } printf("\n"); return 0; } /******************************************************************************* * d_filter_t multiply_filters(d_filter_t f1, d_filter_t f2) * * *******************************************************************************/ d_filter_t multiply_filters(d_filter_t f1, d_filter_t f2){ d_filter_t out = create_empty_filter(); if(f1.initialized!=1 || f2.initialized!=1){ printf("ERROR: filter not initialized\n"); return out; } if(f1.dt != f2.dt){ printf("ERROR: filter timestep dt must match when multiplying.\n"); return out; } // order of new system is sum of old orders int new_order = f1.order + f2.order; // multiply out the transfer function coefficients vector_t newnum = poly_conv(f1.numerator,f2.numerator); if(newnum.initialized != 1){ printf("ERROR:failed to multiply numerator polynomials\n"); return out; } vector_t newden = poly_conv(f1.denominator,f2.denominator); if(newden.initialized != 1){ printf("ERROR:failed to multiply denominator polynomials\n"); return out; } out = create_filter(new_order, f1.dt, &newnum.data[0], &newden.data[0]); out.gain = f1.gain * f2.gain; destroy_vector(&newden); destroy_vector(&newnum); return out; } /******************************************************************************* * d_filter_t C2DTustin(vector_t num, vector_t den, float dt, float w) * * Creates a discrete time filter with similar dynamics to a provided continuous * time transfer function using tustin's approximation with prewarping. * * arguments: * vector_t num: continuous time numerator coefficients * vector_t den: continuous time denominator coefficients * float dt: desired timestep of discrete filter * float w: prewarping frequency in rad/s *******************************************************************************/ d_filter_t C2DTustin(vector_t num, vector_t den, float dt, float w){ int i,j; d_filter_t out = create_empty_filter(); if(!num.initialized || !den.initialized){ printf("ERROR: vector not initialized yet\n"); return out; } float f = 2*(1 - cos(w*dt)) / (w*dt*sin(w*dt)); float c = 2/(f*dt); int m = num.len - 1; // highest order of num int n = den.len - 1; // highest order of den float A0; vector_t numZ = create_vector(n+1); // make vectors with den order +1 vector_t denZ = create_vector(n+1); vector_t p1 = create_vector(2); // (z - 1) p1.data[0] = 1; p1.data[1] = -1; vector_t p2 = create_vector(2); // (z + 1) p2.data[0] = 1; p2.data[1] = 1; vector_t temp, v1, v2; // from zeroth up to and including mth for(i=0;i<=m;i++){ v1 = poly_power(p1,m-i); v2 = poly_power(p2,n-m+i); temp = poly_conv(v1,v2); destroy_vector(&v1); destroy_vector(&v2); for(j=0;j<n+1;j++){ numZ.data[j] += num.data[i]*pow(c,m-i)*temp.data[j]; } destroy_vector(&temp); } for(i=0;i<=n;i++){ v1 = poly_power(p1,n-i); v2 = poly_power(p2,i); temp = poly_conv(v1,v2); destroy_vector(&v1); destroy_vector(&v2); for(j=0;j<n+1;j++){ denZ.data[j] += den.data[i]*pow(c,n-i)*temp.data[j]; } destroy_vector(&temp); } A0 = denZ.data[0]; for(i=0;i<n+1;i++){ numZ.data[i] = numZ.data[i]/A0; denZ.data[i] = denZ.data[i]/A0; } out = create_filter(n,dt,numZ.data,denZ.data); destroy_vector(&numZ); destroy_vector(&denZ); destroy_vector(&p1); destroy_vector(&p2); return out; } /******************************************************************************* * d_filter_t create_first_order_lowpass(float dt, float time_constant) * * Returns a configured and ready to use d_filter_t_t struct with a first order * low pass transfer function. dt is in units of seconds and time_constant is * the number of seconds it takes to rise to 63.4% of a steady-state input. *******************************************************************************/ d_filter_t create_first_order_lowpass(float dt, float time_constant){ float lp_const = dt/time_constant; float numerator[] = {lp_const, 0}; float denominator[] = {1, lp_const-1}; return create_filter(1,dt,numerator,denominator); } /******************************************************************************* * d_filter_t create_first_order_highpass(float dt, float time_constant) * * Returns a configured and ready to use d_filter_t_t struct with a first order * high pass transfer function. dt is in units of seconds and time_constant is * the number of seconds it takes to decay by 63.4% of a steady-state input. *******************************************************************************/ d_filter_t create_first_order_highpass(float dt, float time_constant){ float hp_const = dt/time_constant; float numerator[] = {1-hp_const, hp_const-1}; float denominator[] = {1,hp_const-1}; return create_filter(1,dt,numerator,denominator); } /******************************************************************************* * d_filter_t create_butterworth_lowpass(int order, float dt, float wc) * * Returns a configured and ready to use d_filter_t_t struct with the transfer * function for Butterworth low pass filter of order N and cutoff wc. *******************************************************************************/ d_filter_t create_butterworth_lowpass(int order, float dt, float wc){ vector_t A = poly_butter(order,wc); vector_t B = create_vector(1); B.data[0] = 1; return C2DTustin(B, A, dt, wc); } /******************************************************************************* * d_filter_t create_butterworth_highpass(int order, float dt, float wc) * * Returns a configured and ready to use d_filter_t_t struct with the transfer * function for Butterworth low pass filter of order N and cutoff wc. *******************************************************************************/ d_filter_t create_butterworth_highpass(int order, float dt, float wc){ vector_t A = poly_butter(order,wc); vector_t B = create_vector(order + 1); B.data[0] = 1; return C2DTustin(B, A, dt, wc); } /******************************************************************************* * d_filter_t create_integrator(float dt) * * Returns a configured and ready to use d_filter_t_t struct with the transfer * function for a first order time integral. *******************************************************************************/ d_filter_t create_integrator(float dt){ float numerator[] = {0, dt}; float denominator[] = {1, -1}; return create_filter(1,dt,numerator,denominator); } /******************************************************************************* * d_filter_t create_double_integrator(float dt) * * Returns a configured and ready to use d_filter_t_t struct with the transfer * function for a first order time integral. *******************************************************************************/ d_filter_t create_double_integrator(float dt){ float numerator[] = {0, 0, dt*dt}; float denominator[] = {1, -2, 1}; return create_filter(2,dt,numerator,denominator); } /******************************************************************************* * d_filter_t create_pid(float kp, float ki, float kd, float Tf, float dt) * * discrete-time implementation of a parallel PID controller with rolloff. * This is equivalent to the Matlab function: C = pid(Kp,Ki,Kd,Tf,Ts) * * We cannot implement a pure differentiator with a discrete transfer function * so this filter has high frequency rolloff with time constant Tf. Smaller Tf * results in less rolloff, but Tf must be greater than dt/2 for stability. *******************************************************************************/ d_filter_t create_pid(float kp, float ki, float kd, float Tf, float dt){ if(Tf <= dt/2){ printf("WARNING: Tf must be > dt/2 for stability\n"); Tf=dt; // set to reasonable value } // if ki==0, return a PD filter with rolloff if(ki==0){ float numerator[] = {(kp*Tf+kd)/Tf, -(((ki*dt-kp)*(dt-Tf))+kd)/Tf}; float denominator[] = {1, -(Tf-dt)/Tf}; return create_filter(1,dt,numerator,denominator); } //otherwise PID with roll off else{ float numerator[] = {(kp*Tf+kd)/Tf, (ki*dt*Tf + kp*(dt-Tf) - kp*Tf - 2.0*kd)/Tf, (((ki*dt-kp)*(dt-Tf))+kd)/Tf}; float denominator[] = {1, (dt-(2.0*Tf))/Tf, (Tf-dt)/Tf}; return create_filter(2,dt,numerator,denominator); } }
35.309524
80
0.568131
[ "vector" ]
6ac83a8d71c4a079a0bf9d3abef0167c68b5f674
1,646
c
C
nitan/inherit/banghui/res_depot.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/inherit/banghui/res_depot.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/inherit/banghui/res_depot.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// res_ku.c // 原料倉庫 // by Find. #define MAX_AMOUNT_PER_RES_IN_DEPOT 1000000000 /* protected int depot_number = 1; protected mixed *all_depots = ({}); */ protected mapping res_depot = ([]); protected int do_save_res_to_depot(string, int); /* protected void add_depot_number() { if(depot_number <= 0) depot_number = 1; depot_number++; } */ int save_res_to_depot(object ob) { string res; int n; if(!objectp(ob) || !ob->is_iron_class_res() || !(res = ob->query_mine_class()) || !MINE_D->is_valid_mclass(res)) return 0; if(!n = ob->query_sum()) { n = ob->query_weight()/100; if(!n) return 0; } return (do_save_res_to_depot(res, n) > 0); } protected int do_save_res_to_depot(string res, int num) { string up_res; int ps, up_num; if(!intp(num) || (num <= 0) || !MINE_D->is_valid_mclass(res)) return 0; if(!mapp(res_depot)) res_depot = ([]); if(!undefinedp(res_depot[res])) { if(res_depot[res] >= MAX_AMOUNT_PER_RES_IN_DEPOT) return 0; ps = num + res_depot[res]; } else ps = num; if(ps > MAX_AMOUNT_PER_RES_IN_DEPOT) return 0; if( (up_res = MINE_D->query_mine_class_up_class(res)) && (ps >= (up_num = MINE_D->query_mine_class_up_quantity(res))) ) { int rnt; if( (rnt = do_save_res_to_depot(up_res, ps/up_num)) == 1 ) { if(!(ps %= up_num)) return 1; } else if(rnt < 0) ps = abs(rnt)*up_num + ps%100; } if(undefinedp(res_depot[res])) res_depot += ([ res : ps ]); else { if(ps > MAX_AMOUNT_PER_RES_IN_DEPOT) { res_depot[res] = MAX_AMOUNT_PER_RES_IN_DEPOT; return -(ps - MAX_AMOUNT_PER_RES_IN_DEPOT); } else res_depot[res] = ps; } return 1; }
16.46
66
0.647023
[ "object" ]
6acae2727ceb5a0ddd8b5ebe3fbe4de5c73c3205
4,957
h
C
Src/Projects/manager_PostProcessing/postprocessing_manager.h
Mikkelbf/OpenMoBu
c57c41a0908ad7734d48642549758271d11263b8
[ "BSD-3-Clause" ]
53
2018-04-21T14:16:46.000Z
2022-03-19T11:27:37.000Z
Src/Projects/manager_PostProcessing/postprocessing_manager.h
Mikkelbf/OpenMoBu
c57c41a0908ad7734d48642549758271d11263b8
[ "BSD-3-Clause" ]
6
2019-06-05T16:37:29.000Z
2021-09-20T07:17:03.000Z
Src/Projects/manager_PostProcessing/postprocessing_manager.h
Mikkelbf/OpenMoBu
c57c41a0908ad7734d48642549758271d11263b8
[ "BSD-3-Clause" ]
10
2019-02-22T18:43:59.000Z
2021-09-02T18:53:37.000Z
#ifndef _POST_PROCESSING_MANAGER_H__ #define _POST_PROCESSING_MANAGER_H__ /** \file postprocessing_manager.h Sergei <Neill3d> Solokhin 2018 GitHub page - https://github.com/Neill3d/OpenMoBu Licensed under The "New" BSD License - https://github.com/Neill3d/OpenMoBu/blob/master/LICENSE */ //--- SDK include #include <fbsdk/fbsdk.h> #include "GL/glew.h" #include "graphics_framebuffer.h" #include "postprocessing_data.h" #include "glslShader.h" #include "Framebuffer.h" //#include "WGLFONT.h" #include "postprocessing_fonts.h" #include "postprocessing_effectChain.h" //--- Registration defines #define POSTPROCESSING_MANAGER__CLASSNAME Manager_PostProcessing #define POSTPROCESSING_MANAGER__CLASSSTR "Manager_PostProcessing" // number of entering in render callback #define MAX_ATTACH_STACK 10 // class Socket; //////////////////////////////////////////////////////////////////////////////////////// /** Post Processing Manager. */ class Manager_PostProcessing : public FBCustomManager { //--- FiLMBOX box declaration. FBCustomManagerDeclare(Manager_PostProcessing); public: virtual bool FBCreate(); //!< FiLMBOX creation function. virtual void FBDestroy(); //!< FiLMBOX destruction function. virtual bool Init(); virtual bool Open(); virtual bool Clear(); virtual bool Close(); public: // CALLBACKS void EventSceneChange(HISender pSender, HKEvent pEvent); void EventFileNew(HISender pSender, HKEvent pEvent); void EventFileOpen(HISender pSender, HKEvent pEvent); void EventFileMerge(HISender pSender, HKEvent pEvent); void EventFileOpenComplete(HISender pSender, HKEvent pEvent); void OnPerFrameSynchronizationCallback(HISender pSender, HKEvent pEvent); void OnPerFrameRenderingPipelineCallback(HISender pSender, HKEvent pEvent); void OnPerFrameEvaluationPipelineCallback(HISender pSender, HKEvent pEvent); void EventConnNotify(HISender pSender, HKEvent pEvent); void EventConnDataNotify(HISender pSender, HKEvent pEvent); void OnUIIdle(HISender pSender, HKEvent pEvent); void OnVideoFrameRendering(HISender pSender, HKEvent pEvent); private: bool mFirstRun; FBApplication mApplication; FBSystem mSystem; //FBEvaluateManager mEvalManager; //bool mSettingsMerge; //HdlFBPlugTemplate<PostPersistentData> mSettings; //HdlFBPlugTemplate<FBCamera> mCamera; bool mDoVideoClipTimewrap; // //HGLRC mCurrentContext; bool mSchematicView[4]; bool mVideoRendering; int mViewport[4]; // x, y, width, height //int mLastPostPane; int mViewerViewport[4]; //int mLocalViewport[4]; // local used for chain post-processing // MainFrameBuffer mMainFrameBuffer; std::unique_ptr<GLSLShader> mShaderSimple; // for simple blit quads on a screen PostEffectChain mEffectChain; std::vector<PostPersistentData*> mPaneSettings; // choose a propriate settings according to a pane camera // if each pane has different size (in practice should be not more then 2 PostEffectBuffers mEffectBuffers0; PostEffectBuffers mEffectBuffers1; PostEffectBuffers mEffectBuffers2; PostEffectBuffers mEffectBuffers3; #if defined(HUD_FONT) std::vector<CFont*> mElemFonts; #endif std::vector<FBHUDRectElement*> mRectElements; std::vector<FBHUDTextElement*> mTextElements; // Tango device experiment double mLastSendTimeSecs; void *mSocketSender; void *mSocketRecv; bool mIsSynced; FBTime mLastSyncTime; FBTime mSyncDuration; #if BROADCAST_PREVIEW == 1 bool mSendPreview; int mSocketPort; Network::Address mSendAddress; unsigned char mSendBuffer[MAX_UDP_BUFFER_SIZE]; #endif // int mLastPaneCount; //int mPaneId; int mEnterId; size_t mFrameId; GLint mAttachedFBO[MAX_ATTACH_STACK]; void CheckForAContextChange(); bool PrepPaneSettings(); // manager shaders bool LoadShaders(); const bool CheckShadersPath(const char* path) const; void FreeShaders(); void FreeBuffers(); bool EmptyGLErrorStack(); /* bool OpenSocket(const int portSend, const int portRecv, bool blocking); void CloseSocket(); void SendPreview(PostEffectBuffers *buffers); */ void LoadConfig(); void PushUpperLowerClipForEffects(); void PopUpperLowerClipForEffects(); public: bool mLastProcessCompositions; void PreRenderFirstEntry(); void RenderBeforeRender(const bool processCompositions, const bool renderToBuffer); bool RenderAfterRender(const bool processCompositions, const bool renderToBuffer); void DrawHUD(int panex, int paney, int panew, int paneh, int vieww, int viewh); void DrawHUDRect(FBHUDRectElement *pElem, int panex, int paney, int panew, int paneh, int vieww, int viewh); #if defined(HUD_FONT) void DrawHUDText(FBHUDTextElement *pElem, CFont *pFont, int panex, int paney, int panew, int paneh, int vieww, int viewh); #endif void FreeFonts(); void PrepVideoClipsTimeWrap(); }; #endif /* _POST_PROCESSING_MANAGER_H__ */
25.551546
123
0.746016
[ "render", "vector" ]
6ad8ba56815f874fd943a7078d489c45b9d231ea
487
h
C
Direct3D_11/Sunrin_Engine_D3D11/Example/ColorEntity.h
shh1473/Sunrin_Engine_2019
1782d10a397055f8a64f3b772b342438ede02b36
[ "MIT" ]
null
null
null
Direct3D_11/Sunrin_Engine_D3D11/Example/ColorEntity.h
shh1473/Sunrin_Engine_2019
1782d10a397055f8a64f3b772b342438ede02b36
[ "MIT" ]
null
null
null
Direct3D_11/Sunrin_Engine_D3D11/Example/ColorEntity.h
shh1473/Sunrin_Engine_2019
1782d10a397055f8a64f3b772b342438ede02b36
[ "MIT" ]
null
null
null
#pragma once #include "ColorPass.h" namespace Example { class ColorEntity : public SR_Entity { public: explicit ColorEntity(SR_GameScene * gameScene, const std::wstring & name); bool Initialize( SR_Mesh * mesh, SR_VertexShader * vertexShader, SR_PixelShader * pixelShader, ID3D11Buffer * vs_matrixBuffer); private: SR_ForwardRenderer * m_colorRenderer; std::unique_ptr<SR_RenderTechnique> m_renderTechnique; std::unique_ptr<ColorPass> m_colorPass; }; }
18.037037
76
0.747433
[ "mesh" ]
b9e87dd519022a26c0ee263e315c20eb0235372e
1,283
h
C
src/common.h
FedorSymkin/VirtualLedCtl
765f7d87a5bb847c6757864c0f433abba982bc6f
[ "BSD-2-Clause" ]
null
null
null
src/common.h
FedorSymkin/VirtualLedCtl
765f7d87a5bb847c6757864c0f433abba982bc6f
[ "BSD-2-Clause" ]
null
null
null
src/common.h
FedorSymkin/VirtualLedCtl
765f7d87a5bb847c6757864c0f433abba982bc6f
[ "BSD-2-Clause" ]
null
null
null
#ifndef COMMON_H_ #define COMMON_H_ #include <pthread.h> #include <time.h> #include <vector> #include <string> /* *I use my own classes for Mutex/Lock/Thread for independence from any libs and C++11 *In real project I'd use C++11 or boost */ class MyMutex { pthread_mutex_t m; public: MyMutex() { pthread_mutex_init(&m, NULL); } ~MyMutex() { pthread_mutex_destroy(&m); } void lock() { pthread_mutex_lock(&m); } void unlock() { pthread_mutex_unlock(&m); } friend class MyCond; }; class MyLock { MyMutex *m; public: MyLock(MyMutex &mutex) { m = &mutex; m->lock(); } ~MyLock() { m->unlock(); } }; class MyCond { pthread_cond_t c; public: MyCond() { pthread_cond_init(&c, NULL); } ~MyCond() { pthread_cond_destroy(&c); } void signal() { pthread_cond_signal(&c); } void wait(MyMutex &mtx) { pthread_cond_wait(&c, &mtx.m); } void timedwait(MyMutex &mtx, timespec until) { pthread_cond_timedwait(&c, &mtx.m, &until); } }; enum LedColor { LED_RED = 0, LED_GREEN, LED_BLUE, LED_UNKNOWN }; std::string ColorToStr(LedColor color); LedColor StrToColor(std::string str); bool IsCorrectRate(int rate); void split(const std::string &str, std::vector<std::string> &tokens); long elapsed_ms(timespec &ts); #endif
18.594203
85
0.66251
[ "vector" ]
b9eb44a6494dcdc3faaf658e7d44f1c589995af0
17,460
h
C
modules/recognition/include/v4r/recognition/ghv_opt.h
byiii/clone_v4r_j
628359c7ba19389004618defd6a8d8ab5af35967
[ "MIT" ]
null
null
null
modules/recognition/include/v4r/recognition/ghv_opt.h
byiii/clone_v4r_j
628359c7ba19389004618defd6a8d8ab5af35967
[ "MIT" ]
null
null
null
modules/recognition/include/v4r/recognition/ghv_opt.h
byiii/clone_v4r_j
628359c7ba19389004618defd6a8d8ab5af35967
[ "MIT" ]
null
null
null
/* * hv_go_opt.h * * Created on: Feb 27, 2013 * Author: aitor */ #ifndef FAAT_PCL_GHV_OPT_H_ #define FAAT_PCL_GHV_OPT_H_ #include <pcl/pcl_macros.h> #include <pcl/common/common.h> #include <boost/random/variate_generator.hpp> #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_int.hpp> #include <boost/random/variate_generator.hpp> //#include "pcl/recognition/3rdparty/metslib/mets.hh" #include <metslib/mets.hh> #include <boost/graph/graph_traits.hpp> #include <boost/graph/adjacency_list.hpp> #include <map> #include <iostream> #include <fstream> #include <v4r/core/macros.h> namespace v4r { //Helper classes template<typename ModelT> struct V4R_EXPORTS GHVRecognitionModel { public: std::vector<int> explained_; /// @brief explained scene points by_RM_ std::vector<float> explained_distances_; /// @brief closest distances to the scene for point i std::vector<int> unexplained_in_neighborhood; /// @brief indices vector referencing unexplained_by_RM_neighboorhods std::vector<float> unexplained_in_neighborhood_weights; /// @brief weights for the points not being explained in the neighborhood of a hypothesis std::vector<int> outlier_indices_; /// @brief outlier indices of this model (coming from all types) std::vector<int> color_outliers_indices_; /// @brief all model points that have a scene point nearby but whose color does not match std::vector<int> outliers_3d_indices_; /// @brief all model points that do not have a scene point nearby std::vector<int> complete_cloud_occupancy_indices_; std::vector<bool> scene_point_explained_by_hypothesis_; /// @brief boolean vector indicating if a scene point is explained by this model or not typename pcl::PointCloud<ModelT>::Ptr visible_cloud_; typename pcl::PointCloud<ModelT>::Ptr complete_cloud_; typename pcl::PointCloud<pcl::Normal>::Ptr complete_cloud_normals_; float bad_information_; float outliers_weight_; pcl::PointCloud<pcl::Normal>::Ptr normals_; pcl::PointCloud<pcl::Normal>::Ptr normals_from_visible_; size_t id_; float extra_weight_; /// @brief descriptor distance weight for instance float color_similarity_; float median_; float mean_; Eigen::MatrixXf color_mapping_; float hyp_penalty_; std::string id_s_; std::vector<Eigen::Vector3f> cloud_LAB_; std::vector<Eigen::Vector3f> cloud_LAB_original_; std::vector<Eigen::Vector3f> cloud_RGB_; std::vector<float> cloud_GS_; /// @brief Grayscale cloud float min_contribution_; /// @brief based on the amount of explained points and the amount of information in the hypotheses std::vector<float> normal_angle_histogram_; std::vector<float> color_diff_histogram_; float normal_entropy_; float color_entropy_; std::vector<int> cloud_indices_specified_; float color_diff_trhough_specification_; pcl::PointCloud<pcl::PointXYZL>::Ptr visible_labels_; //inlier indices and distances for cloud_ (this avoids recomputing radius searches twice (one for specification and one for inlier/outlier detection) std::vector<std::vector<int> > inlier_indices_; std::vector<std::vector<float> > inlier_distances_; }; template<typename ModelT, typename SceneT> class V4R_EXPORTS GHV; template<typename ModelT, typename SceneT> class V4R_EXPORTS GHVSAModel : public mets::evaluable_solution { typedef GHV<ModelT, SceneT> SAOptimizerT; public: std::vector<bool> solution_; SAOptimizerT * opt_; mets::gol_type cost_; //Evaluates the current solution mets::gol_type cost_function () const { return cost_; } void copy_from (const mets::copyable& o) { const GHVSAModel& s = dynamic_cast<const GHVSAModel&> (o); solution_ = s.solution_; opt_ = s.opt_; cost_ = s.cost_; } void copy_from (const mets::feasible_solution& o) { const GHVSAModel& s = dynamic_cast<const GHVSAModel&> (o); solution_ = s.solution_; opt_ = s.opt_; cost_ = s.cost_; } mets::gol_type what_if (int /*index*/, bool /*val*/) const { return static_cast<mets::gol_type> (0); } mets::gol_type apply_and_evaluate (int index, bool val) { solution_[index] = val; mets::gol_type sol = opt_->evaluateSolution (solution_, index); //this will update the state of the solution cost_ = sol; return sol; } void apply (int /*index*/, bool /*val*/) { } void unapply (int index, bool val) { solution_[index] = val; //update optimizer solution cost_ = opt_->evaluateSolution (solution_, index); //this will udpate the cost function in opt_ } void setSolution (const std::vector<bool> & sol) { solution_ = sol; } void setOptimizer (SAOptimizerT *opt) { opt_ = opt; } }; /** * @brief Represents a generic move from which all move types should inherit */ class V4R_EXPORTS GHVgeneric_move : public mets::mana_move { public: virtual mets::gol_type evaluate (const mets::feasible_solution& cs) const = 0; virtual mets::gol_type apply_and_evaluate (mets::feasible_solution& cs) = 0; virtual void apply (mets::feasible_solution& s) const = 0; virtual void unapply (mets::feasible_solution& s) const = 0; virtual mets::clonable* clone () const = 0; virtual size_t hash () const = 0; virtual bool operator== (const mets::mana_move&) const = 0; }; /** * @brief Represents a move that deactivates an active hypothesis replacing it by an inactive one * Such moves should be done when the temperature is low * It is based on the intersection of explained points between hypothesis */ template<typename ModelT, typename SceneT> class V4R_EXPORTS GHVreplace_hyp_move : public GHVgeneric_move { int i_, j_; //i_ is an active hypothesis, j_ is an inactive hypothesis int sol_size_; public: GHVreplace_hyp_move (int i, int j, int sol_size) : i_ (i), j_ (j), sol_size_ (sol_size) { } mets::gol_type evaluate (const mets::feasible_solution& cs) const { GHVSAModel<ModelT, SceneT> model; model.copy_from (cs); model.apply_and_evaluate (i_, !model.solution_[i_]); mets::gol_type cost = model.apply_and_evaluate (j_, !model.solution_[j_]); //unapply moves now model.unapply (j_, !model.solution_[j_]); model.unapply (i_, !model.solution_[i_]); return cost; } mets::gol_type apply_and_evaluate (mets::feasible_solution& cs) { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (cs); assert (model.solution_[i_]); model.apply_and_evaluate (i_, !model.solution_[i_]); assert (!model.solution_[j_]); return model.apply_and_evaluate (j_, !model.solution_[j_]); } void apply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.apply_and_evaluate (i_, !model.solution_[i_]); model.apply_and_evaluate (j_, !model.solution_[j_]); } void unapply (mets::feasible_solution& s) const { //go back GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.unapply (j_, !model.solution_[j_]); model.unapply (i_, !model.solution_[i_]); } mets::clonable* clone () const { GHVreplace_hyp_move * m = new GHVreplace_hyp_move (i_, j_, sol_size_); return static_cast<mets::clonable*> (m); } size_t hash () const; /*{ return static_cast<size_t> (sol_size_ + sol_size_ * i_ + j_); }*/ bool operator== (const mets::mana_move& m) const; /*{ const replace_hyp_move& mm = dynamic_cast<const replace_hyp_move&> (m); return (mm.i_ == i_) && (mm.j_ == j_); }*/ }; /** * @brief Represents a move, activate/deactivate an hypothesis */ template<typename ModelT, typename SceneT> class GHVmove : public GHVgeneric_move { int index_; public: GHVmove (int i) : index_ (i) { } int getIndex () { return index_; } mets::gol_type evaluate (const mets::feasible_solution& cs) const { //mets::copyable copyable = dynamic_cast<mets::copyable> (&cs); GHVSAModel<ModelT, SceneT> model; model.copy_from (cs); mets::gol_type cost = model.apply_and_evaluate (index_, !model.solution_[index_]); model.apply_and_evaluate (index_, !model.solution_[index_]); return cost; } mets::gol_type apply_and_evaluate (mets::feasible_solution& cs) { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (cs); return model.apply_and_evaluate (index_, !model.solution_[index_]); } void apply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.apply_and_evaluate (index_, !model.solution_[index_]); } void unapply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.unapply (index_, !model.solution_[index_]); } mets::clonable* clone () const { GHVmove * m = new GHVmove (index_); return static_cast<mets::clonable*> (m); } size_t hash () const; bool operator== (const mets::mana_move& m) const; }; template<typename ModelT, typename SceneT> class V4R_EXPORTS GHVmove_activate : public GHVgeneric_move { int index_; public: GHVmove_activate (int i) : index_ (i) { } int getIndex () { return index_; } mets::gol_type evaluate (const mets::feasible_solution& cs) const { //mets::copyable copyable = dynamic_cast<mets::copyable> (&cs); GHVSAModel<ModelT, SceneT> model; model.copy_from (cs); mets::gol_type cost = model.apply_and_evaluate (index_, true); model.apply_and_evaluate (index_, false); return cost; } mets::gol_type apply_and_evaluate (mets::feasible_solution& cs) { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (cs); return model.apply_and_evaluate (index_, true); } void apply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.apply_and_evaluate (index_, true); } void unapply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.unapply (index_, false); } mets::clonable* clone () const { GHVmove_activate * m = new GHVmove_activate (index_); return static_cast<mets::clonable*> (m); } size_t hash () const; bool operator== (const mets::mana_move& m) const; }; template<typename ModelT, typename SceneT> class GHVmove_deactivate : public GHVgeneric_move { int index_; int problem_size_; public: GHVmove_deactivate (int i, int problem_size) : index_ (i), problem_size_(problem_size) { } int getIndex () { return index_; } mets::gol_type evaluate (const mets::feasible_solution& cs) const { //mets::copyable copyable = dynamic_cast<mets::copyable> (&cs); GHVSAModel<ModelT, SceneT> model; model.copy_from (cs); mets::gol_type cost = model.apply_and_evaluate (index_, false); model.apply_and_evaluate (index_, true); return cost; } mets::gol_type apply_and_evaluate (mets::feasible_solution& cs) { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (cs); return model.apply_and_evaluate (index_, false); } void apply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.apply_and_evaluate (index_, false); } void unapply (mets::feasible_solution& s) const { GHVSAModel<ModelT, SceneT>& model = dynamic_cast<GHVSAModel<ModelT, SceneT>&> (s); model.unapply (index_, true); } mets::clonable* clone () const { GHVmove_deactivate * m = new GHVmove_deactivate (index_, problem_size_); return static_cast<mets::clonable*> (m); } size_t hash () const; bool operator== (const mets::mana_move& m) const; }; template<typename ModelT, typename SceneT> class V4R_EXPORTS GHVmove_manager { bool use_replace_moves_; public: std::vector<GHVgeneric_move*> moves_m; boost::shared_ptr<std::map<std::pair<int, int>, bool> > intersections_; typedef typename std::vector<GHVgeneric_move*>::iterator iterator; int problem_size_; iterator begin () { return moves_m.begin (); } iterator end () { return moves_m.end (); } GHVmove_manager (int problem_size, bool rp_moves = true) { use_replace_moves_ = rp_moves; problem_size_ = problem_size; /*for (int ii = 0; ii != problem_size; ++ii) moves_m.push_back (new move<ModelT, SceneT> (ii));*/ } ~GHVmove_manager () { // delete all moves for (iterator ii = begin (); ii != end (); ++ii) delete (*ii); } void setExplainedPointIntersections (boost::shared_ptr<std::map<std::pair<int, int>, bool> > & intersections) { intersections_ = intersections; } void refresh (mets::feasible_solution& s); }; template<typename ModelT, typename SceneT> class V4R_EXPORTS GHVCostFunctionLogger : public mets::solution_recorder { std::vector<float> costs_; std::vector<float> costs_each_time_evaluated_; int times_evaluated_; boost::function<void (const std::vector<bool> &, float, int)> visualize_function_; public: GHVCostFunctionLogger (); GHVCostFunctionLogger (mets::evaluable_solution& best) : mets::solution_recorder (), best_ever_m (best) { times_evaluated_ = 0; costs_.resize (1); costs_[0] = 0.f; // costs_.resize (0); before merge it was like this ---> What is correct? } void setVisualizeFunction(boost::function<void (const std::vector<bool> &, float, int)> & f) { visualize_function_ = f; } void writeToLog (std::ofstream & of) { const GHVSAModel<ModelT, SceneT>& ss = static_cast<const GHVSAModel<ModelT, SceneT>&> (best_ever_m); of << times_evaluated_ << "\t\t"; of << costs_.size () << "\t\t"; of << costs_[costs_.size () - 1] << std::endl; } void writeEachCostToLog (std::ofstream & of) { for (size_t i = 0; i < costs_each_time_evaluated_.size (); i++) { of << costs_each_time_evaluated_[i] << "\t"; } of << std::endl; } void addCost (float c) { costs_.push_back (c); } void addCostEachTimeEvaluated (float c) { costs_each_time_evaluated_.push_back (c); } void increaseEvaluated () { times_evaluated_++; } int getTimesEvaluated () { return times_evaluated_; } size_t getAcceptedMovesSize () { return costs_.size (); } bool accept (const mets::feasible_solution& sol) { const mets::evaluable_solution& s = dynamic_cast<const mets::evaluable_solution&> (sol); if (s.cost_function () < best_ever_m.cost_function ()) { best_ever_m.copy_from (s); const GHVSAModel<ModelT, SceneT>& ss = static_cast<const GHVSAModel<ModelT, SceneT>&> (sol); costs_.push_back (ss.cost_); // std::cout << "Move accepted:" << ss.cost_ << std::endl; if(visualize_function_) visualize_function_(ss.solution_, ss.cost_, times_evaluated_); return true; } return false; } /// @brief Returns the best solution found since the beginning. const mets::evaluable_solution& best_seen () const { return best_ever_m; } mets::gol_type best_cost () const { return best_ever_m.cost_function (); } void setBestSolution (std::vector<bool> & sol) { GHVSAModel<ModelT, SceneT>& ss = static_cast<GHVSAModel<ModelT, SceneT>&> (best_ever_m); for (size_t i = 0; i < sol.size (); i++) { ss.solution_[i] = sol[i]; //std::cout << "setBestSolution" << ss.solution_[i] << " " << sol[i] << std::endl; } } protected: mets::evaluable_solution& best_ever_m; /// @brief Records the best solution }; } #endif /* FAAT_PCL_HV_GO_OPT_H_ */
28.390244
155
0.627721
[ "vector", "model" ]
b9edba2078309c5be4334fa789018d2ab95756a2
2,691
h
C
src/eos.modules/eosmodule.view/View.h
ultimoistante/eos-multimedia-scripting
8cbc98fd6a2d53cbb322156ea8e83883b4fda6bc
[ "MIT" ]
1
2015-05-04T21:12:58.000Z
2015-05-04T21:12:58.000Z
src/eos.modules/eosmodule.view/View.h
ultimoistante/eos-multimedia-scripting
8cbc98fd6a2d53cbb322156ea8e83883b4fda6bc
[ "MIT" ]
null
null
null
src/eos.modules/eosmodule.view/View.h
ultimoistante/eos-multimedia-scripting
8cbc98fd6a2d53cbb322156ea8e83883b4fda6bc
[ "MIT" ]
null
null
null
/* ----------------------------------------------------------------------------- This source file is part of EOS Multimedia Scripting System For the latest info, see https://github.com/ultimoistante/eos-multimedia-scripting The MIT License (MIT) Copyright (c) 2014-2019 of Salvatore Carotenuto aka ultimoistante of StartupSolutions (mailto: ultimoistante@gmail.com | www.startupsolutions.it) and Alessandro Rasulo (mailto: alex9978@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #ifndef VIEW_H #define VIEW_H #include <stdio.h> #include <map> #include <vector> #include <GLee.h> #include "EOSLuaRuntime.h" #include "ViewDefines.h" #include "ViewScreenInfo.h" #include "ViewWindow.h" #include "ViewSurface.h" class View { public: View(); virtual ~View(); static View* getInstance(); void shutdown(); uint getScreenCount(); bool getScreenInfo(uint num, ViewScreenInfo *si); ulong createWindow(uint display, uint width, uint height, uint bpp, uint antialiasing, bool fullscreen); bool updateWindow(ulong windowId); ViewWindow* getWindowFromId(ulong windowId); void setCurrentWindow(ulong windowId); ViewWindow* getCurrentWindow(); uint createSurface(); uint createSubSurface(); ViewSurface* getSurfaceFromId(uint surfaceId); private: static bool instanceFlag; static View* instance; ViewWindow *currentWindow; std::map<ulong, ViewWindow*> windows; std::vector<ViewSurface*> surfaces; }; #endif
34.5
112
0.680788
[ "vector" ]
b9f23bf47b356dc17d588f2070759b237d6ee163
79,340
c
C
decompiled_scripts/turret_cam_script.c
BitDEVil2K16-Club/GTA-V-Decompiled-Scripts
bcb95d3b95482713fe0ab389edb90aea3941affd
[ "Unlicense" ]
null
null
null
decompiled_scripts/turret_cam_script.c
BitDEVil2K16-Club/GTA-V-Decompiled-Scripts
bcb95d3b95482713fe0ab389edb90aea3941affd
[ "Unlicense" ]
null
null
null
decompiled_scripts/turret_cam_script.c
BitDEVil2K16-Club/GTA-V-Decompiled-Scripts
bcb95d3b95482713fe0ab389edb90aea3941affd
[ "Unlicense" ]
null
null
null
#region Local Var var uLocal_0 = 0; var uLocal_1 = 0; int iLocal_2 = 0; int iLocal_3 = 0; int iLocal_4 = 0; int iLocal_5 = 0; int iLocal_6 = 0; int iLocal_7 = 0; int iLocal_8 = 0; int iLocal_9 = 0; int iLocal_10 = 0; int iLocal_11 = 0; var uLocal_12 = 0; var uLocal_13 = 0; float fLocal_14 = 0f; var uLocal_15 = 0; var uLocal_16 = 0; int iLocal_17 = 0; var uLocal_18 = 0; var uLocal_19 = 0; char* sLocal_20 = NULL; var uLocal_21 = 0; var uLocal_22 = 0; float fLocal_23 = 0f; float fLocal_24 = 0f; float fLocal_25 = 0f; var uLocal_26 = 0; var uLocal_27 = 0; float fLocal_28 = 0f; var uLocal_29 = 0; var uLocal_30 = 0; var uLocal_31 = 0; float fLocal_32 = 0f; float fLocal_33 = 0f; var uLocal_34 = 0; var uLocal_35 = 0; int iLocal_36 = 0; var uLocal_37 = 0; var uLocal_38 = 0; var uLocal_39 = 0; int iLocal_40 = 0; int iLocal_41 = 0; int iLocal_42 = 0; int iLocal_43 = 0; var uLocal_44 = 0; var uLocal_45 = 0; var uLocal_46 = 0; var uLocal_47 = 0; var uLocal_48 = 0; var uLocal_49 = 0; int iLocal_50 = 0; var uLocal_51 = 0; var uLocal_52 = 0; var uLocal_53 = 0; var uLocal_54 = 0; var uLocal_55 = 0; var uLocal_56 = 0; var uLocal_57 = 0; var uLocal_58 = 0; var uLocal_59 = 0; var uLocal_60 = 0; var uLocal_61 = 0; var uLocal_62 = 0; var uLocal_63 = 0; struct<96> Local_64 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 0, 8, 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, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ; struct<62> Local_160 = { 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, -1, -1, 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, -1, 0, 0, 0, 0, 0 } ; var uLocal_222 = 0; var uLocal_223 = 0; var uScriptParam_0 = 0; var uScriptParam_1 = 0; var uScriptParam_2 = 0; var uScriptParam_3 = 0; var uScriptParam_4 = 0; var uScriptParam_5 = 0; var uScriptParam_6 = 0; var uScriptParam_7 = 0; #endregion void __EntryFunction__() { iLocal_2 = 1; iLocal_3 = 134; iLocal_4 = 134; iLocal_5 = 1; iLocal_6 = 1; iLocal_7 = 1; iLocal_8 = 134; iLocal_9 = 1; iLocal_10 = 12; iLocal_11 = 12; fLocal_14 = 0.001f; iLocal_17 = -1; sLocal_20 = "NULL"; fLocal_23 = 80f; fLocal_24 = 140f; fLocal_25 = 180f; fLocal_28 = 0f; fLocal_32 = -0.0375f; fLocal_33 = 0.17f; iLocal_36 = 3; iLocal_40 = 1; iLocal_41 = 65; iLocal_42 = 49; iLocal_43 = 64; if (unk_0x02BFF15CAA701972()) { func_137(&uScriptParam_0); } else { func_128(); } while (true) { func_127(); unk_0x366E7F593105797F(2, 199, 1); unk_0x366E7F593105797F(2, 200, 1); if (func_116()) { func_128(); } if (func_115()) { func_128(); } func_1(); } } void func_1() { func_109(0); unk_0xD6ABECE3CBB224B0(0); switch (Local_160.f_16) { case 0: func_106(); break; case 1: func_2(); break; } } void func_2() { if (unk_0x234B68AC2E35ED5A(Global_2518763, 1)) { unk_0xC664C0067EEAB8D1(&Global_2518763, 1); func_96(Global_2518762); } if (Local_160.f_61 != Global_2518893) { Local_160.f_61 = { Global_2518893 }; } else { Local_160.f_61.f_1 = 0; Local_160.f_61.f_2 = 0; } if (!unk_0xA300BD5F71A8C704() && !func_95()) { func_50(); func_41(); func_37(); func_34(); func_33(); func_13(); } func_10(&(Local_64.f_67), unk_0x234B68AC2E35ED5A(Local_160.f_60, 3)); func_3(&(Local_160.f_38), &(Local_160.f_39)); unk_0xC664C0067EEAB8D1(&Global_2518763, 4); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 1); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 2); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 3); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 6); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 7); } void func_3(var uParam0, var uParam1) { struct<3> Var0; var uVar3; struct<3> Var4; func_9(); Var0 = { unk_0x684B55BC7BEF0475() }; if ((((unk_0xA300BD5F71A8C704() || func_8()) || unk_0x86AF801D34E482FF(2, 199)) || unk_0x5C6675393464A814(2, 199)) || unk_0x609EEF618F8CC869(2, 199)) { unk_0xC8877830539DB973(Var0.x, Var0.f_1); unk_0xF3C80B2E954772A7(Var0.x, Var0.f_1, 0); if (unk_0xA300BD5F71A8C704() || func_8()) { if (unk_0x575B7C28D81C0B4D(unk_0xBE979A383F439BD0())) { unk_0x97A41BF3F05FC07D(unk_0xBE979A383F439BD0(), 255); } } } else if (unk_0x575B7C28D81C0B4D(unk_0xBE979A383F439BD0())) { unk_0x97A41BF3F05FC07D(unk_0xBE979A383F439BD0(), 0); } unk_0x348FE88799E71EA4(Var0.x, Var0.f_1); uVar3 = unk_0x3E8724B048C8403E(); if (unk_0x0E8572B08CEB6A11(uVar3)) { unk_0xF82D990162AFC768(uVar3, 1); } Var4 = { unk_0x2EBAAC7478326ECC(0) }; Var4 = { func_7(Var4) }; if (!unk_0x575B7C28D81C0B4D(*uParam0)) { *uParam1 = func_5(Var0, 0); unk_0x252BE56DB93DF816(*uParam1, 425); unk_0xB5E587F8B911573B(*uParam1, 0); unk_0xF3A3BAE36B132003(*uParam1, 4); unk_0xFA3E6ADC3E5D386E(*uParam1, func_4(2)); unk_0x778AD4620A6469FB(*uParam1, 1, 11); unk_0xDD205B87CDFD0C1B(*uParam1, 0.54f); unk_0xC5BBAB0F8336ECB7(*uParam1, 13 + 1); *uParam0 = func_5(Var0, 0); unk_0x252BE56DB93DF816(*uParam0, 425); unk_0xB5E587F8B911573B(*uParam0, 0); unk_0xF3A3BAE36B132003(*uParam0, 4); unk_0xFA3E6ADC3E5D386E(*uParam0, func_4(18)); unk_0x778AD4620A6469FB(*uParam0, 1, 11); unk_0xDD205B87CDFD0C1B(*uParam0, 0.44f); unk_0xC5BBAB0F8336ECB7(*uParam0, 13 + 1); unk_0x7A4C054D66609AD2(*uParam0, 1); unk_0x0248C79F1248F36C(*uParam0, SYSTEM::ROUND(unk_0x832AD84AA258AE80(Var4.x, Var4.f_1))); unk_0x7A4C054D66609AD2(*uParam1, 1); unk_0x0248C79F1248F36C(*uParam1, SYSTEM::ROUND(unk_0x832AD84AA258AE80(Var4.x, Var4.f_1))); } else { unk_0xC983AF341845804E(*uParam0, Var0); unk_0x0248C79F1248F36C(*uParam0, SYSTEM::ROUND(unk_0x832AD84AA258AE80(Var4.x, Var4.f_1))); unk_0xF3A3BAE36B132003(*uParam0, 5); unk_0xC983AF341845804E(*uParam1, Var0); unk_0x0248C79F1248F36C(*uParam1, SYSTEM::ROUND(unk_0x832AD84AA258AE80(Var4.x, Var4.f_1))); unk_0xF3A3BAE36B132003(*uParam1, 5); } } int func_4(int iParam0) { int iVar0; int iVar1; int iVar2; int iVar3; switch (iParam0) { case 1: return 4; case 0: return 4; case 6: return 59; case 18: return 2; case 13: return 5; case 116: return 38; case 28: return 6; case 29: return 7; case 30: return 8; case 31: return 9; case 32: return 10; case 33: return 11; case 34: return 12; case 35: return 13; case 36: return 14; case 37: return 15; case 38: return 16; case 39: return 17; case 40: return 18; case 41: return 19; case 42: return 20; case 43: return 21; case 44: return 22; case 45: return 23; case 46: return 24; case 47: return 25; case 48: return 26; case 49: return 27; case 50: return 28; case 51: return 29; case 52: return 30; case 53: return 31; case 54: return 32; case 55: return 33; case 56: return 34; case 57: return 35; case 58: return 36; case 59: return 37; case 9: return 57; case 10: return 53; case 118: return 57; case 14: return 56; case 3: return 55; case 21: return 50; case 15: return 51; case 20: return 52; case 11: return 54; case 23: return 58; case 12: return 60; case 24: return 61; case 4: return 62; default: } unk_0xB4D5E37C91862216(iParam0, &iVar0, &iVar1, &iVar2, &iVar3); return ((((iVar0 * 16777216) + (iVar1 * 65536)) + iVar2 * 256) + iVar3); return 0; } var func_5(struct<3> Param0, int iParam3) { var uVar0; uVar0 = unk_0x27E44C95E1D1461C(Param0); unk_0xDD205B87CDFD0C1B(uVar0, func_6(unk_0x02BFF15CAA701972(), 1f, 1f)); unk_0x13CC211F9F7ACE7F(uVar0, iParam3); return uVar0; } float func_6(bool bParam0, float fParam1, float fParam2) { if (bParam0) { return fParam1; } return fParam2; } Vector3 func_7(struct<3> Param0) { struct<3> Var0; Var0.x = SYSTEM::COS(Param0.x); Var0.f_1 = SYSTEM::COS(Param0.f_2); Var0.f_2 = SYSTEM::SIN(Param0.x); Var0.f_1 = (Var0.f_1 * Var0.x); Var0.x = (Var0.x * -SYSTEM::SIN(Param0.f_2)); return Var0; } bool func_8() { return unk_0xC62ED852B1172A41() != 0; } void func_9() { Global_1312684 = 1; } void func_10(var uParam0, bool bParam1) { if (unk_0xAB6A270F84A8781E(uParam0)) { return; } if (bParam1) { if (func_12(uParam0)) { unk_0x66AE54CE92457FEE(1); } return; } if (!func_12(uParam0)) { unk_0x66AE54CE92457FEE(1); func_11(uParam0); } } void func_11(var uParam0) { unk_0xDDEC6D09154BA73A(uParam0); unk_0x4A5DC2FF6E0B609F(0, 1, 1, -1); } bool func_12(var uParam0) { unk_0x4A4799828818A508(uParam0); return unk_0x0222F263F70347A8(0); } void func_13() { if (unk_0x234B68AC2E35ED5A(Global_2518763, 5)) { unk_0xC664C0067EEAB8D1(&Global_2518763, 5); Local_160.f_35 = 0; } func_14(&(Local_64.f_24), &(Local_160.f_35)); } void func_14(var uParam0, var uParam1) { bool bVar0; int iVar1; int iVar2; int iVar3; if (*uParam0 > 0) { bVar0 = func_31(0, -1, 0); if (bVar0) { if ((!*uParam1 || unk_0x0C7C436873368EDB(2)) || unk_0x0C7C436873368EDB(0)) { func_30(-1); iVar1 = 0; while (iVar1 < *uParam0) { iVar2 = uParam0->f_34[iVar1]; if (iVar2 < 32) { func_29(iVar2, &(uParam0->f_1[iVar1 /*4*/]), -1); } else { iVar3 = (iVar2 - 32); func_28(iVar3, &(uParam0->f_1[iVar1 /*4*/]), -1, 0); } iVar1++; } *uParam1 = 1; } func_27(1); func_15(0, -1, 0, 1, 0, 0, 1, 1, 0); } } } void func_15(int iParam0, int iParam1, int iParam2, int iParam3, bool bParam4, bool bParam5, bool bParam6, int iParam7, bool bParam8) { int iVar0; int iVar1; int iVar2; int iVar3; int iVar4; if (!func_26(&iVar0, 0, iParam1)) { return; } iParam0 = iParam0; if (iParam3 && !func_23(bParam4, bParam8)) { return; } if (func_21()) { return; } if (unk_0xFEABE4F1525A0A08()) { return; } if (iParam7 == 0) { if (func_18(unk_0x1146A9AE09CE2B14(), 0)) { return; } } if (unk_0x3640D836D145B814()) { if (unk_0x4793CFF25F0D14B5() == 0 || unk_0xFEABE4F1525A0A08()) { return; } } if (Global_22670.f_5026 != 0) { if (unk_0x0C7C436873368EDB(2)) { iVar1 = 0; while (iVar1 < Global_22670.f_5026) { if (Global_22670.f_5283[iVar1] != 361) { StringCopy(&(Global_22670.f_5028[iVar1 /*16*/]), unk_0x908D1ACF42DAF9B8(2, Global_22670.f_5283[iVar1], 1), 64); } else if (Global_22670.f_5296[iVar1] != 32) { StringCopy(&(Global_22670.f_5028[iVar1 /*16*/]), unk_0xD895F953C52A8886(2, Global_22670.f_5296[iVar1], 1), 64); } iVar1++; } Global_22670.f_5027 = 0; } if (!Global_22670.f_5027) { unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "CLEAR_ALL"); unk_0x392841D58D2EED1D(); unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "SET_MAX_WIDTH"); unk_0x82D42F43BE26EB72((1f - (Global_22670.f_5338 / 100f))); unk_0x392841D58D2EED1D(); if (unk_0x3640D836D145B814()) { unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "TOGGLE_MOUSE_BUTTONS"); unk_0x9D7453DF8B7E9E0B(1); unk_0x392841D58D2EED1D(); } iVar1 = 0; while (iVar1 < Global_22670.f_5026) { if (unk_0x15173FB88ABC94F9(&(Global_22670.f_5221[iVar1 /*4*/])) != unk_0x15173FB88ABC94F9("PREV")) { unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "SET_DATA_SLOT"); unk_0x9E3D03981E2E9AD9(iVar1); func_17(&(Global_22670.f_5028[iVar1 /*16*/])); iVar2 = iVar1 + 1; while (iVar2 < 12 && unk_0x15173FB88ABC94F9(&(Global_22670.f_5221[iVar2 /*4*/])) == unk_0x15173FB88ABC94F9("PREV")) { func_17(&(Global_22670.f_5028[iVar2 /*16*/])); iVar2++; } if (Global_22670.f_5270[iVar1] == -1) { func_16(&(Global_22670.f_5221[iVar1 /*4*/])); } else { iVar3 = Global_22670.f_5270[iVar1]; if (iParam2 >= 0) { iVar3 = iParam2; } unk_0x35CA0C119E6A2A27(&(Global_22670.f_5221[iVar1 /*4*/])); if (bParam5) { unk_0x4E2EF4B6B665F3F4(iVar3, 70); } else { unk_0x38CD3C04C877C35F(iVar3); } unk_0xD4B2C39F7AD5A6A6(); } if (unk_0x3640D836D145B814()) { if (Global_22670.f_5283[iVar1] != 361 && unk_0x234B68AC2E35ED5A(Global_22670.f_5309, iVar1)) { unk_0x9D7453DF8B7E9E0B(1); unk_0x9E3D03981E2E9AD9(Global_22670.f_5283[iVar1]); } else { unk_0x9D7453DF8B7E9E0B(0); unk_0x9E3D03981E2E9AD9(361); } } unk_0x392841D58D2EED1D(); } iVar1++; } if (unk_0x15173FB88ABC94F9(&(Global_4271135.f_16)) != unk_0x15173FB88ABC94F9("")) { unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "SET_DATA_SLOT"); unk_0x9E3D03981E2E9AD9(Global_22670.f_5026); func_17(&Global_4271135); if (Global_4271135.f_20 == -1) { func_16(&(Global_4271135.f_16)); } else { iVar4 = Global_22670.f_5270[iVar1]; if (iParam2 >= 0) { iVar4 = iParam2; } unk_0x35CA0C119E6A2A27(&(Global_4271135.f_16)); if (bParam5) { unk_0x4E2EF4B6B665F3F4(iVar4, 70); } else { unk_0x38CD3C04C877C35F(iVar4); } unk_0xD4B2C39F7AD5A6A6(); } unk_0x392841D58D2EED1D(); } unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "SET_BACKGROUND_COLOUR"); unk_0x9E3D03981E2E9AD9(0); unk_0x9E3D03981E2E9AD9(0); unk_0x9E3D03981E2E9AD9(0); unk_0x9E3D03981E2E9AD9(80); unk_0x392841D58D2EED1D(); unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "DRAW_INSTRUCTIONAL_BUTTONS"); if (Global_22670.f_5339) { unk_0x9E3D03981E2E9AD9(1); } else { unk_0x9E3D03981E2E9AD9(0); } unk_0x392841D58D2EED1D(); Global_22670.f_5027 = 1; } iVar1 = 0; while (iVar1 < Global_22670.f_5026) { if (Global_22670.f_5270[iVar1] != -1) { if (iParam2 > 0) { unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "OVERRIDE_RESPAWN_TEXT"); unk_0x9E3D03981E2E9AD9(iVar1); unk_0x35CA0C119E6A2A27(&(Global_22670.f_5221[iVar1 /*4*/])); if (bParam5) { unk_0x4E2EF4B6B665F3F4(iParam2, 70); } else { unk_0x38CD3C04C877C35F(iParam2); } unk_0xD4B2C39F7AD5A6A6(); unk_0x392841D58D2EED1D(); } } iVar1++; } if (Global_4271135.f_20 != -1) { if (iParam2 > 0) { unk_0x704F8697BB515627(Global_22670.f_5917[iVar0 /*10*/], "OVERRIDE_RESPAWN_TEXT"); unk_0x9E3D03981E2E9AD9(iVar1); unk_0x35CA0C119E6A2A27(&(Global_4271135.f_16)); if (bParam5) { unk_0x4E2EF4B6B665F3F4(iParam2, 70); } else { unk_0x38CD3C04C877C35F(iParam2); } unk_0xD4B2C39F7AD5A6A6(); unk_0x392841D58D2EED1D(); } } unk_0x53CE6C5893F65093(76, 66); unk_0x0C456F50E9145299(0f, 0f, 0f, 0f); if (bParam6) { if (!Global_22670.f_8674) { unk_0x1F2C4D3A741ED5AD(15, 0f, -0.0375f); Global_22670.f_8674 = 1; } } else if (Global_22670.f_8674) { unk_0x956EB3331C33B055(15); Global_22670.f_8674 = 0; } unk_0x17552FF90A99ABEA(); if (Global_22670.f_5312) { unk_0x53CE6C5893F65093(82, 66); unk_0x0C456F50E9145299(0f, 0f, 0f, 0f); unk_0x43D93129BD1AD792(Global_22670.f_5917[iVar0 /*10*/], Global_22670.f_5310, Global_22670.f_5311, 1f, 1f, 255, 255, 255, 255, 0); unk_0x17552FF90A99ABEA(); } else { unk_0x44EF5678D6916481(Global_22670.f_5917[iVar0 /*10*/], 255, 255, 255, 255, 0); } } } void func_16(var uParam0) { unk_0x35CA0C119E6A2A27(uParam0); unk_0xD4B2C39F7AD5A6A6(); } void func_17(var uParam0) { unk_0x5FEAD10623875182(uParam0); } bool func_18(int iParam0, int iParam1) { bool bVar0; if (iParam0 == unk_0x1146A9AE09CE2B14()) { bVar0 = func_19(-1, 0) == 8; } else { bVar0 = Global_1590908[iParam0 /*874*/].f_205 == 8; } if (iParam1 == 1) { if (unk_0x8CFC2F41A749E236(iParam0)) { bVar0 = unk_0x7C3E030BC3ED6671(iParam0) == 8; } } return bVar0; } int func_19(int iParam0, bool bParam1) { int iVar0; int iVar1; iVar1 = iParam0; if (iVar1 == -1) { iVar1 = func_20(); } if (Global_1312882[iVar1] == 1) { if (bParam1) { } iVar0 = 8; } else { iVar0 = Global_1312757[iVar1]; if (bParam1) { } } return iVar0; } int func_20() { return Global_1312763; } int func_21() { struct<3> Var0; if (Global_19798.f_1 > 3) { return 1; } if (func_22()) { Var0 = { 0f, -500f, 0f }; unk_0x3AEC124A3999B3D1(&Var0); if (Global_19743 == 0) { if (Var0.f_1 > -119f) { return 1; } else { return 0; } } else if (Var0.f_1 > -101f) { return 1; } else { return 0; } } return 0; } int func_22() { if (unk_0x636F1F53CC61D2C9(joaat("cellphone_flashhand")) > 0) { return 1; } return 0; } int func_23(bool bParam0, bool bParam1) { if (Global_2441237.f_2012.f_701 != 0) { return 1; } if ((((((((!unk_0xE0A6F16F546C8274() || (func_25(8, -1) && func_24() != 65)) || (unk_0xC62ED852B1172A41() != 0 && !bParam1)) || (unk_0xF471787D45ADC2C1() && !bParam0)) || unk_0x1C8EA7DABB529A31()) || Global_77508) || Global_22670.f_8673) || unk_0xD76BEAE1A33E3251()) || Global_99422.f_1441) { return 0; } return 1; } int func_24() { return Global_1312836; } bool func_25(int iParam0, int iParam1) { switch (iParam0) { case 5: if (iParam1 > -1) { return Global_1379108.f_203[iParam1]; } break; } return unk_0x234B68AC2E35ED5A(Global_1379108.f_1048, iParam0); } int func_26(var uParam0, bool bParam1, int iParam2) { char cVar0[64]; int iVar16; int iVar17; int iVar18; if (iParam2 == -1) { if (unk_0x02BFF15CAA701972() && unk_0x8ED8428AB65B7367()) { iParam2 = unk_0xC9D88F06B228AD40(); } } StringCopy(&cVar0, unk_0x471C98FD94C0A5FD(), 64); StringIntConCat(&cVar0, iParam2, 64); iVar16 = unk_0x15173FB88ABC94F9(&cVar0); iVar18 = -1; iVar17 = 0; while (iVar17 < 6) { if (Global_22670.f_5978[iVar17] == iVar16) { *uParam0 = iVar17; return 1; } else if (Global_22670.f_5978[iVar17] == 0) { iVar18 = iVar17; } iVar17++; } if (bParam1) { if (iVar18 != -1) { Global_22670.f_5978[iVar18] = iVar16; *uParam0 = iVar18; return 1; } } return 0; } void func_27(int iParam0) { Global_1380638.f_1121 = iParam0; } void func_28(int iParam0, char* sParam1, int iParam2, bool bParam3) { char* sVar0; sVar0 = unk_0x908D1ACF42DAF9B8(2, iParam0, 1); if (Global_22670.f_5026 >= 12) { StringCopy(&Global_4271135, sVar0, 64); StringCopy(&(Global_4271135.f_16), sParam1, 16); Global_4271135.f_20 = iParam2; return; return; } if (!bParam3) { unk_0x191DDA30577F440A(&(Global_22670.f_5309), Global_22670.f_5026); } StringCopy(&(Global_22670.f_5028[Global_22670.f_5026 /*16*/]), sVar0, 64); StringCopy(&(Global_22670.f_5221[Global_22670.f_5026 /*4*/]), sParam1, 16); Global_22670.f_5270[Global_22670.f_5026] = iParam2; Global_22670.f_5283[Global_22670.f_5026] = iParam0; Global_22670.f_5296[Global_22670.f_5026] = 32; Global_22670.f_5026++; } void func_29(int iParam0, char* sParam1, int iParam2) { char* sVar0; sVar0 = unk_0xD895F953C52A8886(2, iParam0, 1); if (Global_22670.f_5026 >= 12) { StringCopy(&Global_4271135, sVar0, 64); StringCopy(&(Global_4271135.f_16), sParam1, 16); Global_4271135.f_20 = iParam2; return; return; } unk_0xC664C0067EEAB8D1(&(Global_22670.f_5309), Global_22670.f_5026); StringCopy(&(Global_22670.f_5028[Global_22670.f_5026 /*16*/]), sVar0, 64); StringCopy(&(Global_22670.f_5221[Global_22670.f_5026 /*4*/]), sParam1, 16); Global_22670.f_5270[Global_22670.f_5026] = iParam2; Global_22670.f_5283[Global_22670.f_5026] = 361; Global_22670.f_5296[Global_22670.f_5026] = iParam0; Global_22670.f_5026++; } void func_30(int iParam0) { int iVar0; int iVar1; Global_22670.f_5026 = 0; Global_22670.f_5027 = 0; iVar0 = 0; while (iVar0 < 12) { StringCopy(&(Global_22670.f_5221[iVar0 /*4*/]), "", 16); Global_22670.f_5270[iVar0] = -1; Global_22670.f_5283[iVar0] = 361; Global_22670.f_5296[iVar0] = 32; iVar0++; } Global_22670.f_5309 = 0; StringCopy(&(Global_4271135.f_16), "", 16); Global_4271135.f_20 = -1; if (unk_0x3640D836D145B814()) { if (!func_26(&iVar1, 0, iParam0)) { return; } unk_0x704F8697BB515627(Global_22670.f_5917[iVar1 /*10*/], "TOGGLE_MOUSE_BUTTONS"); unk_0x9D7453DF8B7E9E0B(0); unk_0x392841D58D2EED1D(); } } bool func_31(char* sParam0, int iParam1, bool bParam2) { int iVar0; bool bVar1; bool bVar2; if (!func_26(&iVar0, 1, iParam1)) { return 0; } bVar1 = true; StringCopy(&(Global_22670.f_5892[iVar0 /*4*/]), sParam0, 16); if (!unk_0xAB6A270F84A8781E(&(Global_22670.f_5892[iVar0 /*4*/]))) { unk_0xBB3CDAB62C8773C8(&(Global_22670.f_5892[iVar0 /*4*/]), 9); Global_22670.f_5885[iVar0] = 1; if (!unk_0xA7E5F88C5CF2D04B(&(Global_22670.f_5892[iVar0 /*4*/]), 9)) { bVar1 = false; } } unk_0xA08F3C300F9E3468("CommonMenu", 0); Global_22670.f_5871[iVar0] = 1; if (!unk_0xAD9D75DD073BF477("CommonMenu")) { bVar1 = false; } if (bParam2) { unk_0xA08F3C300F9E3468("MPShopSale", 0); Global_22670.f_5878[iVar0] = 1; if (!unk_0xAD9D75DD073BF477("MPShopSale")) { bVar1 = false; } } bVar2 = false; StringCopy(&(Global_22670.f_5917[iVar0 /*10*/].f_1), "instructional_buttons", 24); bVar2 = func_32(&(Global_22670.f_5917[iVar0 /*10*/])); if (!bVar1 || !bVar2) { } return (bVar1 && bVar2); } bool func_32(var uParam0) { switch (uParam0->f_9) { case 0: if (!unk_0xDAE4BC89A198A6AF(*uParam0)) { *uParam0 = unk_0x42AA2CCF0B61DCD8(&(uParam0->f_1)); uParam0->f_9 = 1; if (uParam0->f_7) { if (unk_0xDAE4BC89A198A6AF(*uParam0)) { uParam0->f_8 = unk_0xDFB7BFA6482FEE1E(); uParam0->f_9 = 2; } } } else { uParam0->f_8 = unk_0xDFB7BFA6482FEE1E(); uParam0->f_9 = 2; } break; case 1: if (unk_0xDAE4BC89A198A6AF(*uParam0)) { uParam0->f_8 = unk_0xDFB7BFA6482FEE1E(); uParam0->f_9 = 2; } break; case 2: if (!unk_0xDAE4BC89A198A6AF(*uParam0)) { uParam0->f_9 = 0; } break; } return uParam0->f_9 == 2; } void func_33() { int iVar0; if (!unk_0x234B68AC2E35ED5A(Local_160.f_60, 7)) { iVar0 = unk_0xE7C79E1B8D592E06(); if (Local_160.f_56 != iVar0) { unk_0x81498BC667997F2F("eyeinthesky"); Local_160.f_56 = unk_0xE7C79E1B8D592E06(); } } } void func_34() { if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 6)) { if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 5)) { func_36(); } } else if (!unk_0x234B68AC2E35ED5A(Local_160.f_60, 5) && !unk_0xAB6A270F84A8781E(&(Local_64.f_80))) { func_35(&(Local_64.f_80)); } } void func_35(var uParam0) { if (unk_0xAB6A270F84A8781E(uParam0)) { return; } if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 5)) { } else { unk_0x1780951D345B980F(uParam0); unk_0x191DDA30577F440A(&(Local_160.f_60), 5); } } void func_36() { if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 5)) { unk_0xBD9F36815B9331DB(); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 5); } } void func_37() { struct<3> Var0; if (Local_64.f_17 == 4) { return; } if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 1)) { return; } if (!unk_0xDAE4BC89A198A6AF(Local_160.f_36)) { Local_160.f_36 = unk_0x42AA2CCF0B61DCD8(Local_64.f_86.f_1); return; } Var0 = { unk_0x864557F89941B870(Local_160, 2) }; switch (Local_64.f_17) { case 1: case 2: case 3: if (!Local_160.f_37) { Local_160.f_37 = 1; func_40(Local_160.f_36, Local_64.f_20); func_39(Local_160.f_36, Local_64.f_20.f_1, Local_64.f_20.f_2, Local_64.f_20.f_3); } case 0: func_38(Local_160.f_36, 0f, unk_0x004B4DE459D9277C(Local_160), Local_64.f_4, Local_64.f_5, Var0.f_2); break; } unk_0x0F33095580A670CE(0); unk_0x44EF5678D6916481(Local_160.f_36, 255, 255, 255, 0, 0); } void func_38(var uParam0, float fParam1, float fParam2, float fParam3, float fParam4, float fParam5) { fParam2 = ((fParam2 - fParam3) / (fParam4 - fParam3)); unk_0x704F8697BB515627(uParam0, "SET_ALT_FOV_HEADING"); unk_0x82D42F43BE26EB72(fParam1); unk_0x82D42F43BE26EB72(fParam2); unk_0x82D42F43BE26EB72(fParam5); unk_0x392841D58D2EED1D(); } void func_39(var uParam0, int iParam1, int iParam2, int iParam3) { unk_0x704F8697BB515627(uParam0, "SET_WEAPON_VALUES"); unk_0x9E3D03981E2E9AD9(uParam1); unk_0x9E3D03981E2E9AD9(uParam2); unk_0x9E3D03981E2E9AD9(uParam3); unk_0x392841D58D2EED1D(); } void func_40(var uParam0, int iParam1) { unk_0x704F8697BB515627(uParam0, "SET_ZOOM_VISIBLE"); unk_0x9D7453DF8B7E9E0B(uParam1); unk_0x392841D58D2EED1D(); } void func_41() { struct<4> Var0; struct<3> Var4; struct<3> Var7; struct<3> Var10; if (Local_64.f_94 != 0) { Local_160.f_4 = { unk_0xD6E677FAD7521410(Local_64.f_95, 1) }; Local_160.f_4.f_3 = { unk_0x4BB6BF4A85268A22(Local_64.f_95, 2) }; } if (!unk_0x234B68AC2E35ED5A(Local_160.f_60, 2)) { Var0 = { func_46(Local_160, &(Local_160.f_1), Local_64, Local_64.f_6.f_1, Local_64.f_6) }; } Var4 = { Local_64.f_91 + Local_160.f_1 }; Var7 = { func_45(Local_64.f_71, Var4.f_2) }; Var10 = { Local_64.f_88 + Var7 }; switch (Local_64.f_94) { case 0: func_44(Local_160, Var10, Var4); break; case 1: func_43(Local_160, Var10, Var4, Local_64.f_95); break; } func_42(Local_160.f_40, Local_160.f_40.f_2, Local_160.f_40.f_8, Local_160.f_40.f_3, Local_160.f_40.f_9, Local_160.f_40.f_4, Local_160.f_40.f_10, Local_160.f_40.f_5, Local_160.f_40.f_11, Local_160.f_40.f_6, Local_160.f_40.f_12, Local_160.f_40.f_7, Var0, Var0.f_1, Local_160.f_61.f_1, Local_160.f_61.f_2 > 0); Local_160.f_4.f_6 = { unk_0x0D9118860A976DFD(Local_160) }; Local_160.f_4.f_9 = { unk_0x864557F89941B870(Local_160, 2) }; } void func_42(var uParam0, char* sParam1, int iParam2, char* sParam3, int iParam4, char* sParam5, int iParam6, char* sParam7, int iParam8, char* sParam9, int iParam10, char* sParam11, float fParam12, struct<3> Param13, int iParam16, bool bParam17) { float fVar0; var uVar1; var uVar2; bool bVar3; float fVar4; if (unk_0xAB6A270F84A8781E(uParam0) || unk_0x952AB441FA24BF16(uParam0, 0, -1)) { if (fParam12 != 0f) { if (iParam4 != -1) { if (unk_0x964C4D363AF812CB(iParam4)) { unk_0x9B0169E27978C1A2(iParam4, uParam5, uParam1, 1); } unk_0xB76EE71E771BDAA1(iParam4, "Ctrl", fParam12); if (fParam12 < 0f) { unk_0xB76EE71E771BDAA1(iParam4, "Dir", -1f); } else { unk_0xB76EE71E771BDAA1(iParam4, "Dir", 1f); } } } else if (iParam4 != -1) { if (!unk_0x964C4D363AF812CB(iParam4)) { unk_0x791B4C3811D53DFA(iParam4); } } fVar0 = SYSTEM::VMAG(Param13); if (fVar0 > 0f) { if (iParam2 != -1) { if (unk_0x964C4D363AF812CB(iParam2)) { unk_0x9B0169E27978C1A2(iParam2, uParam3, sParam1, 1); } unk_0xB76EE71E771BDAA1(iParam2, "Ctrl", fVar0); } } else if (iParam2 != -1) { if (!unk_0x964C4D363AF812CB(iParam2)) { unk_0x791B4C3811D53DFA(iParam2); } } if (iParam6 != -1) { if (unk_0x964C4D363AF812CB(iParam6)) { unk_0x9B0169E27978C1A2(iParam6, uParam7, sParam1, 1); } } uVar1 = unk_0x7D2B9E6A64637269(); if (unk_0xC49311A2A500FF09(uVar1, 0)) { uVar2 = unk_0x75B58B38E45C6F9A(uVar1, 0); } else { uVar2 = uVar1; } if (iParam8 != -1) { bVar3 = bParam17; if (!bVar3) { fVar4 = SYSTEM::TO_FLOAT(unk_0x6352BFB5F372FA37(uVar2)); bVar3 = (IntToFloat(iParam16) / fVar4) > 0.1f; } if (bVar3) { if (unk_0x964C4D363AF812CB(iParam8)) { unk_0x9B0169E27978C1A2(iParam8, uParam9, uParam9, 1); } } } if (iParam10 != -1) { if ((IntToFloat(unk_0x5E7C0A485B91DB87(uVar1)) / SYSTEM::TO_FLOAT(unk_0x6352BFB5F372FA37(uVar1))) < 0.15f || (IntToFloat(unk_0x5E7C0A485B91DB87(uVar2)) / SYSTEM::TO_FLOAT(unk_0x6352BFB5F372FA37(uVar2))) < 0.15f) { if (unk_0x964C4D363AF812CB(iParam10)) { unk_0x9B0169E27978C1A2(iParam10, uParam11, sParam1, 1); } } else if (!unk_0x964C4D363AF812CB(iParam10)) { unk_0x791B4C3811D53DFA(iParam10); } } } } void func_43(var uParam0, struct<3> Param1, struct<3> Param4, var uParam7) { unk_0x612434A5544F5847(uParam0, uParam7, Param1, 1); unk_0xBD833AA6EB59C81B(uParam0, Param4 + unk_0x4BB6BF4A85268A22(uParam7, 2), 2); } void func_44(var uParam0, struct<3> Param1, struct<3> Param4) { unk_0x7508AE96782B0441(uParam0, Param1); unk_0xBD833AA6EB59C81B(uParam0, Param4, 2); } Vector3 func_45(struct<3> Param0, float fParam3) { struct<3> Var0; float fVar3; float fVar4; fVar3 = SYSTEM::SIN(fParam3); fVar4 = SYSTEM::COS(fParam3); Var0.x = ((Param0.x * fVar4) - (Param0.f_1 * fVar3)); Var0.f_1 = ((Param0.x * fVar3) + (Param0.f_1 * fVar4)); Var0.f_2 = Param0.f_2; return Var0; } struct<4> func_46(var uParam0, var uParam1, struct<6> Param2, float fParam8, float fParam9) { float fVar0; struct<4> Var1; float fVar5; struct<3> Var6; float fVar9; float fVar10; float fVar11; struct<3> Var12; struct<3> Var15; float fVar18; struct<3> Var19; bool bVar22; fVar0 = unk_0x004B4DE459D9277C(uParam0); Var1 = -fVar0; Var1.f_1 = { -*uParam1 }; fVar5 = unk_0xC40DD87705E0DB63(0, 39); Var6 = { -Vector(unk_0xA1108F381688010B(0, 290), 0f, unk_0xA1108F381688010B(0, 291)) }; if (unk_0x0D901EFDFD7EF9D5(2)) { fParam8 = (fParam8 * 8f); } else { if (unk_0x0BCA9ADE67DF9DD8(fVar5) < 0.06f) { fVar5 = 0f; } if (SYSTEM::VMAG(Var6) < 0.06f) { Var6 = { 0f, 0f, 0f }; } } fVar9 = unk_0x7FF6ACE380ED166C(); fVar10 = func_49((fVar0 + ((fVar5 * fParam9) * fVar9)), Param2.f_4, Param2.f_5); unk_0xEF20E9A7B745D17A(uParam0, fVar10); unk_0xCD29B8E8A95DC63C(uParam0, 0.01f); fVar11 = ((fVar10 - 5f) / 42f); unk_0x791FA2C27A7A2BC5(1f); unk_0x9113A3C615625C95(fVar11); Var12.x = Param2.f_2; Var12.f_1 = 0f; Var12.f_2 = Param2; Var15.x = Param2.f_3; Var15.f_1 = 0f; Var15.f_2 = Param2.f_1; fVar18 = (((fVar9 * fVar10) * fParam8) * (1f + ((fVar10 - Param2.f_4) / (Param2.f_5 - Param2.f_4)))); Var19 = { Var6 }; Var19.f_2 = (Var19.f_2 * fVar18); Var19.x = (Var19.x * fVar18); *uParam1 = { *uParam1 + Var19 }; bVar22 = Var12.f_2 > Var15.f_2; if (bVar22) { *uParam1 = func_49(*uParam1, Var12.x, Var15.x); uParam1->f_1 = func_49(uParam1->f_1, Var12.f_1, Var15.f_1); uParam1->f_2 = func_48(uParam1->f_2); } else { *uParam1 = { func_47(*uParam1, Var12, Var15) }; } Var1 = (Var1 + fVar10); Var1.f_1 = { Var1.f_1 + *uParam1 }; return Var1; } Vector3 func_47(struct<3> Param0, struct<3> Param3, struct<3> Param6) { Param0.x = func_49(Param0.x, Param3.x, Param6.x); Param0.f_1 = func_49(Param0.f_1, Param3.f_1, Param6.f_1); Param0.f_2 = func_49(Param0.f_2, Param3.f_2, Param6.f_2); return Param0; } float func_48(float fParam0) { while (fParam0 > 180f) { fParam0 = (fParam0 - 360f); } while (fParam0 < -180f) { fParam0 = (fParam0 + 360f); } return fParam0; } float func_49(float fParam0, float fParam1, float fParam2) { if (fParam0 > fParam2) { return fParam2; } else if (fParam0 < fParam1) { return fParam1; } return fParam0; } void func_50() { switch (Local_64.f_8.f_1) { case 1: func_85(); break; case 2: func_70(); break; case 3: func_51(); break; } } void func_51() { var uVar0; var uVar3; struct<3> Var6; if (unk_0x636F1F53CC61D2C9(joaat("am_mp_drone")) < 1) { if (!Local_160.f_29.f_5) { Local_160.f_29.f_5 = 1; } if (!func_65(4, 0f, 0f, 0f, Local_160.f_4.f_6, 0f, 0f, 0f)) { if (func_64()) { unk_0x9B0169E27978C1A2(-1, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } return; } } if (Local_160.f_29) { if (unk_0x8B6A925F148E0E94()) { if (Local_160.f_29.f_1) { if (func_62(unk_0x1146A9AE09CE2B14())) { unk_0x6E1E3A5B1F9AB95B(250); unk_0x4569EA65F1B056ED(Local_160.f_40.f_13.f_2, Local_160.f_40.f_13.f_1, Local_160.f_29.f_2, Local_160.f_40.f_13, 1, 500, 0); Local_160.f_29.f_1 = 0; Local_160.f_29 = 0; } } else { Local_160.f_29.f_1 = 1; func_61(&(Local_160.f_17), 0, 0); unk_0x191DDA30577F440A(&Global_2518763, 0); func_58(3f, 100f, &(Local_160.f_29.f_2), &uVar0, &uVar3, &Var6); func_57(1); func_55(Local_160.f_29.f_2, Var6); } } } if (func_54() || Local_160.f_29) { unk_0x191DDA30577F440A(&(Local_160.f_60), 1); unk_0x191DDA30577F440A(&(Local_160.f_60), 2); unk_0x191DDA30577F440A(&(Local_160.f_60), 3); if (!Local_160.f_29) { unk_0x191DDA30577F440A(&(Local_160.f_60), 6); unk_0x191DDA30577F440A(&(Local_160.f_60), 7); } return; } if (func_64()) { if (func_52(&(Local_160.f_17), Local_64.f_8.f_2, 0)) { Local_160.f_29 = 1; unk_0x8BA9BCDD56AA7115(250); } else { unk_0x9B0169E27978C1A2(-1, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } } } int func_52(var uParam0, int iParam1, bool bParam2) { if (iParam1 == -1) { return 1; } func_53(uParam0, bParam2, 0); if (unk_0x02BFF15CAA701972() && !bParam2) { if (unk_0x909F156FC4077611(unk_0x2D57EADCBEDDB2AA(unk_0x551F46B3C7DFB654(), *uParam0)) >= iParam1) { return 1; } } else if (unk_0x909F156FC4077611(unk_0x2D57EADCBEDDB2AA(unk_0xDFB7BFA6482FEE1E(), *uParam0)) >= iParam1) { return 1; } return 0; } void func_53(var uParam0, bool bParam1, bool bParam2) { if (uParam0->f_1 == 0) { if (unk_0x02BFF15CAA701972() && !bParam1) { if (!bParam2) { *uParam0 = unk_0x551F46B3C7DFB654(); } else { *uParam0 = unk_0xCB3024ED32EBF9EC(); } } else { *uParam0 = unk_0xDFB7BFA6482FEE1E(); } uParam0->f_1 = 1; } } bool func_54() { return unk_0x234B68AC2E35ED5A(Global_1695733, 5); } void func_55(struct<3> Param0, struct<3> Param3) { if (!func_56(Global_1695733.f_13, Param0, 0)) { Global_1695733.f_13 = { Param0 }; Param3 = { Param3 + Vector(0f, -180f, 180f) }; Global_1695733.f_16 = { Param3 }; } } bool func_56(struct<3> Param0, struct<3> Param3, bool bParam6) { if (bParam6) { return (Param0.x == Param3.x && Param0.f_1 == Param3.f_1); } return ((Param0.x == Param3.x && Param0.f_1 == Param3.f_1) && Param0.f_2 == Param3.f_2); } void func_57(bool bParam0) { if (bParam0) { if (!unk_0x234B68AC2E35ED5A(Global_1695733.f_2, 4)) { Global_1695733.f_2 = 0; unk_0x191DDA30577F440A(&(Global_1695733.f_2), 4); } } else if (unk_0x234B68AC2E35ED5A(Global_1695733.f_2, 4)) { unk_0xC664C0067EEAB8D1(&(Global_1695733.f_2), 4); } } void func_58(float fParam0, float fParam1, var uParam2, var uParam3, var uParam4, var uParam5) { struct<3> Var0; struct<3> Var3; struct<3> Var6; struct<3> Var9; int iVar12; float fVar13; int iVar14; float fVar15; if (Local_64.f_74 == 0) { *uParam5 = { unk_0x864557F89941B870(Local_160, 2) }; *uParam4 = { func_7(*uParam5) }; *uParam2 = { Local_160.f_4.f_6 + Vector(fParam0, fParam0, fParam0) * *uParam4 }; *uParam3 = { func_60(*uParam2, fParam1) }; } else { Var0 = { func_7(unk_0x864557F89941B870(Local_160, 2)) }; Var3 = { unk_0x9E695CE384C77EF0(Local_64.f_95, Local_64.f_88) }; Var6 = { unk_0xE3362FD369CEE0FC(Local_64.f_95, Local_64.f_74.f_1[0]) }; Var9 = { Var6 - Var3 }; *uParam2 = { Var6 }; iVar12 = 0; fVar13 = func_59(Var9, Var0); iVar14 = 1; while (iVar14 <= (Local_64.f_74 - 1)) { Var6 = { unk_0xE3362FD369CEE0FC(Local_64.f_95, Local_64.f_74.f_1[iVar14]) }; Var9 = { Var6 - Var3 }; fVar15 = func_59(Var9, Var0); if (fVar15 > fVar13) { fVar13 = fVar15; iVar12 = iVar14; *uParam2 = { Var6 }; } iVar14++; } *uParam5 = { unk_0x571632CCE26C19A6(Local_64.f_95, Local_64.f_74.f_1[iVar12]) }; *uParam4 = { func_7(*uParam5) }; *uParam2 = { *uParam2 + Vector(fParam0, fParam0, fParam0) * *uParam4 }; *uParam3 = { *uParam2 + Vector(fParam1, fParam1, fParam1) * *uParam4 }; } } float func_59(struct<3> Param0, struct<3> Param3) { return (((Param0.x * Param3.x) + (Param0.f_1 * Param3.f_1)) + (Param0.f_2 * Param3.f_2)); } Vector3 func_60(struct<3> Param0, float fParam3) { struct<3> Var0; struct<3> Var3; Var0 = { unk_0x2EBAAC7478326ECC(2) }; Var3 = { func_7(Var0) }; return Param0 + Vector(fParam3, fParam3, fParam3) * Var3; } void func_61(var uParam0, bool bParam1, bool bParam2) { if (unk_0x02BFF15CAA701972() && !bParam1) { if (!bParam2) { *uParam0 = unk_0x551F46B3C7DFB654(); } else { *uParam0 = unk_0xCB3024ED32EBF9EC(); } } else { *uParam0 = unk_0xDFB7BFA6482FEE1E(); } uParam0->f_1 = 1; } int func_62(int iParam0) { if (iParam0 != func_63()) { return unk_0x234B68AC2E35ED5A(Global_1590908[iParam0 /*874*/].f_267.f_336, 26); } return 0; } int func_63() { return -1; } bool func_64() { return (unk_0x234B68AC2E35ED5A(Global_2518763, 4) || unk_0x96DF114B59E81B9C(0, 229)); } int func_65(int iParam0, struct<3> Param1, struct<3> Param4, struct<3> Param7) { struct<9> Var0; if (func_69()) { if (!func_68(&uLocal_48)) { func_53(&uLocal_48, 0, 0); } else if (func_52(&uLocal_48, 8000, 0)) { func_67(&uLocal_48); func_66(0); } } if (!unk_0x4BE697D014536271(iLocal_50) && !unk_0xD3419C924F3692F7(joaat("am_mp_drone"))) { unk_0xA7988ABD4140D469("AM_MP_DRONE"); } if ((unk_0xD3419C924F3692F7(joaat("am_mp_drone")) && !unk_0x4BE697D014536271(iLocal_50)) && !func_69()) { Var0.f_1 = -1; Var0 = 0; Var0.f_2 = { Param1 }; Var0.f_5 = { Param4 }; Var0.f_8 = { Param7 }; Var0.f_1 = iParam0; if (unk_0x636F1F53CC61D2C9(joaat("am_mp_drone")) < 1) { if (!unk_0x3F466B2A5F02D328("AM_MP_DRONE", Var0, 1, 0)) { iLocal_50 = SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH_AND_ARGS(joaat("am_mp_drone"), &Var0, 12, 1424); unk_0x41BE3F722FC386CD(joaat("am_mp_drone")); func_67(&uLocal_48); } else { return 1; } } } else if (unk_0x4BE697D014536271(iLocal_50) && !func_69()) { return 1; } return 0; } void func_66(bool bParam0) { if (bParam0) { if (unk_0x636F1F53CC61D2C9(unk_0x15173FB88ABC94F9("AM_MP_DRONE")) > 0) { if (!func_69()) { unk_0x191DDA30577F440A(&Global_1695733, 0); } } } else if (func_69()) { unk_0xC664C0067EEAB8D1(&Global_1695733, 0); } } void func_67(var uParam0) { uParam0->f_1 = 0; } bool func_68(var uParam0) { return uParam0->f_1; } bool func_69() { return unk_0x234B68AC2E35ED5A(Global_1695733, 0); } void func_70() { bool bVar0; int iVar1; var uVar2; var uVar3; struct<3> Var4; struct<3> Var7; func_77(); if (Local_160.f_22 != -1) { bVar0 = func_52(&(Local_160.f_22.f_2), 2000, 0); if (bVar0) { if (unk_0x55F5BD4ABD80B211(Local_160.f_22.f_4)) { uVar2 = unk_0x611CD1312FD3CA66(Local_160.f_22.f_4); unk_0xFED8430C207866D5(uVar2, 2); } func_76(&(Local_160.f_22.f_5)); func_75(&(Local_160.f_22.f_6), "Bleep", "DLC_IE_Steal_EITS_Sounds", 1); iVar1 = 6; } else { if (unk_0x55F5BD4ABD80B211(Local_160.f_22.f_4)) { uVar3 = unk_0x611CD1312FD3CA66(Local_160.f_22.f_4); unk_0xFED8430C207866D5(uVar3, 1); } func_75(&(Local_160.f_22.f_5), "VULKAN_LOCK_ON_AMBER", 0, 1); iVar1 = 9; } func_72(Local_160.f_22.f_4, !bVar0, iVar1); if (func_64()) { if (Local_64.f_16 != 0 && !unk_0xA9C0BBFB9CBB66F1(Local_64.f_16)) { unk_0x9B0169E27978C1A2(-1, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); return; } if (bVar0 && func_52(&(Local_160.f_17), Local_64.f_8.f_2, 0)) { func_61(&(Local_160.f_17), 0, 0); func_71(1f, &Var4, &Var7); unk_0x91F06D934631F28B(Var4, Var7, Local_64.f_8.f_3, 1, Local_64.f_8, unk_0x7D2B9E6A64637269(), 1, 1, -1082130432, Local_64.f_95, 0, 0, Local_160.f_22, 1, 0, Local_64.f_94 != 0, 0); unk_0x4569EA65F1B056ED(Local_160.f_40.f_13.f_2, Local_160.f_40.f_13.f_1, Var4, Local_160.f_40.f_13, 1, 500, 0); } else { unk_0x9B0169E27978C1A2(-1, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } } } } void func_71(float fParam0, var uParam1, var uParam2) { var uVar0; func_58(0f, fParam0, uParam1, uParam2, &uVar0, &uVar0); } void func_72(var uParam0, bool bParam1, int iParam2) { float fVar0; float fVar1; struct<3> Var2; var uVar5; var uVar6; var uVar7; int iVar8; var uVar9; if (!unk_0xAD9D75DD073BF477("helicopterhud")) { return; } unk_0x0F33095580A670CE(1); Var2 = { unk_0xD6E677FAD7521410(uParam0, 1) }; unk_0x2409E8C654B3CB46(Var2, 0); fVar0 = func_74(uParam0, Local_160, 0.5f); fVar0 = func_49(fVar0, 0.015f, fVar0); fVar1 = (fVar0 * unk_0x451E904FC8FB5C54(0)); unk_0xB4D5E37C91862216(iParam2, &uVar5, &uVar6, &uVar7, &iVar8); uVar9 = func_73((bParam1 && (unk_0xDFB7BFA6482FEE1E() % 300) < 150), SYSTEM::CEIL((SYSTEM::TO_FLOAT(iVar8) / 4f)), iVar8); unk_0xDDD5C8D7152E128F("helicopterhud", "hud_outline", 0f, 0f, fVar0, fVar1, 0f, uVar5, uVar6, uVar7, uVar9, 0); unk_0x9DA3CC3D2D3B3C2B(); } int func_73(bool bParam0, int iParam1, int iParam2) { if (bParam0) { return iParam1; } return iParam2; } float func_74(var uParam0, var uParam1, float fParam2) { struct<3> Var0; struct<3> Var3; float fVar6; float fVar7; float fVar8; float fVar9; float fVar10; Var0 = { unk_0x0D9118860A976DFD(uParam1) }; Var3 = { unk_0xD6E677FAD7521410(uParam0, 1) }; fVar6 = unk_0x0BABEFEA577FCFA4(Var0, Var3, 1); fVar7 = unk_0x004B4DE459D9277C(uParam1); fVar8 = 1f; fVar9 = (fVar8 / unk_0x1567C6DF07BA7B08((fVar7 / 2f))); fVar10 = ((fVar9 * fParam2) / fVar6); return fVar10; } void func_75(var uParam0, char* sParam1, char* sParam2, int iParam3) { if (*uParam0 == -1) { *uParam0 = unk_0x5AD02BBC63E31E46(); unk_0x9B0169E27978C1A2(*uParam0, sParam1, sParam2, iParam3); } } void func_76(var uParam0) { if (*uParam0 != -1) { unk_0x791B4C3811D53DFA(*uParam0); unk_0xBAB6F7501A822416(*uParam0); *uParam0 = -1; } } void func_77() { bool bVar0; var uVar1; if (func_84(&(Local_160.f_22.f_1), Local_160.f_22.f_4, &bVar0)) { if (bVar0) { if (Local_160.f_22 != Local_160.f_22.f_4) { func_61(&(Local_160.f_22.f_2), 0, 0); func_76(&(Local_160.f_22.f_5)); func_76(&(Local_160.f_22.f_6)); } Local_160.f_22 = Local_160.f_22.f_4; } else { func_83(); uVar1 = func_81(Local_64.f_8.f_4); Local_160.f_22.f_4 = uVar1; } if (Local_160.f_22.f_4 != -1) { func_79(Local_160.f_22.f_4); } } if (Local_160.f_22 != -1) { if (((Local_160.f_22.f_4 != Local_160.f_22 || unk_0xE50EB54E0F21BED0(Local_160.f_22, 0)) || func_78(Local_160.f_22) > 0.04f) || SYSTEM::VMAG(unk_0xD6E677FAD7521410(Local_160.f_22, 1) - Local_160.f_4.f_6) > Local_64.f_8.f_4) { func_83(); } } } float func_78(var uParam0) { struct<3> Var0; Var0 = { unk_0xD6E677FAD7521410(uParam0, 1) }; if (!unk_0x09A7440D17F223C3(Var0, &Var0, &(Var0.f_1))) { return 1f; } Var0 = { Var0 - Vector(0f, 0.5f, 0.5f) }; Var0.f_2 = 0f; return SYSTEM::VMAG2(Var0); } void func_79(var uParam0) { struct<3> Var0; struct<3> Var3; Var0 = { unk_0x0D9118860A976DFD(Local_160) }; Var3 = { unk_0xD6E677FAD7521410(uParam0, 1) }; Var3 = { Var3 + Vector(2f, 2f, 2f) * func_80(Var3 - Var0) }; Local_160.f_22.f_1 = unk_0x3F7B472B49D4D2AC(Var0, Var3, 511, 0, 4); if (Local_160.f_22.f_1 == 0) { } } Vector3 func_80(struct<3> Param0) { float fVar0; float fVar1; fVar0 = SYSTEM::VMAG(Param0); if (fVar0 != 0f) { fVar1 = (1f / fVar0); Param0 = { Param0 * Vector(fVar1, fVar1, fVar1) }; } else { Param0.x = 0f; Param0.f_1 = 0f; Param0.f_2 = 0f; } return Param0; } int func_81(float fParam0) { int iVar0; bool bVar1; int iVar2; float fVar3; bool bVar4; float fVar5; int iVar6; int iVar7; var uVar8; float fVar9; var uVar10; int iVar11; iVar0 = unk_0x7C3E030BC3ED6671(unk_0x1146A9AE09CE2B14()); bVar1 = iVar0 != -1; fVar3 = 0.005f; bVar4 = false; fVar5 = (fParam0 * fParam0); iVar6 = 0; while (iVar6 < 32) { iVar7 = iVar6; uVar8 = unk_0xD56332194D622ECE(iVar7); if (((!unk_0x8CFC2F41A749E236(iVar7) || !func_82(iVar7, 1, 1)) || (bVar1 && unk_0x7C3E030BC3ED6671(iVar7) == iVar0)) || SYSTEM::VMAG2(Local_160.f_4.f_6 - unk_0xD6E677FAD7521410(uVar8, 1)) > fVar5) { } else { fVar9 = func_78(uVar8); if (fVar9 < fVar3) { iVar2 = iVar7; fVar3 = fVar9; bVar4 = true; } } iVar6++; } if (bVar4) { uVar10 = unk_0xD56332194D622ECE(iVar2); if (unk_0xC49311A2A500FF09(uVar10, 0)) { iVar11 = unk_0x75B58B38E45C6F9A(uVar10, 0); if (!unk_0xE50EB54E0F21BED0(iVar11, 0)) { return iVar11; } } } return -1; } int func_82(int iParam0, bool bParam1, bool bParam2) { int iVar0; iVar0 = iParam0; if (iVar0 != -1) { if (unk_0x8CFC2F41A749E236(iParam0)) { if (bParam1) { if (!unk_0xCAD1755E530A6012(iParam0)) { return 0; } } if (bParam2) { if (!Global_2441237.f_3[iVar0]) { return 0; } } return 1; } } return 0; } void func_83() { Local_160.f_22 = -1; Local_160.f_22.f_4 = -1; func_76(&(Local_160.f_22.f_5)); func_76(&(Local_160.f_22.f_6)); } int func_84(var uParam0, int iParam1, var uParam2) { int iVar0; var uVar1; var uVar4; int iVar7; int iVar8; var uVar9; *uParam2 = 0; if (*uParam0 == 0 || iParam1 == -1) { return 1; } iVar8 = unk_0xA2B3B271E2AE7A08(*uParam0, &iVar0, &uVar4, &uVar1, &iVar7); if (!unk_0x55F5BD4ABD80B211(iVar7)) { if (unk_0xA2CCAAC7F5CA3F49(iVar7)) { uVar9 = unk_0xFAA5505029C4B5A6(iVar7); if (unk_0xC49311A2A500FF09(uVar9, 0)) { iVar7 = unk_0x75B58B38E45C6F9A(uVar9, 0); } } } if (iVar8 == 2) { if (iVar0 != 0) { if (unk_0x419E13582192CFEA(iVar7)) { *uParam2 = (iParam1 == iVar7 && !unk_0xE50EB54E0F21BED0(iVar7, 0)); } } return 1; } else if (iVar8 == 0) { return 1; } return 0; } void func_85() { bool bVar0; bool bVar1; int iVar2; char* sVar3; int iVar4; int iVar5; struct<3> Var6; struct<3> Var9; var uVar12; struct<3> Var15; struct<3> Var18; unk_0xD991F7672CE8EAD3(unk_0x7D2B9E6A64637269(), 452, 1); bVar0 = Local_64.f_13.f_1 > 0; bVar1 = (bVar0 && !func_52(&(Local_160.f_19), Local_64.f_13.f_2, 0)); if (bVar0) { if (bVar1) { iVar2 = 6; sVar3 = "TC_RELOAD"; iVar5 = Local_64.f_13.f_2; iVar4 = func_94(&(Local_160.f_19), 0, 0); } else { iVar2 = 1; sVar3 = "TC_AMMO"; iVar5 = Local_64.f_13.f_1; iVar4 = (iVar5 - Local_160.f_19.f_2); } func_91(iVar4, iVar5, sVar3, iVar2, -1, 11, -1082130432, -1082130432, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, -1, 0, -1, -1082130432, -1082130432, 0, 1, 0, 0, 1, -1, 0, -1, 1); } if (bVar0 && !bVar1) { if (unk_0x96DF114B59E81B9C(0, 225)) { func_90(); } } if (!bVar1 && func_89()) { Local_160.f_19.f_2 = (Local_160.f_19.f_2 + SYSTEM::ROUND((unk_0x7FF6ACE380ED166C() * 1000f))); if (func_52(&(Local_160.f_17), Local_64.f_8.f_2, 0)) { func_61(&(Local_160.f_17), 0, 0); if (Local_64.f_13.f_1 > 0 && Local_160.f_19.f_2 >= Local_64.f_13.f_1) { func_61(&(Local_160.f_19), 0, 0); Local_160.f_19.f_2 = 0; } func_58(0f, Local_64.f_8.f_4, &Var6, &Var9, &uVar12, &Var15); Var18 = { Vector(Local_64.f_13, Local_64.f_13, Local_64.f_13) * func_86(0f, 0f, 0f, 1f) }; Var18.f_1 = 0f; Var15 = { Var15 + Var18 }; Var9 = { Var6 + FtoV(SYSTEM::VMAG(Var9 - Var6)) * func_7(Var15) }; Var6.f_2 = (Var6.f_2 - 1f); unk_0x91F06D934631F28B(Var6, Var9, Local_64.f_8.f_3, 0, Local_64.f_8, unk_0x7D2B9E6A64637269(), 1, 1, -1082130432, Local_64.f_95, 0, 0, 0, 1, 0, Local_64.f_94 != 0, 0); if (Local_160.f_40.f_13.f_2 != -1 && unk_0x964C4D363AF812CB(Local_160.f_40.f_13.f_2)) { unk_0x4569EA65F1B056ED(Local_160.f_40.f_13.f_2, Local_160.f_40.f_13.f_1, Var6, Local_160.f_40.f_13, 1, 500, 0); } } } else if (Local_160.f_40.f_13.f_2 != -1 && !unk_0x964C4D363AF812CB(Local_160.f_40.f_13.f_2)) { unk_0x791B4C3811D53DFA(Local_160.f_40.f_13.f_2); } } Vector3 func_86(struct<3> Param0, float fParam3) { struct<3> Var0; float fVar3; int iVar4; fVar3 = (fParam3 * fParam3); iVar4 = 0; while (iVar4 < 20) { Var0 = { unk_0x644B8DBA4F69BB73(-fParam3, fParam3), unk_0x644B8DBA4F69BB73(-fParam3, fParam3), unk_0x644B8DBA4F69BB73(-fParam3, fParam3) }; if (SYSTEM::VDIST2(Var0, 0f, 0f, 0f) <= fVar3) { return Param0 + Var0; } iVar4++; } return func_87(Param0, fParam3); } Vector3 func_87(struct<3> Param0, float fParam3) { struct<3> Var0; Var0 = { unk_0x644B8DBA4F69BB73(-1f, 1f), unk_0x644B8DBA4F69BB73(-1f, 1f), unk_0x644B8DBA4F69BB73(-1f, 1f) }; return Param0 + func_88(Var0, unk_0x644B8DBA4F69BB73(0f, fParam3)); } Vector3 func_88(struct<3> Param0, float fParam3) { float fVar0; if (fParam3 == 0f) { return 0f, 0f, 0f; } fVar0 = SYSTEM::VMAG(Param0); if (fVar0 != 0f) { return Param0 * FtoV((fParam3 / fVar0)); } return 0f, 0f, 0f; } bool func_89() { return (unk_0x234B68AC2E35ED5A(Global_2518763, 4) || unk_0x51794501073F0A33(0, 229)); } void func_90() { func_61(&(Local_160.f_19), 0, 0); Local_160.f_19.f_2 = 0; } void func_91(int iParam0, int iParam1, char* sParam2, int iParam3, int iParam4, int iParam5, int iParam6, int iParam7, int iParam8, int iParam9, int iParam10, int iParam11, int iParam12, int iParam13, int iParam14, int iParam15, int iParam16, int iParam17, int iParam18, int iParam19, int iParam20, int iParam21, int iParam22, int iParam23, int iParam24, int iParam25, int iParam26, int iParam27, int iParam28, int iParam29, int iParam30, int iParam31, int iParam32, int iParam33, int iParam34, int iParam35, int iParam36) { int iVar0; int iVar1; iVar0 = -1; iVar1 = 0; while (iVar1 <= 9) { if (iVar0 == -1) { if (func_93(0, iVar1) == 0) { iVar0 = iVar1; } } iVar1++; } if (iVar0 > -1) { Global_1380638.f_1 = 1; func_92(0, iVar0); Global_1380638.f_1135[iVar0] = iParam0; Global_1380638.f_1135.f_11[iVar0] = iParam1; StringCopy(&(Global_1380638.f_1135.f_22[iVar0 /*16*/]), sParam2, 64); Global_1380638.f_1135.f_194[iVar0] = iParam3; Global_1380638.f_1135.f_183[iVar0] = iParam4; Global_1380638.f_1135.f_216[iVar0] = iParam5; Global_1380638.f_1135.f_227[iVar0 /*3*/] = iParam6; Global_1380638.f_1135.f_227[iVar0 /*3*/].f_1 = iParam7; Global_1380638.f_1135.f_258[iVar0] = iParam8; Global_1380638.f_1135.f_269[iVar0] = iParam9; Global_1380638.f_1135.f_312[iVar0] = iParam10; Global_1380638.f_1135.f_323[iVar0] = iParam11; Global_1380638.f_1135.f_334[iVar0] = iParam12; Global_1380638.f_1135.f_345[iVar0] = iParam13; Global_1380638.f_1130 = 1; Global_1380638.f_1135.f_356[iVar0] = iParam14; Global_1380638.f_1135.f_367[iVar0] = iParam15; Global_1380638.f_1135.f_378[iVar0] = iParam16; Global_1380638.f_1135.f_389[iVar0] = iParam17; Global_1380638.f_1135.f_400[iVar0] = iParam18; Global_1380638.f_1135.f_411[iVar0] = iParam19; Global_1380638.f_1135.f_422[iVar0] = iParam20; Global_1380638.f_1135.f_433[iVar0] = iParam21; Global_1380638.f_1135.f_444[iVar0] = iParam22; Global_1380638.f_1135.f_455[iVar0] = iParam23; Global_1380638.f_1135.f_466[iVar0] = iParam24; Global_1380638.f_1135.f_205[iVar0] = iParam25; Global_1380638.f_1135.f_477[iVar0] = iParam26; Global_1380638.f_1135.f_488[iVar0] = iParam27; Global_1380638.f_1135.f_499[iVar0] = iParam28; Global_1380638.f_1135.f_510[iVar0] = iParam29; Global_1380638.f_1135.f_521[iVar0] = iParam30; Global_1380638.f_1135.f_532[iVar0] = iParam31; Global_1380638.f_1135.f_543[iVar0] = iParam32; Global_1380638.f_1135.f_554[iVar0] = iParam33; Global_1380638.f_1135.f_565[iVar0] = iParam34; Global_1380638.f_1135.f_576[iVar0] = iParam35; Global_1380638.f_1135.f_587[iVar0] = iParam36; } } void func_92(int iParam0, int iParam1) { unk_0x191DDA30577F440A(&(Global_1380638.f_6736[iParam0]), iParam1); } bool func_93(int iParam0, int iParam1) { return unk_0x234B68AC2E35ED5A(Global_1380638.f_6736[iParam0], iParam1); } var func_94(var uParam0, bool bParam1, bool bParam2) { if (unk_0x02BFF15CAA701972() && !bParam1) { if (!bParam2) { return unk_0x2D57EADCBEDDB2AA(unk_0x551F46B3C7DFB654(), *uParam0); } else { return unk_0x2D57EADCBEDDB2AA(unk_0xCB3024ED32EBF9EC(), *uParam0); } } return unk_0x2D57EADCBEDDB2AA(unk_0xDFB7BFA6482FEE1E(), *uParam0); } bool func_95() { return Global_74428; } void func_96(int iParam0) { var uVar0; uVar0 = iParam0; func_103(iParam0); if (func_102(&uVar0, 2)) { func_61(&(Local_160.f_17), 0, 0); Local_64.f_8 = { Global_2518675.f_8 }; } if (func_102(&uVar0, 6)) { Local_64.f_19 = Global_2518675.f_19; } if (func_102(&uVar0, 10)) { Local_64.f_74 = { Global_2518675.f_74 }; } if (func_102(&uVar0, 8)) { Local_64.f_67 = { Global_2518675.f_67 }; } if (func_102(&uVar0, 12)) { Local_64.f_20 = { Global_2518675.f_20 }; } func_97(iParam0); } void func_97(int iParam0) { var uVar0; uVar0 = iParam0; if (func_102(&uVar0, 0)) { } if (func_102(&uVar0, 1)) { } if (func_102(&uVar0, 2)) { Local_64.f_8 = { Global_2518675.f_8 }; switch (Local_64.f_8.f_1) { case 1: unk_0x96BAB7B7F43C0906(1.5f); if (Local_160.f_19.f_2 == 0 && func_101()) { func_98(&(Local_160.f_19), Local_64.f_13.f_2, 0, 0); } else { func_90(); } break; case 2: Local_64.f_86 = "helicopterhud"; Local_64.f_16 = Global_2518675.f_16; if (Local_64.f_16 != 0) { unk_0x16E516CA9C88FF48(Local_64.f_16); } break; default: break; } if (!unk_0xAB6A270F84A8781E(Local_64.f_86)) { unk_0xA08F3C300F9E3468(Local_64.f_86, 0); } } if (func_102(&uVar0, 4)) { switch (Local_64.f_17) { case 4: Local_64.f_86.f_1 = ""; break; case 0: Local_64.f_86.f_1 = "turret_cam"; break; case 1: Local_64.f_86.f_1 = "ARENA_GUN_CAM_APOCALYPSE"; break; case 2: Local_64.f_86.f_1 = "ARENA_GUN_CAM_SCIFI"; break; case 3: Local_64.f_86.f_1 = "ARENA_GUN_CAM_CONSUMER"; break; default: Local_64.f_86.f_1 = "UNDEFINED"; break; } if (!unk_0xAB6A270F84A8781E(Local_64.f_86.f_1)) { Local_160.f_36 = unk_0x42AA2CCF0B61DCD8(Local_64.f_86.f_1); } } if (func_102(&uVar0, 6)) { Local_160.f_40.f_13.f_2 = -1; switch (Local_64.f_19) { case 0: Local_160.f_40.f_13 = "dlc_aw_Arena_Spectator_Turret_turret_Sounds"; Local_160.f_40.f_13.f_1 = "Fire_MG_Loop"; Local_160.f_40.f_13.f_2 = unk_0x5AD02BBC63E31E46(); break; case 1: Local_160.f_40.f_13 = "dlc_aw_Arena_Gun_Turret_Sounds"; Local_160.f_40.f_13.f_1 = "Fire_MG_Loop"; Local_160.f_40.f_13.f_2 = unk_0x5AD02BBC63E31E46(); break; case 2: Local_160.f_40.f_13 = "dlc_aw_Arena_Gun_Turret_Sounds"; Local_160.f_40.f_13.f_1 = "Fire_Rockets_Oneshot"; Local_160.f_40.f_13.f_2 = unk_0x5AD02BBC63E31E46(); break; case 3: Local_160.f_40.f_13 = "dlc_aw_Arena_Gun_Turret_Sounds"; Local_160.f_40.f_13.f_1 = "Launch_Piloted_Missile"; Local_160.f_40.f_13.f_2 = unk_0x5AD02BBC63E31E46(); break; default: Local_160.f_40.f_13 = 0; Local_160.f_40.f_13.f_1 = 0; Local_160.f_40.f_13.f_2 = -1; break; } } if (func_102(&uVar0, 5)) { Local_160.f_40.f_10 = -1; Local_160.f_40.f_8 = -1; Local_160.f_40.f_9 = -1; Local_160.f_40.f_11 = -1; Local_160.f_40.f_12 = -1; switch (Local_64.f_18) { case 0: Local_160.f_40 = "SCRIPT\POLICE_CHOPPER_CAM"; Local_160.f_40.f_1 = "dlc_aw_arena_turret_scene"; Local_160.f_40.f_2 = "dlc_aw_Arena_Spectator_Turret_turret_Sounds"; Local_160.f_40.f_5 = "Turret_Camera_Hum_Loop"; Local_160.f_40.f_10 = unk_0x5AD02BBC63E31E46(); Local_160.f_40.f_3 = "Pan"; Local_160.f_40.f_8 = unk_0x5AD02BBC63E31E46(); Local_160.f_40.f_4 = "Zoom"; Local_160.f_40.f_9 = unk_0x5AD02BBC63E31E46(); break; case 1: Local_160.f_40 = "SCRIPT\POLICE_CHOPPER_CAM"; Local_160.f_40.f_1 = "dlc_aw_arena_turret_scene"; Local_160.f_40.f_2 = "dlc_aw_Arena_Gun_Turret_Sounds"; Local_160.f_40.f_5 = "Turret_Camera_Hum_Loop"; Local_160.f_40.f_10 = unk_0x5AD02BBC63E31E46(); Local_160.f_40.f_3 = "Pan"; Local_160.f_40.f_8 = unk_0x5AD02BBC63E31E46(); Local_160.f_40.f_4 = "Zoom"; Local_160.f_40.f_9 = unk_0x5AD02BBC63E31E46(); Local_160.f_40.f_6 = "Take_Damage"; Local_160.f_40.f_11 = unk_0x5AD02BBC63E31E46(); Local_160.f_40.f_7 = "Low_Health_Warning"; Local_160.f_40.f_12 = unk_0x5AD02BBC63E31E46(); break; default: Local_160.f_40 = 0; Local_160.f_40.f_2 = 0; Local_160.f_40.f_5 = 0; Local_160.f_40.f_10 = -1; Local_160.f_40.f_3 = 0; Local_160.f_40.f_8 = -1; Local_160.f_40.f_4 = 0; Local_160.f_40.f_9 = -1; break; } if (!unk_0xAB6A270F84A8781E(Local_160.f_40)) { unk_0x9C14AB9191A9291F(Local_160.f_40, 0, -1); } } if (func_102(&uVar0, 3)) { } if (func_102(&uVar0, 7)) { if (Local_64.f_24 > 0) { func_31(0, -1, 0); } } if (func_102(&uVar0, 8)) { } if (func_102(&uVar0, 9)) { } if (func_102(&uVar0, 10)) { } if (func_102(&uVar0, 11)) { if (!unk_0xAB6A270F84A8781E(&(Local_64.f_80))) { func_35(&(Local_64.f_80)); } } if (func_102(&uVar0, 12)) { } } void func_98(var uParam0, int iParam1, bool bParam2, bool bParam3) { if (uParam0->f_1 == 0) { *uParam0 = unk_0x5FBE5EA201067B5E(func_100(bParam2, bParam3), func_99(-iParam1, 0)); uParam0->f_1 = 1; } } int func_99(int iParam0, int iParam1) { if (iParam0 > iParam1) { return iParam1; } return iParam0; } int func_100(bool bParam0, bool bParam1) { if (unk_0x02BFF15CAA701972() && !bParam0) { if (!bParam1) { return unk_0x551F46B3C7DFB654(); } else { return unk_0xCB3024ED32EBF9EC(); } } return unk_0xDFB7BFA6482FEE1E(); } bool func_101() { return (!func_68(&(Local_160.f_19)) || func_52(&(Local_160.f_19), Local_64.f_13.f_2, 0)); } int func_102(var uParam0, int iParam1) { if (unk_0x234B68AC2E35ED5A(*uParam0, iParam1)) { unk_0xC664C0067EEAB8D1(uParam0, iParam1); return 1; } return 0; } void func_103(int iParam0) { if (func_102(&iParam0, 0)) { } if (func_102(&iParam0, 1)) { } if (func_102(&iParam0, 2)) { Local_160.f_37 = 0; switch (Local_64.f_8.f_1) { case 1: unk_0x96BAB7B7F43C0906(1f); break; case 3: if (Local_160.f_29) { unk_0x6E1E3A5B1F9AB95B(250); } Local_160.f_29.f_1 = 0; Local_160.f_29 = 0; if (Local_160.f_29.f_5) { Local_160.f_29.f_5 = 0; func_66(1); } break; case 2: func_83(); if (Local_64.f_16 != 0) { unk_0x824F744352C8BC82(Local_64.f_16); Local_64.f_16 = 0; } break; } if (!unk_0xAB6A270F84A8781E(Local_64.f_86)) { unk_0xB5F867E143F78583(Local_64.f_86); Local_64.f_86 = ""; } } if (func_102(&iParam0, 3)) { } if (func_102(&iParam0, 4)) { Local_160.f_37 = 0; Local_64.f_86.f_1 = ""; if (Local_160.f_36 != -1) { unk_0x3D9BC07C93913E04(&(Local_160.f_36)); Local_160.f_36 = -1; } } if (func_102(&iParam0, 6)) { func_76(&(Local_160.f_40.f_13.f_2)); } if (func_102(&iParam0, 5)) { unk_0x94B9C0AF4E5E520F(); unk_0xF2317BDAE5CFE9EC(); if (!unk_0xAB6A270F84A8781E(Local_160.f_40)) { unk_0x315DA2F7337A8638(Local_160.f_40); } func_76(&(Local_160.f_40.f_8)); func_76(&(Local_160.f_40.f_9)); func_76(&(Local_160.f_40.f_10)); func_76(&(Local_160.f_40.f_11)); func_76(&(Local_160.f_40.f_12)); } if (func_102(&iParam0, 7)) { if (Local_64.f_24 > 0) { func_104(1, -1); } } if (func_102(&iParam0, 8)) { if (!unk_0xAB6A270F84A8781E(&(Local_64.f_67)) && func_12(&(Local_64.f_67))) { unk_0x66AE54CE92457FEE(1); } } if (func_102(&iParam0, 9)) { } if (func_102(&iParam0, 10)) { } if (func_102(&iParam0, 11)) { if (!unk_0xAB6A270F84A8781E(&(Local_64.f_80))) { func_36(); StringCopy(&(Local_64.f_80), "", 16); } } if (func_102(&iParam0, 12)) { Local_160.f_37 = 0; } } void func_104(bool bParam0, int iParam1) { int iVar0; if (!func_26(&iVar0, 0, iParam1)) { return; } if (Global_22670.f_8674) { unk_0x956EB3331C33B055(15); Global_22670.f_8674 = 0; } unk_0x643A5EAD42A4060C(0f); if (Global_22670.f_5885[iVar0]) { unk_0xE498E37B41AEA1DF(9, 0); Global_22670.f_5885[iVar0] = 0; } if (Global_22670.f_5871[iVar0]) { unk_0xB5F867E143F78583("CommonMenu"); Global_22670.f_5871[iVar0] = 0; } if (Global_22670.f_5878[iVar0]) { unk_0xB5F867E143F78583("MPShopSale"); Global_22670.f_5878[iVar0] = 0; } if (bParam0) { func_105(&(Global_22670.f_5917[iVar0 /*10*/])); Global_22670.f_5978[iVar0] = 0; } else { Global_22670.f_5978[iVar0] = 0; } } void func_105(var uParam0) { if (uParam0->f_9 != 0) { if (unk_0xDAE4BC89A198A6AF(*uParam0)) { unk_0x3D9BC07C93913E04(uParam0); } *uParam0 = 0; uParam0->f_9 = 0; } } void func_106() { if ((!unk_0x4E38E404B98F3D9A() && !unk_0x8B6A925F148E0E94()) && unk_0x234B68AC2E35ED5A(Local_64.f_84.f_1, 1)) { unk_0x8BA9BCDD56AA7115(Local_64.f_84); } if (func_52(&(Local_160.f_58), Local_64.f_84, 0)) { if (!unk_0x234B68AC2E35ED5A(Local_64.f_84.f_1, 0) || func_108(Local_64.f_88, 0)) { if (!unk_0x0E8572B08CEB6A11(Local_160)) { Local_160 = unk_0x84F073038B557438(26379945, 1); unk_0x191DDA30577F440A(&(Local_160.f_60), 2); func_41(); unk_0xC664C0067EEAB8D1(&(Local_160.f_60), 2); unk_0x4E55B9968F9B185A(Local_160.f_4.f_6); } else { if (unk_0x234B68AC2E35ED5A(Local_64.f_84.f_1, 0)) { unk_0xED93DAC36CA89AF2(); } unk_0x09F9466B03D29D2D(1, 0, 0, 1, 1, 0); func_3(&(Local_160.f_38), &(Local_160.f_39)); func_37(); if (!unk_0xAB6A270F84A8781E(Local_160.f_40.f_1)) { unk_0xB84B43B766630B5C(Local_160.f_40.f_1); } func_61(&(Local_160.f_17), 0, 0); unk_0x191DDA30577F440A(&Global_2518763, 3); func_107(1); if (unk_0xE7C79E1B8D592E06() >= 0) { Local_160.f_57 = 1; unk_0xF1057FBC3AF0C1D1(); } unk_0x81498BC667997F2F("eyeinthesky"); Local_160.f_56 = unk_0xE7C79E1B8D592E06(); if (unk_0x234B68AC2E35ED5A(Local_64.f_84.f_1, 2)) { if (unk_0x4E38E404B98F3D9A() || unk_0x8B6A925F148E0E94()) { unk_0x6E1E3A5B1F9AB95B(800); } } } } } } void func_107(int iParam0) { Local_160.f_16 = iParam0; } int func_108(struct<3> Param0, int iParam3) { if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 0)) { if (unk_0xABE4F4FD4329B037()) { return 1; } } else if (unk_0x22C43B6780E8FE5B(Param0, 100f, iParam3)) { unk_0x191DDA30577F440A(&(Local_160.f_60), 0); } return 0; } void func_109(int iParam0) { if (func_114()) { return; } if (!Global_19798.f_1 == 1) { if (func_113(0)) { func_110(iParam0); } unk_0x191DDA30577F440A(&Global_7669, 2); } } void func_110(int iParam0) { if (func_114()) { return; } if (Global_19984) { if (func_54()) { func_112(1, 1); } else { func_112(0, 0); } } if (Global_19798.f_1 == 10 || Global_19798.f_1 == 9) { unk_0x191DDA30577F440A(&Global_7669, 16); } if (unk_0x8820F6FCD373F9F7()) { unk_0x75B41F5020877259(0); } Global_21125 = 5; if (iParam0 == 1) { unk_0x191DDA30577F440A(&Global_7668, 30); } else { unk_0xC664C0067EEAB8D1(&Global_7668, 30); } if (!func_111()) { Global_19798.f_1 = 3; } } int func_111() { if (Global_19798.f_1 == 1 || Global_19798.f_1 == 0) { return 1; } return 0; } void func_112(bool bParam0, bool bParam1) { if (bParam0) { if (func_113(0)) { Global_19984 = 1; if (bParam1) { unk_0x3AEC124A3999B3D1(&Global_19735); } Global_19726 = { Global_19744[Global_19743 /*3*/] }; unk_0xA48FA5CE681A5230(Global_19726); } } else if (Global_19984 == 1) { Global_19984 = 0; Global_19726 = { Global_19751[Global_19743 /*3*/] }; if (bParam1) { unk_0xA48FA5CE681A5230(Global_19735); } else { unk_0xA48FA5CE681A5230(Global_19726); } } } int func_113(int iParam0) { if (iParam0 == 1) { if (Global_19798.f_1 > 3) { if (unk_0x234B68AC2E35ED5A(Global_7668, 14)) { return 1; } else { return 0; } } else { return 0; } } if (unk_0x636F1F53CC61D2C9(joaat("cellphone_flashhand")) > 0) { return 1; } if (Global_19798.f_1 > 3) { return 1; } return 0; } bool func_114() { return unk_0x234B68AC2E35ED5A(Global_1695733, 19); } int func_115() { if (Local_64.f_94 != 0) { if (!unk_0x419E13582192CFEA(Local_64.f_95) || unk_0xE50EB54E0F21BED0(Local_64.f_95, 0)) { return 1; } } if (!func_82(unk_0x1146A9AE09CE2B14(), 1, 1)) { return 1; } if (Global_2518673) { return 1; } return 0; } int func_116() { var uVar0; func_124(&uVar0); if (Global_1312878 == 0) { if (!unk_0x02BFF15CAA701972()) { return 1; } } if (func_123()) { return 1; } if (Global_2465749) { return 1; } if (func_122()) { return 1; } if (func_121(159)) { if (!func_120()) { return 1; } } if (func_121(157)) { return 1; } if (!unk_0x0B4295B1608BB934()) { return 1; } if (func_117() != 0) { if (unk_0x636F1F53CC61D2C9(func_117()) == 0) { return 1; } } return 0; } int func_117() { switch (func_119()) { case 0: return func_118(); break; case 2: return joaat("creator"); break; } return 0; } int func_118() { switch (Global_2465851) { case 0: return joaat("freemode"); default: } return joaat("freemode"); } int func_119() { return Global_31345; } bool func_120() { return Global_2453009.f_698; } int func_121(int iParam0) { if (unk_0x7B95B829DF1701E0(1, iParam0)) { return 1; } return 0; } bool func_122() { return Global_2463497; } bool func_123() { return Global_2453009.f_693; } void func_124(var uParam0) { int iVar0; int iVar1; int iVar2; struct<3> Var4; iVar0 = 0; while (iVar0 < unk_0x1131A9F5A725F45A(1)) { iVar1 = unk_0x5F0847A02025CAB5(1, iVar0); if (iVar1 == 174) { unk_0x53858F1E03A88AE1(1, iVar0, &iVar2, 2); switch (iVar2) { case -771178269: func_125(iVar0); break; case -1320260596: unk_0x53858F1E03A88AE1(1, iVar0, &Var4, 4); if (Var4.f_2 == -2138305833) { *uParam0 = 1; } break; } } iVar0++; } } void func_125(int iParam0) { struct<3> Var0; var uVar3; var uVar4; bool bVar5; if (unk_0x53858F1E03A88AE1(1, iParam0, &Var0, 3)) { if (func_82(Var0.f_1, 1, 1)) { uVar3 = unk_0xD56332194D622ECE(Var0.f_1); if (unk_0x419E13582192CFEA(uVar3)) { if (unk_0xC49311A2A500FF09(iVar3, 0)) { uVar4 = unk_0x75B58B38E45C6F9A(iVar3, 0); if (unk_0xF2A0B4A5DE0987FB(uVar4, Var0.f_2) && unk_0x8ED8428AB65B7367()) { if (func_126(uVar4, &bVar5)) { unk_0x2B360ED559ED11A6(uVar4, Var0.f_2); } if (bVar5) { unk_0x795957CD3A0042C8(&uVar4); } } } } } } } int func_126(int iParam0, var uParam1) { if (unk_0x419E13582192CFEA(uParam0)) { if (!unk_0xEE1D92A39CF8E1E6(iParam0)) { if (unk_0x456C91FDAFEEF560(iParam0)) { if (!unk_0x8C6BE3ED9638F314(unk_0x6471F4759775FCA4(iParam0))) { unk_0x4985CD0720AFD468(iParam0, 0, 1); *uParam1 = 1; } } } if (unk_0x9984C023D4E57C2E(iParam0, 0)) { if (unk_0xA6BE8F025C6B653F(iParam0)) { return 1; } } } return 0; } void func_127() { SYSTEM::WAIT(0); } void func_128() { var uVar0; var uVar1; if (Local_160.f_16 == 0 && unk_0x234B68AC2E35ED5A(Local_64.f_84.f_1, 1)) { unk_0x6E1E3A5B1F9AB95B(250); } func_103(-1); if (func_136()) { func_135(0); } unk_0xD6ABECE3CBB224B0(1); unk_0x97D6BA3D63E00279(); unk_0x0471F84E07D156D1(); uVar0 = unk_0x7D2B9E6A64637269(); if (func_134(uVar0) && unk_0xC49311A2A500FF09(uVar0, 1)) { uVar1 = unk_0x75B58B38E45C6F9A(unk_0x7D2B9E6A64637269(), 0); if (unk_0xA6BE8F025C6B653F(uVar1)) { unk_0x32051C1124051B7B(iVar1, 1); func_132(1); } } if (unk_0x234B68AC2E35ED5A(Local_160.f_60, 4)) { func_131(); } unk_0x5E966E6F3D296D4B(); unk_0x53DE24D8A6C88A9A(); if (Local_160.f_57) { unk_0x9318BB548FEB68C5(); } func_130(Local_160.f_38); func_130(Local_160.f_39); Global_2518662 = 0; Global_2518763 = 0; func_129(); } void func_129() { unk_0x4BFE89D21F9885DC(); } void func_130(var uParam0) { if (unk_0x575B7C28D81C0B4D(uParam0)) { unk_0x1AD5BCFEC31BB8D9(&uParam0); } } void func_131() { if (Global_2441237.f_1274.f_10) { Global_2441237.f_1274.f_10 = 0; } } void func_132(int iParam0) { var uVar0; if (Global_2405077.f_2688 == 1) { Global_2405077.f_2688 = 0; return; } if (unk_0xC49311A2A500FF09(unk_0x7D2B9E6A64637269(), 0)) { if (!Global_2405077.f_2690.f_1) { if (!Global_2405077.f_2686 == -1) { if (((Global_2405077.f_2686 < 255 && !func_133()) && !unk_0x234B68AC2E35ED5A(Global_4456448.f_134001, 0)) && !(unk_0x38684A9B76A50D6A() && (Global_2405077.f_2687 == 0 && iParam0 == 0))) { unk_0x1817E299AF9979DE(Global_2405077.f_2686); } else if (Global_2405077.f_2686 >= 255) { unk_0x28914D795612530C("OFF"); uVar0 = unk_0x75B58B38E45C6F9A(unk_0x7D2B9E6A64637269(), 0); if (unk_0x419E13582192CFEA(uVar0)) { if (unk_0xA6BE8F025C6B653F(iVar0)) { unk_0x3D72B9992AD4B7C5(iVar0, "OFF"); } } } } Global_2405077.f_2686 = -1; Global_2405077.f_2690.f_1 = 1; } } } bool func_133() { return Global_1626819; } int func_134(int iParam0) { if (unk_0x419E13582192CFEA(uParam0)) { if (!unk_0xE50EB54E0F21BED0(iParam0, 0)) { return 1; } } return 0; } void func_135(int iParam0) { Global_2465786 = iParam0; } bool func_136() { return Global_2465786; } void func_137(var uParam0) { unk_0x191DDA30577F440A(&Global_2518763, 2); if (unk_0x02BFF15CAA701972()) { unk_0x35BEDD7AFD26FCD5(32, 0, -1); func_155(0, -1, 0); } else { func_128(); } func_138(uParam0); } void func_138(var uParam0) { var uVar0; var uVar1; Local_64.f_88 = { *uParam0 }; Local_64.f_91 = { uParam0->f_3 }; Local_64.f_94 = uParam0->f_6; Local_64.f_95 = uParam0->f_7; Local_160.f_22.f_4 = -1; uVar0 = unk_0x7D2B9E6A64637269(); if (func_134(uVar0) && unk_0xC49311A2A500FF09(uVar0, 1)) { uVar1 = unk_0x75B58B38E45C6F9A(unk_0x7D2B9E6A64637269(), 0); if (unk_0xA6BE8F025C6B653F(uVar1)) { func_154(1); unk_0x32051C1124051B7B(iVar1, 0); } } if (!func_153()) { unk_0x191DDA30577F440A(&(Local_160.f_60), 4); func_152(); } func_139(); } void func_139() { if (!unk_0x234B68AC2E35ED5A(Global_2518761, 0)) { func_151(-1028390912, 1119092736, -1036779520, 1110704128, 1106247680, 1114636288); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 1)) { func_150(1058642330, 1101004800); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 2)) { func_149(); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 3)) { func_147(1, 1, 0, 500); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 4)) { func_146(0); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 5)) { func_145(0); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 6)) { func_144(0); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 7)) { unk_0x191DDA30577F440A(&Global_2518761, 7); Global_2518675.f_24 = 0; } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 8)) { func_143(0); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 9)) { func_142(0f, 0f, 0f); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 10)) { unk_0x191DDA30577F440A(&Global_2518761, 10); Global_2518675.f_74 = 0; } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 11)) { func_141(0); } if (!unk_0x234B68AC2E35ED5A(Global_2518761, 12)) { func_140(1, 3, 3, 3); } Local_64 = { Global_2518675 }; func_97(Global_2518761); func_107(0); } void func_140(int iParam0, int iParam1, int iParam2, int iParam3) { unk_0x191DDA30577F440A(&Global_2518761, 12); Global_2518675.f_20 = iParam0; Global_2518675.f_20.f_1 = iParam1; Global_2518675.f_20.f_2 = iParam2; Global_2518675.f_20.f_3 = iParam3; } void func_141(char* sParam0) { unk_0x191DDA30577F440A(&Global_2518761, 11); StringCopy(&(Global_2518675.f_80), sParam0, 16); } void func_142(struct<3> Param0) { unk_0x191DDA30577F440A(&Global_2518761, 9); Global_2518675.f_71 = { Param0 }; } void func_143(char* sParam0) { unk_0x191DDA30577F440A(&Global_2518761, 8); StringCopy(&(Global_2518675.f_67), sParam0, 16); } void func_144(int iParam0) { unk_0x191DDA30577F440A(&Global_2518761, 6); Global_2518675.f_19 = iParam0; } void func_145(int iParam0) { unk_0x191DDA30577F440A(&Global_2518761, 5); Global_2518675.f_18 = iParam0; } void func_146(int iParam0) { unk_0x191DDA30577F440A(&Global_2518761, 4); Global_2518675.f_17 = iParam0; } void func_147(bool bParam0, bool bParam1, bool bParam2, int iParam3) { unk_0x191DDA30577F440A(&Global_2518761, 3); Global_2518675.f_84 = iParam3; func_148(&(Global_2518675.f_84.f_1), 1, bParam0); func_148(&(Global_2518675.f_84.f_1), 2, bParam1); func_148(&(Global_2518675.f_84.f_1), 0, bParam2); } void func_148(var uParam0, int iParam1, bool bParam2) { if (bParam2) { unk_0x191DDA30577F440A(uParam0, iParam1); } else { unk_0xC664C0067EEAB8D1(uParam0, iParam1); } } void func_149() { unk_0x191DDA30577F440A(&Global_2518761, 2); Global_2518675.f_8.f_1 = 0; } void func_150(int iParam0, int iParam1) { unk_0x191DDA30577F440A(&Global_2518761, 1); Global_2518675.f_6.f_1 = iParam0; Global_2518675.f_6 = iParam1; } void func_151(int iParam0, int iParam1, int iParam2, int iParam3, int iParam4, int iParam5) { unk_0x191DDA30577F440A(&Global_2518761, 0); Global_2518675 = iParam0; Global_2518675.f_1 = iParam1; Global_2518675.f_2 = iParam2; Global_2518675.f_3 = iParam3; Global_2518675.f_4 = iParam4; Global_2518675.f_5 = iParam5; } void func_152() { if (!Global_2441237.f_1274.f_10) { Global_2441237.f_1274.f_10 = 1; } } bool func_153() { return Global_2441237.f_1274.f_10; } void func_154(int iParam0) { int iVar0; iVar0 = Global_2405077.f_2689; if ((unk_0x38684A9B76A50D6A() && Global_2405077.f_2687 == 0) && iParam0 == 0) { iVar0 = 255; } if (!iVar0 == Global_2405077.f_2686) { if (!unk_0x1275587246A96F24()) { Global_2405077.f_2686 = iVar0; } } } int func_155(int iParam0, int iParam1, bool bParam2) { int iVar0; iVar0 = unk_0x41BB6B0BDB7933FF(); while (iVar0 != 2) { if (((iVar0 == 3 || iVar0 == 4) || iVar0 == 5) || iVar0 == 6) { if (!bParam2) { func_129(); } else { return 0; } } if (!func_156()) { if (iParam0 == 0) { if (!unk_0x02BFF15CAA701972()) { if (!bParam2) { func_129(); } else { return 0; } } if (func_123()) { if (!bParam2) { func_129(); } else { return 0; } } if (func_121(157)) { if (!bParam2) { func_129(); } else { return 0; } } } else if (!unk_0x930F75DAF7DE892B()) { if (!bParam2) { func_129(); } else { return 0; } } } SYSTEM::WAIT(0); iVar0 = unk_0x41BB6B0BDB7933FF(); } if (iParam1 > -1) { Global_1312519 = iVar0; } if (iParam0 == 0) { if (!unk_0x02BFF15CAA701972()) { if (!bParam2) { func_129(); } else { return 0; } } } else if (!unk_0x930F75DAF7DE892B()) { if (!bParam2) { func_129(); } else { return 0; } } return 1; } bool func_156() { return Global_1312878; }
20.900948
523
0.621099
[ "vector" ]
b9f6294bee69e14b04a8cfe6441f5a6546bd4a7f
2,846
h
C
deprecated/include/Graphics/Text/FontRenderer.h
Arzana/Plutonium
5a17c93e5072ac291b96347a4df196e1609fabe2
[ "MIT" ]
4
2019-03-21T16:02:03.000Z
2020-04-09T08:53:29.000Z
deprecated/include/Graphics/Text/FontRenderer.h
Arzana/Plutonium
5a17c93e5072ac291b96347a4df196e1609fabe2
[ "MIT" ]
24
2018-04-06T08:25:17.000Z
2020-10-19T11:01:09.000Z
deprecated/include/Graphics/Text/FontRenderer.h
Arzana/Plutonium
5a17c93e5072ac291b96347a4df196e1609fabe2
[ "MIT" ]
null
null
null
#pragma once #include "Graphics\Rendering\Shader.h" #include "Graphics\Native\Buffer.h" #include "Game.h" #include "Font.h" #include <vector> namespace Plutonium { /* Defines a helper object for rendering text. */ class FontRenderer { public: /* Initializes a new instance of a font renderer. */ FontRenderer(_In_ Game *game, _In_ const char *font, _In_ const char *vrtxShdr, _In_ const char *fragShdr, _In_ int loadWeight); FontRenderer(_In_ const FontRenderer &value) = delete; FontRenderer(_In_ FontRenderer &&value) = delete; /* Releases the resources allocated by the font renderer. */ ~FontRenderer(void); _Check_return_ FontRenderer& operator =(_In_ const FontRenderer &other) = delete; _Check_return_ FontRenderer& operator =(_In_ FontRenderer &&other) = delete; /* Adds a string to the font renderer to be rendered in the next frame. */ void AddString(_In_ Vector2 pos, _In_ const char *str, _In_ Color clr = Color::White()); /* Adds a string to the font renderer to be rendered in the next frame. */ void AddString(_In_ Vector2 pos, _In_ const char32 *str, _In_ Color clr = Color::White()); /* Renders the strings specified throughout the frame. */ virtual void Render(void); /* Gets the font used by this renderer. */ _Check_return_ inline const Font* GetFont(void) const { return font; } protected: /* Defines the rendering attributes for a string. */ struct LineInfo { /* The string to render, */ const char32 *String; /* Where to render the string(top-left). */ Vector2 Position; /* The color of the string. */ Color Color; /* Initializes a new instance. */ LineInfo(_In_ const char *string, _In_ Vector2 pos, _In_ Plutonium::Color clr); LineInfo(_In_ const char32 *string, _In_ Vector2 pos, _In_ Plutonium::Color clr); LineInfo(_In_ const LineInfo &value) = delete; LineInfo(_In_ LineInfo &&value) = delete; /* Releases the underlying string. */ ~LineInfo(void) noexcept; _Check_return_ LineInfo& operator =(_In_ const LineInfo &other) = delete; _Check_return_ LineInfo& operator =(_In_ LineInfo &&other) = delete; }; /* The font used by the renderer. */ Font *font; /* A buffer for storing the strings. */ std::vector<LineInfo*> strs; /* The game associated with the renderer. */ Game *parent; private: Buffer *vbo; Shader *shdr; Uniform *clr; Uniform *tex; Uniform *wvp; Attribute *pos; Matrix proj; float percentage; void RenderString(LineInfo *info); void UpdateVBO(Vector2 pos, const char32 *str); void AddSingleString(Vector2 pos, const char *str, Color clr); void AddSingleString(Vector2 pos, const char32 *str, Color clr); void WindowResizeEventHandler(WindowHandler sender, EventArgs); void ClearBuffer(void); void OnLoadComplete(const AssetLoader*, Font *result); }; }
32.712644
130
0.711174
[ "render", "object", "vector" ]
6a1019a4ed9a84603232f36ae25846ee4aed8987
4,336
h
C
include/dukat/mathutil.h
bdamer/dukat
e138893b1c7e28ef50c19f256bae98a79d22f9c5
[ "MIT" ]
4
2019-05-20T18:30:36.000Z
2021-10-01T15:54:59.000Z
include/dukat/mathutil.h
bdamer/dukat
e138893b1c7e28ef50c19f256bae98a79d22f9c5
[ "MIT" ]
19
2017-02-20T23:54:34.000Z
2021-09-30T05:43:49.000Z
include/dukat/mathutil.h
bdamer/dukat
e138893b1c7e28ef50c19f256bae98a79d22f9c5
[ "MIT" ]
2
2020-06-05T07:18:23.000Z
2021-10-01T15:55:02.000Z
#pragma once #include <cmath> #include <climits> #include <random> namespace dukat { static constexpr float pi = 3.14159265f; static constexpr float two_pi = pi * 2.0f; static constexpr float pi_over_two = pi / 2.0f; static constexpr float pi_over_three = pi / 3.0f; static constexpr float pi_over_four = pi / 4.0f; static constexpr float pi_over_six = pi / 6.0f; static constexpr float pi_over_eight = pi / 8.0f; static constexpr float one_over_pi = 1.0f / pi; static constexpr float one_over_two_pi = 1.0f / two_pi; static constexpr float small_number = 0.000001f; static constexpr float big_number = 1e37f; static constexpr float no_intersection = 1e30f; // Fast inverse square root. float inv_sqrt(float number); // "Wrap an angle in range -PI...PI by adding the correct multiple of 2 PI float wrap_pi(float theta); // "Safe" inverse trig functions // Same as acos(x), but if x is out of range, it is "clamped" to the nearest // valid value. The value returned is in range 0...PI, the same as the // standard C acos function. float safe_acos(float x); // Compute the sin and cosine of an angle. On some platforms, if we know // that we need both values, it can be computed faster than computing the // two values seperately. inline void sin_cos(float &return_sin, float& return_cos, float theta) { // For simplicity, we'll just use the normal trig functions. // Not that on some platforms we may be able to do better. return_sin = std::sin(theta); return_cos = std::cos(theta); } // Fast sin / cos based on lookup tables. float fast_sin(float value); float fast_cos(float value); // convert degrees to radians and back inline float deg_to_rad(float x) { return (x*pi)/180.0f; } inline float rad_to_deg(float x) { return (x*180.0f)/pi; } // Returns the next value greater than v that is a power of 2. inline int next_pow_two(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; return ++v; } // Rounds r to the next integer. inline int round(float r) { return static_cast<int>(r > 0.0f ? (r + 0.5f) : (r - 0.5f)); } // Rounds r to the next multiple of base. inline float round(float r, float base) { if (base != 0.f && r != 0.f) { const auto sign = r > 0.f ? 1.f : -1.f; r *= sign; r /= base; const auto fixed_point = static_cast<int>(std::ceil(r)); r = fixed_point * base; r *= sign; } return r; } // Returns the positive modulo value. inline int pos_mod(int i, int n) { return (i % n + n) % n; } // normalizes the value of an angle between 0 and 2 pi inline void normalize_angle(float& angle) { if (angle < 0) angle += two_pi; else if (angle > two_pi) angle -= two_pi; } // computes the smallest angle between two angles. inline float angle_delta(float a, float b) { float diff = a - b; while (diff < pi) diff += two_pi; while (diff > pi) diff -= two_pi; return diff; } template<typename T> inline void clamp(T& value, const T min, const T max) { if (value < min) value = min; else if (value > max) value = max; } inline float normalize(int value, int max_value = INT_MAX) { return static_cast<float>(value) / static_cast<float>(max_value); } inline float normalize(short value, short max_value = SHRT_MAX) { return static_cast<float>(value) / static_cast<float>(max_value); } inline float normalize(char value, char max_value = CHAR_MAX) { return static_cast<float>(value) / static_cast<float>(max_value); } inline float normalize(unsigned char value) { return static_cast<float>(value) / 255.0f; } template <typename T> inline T denormalize(float value, T max_value) { return static_cast<T>(value * static_cast<float>(max_value)); } template <typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); } // Returns linear interpolation between p and q. template<typename T> T lerp(const T& p, const T& q, float t) { return p + (q - p) * t; } // Generates distribution of values within range [min_val..max_val] into data. template <typename T> void generate_distribution(std::vector<T>& data, T min_val, T max_val) { std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<T> dist(min_val, max_val); for (auto& el : data) el = dist(gen); } }
26.120482
79
0.669972
[ "vector" ]
6a165159ca6b92329a35f66611742f94b5df1ed4
250
c
C
popendemo.c
deweixu/ulcdemo
f96db1da72ac5a86d5156587015f7d6abc162666
[ "MIT" ]
2
2017-03-31T02:35:14.000Z
2017-03-31T15:05:15.000Z
popendemo.c
deweixu/ulcdemo
f96db1da72ac5a86d5156587015f7d6abc162666
[ "MIT" ]
null
null
null
popendemo.c
deweixu/ulcdemo
f96db1da72ac5a86d5156587015f7d6abc162666
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> int main() { FILE *fp = NULL; char buf[100]; int i = 0; fp = popen("who|sort", "r"); while (fgets(buf, 100, fp) != NULL) printf("%3d %s", i++, buf); pclose(fp); return 0; }
15.625
39
0.496
[ "3d" ]
6a21a6daf4b2a284cbaf4be5d7c234b10e23d375
18,597
c
C
tests.c
quietboil/jspp
29edd065ddec7e2bee2d4620a6ec013cc431f64f
[ "MIT" ]
1
2018-12-03T10:46:51.000Z
2018-12-03T10:46:51.000Z
tests.c
quietboil/jspp
29edd065ddec7e2bee2d4620a6ec013cc431f64f
[ "MIT" ]
null
null
null
tests.c
quietboil/jspp
29edd065ddec7e2bee2d4620a6ec013cc431f64f
[ "MIT" ]
null
null
null
#include "test.h" #include "jspp.h" #include <string.h> #include <stdio.h> #define check_text(v) \ text = jspp_text(&parser, &length); \ check(length == sizeof(v) - 1); \ check(strncmp(text, v, length) == 0) static int parse_simple_json() { jspp_t parser; const char * text; uint16_t length; check(JSON_NULL == jspp_start(&parser, "null", 4)); check(JSON_NULL == jspp_start(&parser, "\n null\n", 10)); check(JSON_TRUE == jspp_start(&parser, "true", 4)); check(JSON_FALSE == jspp_start(&parser, "false", 5)); check(JSON_STRING == jspp_start(&parser, "\n \"Hello, World!\"\n\n", 22)); check_text("Hello, World!"); check(JSON_STRING == jspp_start(&parser, "\n \"Hello\\n,\\t\\\"World\\\"!\"\n\n", 28)); check_text("Hello\\n,\\t\\\"World\\\"!"); return 0; } static int parse_split_string() { const char * json[] = { "\n \n \n \"\\\"Hello, ", "World!\\\" is often used to illustrate", "a basic working program.\"\n\n\n" }; jspp_t parser; const char * text; uint16_t length; check(JSON_STRING_PART == jspp_start(&parser, json[0], strlen(json[0]))); check_text("\\\"Hello, "); check(JSON_STRING_PART == jspp_continue(&parser, json[1], strlen(json[1]))); check_text("World!\\\" is often used to illustrate"); check(JSON_STRING == jspp_continue(&parser, json[2], strlen(json[2]))); check_text("a basic working program."); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_split_null() { const char * json[] = { " nu", "ll with some trailing text..." }; jspp_t parser; check(JSON_CONTINUE == jspp_start(&parser, json[0], strlen(json[0]))); check(JSON_NULL == jspp_continue(&parser, json[1], strlen(json[1]))); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_invalid_elements() { jspp_t parser; check(JSON_INVALID == jspp_start(&parser, " NULL ", 7)); check(JSON_INVALID == jspp_start(&parser, " nulL ", 7)); check(JSON_INVALID == jspp_start(&parser, " True ", 7)); check(JSON_INVALID == jspp_start(&parser, " trUe ", 7)); check(JSON_INVALID == jspp_start(&parser, " False ", 7)); check(JSON_INVALID == jspp_start(&parser, " faLse ", 7)); check(JSON_INVALID == jspp_start(&parser, " falsE ", 7)); return 0; } static int parse_numbers() { jspp_t parser; const char * text; uint16_t length; check(JSON_INTEGER == jspp_start(&parser, " 12345 ", 7)); check_text("12345"); check(JSON_END == jspp_next(&parser)); check(JSON_INTEGER == jspp_start(&parser, " -1234 ", 7)); check_text("-1234"); check(JSON_END == jspp_next(&parser)); check(JSON_DECIMAL == jspp_start(&parser, " 12.34 ", 7)); check_text("12.34"); check(JSON_END == jspp_next(&parser)); check(JSON_DECIMAL == jspp_start(&parser, " -1.23 ", 7)); check_text("-1.23"); check(JSON_END == jspp_next(&parser)); check(JSON_FLOATING_POINT == jspp_start(&parser, " 12e34 ", 7)); check_text("12e34"); check(JSON_END == jspp_next(&parser)); check(JSON_FLOATING_POINT == jspp_start(&parser, " 12E34 ", 7)); check_text("12E34"); check(JSON_END == jspp_next(&parser)); check(JSON_FLOATING_POINT == jspp_start(&parser, " 1.2e3 ", 7)); check_text("1.2e3"); check(JSON_END == jspp_next(&parser)); check(JSON_FLOATING_POINT == jspp_start(&parser, " -1.23e-45 ", 11)); check_text("-1.23e-45"); check(JSON_END == jspp_next(&parser)); check(JSON_FLOATING_POINT == jspp_start(&parser, " -1.23e+45 ", 11)); check_text("-1.23e+45"); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_split_numbers() { jspp_t parser; const char * text; uint16_t length; check(JSON_NUMBER_PART == jspp_start(&parser, " 123456", 7)); check_text("123456"); check(JSON_INTEGER == jspp_continue(&parser, "7890 ", 7)); check_text("7890"); check(JSON_END == jspp_next(&parser)); check(JSON_NUMBER_PART == jspp_start(&parser, " 123456", 7)); check_text("123456"); check(JSON_DECIMAL == jspp_continue(&parser, "789.0 ", 7)); check_text("789.0"); check(JSON_END == jspp_next(&parser)); check(JSON_NUMBER_PART == jspp_start(&parser, " 1.2345", 7)); check_text("1.2345"); check(JSON_FLOATING_POINT == jspp_continue(&parser, "6e-78 ", 7)); check_text("6e-78"); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_array() { jspp_t parser; const char * text; uint16_t length; check(JSON_ARRAY_BEGIN == jspp_start(&parser, " [ ] ", 5)); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); check(JSON_ARRAY_BEGIN == jspp_start(&parser, "[[],[]]", 7)); check(JSON_ARRAY_BEGIN == jspp_next(&parser)); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_ARRAY_BEGIN == jspp_next(&parser)); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); check(JSON_ARRAY_BEGIN == jspp_start(&parser, " [ 43, true, \"ok\" ] ", 20)); check(JSON_INTEGER == jspp_next(&parser)); check_text("43"); check(JSON_TRUE == jspp_next(&parser)); check(JSON_STRING == jspp_next(&parser)); check_text("ok"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); check(JSON_ARRAY_BEGIN == jspp_start(&parser, " [ 29, [ \"yes\", \"no\" ], [ 1, 2.3 ] ] ", 37)); check(JSON_INTEGER == jspp_next(&parser)); check_text("29"); check(JSON_ARRAY_BEGIN == jspp_next(&parser)); check(JSON_STRING == jspp_next(&parser)); check_text("yes"); check(JSON_STRING == jspp_next(&parser)); check_text("no"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_ARRAY_BEGIN == jspp_next(&parser)); check(JSON_INTEGER == jspp_next(&parser)); check_text("1"); check(JSON_DECIMAL == jspp_next(&parser)); check_text("2.3"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_split_array() { const char * json[] = { " [ 29, [ \"yes\", \"n", "o\", \"whatever\" ], [ 1, 2.3 ] ] " }; jspp_t parser; const char * text; uint16_t length; check(JSON_ARRAY_BEGIN == jspp_start(&parser, json[0], strlen(json[0]))); check(JSON_INTEGER == jspp_next(&parser)); check_text("29"); check(JSON_ARRAY_BEGIN == jspp_next(&parser)); check(JSON_STRING == jspp_next(&parser)); check_text("yes"); check(JSON_STRING_PART == jspp_next(&parser)); check_text("n"); check(JSON_STRING == jspp_continue(&parser, json[1], strlen(json[1]))); check_text("o"); check(JSON_STRING == jspp_next(&parser)); check_text("whatever"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_ARRAY_BEGIN == jspp_next(&parser)); check(JSON_INTEGER == jspp_next(&parser)); check_text("1"); check(JSON_DECIMAL == jspp_next(&parser)); check_text("2.3"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_object() { jspp_t parser; const char * text; uint16_t length; check(JSON_OBJECT_BEGIN == jspp_start(&parser, " { } ", 5)); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); check(JSON_OBJECT_BEGIN == jspp_start(&parser, " { \"answer\": 42 } ", 18)); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("answer"); check(JSON_INTEGER == jspp_next(&parser)); check_text("42"); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); const char json[] = "{ \"property\": \"The White House\", " " \"owner\": \"National Park Service\", " " \"address\": { " " \"street\": { " " \"number\": 1600, " " \"name\": \"Pennsylvania Avenue\", " " \"direction\": \"NW\" " " }, " " \"city\": \"Washington\", " " \"region\": \"DC\", " " \"zip\": \"20500\" " " }" "}" ; check(JSON_OBJECT_BEGIN == jspp_start(&parser, json, sizeof(json) - 1)); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("property"); check(JSON_STRING == jspp_next(&parser)); check_text("The White House"); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("owner"); check(JSON_STRING == jspp_next(&parser)); check_text("National Park Service"); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("address"); check(JSON_OBJECT_BEGIN == jspp_next(&parser)); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("street"); check(JSON_OBJECT_BEGIN == jspp_next(&parser)); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("number"); check(JSON_INTEGER == jspp_next(&parser)); check_text("1600"); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("name"); check(JSON_STRING == jspp_next(&parser)); check_text("Pennsylvania Avenue"); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("direction"); check(JSON_STRING == jspp_next(&parser)); check_text("NW"); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("city"); check(JSON_STRING == jspp_next(&parser)); check_text("Washington"); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("region"); check(JSON_STRING == jspp_next(&parser)); check_text("DC"); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("zip"); check(JSON_STRING == jspp_next(&parser)); check_text("20500"); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } static int parse_split_object() { const char * json[] = { " { \"question\": \"What do you get wh", "en you multiply six by nine\", \"ans", "wer\": 42 } " }; #define MAX_MEMBER_NAME_LENGTH 8 char name[MAX_MEMBER_NAME_LENGTH + 1]; uint16_t name_length; jspp_t parser; const char * text; uint16_t length; check(JSON_OBJECT_BEGIN == jspp_start(&parser, json[0], strlen(json[0]))); check(JSON_MEMBER_NAME == jspp_next(&parser)); check_text("question"); check(JSON_STRING_PART == jspp_next(&parser)); check_text("What do you get wh"); // The next call is unnecessary as previous code - PART - already signalled the // end of the fragment. However in case it is easier to check for one condition // parser also will keep returning CONTINUE until it is fed more data check(JSON_CONTINUE == jspp_next(&parser)); check(JSON_STRING == jspp_continue(&parser, json[1], strlen(json[1]))); check_text("en you multiply six by nine"); check(JSON_MEMBER_NAME_PART == jspp_next(&parser)); text = jspp_text(&parser, &length); // assemble it from parts strncpy(name, text, length); name_length = length; check(JSON_CONTINUE == jspp_next(&parser)); check(JSON_MEMBER_NAME == jspp_continue(&parser, json[2], strlen(json[2]))); text = jspp_text(&parser, &length); // add the tail strncpy(name + name_length, text, length); name_length += length; check(name_length == 6); check(strncmp(name, "answer", name_length) == 0); check(JSON_INTEGER == jspp_next(&parser)); check_text("42"); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } static int skip_elements() { jspp_t parser; const char * text; uint16_t length; const char json1[] = "{ \"status\": \"ok\", \"a\": 1, \"b\": 2, \"c\": 3, \"x\": 42, \"y\": 87, \"z\": 99 }"; check(JSON_OBJECT_BEGIN == jspp_start(&parser, json1, sizeof(json1) - 1)); // we know that it starts with the "status", which we do no need, so let's skip it altogether check(JSON_MEMBER_NAME == jspp_skip_next(&parser)); // we are we now? check_text("a"); // skip the value of "a" as well uint8_t token = jspp_skip_next(&parser); check(JSON_MEMBER_NAME == token); // now, let's look for what we need while (token == JSON_MEMBER_NAME) { text = jspp_text(&parser, &length); if (strncmp("x", text, length) == 0) break; token = jspp_skip_next(&parser); } check(strncmp("x", text, length) == 0); check(JSON_INTEGER == jspp_next(&parser)); check_text("42"); // now look for "z" token = jspp_next(&parser); while (token == JSON_MEMBER_NAME) { text = jspp_text(&parser, &length); if (strncmp("z", text, length) == 0) break; token = jspp_skip_next(&parser); } check(strncmp("z", text, length) == 0); check(JSON_INTEGER == jspp_next(&parser)); check_text("99"); check(JSON_OBJECT_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); const char json2[] = "{ \"response\": { \"a\": 1, \"b\": { \"q\": \"aaa\", \"r\": 98.7 }, \"c\": [11,22,33,44]," " \"x\": 42 }, \"status\": \"ok\", \"rc\": 97 }"; check(JSON_OBJECT_BEGIN == jspp_start(&parser, json2, sizeof(json2) - 1)); // skip "response" check(JSON_MEMBER_NAME == jspp_skip_next(&parser)); check_text("status"); check(JSON_STRING == jspp_next(&parser)); check_text("ok"); check(JSON_OBJECT_END == jspp_skip_next(&parser)); check(JSON_END == jspp_next(&parser)); const char json31[] = "{ \"response\": { \"a\": 1, \"b\": { \"q\": \"aaa\", \"r\": 98.7 }, \"c\": [11,2"; const char json32[] = "2,33,44], \"x\": 42 }, \"status\": \"ok\", \"rc\": 97 }"; check(JSON_OBJECT_BEGIN == jspp_start(&parser, json31, sizeof(json31) - 1)); // skip "response" check(JSON_CONTINUE == jspp_skip_next(&parser)); check(JSON_MEMBER_NAME == jspp_continue(&parser, json32, sizeof(json32) - 1)); check_text("status"); check(JSON_STRING == jspp_next(&parser)); check_text("ok"); check(JSON_OBJECT_END == jspp_skip_next(&parser)); check(JSON_END == jspp_next(&parser)); const char json41[] = "{ \"response\": { \"a\": 1, \"b\": { \"q\": \"aaa\", \"r\": 98.7 }, \"c\": [11,22,33,44], \"x\": 42 }, \"sta"; const char json42[] = "tus\": \"ok\", \"rc\": 97 }"; check(JSON_OBJECT_BEGIN == jspp_start(&parser, json41, sizeof(json41) - 1)); // skip "response" check(JSON_MEMBER_NAME_PART == jspp_skip_next(&parser)); check_text("sta"); // skip "status" check(JSON_CONTINUE == jspp_skip_next(&parser)); check(JSON_MEMBER_NAME == jspp_continue(&parser, json42, sizeof(json42) - 1)); check_text("rc"); check(JSON_INTEGER == jspp_next(&parser)); check_text("97"); check(JSON_OBJECT_END == jspp_skip_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } // test token ID re-ordering regression fix static int skip_split_values() { jspp_t parser; const char * text; uint16_t length; const char json11[] = "[ 659, 72"; const char json12[] = "7, 929]"; check(JSON_ARRAY_BEGIN == jspp_start(&parser, json11, sizeof(json11) - 1)); check(JSON_INTEGER == jspp_next(&parser)); check_text("659"); check(JSON_CONTINUE == jspp_skip_next(&parser)); check(JSON_INTEGER == jspp_continue(&parser, json12, sizeof(json12) - 1)); check_text("929"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); const char json21[] = "[ \"abc\", \"de"; const char json22[] = "f\", \"klm\"]"; check(JSON_ARRAY_BEGIN == jspp_start(&parser, json21, sizeof(json21) - 1)); check(JSON_STRING == jspp_next(&parser)); check_text("abc"); check(JSON_CONTINUE == jspp_skip_next(&parser)); check(JSON_STRING == jspp_continue(&parser, json22, sizeof(json22) - 1)); check_text("klm"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } static int skip_current() { jspp_t parser; const char * text; uint16_t length; const char json11[] = "[ 659, { \"name\": \"unexpected\", \"value\": 727 }, 929]"; check(JSON_ARRAY_BEGIN == jspp_start(&parser, json11, sizeof(json11) - 1)); check(JSON_INTEGER == jspp_next(&parser)); check_text("659"); check(JSON_OBJECT_BEGIN == jspp_next(&parser)); check(JSON_INTEGER == jspp_skip(&parser)); check_text("929"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); const char json21[] = "[ \"abc\", \"de"; const char json22[] = "f\", \"klm\"]"; check(JSON_ARRAY_BEGIN == jspp_start(&parser, json21, sizeof(json21) - 1)); check(JSON_STRING == jspp_next(&parser)); check_text("abc"); check(JSON_STRING_PART == jspp_next(&parser)); check(JSON_CONTINUE == jspp_skip(&parser)); check(JSON_STRING == jspp_continue(&parser, json22, sizeof(json22) - 1)); check_text("klm"); check(JSON_ARRAY_END == jspp_next(&parser)); check(JSON_END == jspp_next(&parser)); return 0; } int main() { test(parse_simple_json, "Parse a one element JSON"); test(parse_split_string, "Parse a string that spans several data transmission fragments"); test(parse_split_null, "Parse null that is split in two halves"); test(parse_invalid_elements, "Reject JSON with a single non-conforming element"); test(parse_numbers, "Parse a single element JSON(s) with various (formats of) numbers"); test(parse_split_numbers, "Parse numbers split between transmission fragments"); test(parse_array, "Parse JSON arrays"); test(parse_split_array, "Parse array that continues in another transmission fragment"); test(parse_object, "Parse JSON objects"); test(parse_split_object, "Parse object split between transmission fragments"); test(skip_elements, "Skip JSON elements"); test(skip_split_values, "Skip split numbers and strings"); test(skip_current, "Skip current element"); printf("DONE: %d/%d\n", num_tests_passed, num_tests_passed + num_tests_failed); return num_tests_failed > 0; }
33.751361
137
0.618756
[ "object" ]
6a23c8063abcc895a2e41e0883f5e807ba1a7878
11,335
c
C
moves.c
myconundrum/chess
eb05c28c0d6aebce97f28beed761ba5041b87799
[ "MIT" ]
null
null
null
moves.c
myconundrum/chess
eb05c28c0d6aebce97f28beed761ba5041b87799
[ "MIT" ]
null
null
null
moves.c
myconundrum/chess
eb05c28c0d6aebce97f28beed761ba5041b87799
[ "MIT" ]
null
null
null
#include "chess.h" uint64_t g_kingMoves[64]; uint64_t g_knightMoves[64]; uint64_t g_rookMoves[64]; // Implementing Kingergarten Multiplication for our slider move generators. uint8_t g_rankMoves[8][256]; MOVELIST g_moveList; uint64_t g_kCastleMasks[2]; uint64_t g_qCastleMasks[2]; void movegen_clearMoves(POSITION *pos) { memset(pos->moves,0,sizeof(pos->moves)); pos->moveCount = 0; } void movegen_addCastleMove(POSITION *pos, int color, bool kSide) { pos->moves[pos->moveCount].color = color; pos->moves[pos->moveCount].kCastle = kSide; pos->moves[pos->moveCount].from = color == WHITE ? E1 : E8; if (kSide) { pos->moves[pos->moveCount].to = color == WHITE ? G1 : G8; } else { pos->moves[pos->moveCount].to = color == WHITE ? C1 : C8; } pos->moves[pos->moveCount++].qCastle = !kSide; } void movegen_addMove(POSITION *pos, int color, int piece, int from, int to, bool capture) { pos->moves[pos->moveCount].color = color; pos->moves[pos->moveCount].piece = piece; pos->moves[pos->moveCount].from = from; pos->moves[pos->moveCount].to = to; // // if this is a capture, find the captured piece. // Note: EP captures show up as a bool flag (epcapture) vs a capture in the move list. // if (capture) { pos = eng_curPosition(); for (PIECES p = PAWN ; p < PMAX; p++) { if (SQUAREMASKS[to] & pos->pieces[OPPONENT(color)][p]) { pos->moves[pos->moveCount].capture = p; break; } } } pos->moveCount++; } void movegen_addPawnMove(POSITION *pos, int color, int piece, int from, int to, bool capture, bool epCapture, bool epMove) { // // Check to see if this is a pawn promotion, and generate all promotion possibilities if so. // if (RANKMASKS[color == WHITE ? 7 : 0] & SQUAREMASKS[to]) { for (PIECES p = KNIGHT; p < KING; p++) { pos->moves[pos->moveCount].promotion = p; movegen_addMove(pos,color,piece,from,to,capture); } } else { pos->moves[pos->moveCount].epCapture = epCapture; pos->moves[pos->moveCount].epMove = epMove; movegen_addMove(pos,color,piece,from,to,capture); } } void movegen_king(POSITION *pos) { int from; int to; uint64_t m; uint64_t kings = pos->pieces[pos->toMove][KING]; uint64_t opp = pos->sides[OPPONENT(pos->toMove)]; while (kings) { // // normally, there would only be one king, however some puzzles and tests // will have more than one king on the board. // from = bitScanForward(kings); kings ^= SQUAREMASKS[from]; m = g_kingMoves[from] & ~pos->sides[pos->toMove]; // add candidate moves to movelist. while(m) { to = bitScanForward(m); m ^= SQUAREMASKS[to]; movegen_addMove(pos,pos->toMove,KING,from,to,SQUAREMASKS[to] & opp); } } } void movegen_knight(POSITION *pos) { int from; int to; uint64_t m; uint64_t knights = pos->pieces[pos->toMove][KNIGHT]; uint64_t opp = pos->sides[OPPONENT(pos->toMove)]; while (knights) { from = bitScanForward(knights); knights ^= SQUAREMASKS[from]; m = g_knightMoves[from] & ~pos->sides[pos->toMove]; // add candidate moves to movelist. while(m) { to = bitScanForward(m); m ^= SQUAREMASKS[to]; movegen_addMove(pos,pos->toMove,KNIGHT,from,to,SQUAREMASKS[to] & opp); } } } uint64_t movegen_getFileMoves(POSITION * pos, uint8_t sq) { uint8_t file = FILEFROMSQUARE(sq); uint64_t occ = AFILE_MASK & (pos->all >> file); uint64_t m; // map file to the 1st rank. occ = (occ * A1H8_MASK) >> 56; // map the rook position to the position on the 1st rank and look up the rank. m = g_rankMoves[(sq ^ 56) >> 3][occ]; // map back to the right file and return return (HFILE_MASK & (m * A1H8_MASK)) >> (file ^ 7); } uint64_t movegen_getRankMoves(POSITION *pos, uint8_t sq) { uint8_t file = sq & 7; uint8_t rank = sq >> 3; return ((uint64_t) g_rankMoves[file][(uint8_t )(pos->all >> (8*rank))] )<< (8*rank); } uint64_t movegen_getDiagonalMoves(POSITION *pos, uint8_t sq) { uint8_t file = sq & 7; // map diagonal in question to first rank. uint64_t occ = ((DIAGONALMASKS[sq] & pos->all) * AFILE_MASK) >> 56; // look up on first rank moves and then transform back to diagonal. uint64_t md = g_rankMoves[file][occ] * AFILE_MASK; uint64_t mad; occ = ((ANTIDIAGONALMASKS[sq] & pos->all) * AFILE_MASK) >> 56; mad = g_rankMoves[file][occ] * AFILE_MASK; return (md & DIAGONALMASKS[sq]) | (mad & ANTIDIAGONALMASKS[sq]); } void movegen_sliderDiagonal(POSITION *pos, PIECES piece) { uint64_t sliders = pos->pieces[pos->toMove][piece]; uint8_t from, to; uint64_t m; uint64_t opp = pos->sides[OPPONENT(pos->toMove)]; uint64_t self = pos->sides[pos->toMove]; while (sliders) { from = bitScanForward(sliders); sliders ^= SQUAREMASKS[from]; m = movegen_getDiagonalMoves(pos,from); while (m) { to = bitScanForward(m); m ^= SQUAREMASKS[to]; if ((SQUAREMASKS[to] & self) == 0) { movegen_addMove(pos,pos->toMove,piece,from,to,SQUAREMASKS[to] & opp); } } } } void movegen_castling(POSITION *pos) { if (pos->kCastle[pos->toMove] && ((g_kCastleMasks[pos->toMove] & pos->all) == 0)) { movegen_addCastleMove(pos,pos->toMove,true); } if (pos->qCastle[pos->toMove] && ((g_qCastleMasks[pos->toMove] & pos->all) == 0)) { movegen_addCastleMove(pos,pos->toMove,false); } } void movegen_sliderFileRank(POSITION *pos,PIECES piece) { uint64_t sliders = pos->pieces[pos->toMove][piece]; uint8_t from, to; uint64_t m; uint64_t opp = pos->sides[OPPONENT(pos->toMove)]; uint64_t self = pos->sides[pos->toMove]; while (sliders) { from = bitScanForward(sliders); sliders ^= SQUAREMASKS[from]; m = movegen_getRankMoves(pos,from); while (m) { to = bitScanForward(m); m ^= SQUAREMASKS[to]; if ((SQUAREMASKS[to] & self) == 0) { movegen_addMove(pos,pos->toMove,piece,from,to,SQUAREMASKS[to] & opp); } } m = movegen_getFileMoves(pos,from); while (m) { to = bitScanForward(m); m ^= SQUAREMASKS[to]; if ((SQUAREMASKS[to] & self) == 0) { movegen_addMove(pos,pos->toMove,piece,from,to,SQUAREMASKS[to] & opp); } } } } void movegen_queen(POSITION *pos) { movegen_sliderDiagonal(pos,QUEEN); movegen_sliderFileRank(pos,QUEEN); } void movegen_bishop(POSITION *pos) {movegen_sliderDiagonal(pos,BISHOP);} void movegen_rook(POSITION *pos) {movegen_sliderFileRank(pos,ROOK);} void movegen_blackPawn(POSITION *pos) { // potential 1 forward moves uint64_t m1 = SHIFTSOUTH(pos->pieces[BLACK][PAWN]); // potential 2 forward moves uint64_t m2; // potential left attacks (and EP left attacks) uint64_t al = SHIFTEAST(m1 & ~FILEMASKS[H]); uint64_t alep = al; // potential right attacks (and EP right attacks) uint64_t ar = SHIFTWEST(m1 & ~FILEMASKS[A]); uint64_t arep = ar; uint8_t sq; // only allow forward moves if it is not occupied. m1 = m1 & ~pos->all; // now check for possible two forward moves (both squares must not be occupied) m2 = SHIFTSOUTH(m1 & RANKMASKS[5]) & ~pos->all; // check for occupied squared for attacks. ar &= pos->sides[WHITE]; arep &= pos->ep; al &= pos->sides[WHITE]; alep &= pos->ep; // add candidate moves to movelist. while(m1) { sq = bitScanForward(m1); m1 ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,BLACK,PAWN,sq + NORTH, sq, false, false, false); } while(m2) { sq = bitScanForward(m2); m2 ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,BLACK,PAWN,sq + NORTH + NORTH, sq, false, false, false); } while(al) { sq = bitScanForward(al); al ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,BLACK,PAWN,sq + NORTHWEST, sq, true, false, false); } while(ar) { sq = bitScanForward(ar); ar ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,BLACK,PAWN,sq + NORTHEAST, sq, true, false, false); } while(alep) { sq = bitScanForward(alep); alep ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,BLACK,PAWN,sq + NORTHWEST, sq, false, true, false); } while(arep) { sq = bitScanForward(arep); arep ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,BLACK,PAWN,sq + NORTHEAST, sq, false, true, false); } } void movegen_whitePawn(POSITION *pos) { // potential 1 forward moves uint64_t m1 = SHIFTNORTH(pos->pieces[WHITE][PAWN]); // potential 2 forward moves uint64_t m2; // potential left attacks (and EP left attacks) uint64_t al = SHIFTWEST(m1 & ~FILEMASKS[A]); uint64_t alep = al; // potential right attacks (and EP right attacks) uint64_t ar = SHIFTEAST(m1 & ~FILEMASKS[H]); uint64_t arep = ar; uint8_t sq; // only allow forward moves if it is not occupied. m1 = m1 & ~pos->all; // now check for possible two forward moves (both squares must not be occupied) m2 = SHIFTNORTH(m1 & RANKMASKS[2]) & ~pos->all; // check for occupied squared for attacks. ar &= pos->sides[BLACK]; arep &= pos->ep; al &= pos->sides[BLACK]; alep &= pos->ep; // add candidate moves to movelist. while(m1) { sq = bitScanForward(m1); m1 ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,WHITE,PAWN,sq + SOUTH, sq, false, false, false); } while(m2) { sq = bitScanForward(m2); m2 ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,WHITE,PAWN,sq + SOUTH + SOUTH, sq, false, false, false); } while(al) { sq = bitScanForward(al); al ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,WHITE,PAWN,sq + SOUTHEAST, sq, true, false, false); } while(ar) { sq = bitScanForward(ar); ar ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,WHITE,PAWN,sq + SOUTHWEST, sq, true, false, false); } while(alep) { sq = bitScanForward(alep); alep ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,WHITE,PAWN,sq + SOUTHEAST, sq, false, true, false); } while(arep) { sq = bitScanForward(arep); arep ^= SQUAREMASKS[sq]; movegen_addPawnMove(pos,WHITE,PAWN,sq + SOUTHWEST, sq, false, true, false); } } void movegen_pawn(POSITION *pos) { if (pos->toMove == WHITE) { movegen_whitePawn(pos); } else { movegen_blackPawn(pos); } } void movegen_initRankMoves() { uint8_t test; memset(g_rankMoves,0,sizeof(g_rankMoves)); for (int i = 0; i < 8; i++) { for (int occ = 0; occ < 256; occ++) { // test left. test = 0x1 << i; while (test != 0x80) { test <<= 1; g_rankMoves[i][occ] |= test; if (test & occ) { break; } } // test right. test = 0x1 << i; while (test) { test >>= 1; g_rankMoves[i][occ] |= test; if (test & occ) { break; } } } } } void movegen_init() { memset(g_kingMoves,0,sizeof(g_kingMoves)); memset(g_knightMoves,0,sizeof(g_knightMoves)); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { if (DISTANCE(i,j) == 1) { g_kingMoves[i] |= SQUAREMASKS[j]; } if ((RANKDISTANCE(i,j) == 1 && FILEDISTANCE(i,j) == 2 )|| (RANKDISTANCE(i,j) == 2 && FILEDISTANCE(i,j) == 1 )) { g_knightMoves[i] |= SQUAREMASKS[j]; } if ((RANKDISTANCE(i,j) == 0 || FILEDISTANCE(i,j) == 0) && i != j) { g_rookMoves[i] |= SQUAREMASKS[j]; } } } g_kCastleMasks[WHITE] = BPOS(F1) | BPOS(G1); g_kCastleMasks[BLACK] = BPOS(F8) | BPOS(G8); g_qCastleMasks[WHITE] = BPOS(B1) | BPOS(C1) | BPOS(D1); g_qCastleMasks[BLACK] = BPOS(B8) | BPOS(C8) | BPOS(D8); movegen_initRankMoves(); } void movegen_generate(POSITION *pos) { movegen_clearMoves(pos); movegen_king(pos); movegen_queen(pos); movegen_rook(pos); movegen_bishop(pos); movegen_knight(pos); movegen_pawn(pos); movegen_castling(pos); }
24.428879
124
0.656815
[ "transform" ]
6a29cf6b86237f3a4df9a02036bf408e1ea95426
4,273
h
C
include/ED_Lib/ED.h
ruelj2/ED_Lib
b48add475f392dc70aec0098c61a3b0f7c6e2d8f
[ "MIT" ]
null
null
null
include/ED_Lib/ED.h
ruelj2/ED_Lib
b48add475f392dc70aec0098c61a3b0f7c6e2d8f
[ "MIT" ]
null
null
null
include/ED_Lib/ED.h
ruelj2/ED_Lib
b48add475f392dc70aec0098c61a3b0f7c6e2d8f
[ "MIT" ]
null
null
null
/************************************************************************************************************** * Edge Drawing (ED) and Edge Drawing Parameter Free (EDPF) source codes. * Copyright (C) Cihan Topal & Cuneyt Akinlar * E-mails of the authors: cihantopal@gmail.com, cuneytakinlar@gmail.com * * Please cite the following papers if you use Edge Drawing library: * * [1] C. Topal and C. Akinlar, “Edge Drawing: A Combined Real-Time Edge and Segment Detector,” * Journal of Visual Communication and Image Representation, 23(6), 862-872, DOI: 10.1016/j.jvcir.2012.05.004 (2012). * * [2] C. Akinlar and C. Topal, “EDPF: A Real-time Parameter-free Edge Segment Detector with a False Detection Control,” * International Journal of Pattern Recognition and Artificial Intelligence, 26(1), DOI: 10.1142/S0218001412550026 (2012). **************************************************************************************************************/ #ifndef _ED_ #define _ED_ #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include "EDColor.h" namespace EDLIB { /// Special defines #define EDGE_VERTICAL 1 #define EDGE_HORIZONTAL 2 #define ANCHOR_PIXEL 254 #define EDGE_PIXEL 255 #define LEFT 1 #define RIGHT 2 #define UP 3 #define DOWN 4 enum GradientOperator { PREWITT_OPERATOR = 101, SOBEL_OPERATOR = 102, SCHARR_OPERATOR = 103, LSD_OPERATOR = 104 }; struct StackNode { int r, c; // starting pixel int parent; // parent chain (-1 if no parent) int dir; // direction where you are supposed to go }; // Used during Edge Linking struct Chain { int dir; // Direction of the chain int len; // # of pixels in the chain int parent; // Parent of this node (-1 if no parent) int children[2]; // Children of this node (-1 if no children) cv::Point *pixels; // Pointer to the beginning of the pixels array }; class ED { public: ED(cv::Mat _srcImage, GradientOperator _op = PREWITT_OPERATOR, int _gradThresh = 20, int _anchorThresh = 0, int _scanInterval = 1, int _minPathLen = 10, double _sigma = 1.0, bool _sumFlag = true); ED(const ED &cpyObj); ED(short *gradImg, uchar *dirImg, int _width, int _height, int _gradThresh, int _anchorThresh, int _scanInterval = 1, int _minPathLen = 10, bool selectStableAnchors = true); ED(EDColor &cpyObj); ED(); cv::Mat getEdgeImage(); cv::Mat getAnchorImage(); cv::Mat getSmoothImage(); cv::Mat getGradImage(); int getSegmentNo(); int getAnchorNo(); std::vector<cv::Point> getAnchorPoints(); std::vector<std::vector<cv::Point>> getSegments(); std::vector<std::vector<cv::Point>> getSortedSegments(); cv::Mat drawParticularSegments(std::vector<int> list); protected: int width; // width of source image int height; // height of source image uchar *srcImg; std::vector<std::vector<cv::Point> > segmentPoints; double sigma; // Gaussian sigma cv::Mat smoothImage; uchar *edgeImg; // pointer to edge image data uchar *smoothImg; // pointer to smoothed image data int segmentNos; int minPathLen; cv::Mat srcImage; private: void ComputeGradient(); void ComputeAnchorPoints(); void JoinAnchorPointsUsingSortedAnchors(); void sortAnchorsByGradValue(); int *sortAnchorsByGradValue1(); static int LongestChain(Chain *chains, int root); static int RetrieveChainNos(Chain *chains, int root, int chainNos[]); int anchorNos; std::vector<cv::Point> anchorPoints; std::vector<cv::Point> edgePoints; cv::Mat edgeImage; cv::Mat gradImage; uchar *dirImg; // pointer to direction image data short *gradImg; // pointer to gradient image data GradientOperator op; // operation used in gradient calculation int gradThresh; // gradient threshold int anchorThresh; // anchor point threshold int scanInterval; bool sumFlag; }; } #endif
31.189781
125
0.601217
[ "vector" ]
6a2f33aeea50cfbd608c05772b43072bb5caf2b2
420
h
C
ios/Pods/Headers/Public/libmuse/Muse/api/IXNRunEventLoop.h
bimslab/mobileapp_eegmuselib
a28773ab29188b824a3afae4a5f3c9ec0b089419
[ "MIT" ]
2
2018-01-27T16:09:58.000Z
2021-06-20T15:04:03.000Z
ios/Pods/Headers/Public/libmuse/Muse/api/IXNRunEventLoop.h
bimslab/mobileapp_eegmuselib
a28773ab29188b824a3afae4a5f3c9ec0b089419
[ "MIT" ]
null
null
null
ios/Pods/Headers/Public/libmuse/Muse/api/IXNRunEventLoop.h
bimslab/mobileapp_eegmuselib
a28773ab29188b824a3afae4a5f3c9ec0b089419
[ "MIT" ]
null
null
null
// Copyright 2016 Interaxon, Inc. #import <Foundation/Foundation.h> #import "Muse/api/IXNEventLoop.h" /** * An IXNEventLoop implementation using NSRunLoop */ @interface IXNRunEventLoop : NSObject <IXNEventLoop> /** * Initializes the object with the passed NSRunLoop. * * \param runLoop The NSRunLoop to use for the IXNEventLoop. */ - (instancetype)initWithRunLoop:(NSRunLoop *)runLoop; @end
23.333333
64
0.711905
[ "object" ]
6a3737b8e52eb84a7f4fd005caa9ebb471dcfd15
1,904
h
C
sensor_module/sensor_module/src/incl/accelerator_module.h
KMM2019-CrazyTaxi/sensor-module
b26d1634c67ccf2cfdefc2657ccf6b1d0990d910
[ "MIT" ]
null
null
null
sensor_module/sensor_module/src/incl/accelerator_module.h
KMM2019-CrazyTaxi/sensor-module
b26d1634c67ccf2cfdefc2657ccf6b1d0990d910
[ "MIT" ]
23
2019-11-05T08:42:40.000Z
2019-12-20T13:46:35.000Z
sensor_module/sensor_module/src/incl/accelerator_module.h
KMM2019-CrazyTaxi/sensor-module
b26d1634c67ccf2cfdefc2657ccf6b1d0990d910
[ "MIT" ]
null
null
null
/* * accelerator_module.h * * Created: 2019-11-08 18:57:08 * Author: herap603 */ #ifndef ACCELERATOR_MODULE_H_ #define ACCELERATOR_MODULE_H_ #include <stdint.h> #include "i2c.h" #define ACCELERATOR_ADR 0x32 #define ACCELERATOR_CTRL_REG1_A 0x20 #define ACCELERATOR_OUT_X_L_A 0x28 #define ACCELERATOR_STATUS_REG_A 0x27 /* * Initializes the accelerator module to read linear acceleration values. */ void accelerator_init(void); /* * Sets the value of a register in the accelerator module. * * reg_adr: The register address. * data: The data to write. * Assumes: I2C has been initialized. */ void accelerator_set_register_value(const uint8_t reg_adr, const uint8_t data); /* * Reads the value of a register in the accelerator module. * * reg_adr: The register address. * buffer: A pointer to a 1-byte buffer to save the data to. * Assumes: I2C has been initialized. */ void accelerator_get_register_value(const uint8_t reg_adr, uint8_t* buffer); /* * Reads the values of multiple consecutive registers in the accelerator module. * * start_adr: The address of the first register. * buffer: A pointer to a buffer of size at least n_bytes to save the data to. * n_bytes: The number of bytes to read. * Assumes: I2C has been initialized. */ void accelerator_get_multiple_register_values(const uint8_t start_adr, uint8_t* buffer, const uint8_t n_bytes); /* * Reads the values of the 3D linear acceleration. * * buffer: A pointer to a buffer of at least 6 bytes to save the data to. The data is saved in order XYZ, little endian. * Assumes: I2C and the acceleration module has been initialized. */ void accelerator_get_linear_acceleration(uint8_t* buffer); /* * Check if there are new accelerator values available. * * Returns: A value > 0 if new values are available, else 0. */ uint8_t accelerator_new_values_available(void); #endif /* ACCELERATOR_MODULE_H_ */
28
120
0.754202
[ "3d" ]
6a3a03af1f7c6ce0fabe827e730926ba9a4618dd
2,958
h
C
src/UGF12/DirectX/FeatureSupport/FS_Options6.h
Ohjurot/UGF12
b3ac8ed9d37bf37ad4a0ac5c2517698e857914f9
[ "BSD-2-Clause" ]
null
null
null
src/UGF12/DirectX/FeatureSupport/FS_Options6.h
Ohjurot/UGF12
b3ac8ed9d37bf37ad4a0ac5c2517698e857914f9
[ "BSD-2-Clause" ]
null
null
null
src/UGF12/DirectX/FeatureSupport/FS_Options6.h
Ohjurot/UGF12
b3ac8ed9d37bf37ad4a0ac5c2517698e857914f9
[ "BSD-2-Clause" ]
null
null
null
#pragma once #include "pch.h" #include <UGF12/Util/TSysInfo.h> #include <UGF12/Util/Exeption.h> #include <UGF12/DirectX/XContext.h> namespace GxDirect { namespace FeaturSupport { /// <summary> /// Container for D3D12_FEATURE_D3D12_OPTIONS6 /// </summary> class FS_Options6 { public: /// <summary> /// Create options based on a context /// </summary> /// <param name="ptrContext">context to query</param> FS_Options6(GxDirect::XContext* ptrContext); /// <summary> /// Retrive the result of the query /// </summary> /// <returns>Result of query</returns> HRESULT getQueryResult(); /// <summary> /// Gennerates the text representation for feature support (Will fail on Shipping configuration!) /// </summary> void gennerateTextRepresentation(); public: /// <summary> /// https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options6 /// </summary> /// <returns>const ref Info object</returns> const TSysInfo(BOOL)& getAdditionalShadingRatesSupported(); /// <summary> /// https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options6 /// </summary> /// <returns>const ref Info object</returns> const TSysInfo(BOOL)& getPerPrimitiveShadingRateSupportedWithViewportIndexing(); /// <summary> /// VSR Tier /// </summary> /// <returns>const ref Info object</returns> const TSysInfo(D3D12_VARIABLE_SHADING_RATE_TIER)& getVariableShadingRateTier(); /// <summary> /// VSR Tile width in px /// </summary> /// <returns>const ref Info object</returns> const TSysInfo(UINT)& getShadingRateImageTileSize(); /// <summary> /// Indicates if background processing is supported /// </summary> /// <returns>const ref Info object</returns> const TSysInfo(BOOL)& getBackgroundProcessingSupported(); private: /// <summary> /// Query result /// </summary> HRESULT m_hrQueryResult; /// <summary> /// https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options6 /// </summary> TSysInfo(BOOL) m_siAdditionalShadingRatesSupported = FALSE; /// <summary> /// https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options6 /// </summary> TSysInfo(BOOL) m_siPerPrimitiveShadingRateSupportedWithViewportIndexing = FALSE; /// <summary> /// VSR Tier /// </summary> TSysInfo(D3D12_VARIABLE_SHADING_RATE_TIER) m_siVariableShadingRateTier = D3D12_VARIABLE_SHADING_RATE_TIER_NOT_SUPPORTED; /// <summary> /// VSR Tile width in px /// </summary> TSysInfo(UINT) m_siShadingRateImageTileSize = 0; /// <summary> /// Indicates if background processing is supported /// </summary> TSysInfo(BOOL) m_siBackgroundProcessingSupported = FALSE; }; } }
30.8125
124
0.672414
[ "object" ]
6a3a0eae67dbeb7897cf7ad6c89c9fd0c312c60e
1,957
c
C
lib/wizards/rimber/dragon.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/rimber/dragon.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/rimber/dragon.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
string master, short; int follow_mode; reset(arg) { if(arg) return; follow_mode = 0; } string masteri() { master = "/wizards/rimber/test/room2.c"->master(); tell_room(environment(this_player()), "Dragon booms: 'You called Master "+master+"?\n"); short = master+"'s pet dragon"; return master; } short() { return short; } id() { return "dragon"; } long() { write("This is "+master+"'s pet dragon. Dragonmaster's usually command these beasts\n"+ "simply saying what the beast must to do.\nWord 'help' will give you more instructions.\n"); } init() { add_action("dragon", "dragon"); } status dragon(string str) { object ob; string what; if(!str) { write("Use 'dragon help' to see commands.\n"); return 1; } if(sscanf(str, "attack %s", what) == 1) { ob = find_object(what); if(!ob) { tell_room(environment(this_player()), "Dragon booms: 'Who you want me to kill Master?'\n"); return 1; } tell_room(environment(this_player()), "Dragon booms: 'As you wish Master.'\n"); return 1; } if(str == "help") { write("Dragon's commands:\n 'follow' Makes dragon to follow "+ "you.\n 'stay' makes it stop following.\n 'eat corpse' Dragon eats corpse.\n "+ "'attack <target>' Makes dragon to attack given target.\n 'dismiss' The dragon "+ "leaves.\n\n"); return 1; } if(str == "follow") { tell_room(environment(this_player()), "Dragon booms: 'I will now follow you Master.'\n"); follow_mode = 1; return 1; } if(str == "dismiss") { ob = this_object(); tell_room(environment(this_player()), "Dragon booms: 'If that's your command Master.\n"); tell_room(environment(this_player()), "Dragon disappears.\n"); destruct(ob); return 1; } return 1; } catch_tell(fol) { string who, dir; object kuka; if(sscanf(fol, "%s leaves %s.", who, dir) == 2) { kuka = find_player(lower_case(who)); if(!kuka) return; if(follow_mode == 0) return; if(who != master) return; init_command(dir); return 1; } return 1; }
24.772152
96
0.653551
[ "object" ]
6a3a77bb0fe366de0038fb7f696d911afb0bd996
388
h
C
Include/algorithms/kamenevs/chain_class.h
av-elier/fast-exponentiation-algs
1d6393021583686372564a7ca52b09dc7013fb38
[ "MIT" ]
2
2016-10-17T20:30:05.000Z
2020-03-24T19:52:14.000Z
Include/algorithms/kamenevs/chain_class.h
av-elier/fast-exponentiation-algs
1d6393021583686372564a7ca52b09dc7013fb38
[ "MIT" ]
null
null
null
Include/algorithms/kamenevs/chain_class.h
av-elier/fast-exponentiation-algs
1d6393021583686372564a7ca52b09dc7013fb38
[ "MIT" ]
null
null
null
#include <NTL/ZZ_pXFactoring.h> #include <NTL/ZZ_pEX.h> #include <vector> #include <string> NTL_CLIENT #ifndef _CHAIN #define _CHAIN class Chain{ public: class Link { public: ZZ chain_v; string bits; int start; int end; }; vector<Link> link; Chain(); int Size(); void Generation(ZZ_p high_number); bool Add(Link l); private: Link NewLink(ZZ_p high_number); }; #endif
13.37931
35
0.698454
[ "vector" ]
6a3b9c339e31bddc82e7c0cccf7bda5979463fea
1,758
h
C
src/Studio/ReDSDebugTools.h
danielbui78/reality
7ecd01b71f28e581becfe5093fab3ddcd6d9b2c1
[ "BSD-3-Clause" ]
2
2021-12-25T17:24:03.000Z
2022-03-14T05:07:51.000Z
src/Studio/ReDSDebugTools.h
danielbui78/reality
7ecd01b71f28e581becfe5093fab3ddcd6d9b2c1
[ "BSD-3-Clause" ]
null
null
null
src/Studio/ReDSDebugTools.h
danielbui78/reality
7ecd01b71f28e581becfe5093fab3ddcd6d9b2c1
[ "BSD-3-Clause" ]
2
2021-12-10T05:33:04.000Z
2021-12-10T16:38:54.000Z
/** * \file * Reality plug-in * Copyright (c) Pret-a-3D/Paolo Ciccone 2014. All rights reserved. */ #include <QtCore> #include "dzobject.h" #include "dzshape.h" #include "dzmaterial.h" /** Class: ReDSDebugTool */ class ReDSDebugTool : public QObject { Q_OBJECT private: static ReDSDebugTool* instance; //! Constructor: ReDSDebugTool ReDSDebugTool() { }; static void init(); public: static ReDSDebugTool* getInstance(); private slots: // DzObject debugging void currentShapeSwitchedHandler(); void drawnDataChangedHandler(); void materialListChangedHandler(); void materialSelectionChangedHandler(); void modifierAddedHandler(DzModifier* md); void modifierRemovedHandler(DzModifier* md); void modifierStackChangedHandler(); void shapeAddedHandler(DzShape* shape); void shapeRemovedHandler(DzShape* shape); void uvsChangedHandler(); // DzShape signal handlers void shapeGeomChangedHandler(); void shapeMaterialAddedHandler(DzMaterial* mat); void shapeMaterialChangedHandler(); void shapeMaterialListChangedHandler(); void shapeMaterialRemovedHandler(DzMaterial* mat); void shapeMaterialSelectedHandler(DzMaterial* mat); void shapeMaterialSelectionChangedHandler(); void shapeMaterialUnselectedHandler(DzMaterial* mat); void shapeRigidityGroupListChangedHandler(); void shapeRigidityMapChangedHandler(); void shapeSmoothingChangedHandler(); void shapeUvsChangedHandler(); public slots: void monitorObject( DzObject* obj ); void monitorShape( DzShape* shape ); }; inline void dsMonitorObject( DzObject* obj ) { ReDSDebugTool::getInstance()->monitorObject(obj); } inline void dsMonitorShape( DzShape* shape ) { ReDSDebugTool::getInstance()->monitorShape(shape); }
24.416667
72
0.760523
[ "shape", "3d" ]
6a40a7872a2e9b46b6b8bd8256774cdb97ed534c
2,616
h
C
dependencies/Vizrt/Include/evPlugin_SCRIPT_PLUGIN.h
sultangal/SGF_Bounce
1178eebcb6661f1b80a046a97ebd02a98b522789
[ "Apache-2.0" ]
null
null
null
dependencies/Vizrt/Include/evPlugin_SCRIPT_PLUGIN.h
sultangal/SGF_Bounce
1178eebcb6661f1b80a046a97ebd02a98b522789
[ "Apache-2.0" ]
null
null
null
dependencies/Vizrt/Include/evPlugin_SCRIPT_PLUGIN.h
sultangal/SGF_Bounce
1178eebcb6661f1b80a046a97ebd02a98b522789
[ "Apache-2.0" ]
null
null
null
/*! @file * @brief this file is part of the plugin library. * */ /* ============================================================================= * * * * Copyright 2006,2013 Vizrt Austria GmbH * * All Rights Reserved. * * * * This is PROPRIETARY SOURCE CODE ofVizrt Austria GmbH; * * the contents of this file may not be disclosed to third parties, copied or * * duplicated in any form, in whole or in part, without the prior written * * permission of Vizrt Austria GmbH * * * * ============================================================================= */ /* CAUTION: * -------- * This file contains no user-modifiable data * Under no circumstances change anything in this file without an * explicit order from Vizrt Austria GmbH * */ #if ! defined( EV_PLUGIN_SCRIPT_PLUGIN_H ) #define EV_PLUGIN_SCRIPT_PLUGIN_H #include "evPlugin_BASE.h" // --------------------------------------------------------------------- // forward decls // --------------------------------------------------------------------- class PLUGIN_INSTANCE; class PLUGIN_PARAMETER; class ANIMATION; //========================================================================= // SCRIPT_PLUGIN OBJECT //========================================================================= /*! @brief ? * * @todo documentation to be done. */ class SCRIPT_PLUGIN : public BASE { public: /*! @brief script plugin * * @param[in] rhs right hand side * @return ? * @todo documentation to be done. */ const SCRIPT_PLUGIN& operator=( const SCRIPT_PLUGIN & rhs ); // cast-operator /*! @brief ? * * @todo documentation to be done. */ operator PLUGIN_INSTANCE() const; /*! @brief with class PLUGIN_PARAMETER you can manipulate all values of script plugin * * @param parameter ? * @return ? * @todo documentation to be done. */ int set( PLUGIN_PARAMETER & parameter ); /*! @brief with class PLUGIN_PARAMETER get all values of script plugin * * @param parameter ? * @return ? * @todo documentation to be done. */ int get( PLUGIN_PARAMETER & parameter ); }; #endif // EV_PLUGIN_SCRIPT_PLUGIN_H
29.727273
89
0.43578
[ "object" ]
6a420b6d44971d9971ccdcd3813d349bfd7054f3
1,080
h
C
facerecognizer.h
ctava/opencv-facial-recognition
04bf6ab5b7b34344bb7759c0917a6b9e590c2926
[ "Apache-2.0" ]
1
2018-03-09T20:46:22.000Z
2018-03-09T20:46:22.000Z
facerecognizer.h
ctava/opencv-facial-recognition
04bf6ab5b7b34344bb7759c0917a6b9e590c2926
[ "Apache-2.0" ]
null
null
null
facerecognizer.h
ctava/opencv-facial-recognition
04bf6ab5b7b34344bb7759c0917a6b9e590c2926
[ "Apache-2.0" ]
1
2019-11-12T15:37:15.000Z
2019-11-12T15:37:15.000Z
#include <stdio.h> #include <iostream> #include <vector> #include "opencv2/opencv.hpp" class FaceRecognizer : public cv::Algorithm { private: int _num_components; double _threshold; cv::Mat _eigenvectors; cv::Mat _eigenvalues; cv::Mat _mean; std::vector<cv::Mat> _projections; cv::Mat _labels; double getSimilarity(const cv::Mat A, const cv::Mat B); cv::Mat reconstructFace(const cv::Mat preprocessedFace); void train(cv::InputArrayOfArrays src, cv::InputArray _lbls); public: cv::Mat getMean(); cv::Mat getEigenvectors(); cv::Mat getEigenvalues(); std::vector <cv::Mat> getProjections(); void learnCollectedFaces(const std::vector<cv::Mat> preprocessedFaces, const std::vector<int> faceLabels, const std::string facerecAlgorithm = "FaceRecognizer.Fisherfaces"); cv::Mat reconstructFace(FaceRecognizer faceRecognizer, const cv::Mat preprocessedFace); int predict(cv::InputArray _src); void load(const cv::FileStorage& fs); void save(cv::FileStorage& fs); };
31.764706
178
0.682407
[ "vector" ]
6a5d5839ab3979d5f3fa28e6d4115cbb10d460d0
526
h
C
tspfilereader.h
msiley/GeneticAlgorithmTSP
e4fda65e12df69f52f0a1f1bd7469857637e5e47
[ "MIT" ]
null
null
null
tspfilereader.h
msiley/GeneticAlgorithmTSP
e4fda65e12df69f52f0a1f1bd7469857637e5e47
[ "MIT" ]
null
null
null
tspfilereader.h
msiley/GeneticAlgorithmTSP
e4fda65e12df69f52f0a1f1bd7469857637e5e47
[ "MIT" ]
null
null
null
#include <iostream> #include <sstream> #include <vector> #include <string> #include <cmath> #include <fstream> #include <cassert> using namespace std; #ifndef __TSPFILEREADER__ #define __TSPFILEREADER__ class TSPFileReader { private: string filename; vector<vector<double> > tour; public: TSPFileReader(const char *filename); TSPFileReader(string &filename); vector<vector<double> > &read(void); void print_tour(void); static double distance(double x1, double y1, double x2, double y2); }; #endif
16.967742
71
0.728137
[ "vector" ]
6a5d93089244fe14f02ae3bb125c9957a4156a3c
10,395
h
C
src/game/server/hl2/npc_turret_floor.h
vxsd/refraction
bb6def1feb6c2e5c94b2604ad55607ed380a2d7e
[ "MIT" ]
14
2021-02-16T14:13:50.000Z
2022-03-17T18:29:19.000Z
src/game/server/hl2/npc_turret_floor.h
undbsd/refraction
bb6def1feb6c2e5c94b2604ad55607ed380a2d7e
[ "MIT" ]
7
2021-08-06T18:40:37.000Z
2022-03-09T18:05:08.000Z
src/game/server/hl2/npc_turret_floor.h
undbsd/refraction
bb6def1feb6c2e5c94b2604ad55607ed380a2d7e
[ "MIT" ]
2
2021-08-05T16:03:03.000Z
2021-11-26T00:11:27.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// #ifndef NPC_TURRET_FLOOR_H #define NPC_TURRET_FLOOR_H #ifdef _WIN32 #pragma once #endif #include "ai_basenpc.h" #include "player_pickup.h" #include "particle_system.h" //Turret states enum turretState_e { TURRET_SEARCHING, TURRET_AUTO_SEARCHING, TURRET_ACTIVE, TURRET_SUPPRESSING, TURRET_DEPLOYING, TURRET_RETIRING, TURRET_TIPPED, TURRET_SELF_DESTRUCTING, TURRET_STATE_TOTAL }; //Eye states enum eyeState_t { TURRET_EYE_SEE_TARGET, //Sees the target, bright and big TURRET_EYE_SEEKING_TARGET, //Looking for a target, blinking (bright) TURRET_EYE_DORMANT, //Not active TURRET_EYE_DEAD, //Completely invisible TURRET_EYE_DISABLED, //Turned off, must be reactivated before it'll deploy again (completely invisible) TURRET_EYE_ALARM, // On side, but warning player to pick it back up }; //Spawnflags // BUG: These all stomp Base NPC spawnflags. Any Base NPC code called by this // this class may have undesired side effects due to these being set. #define SF_FLOOR_TURRET_AUTOACTIVATE 0x00000020 #define SF_FLOOR_TURRET_STARTINACTIVE 0x00000040 #define SF_FLOOR_TURRET_FASTRETIRE 0x00000080 #define SF_FLOOR_TURRET_OUT_OF_AMMO 0x00000100 #define SF_FLOOR_TURRET_CITIZEN 0x00000200 // Citizen modified turret class CTurretTipController; class CBeam; class CSprite; //----------------------------------------------------------------------------- // Purpose: Floor turret //----------------------------------------------------------------------------- class CNPC_FloorTurret : public CNPCBaseInteractive<CAI_BaseNPC>, public CDefaultPlayerPickupVPhysics { DECLARE_CLASS( CNPC_FloorTurret, CNPCBaseInteractive<CAI_BaseNPC> ); public: CNPC_FloorTurret( void ); virtual void Precache( void ); virtual void Spawn( void ); virtual void Activate( void ); virtual bool CreateVPhysics( void ); virtual void UpdateOnRemove( void ); virtual int OnTakeDamage( const CTakeDamageInfo &info ); virtual void PlayerPenetratingVPhysics( void ); virtual int VPhysicsTakeDamage( const CTakeDamageInfo &info ); virtual bool CanBecomeServerRagdoll( void ) { return false; } #ifdef HL2_EPISODIC // We don't want to be NPCSOLID because we'll collide with NPC clips virtual unsigned int PhysicsSolidMaskForEntity( void ) const { return MASK_SOLID; } #endif // HL2_EPISODIC // Player pickup virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason ); virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason ); virtual bool HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer ); virtual QAngle PreferredCarryAngles( void ); virtual bool OnAttemptPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason ); const char *GetTracerType( void ) { return "AR2Tracer"; } bool ShouldSavePhysics() { return true; } bool HandleInteraction( int interactionType, void *data, CBaseCombatCharacter *sourceEnt ); // Think functions virtual void Retire( void ); virtual void Deploy( void ); virtual void ActiveThink( void ); virtual void SearchThink( void ); virtual void AutoSearchThink( void ); virtual void TippedThink( void ); virtual void InactiveThink( void ); virtual void SuppressThink( void ); virtual void DisabledThink( void ); virtual void SelfDestructThink( void ); virtual void BreakThink( void ); virtual void HackFindEnemy( void ); virtual float GetAttackDamageScale( CBaseEntity *pVictim ); virtual Vector GetAttackSpread( CBaseCombatWeapon *pWeapon, CBaseEntity *pTarget ); // Do we have a physics attacker? CBasePlayer *HasPhysicsAttacker( float dt ); bool IsHeldByPhyscannon( ) { return VPhysicsGetObject() && (VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_PLAYER_HELD); } // Use functions void ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); int ObjectCaps() { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE; } void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBasePlayer *pPlayer = ToBasePlayer( pActivator ); if ( pPlayer ) { pPlayer->PickupObject( this, false ); } } // Inputs void InputToggle( inputdata_t &inputdata ); void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); void InputDepleteAmmo( inputdata_t &inputdata ); void InputRestoreAmmo( inputdata_t &inputdata ); void InputSelfDestruct( inputdata_t &inputdata ); virtual bool IsValidEnemy( CBaseEntity *pEnemy ); bool CanBeAnEnemyOf( CBaseEntity *pEnemy ); bool IsBeingCarriedByPlayer( void ) { return m_bCarriedByPlayer; } bool WasJustDroppedByPlayer( void ); int BloodColor( void ) { return DONT_BLEED; } float MaxYawSpeed( void ); virtual Class_T Classify( void ); Vector EyePosition( void ) { UpdateMuzzleMatrix(); Vector vecOrigin; MatrixGetColumn( m_muzzleToWorld, 3, vecOrigin ); Vector vecForward; MatrixGetColumn( m_muzzleToWorld, 0, vecForward ); // Note: We back up into the model to avoid an edge case where the eyes clip out of the world and // cause problems with the PVS calculations -- jdw vecOrigin -= vecForward * 8.0f; return vecOrigin; } Vector EyeOffset( Activity nActivity ) { return Vector( 0, 0, 58 ); } // Restore the turret to working operation after falling over void ReturnToLife( void ); int DrawDebugTextOverlays( void ); // INPCInteractive Functions virtual bool CanInteractWith( CAI_BaseNPC *pUser ) { return false; } // Disabled for now (sjb) virtual bool HasBeenInteractedWith() { return m_bHackedByAlyx; } virtual void NotifyInteraction( CAI_BaseNPC *pUser ) { // For now, turn green so we can tell who is hacked. SetRenderColor( 0, 255, 0 ); m_bHackedByAlyx = true; } static float fMaxTipControllerVelocity; static float fMaxTipControllerAngularVelocity; protected: virtual bool PreThink( turretState_e state ); virtual void Shoot( const Vector &vecSrc, const Vector &vecDirToEnemy, bool bStrict = false ); virtual void SetEyeState( eyeState_t state ); void Ping( void ); void Toggle( void ); void Enable( void ); void Disable( void ); void SpinUp( void ); void SpinDown( void ); virtual bool OnSide( void ); bool IsCitizenTurret( void ) { return HasSpawnFlags( SF_FLOOR_TURRET_CITIZEN ); } bool UpdateFacing( void ); void DryFire( void ); void UpdateMuzzleMatrix(); protected: matrix3x4_t m_muzzleToWorld; int m_muzzleToWorldTick; int m_iAmmoType; bool m_bAutoStart; bool m_bActive; //Denotes the turret is deployed and looking for targets bool m_bBlinkState; bool m_bEnabled; //Denotes whether the turret is able to deploy or not bool m_bNoAlarmSounds; bool m_bSelfDestructing; // Going to blow up float m_flDestructStartTime; float m_flShotTime; float m_flLastSight; float m_flThrashTime; float m_flPingTime; float m_flNextActivateSoundTime; bool m_bCarriedByPlayer; bool m_bUseCarryAngles; float m_flPlayerDropTime; int m_iKeySkin; CHandle<CBaseCombatCharacter> m_hLastNPCToKickMe; // Stores the last NPC who tried to knock me over float m_flKnockOverFailedTime; // Time at which we should tell the NPC that he failed to knock me over QAngle m_vecGoalAngles; int m_iEyeAttachment; int m_iMuzzleAttachment; eyeState_t m_iEyeState; CHandle<CSprite> m_hEyeGlow; CHandle<CBeam> m_hLaser; CHandle<CTurretTipController> m_pMotionController; CHandle<CParticleSystem> m_hFizzleEffect; Vector m_vecEnemyLKP; // physics influence CHandle<CBasePlayer> m_hPhysicsAttacker; float m_flLastPhysicsInfluenceTime; static const char *m_pShotSounds[]; COutputEvent m_OnDeploy; COutputEvent m_OnRetire; COutputEvent m_OnTipped; COutputEvent m_OnPhysGunPickup; COutputEvent m_OnPhysGunDrop; bool m_bHackedByAlyx; HSOUNDSCRIPTHANDLE m_ShotSounds; DECLARE_DATADESC(); DEFINE_CUSTOM_AI; }; // // Tip controller // class CTurretTipController : public CPointEntity, public IMotionEvent { DECLARE_CLASS( CTurretTipController, CPointEntity ); DECLARE_DATADESC(); public: ~CTurretTipController( void ); void Spawn( void ); void Activate( void ); void Enable( bool state = true ); void Suspend( float time ); float SuspendedTill( void ); bool Enabled( void ); static CTurretTipController *CreateTipController( CNPC_FloorTurret *pOwner ) { if ( pOwner == NULL ) return NULL; CTurretTipController *pController = (CTurretTipController *) Create( "floorturret_tipcontroller", pOwner->GetAbsOrigin(), pOwner->GetAbsAngles() ); if ( pController != NULL ) { pController->m_pParentTurret = pOwner; } return pController; } // IMotionEvent virtual simresult_e Simulate( IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular ); private: bool m_bEnabled; float m_flSuspendTime; Vector m_worldGoalAxis; Vector m_localTestAxis; IPhysicsMotionController *m_pController; float m_angularLimit; CNPC_FloorTurret *m_pParentTurret; }; #endif //#ifndef NPC_TURRET_FLOOR_H
33.75
157
0.657624
[ "vector", "model" ]
6a60dad4bcd2ecdfa94c31fa1b78bd1f521f2402
30,740
h
C
codec/nvbuf_utils.h
emielsteerneman/jetson-utils
9c230aca6e1b401218d2e181d8e82d413bd974d3
[ "MIT" ]
372
2018-02-01T17:48:42.000Z
2022-03-30T08:26:10.000Z
codec/nvbuf_utils.h
emielsteerneman/jetson-utils
9c230aca6e1b401218d2e181d8e82d413bd974d3
[ "MIT" ]
102
2018-08-19T18:26:05.000Z
2022-03-31T18:18:03.000Z
codec/nvbuf_utils.h
emielsteerneman/jetson-utils
9c230aca6e1b401218d2e181d8e82d413bd974d3
[ "MIT" ]
198
2018-02-13T02:19:00.000Z
2022-03-26T00:11:59.000Z
/* * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved. * * NVIDIA Corporation and its licensors retain all intellectual property * and proprietary rights in and to this software, related documentation * and any modifications thereto. Any use, reproduction, disclosure or * distribution of this software and related documentation without an express * license agreement from NVIDIA Corporation is strictly prohibited. */ /** * @file * <b>NVIDIA Multimedia Utilities: Buffering and Transform/Composition/Blending</b> * */ /** * @defgroup ee_nvbuffering_group Buffer Manager * @ingroup common_utility_group * NVIDIA buffering utility library for use by applications. * The utility also transforms, composits, and blends. * @{ */ #ifndef _NVBUF_UTILS_H_ #define _NVBUF_UTILS_H_ #ifdef __cplusplus extern "C" { #endif #include <EGL/egl.h> #include <EGL/eglext.h> #include <errno.h> #include <stdbool.h> /** * Defines the maximum number of planes for a video frame. */ #define MAX_NUM_PLANES 4 /** * Defines the maximum number of input video frames that can be used for composition. */ #define MAX_COMPOSITE_FRAME 16 /** * Defines the default values for chroma subsampling. * The default value matches JPEG/MPEG use cases. */ #define NVBUF_CHROMA_SUBSAMPLING_HORIZ_DEFAULT 0 #define NVBUF_CHROMA_SUBSAMPLING_VERT_DEFAULT 1 /** * Defines the maximum number of sync object parameters. */ #define NVBUF_MAX_SYNCOBJ_PARAMS 5 /** * Use this value to represent an infinite wait interval. * A value of zero should not be interpreted as infinite, * it should be interpreted as "time out immediately" and * simply check whether the event has already happened. */ #define NVBUFFER_SYNCPOINT_WAIT_INFINITE 0xFFFFFFFF /** * Defines Payload types for NvBuffer. */ typedef enum { /** buffer payload with hardware memory handle for set of planes. */ NvBufferPayload_SurfArray, /** buffer payload with hardware memory handle for specific memory size. */ NvBufferPayload_MemHandle, } NvBufferPayloadType; /** * Defines display scan formats for NvBuffer video planes. */ typedef enum { /** Progessive scan formats. */ NvBufferDisplayScanFormat_Progressive = 0, /** Interlaced scan formats. */ NvBufferDisplayScanFormat_Interlaced, } NvBufferDisplayScanFormat; /** * Defines Layout formats for NvBuffer video planes. */ typedef enum { /** Pitch Layout. */ NvBufferLayout_Pitch, /** BlockLinear Layout. */ NvBufferLayout_BlockLinear, } NvBufferLayout; /** * Defines memory access flags for NvBuffer. */ typedef enum { /** Memory read. */ NvBufferMem_Read, /** Memory write. */ NvBufferMem_Write, /** Memory read & write. */ NvBufferMem_Read_Write, } NvBufferMemFlags; /** * Defines tags that identify the components requesting a memory allocation. * The tags can be used later to identify the total memory allocated to * particular types of components. */ typedef enum { /** tag None. */ NvBufferTag_NONE = 0x0, /** tag for Camera. */ NvBufferTag_CAMERA = 0x200, /** tag for Jpeg Encoder/Decoder. */ NvBufferTag_JPEG = 0x1500, /** tag for VPR Buffers. */ NvBufferTag_PROTECTED = 0x1504, /** tag for H264/H265 Video Encoder. */ NvBufferTag_VIDEO_ENC = 0x1200, /** tag for H264/H265/VP9 Video Decoder. */ NvBufferTag_VIDEO_DEC = 0x1400, /** tag for Video Transform/Composite. */ NvBufferTag_VIDEO_CONVERT = 0xf01, } NvBufferTag; /** * Defines color formats for NvBuffer. */ typedef enum { /** BT.601 colorspace - YUV420 multi-planar. */ NvBufferColorFormat_YUV420, /** BT.601 colorspace - YUV420 multi-planar. */ NvBufferColorFormat_YVU420, /** BT.601 colorspace - YUV422 multi-planar. */ NvBufferColorFormat_YUV422, /** BT.601 colorspace - YUV420 ER multi-planar. */ NvBufferColorFormat_YUV420_ER, /** BT.601 colorspace - YVU420 ER multi-planar. */ NvBufferColorFormat_YVU420_ER, /** BT.601 colorspace - Y/CbCr 4:2:0 multi-planar. */ NvBufferColorFormat_NV12, /** BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar. */ NvBufferColorFormat_NV12_ER, /** BT.601 colorspace - Y/CbCr 4:2:0 multi-planar. */ NvBufferColorFormat_NV21, /** BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar. */ NvBufferColorFormat_NV21_ER, /** BT.601 colorspace - YUV 4:2:2 planar. */ NvBufferColorFormat_UYVY, /** BT.601 colorspace - YUV ER 4:2:2 planar. */ NvBufferColorFormat_UYVY_ER, /** BT.601 colorspace - YUV 4:2:2 planar. */ NvBufferColorFormat_VYUY, /** BT.601 colorspace - YUV ER 4:2:2 planar. */ NvBufferColorFormat_VYUY_ER, /** BT.601 colorspace - YUV 4:2:2 planar. */ NvBufferColorFormat_YUYV, /** BT.601 colorspace - YUV ER 4:2:2 planar. */ NvBufferColorFormat_YUYV_ER, /** BT.601 colorspace - YUV 4:2:2 planar. */ NvBufferColorFormat_YVYU, /** BT.601 colorspace - YUV ER 4:2:2 planar. */ NvBufferColorFormat_YVYU_ER, /** LegacyRGBA colorspace - BGRA-8-8-8-8 planar. */ NvBufferColorFormat_ABGR32, /** LegacyRGBA colorspace - XRGB-8-8-8-8 planar. */ NvBufferColorFormat_XRGB32, /** LegacyRGBA colorspace - ARGB-8-8-8-8 planar. */ NvBufferColorFormat_ARGB32, /** BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ NvBufferColorFormat_NV12_10LE, /** BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ NvBufferColorFormat_NV12_10LE_709, /** BT.709_ER colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ NvBufferColorFormat_NV12_10LE_709_ER, /** BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ NvBufferColorFormat_NV12_10LE_2020, /** BT.601 colorspace - Y/CrCb 4:2:0 10-bit multi-planar. */ NvBufferColorFormat_NV21_10LE, /** BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar. */ NvBufferColorFormat_NV12_12LE, /** BT.2020 colorspace - Y/CbCr 4:2:0 12-bit multi-planar. */ NvBufferColorFormat_NV12_12LE_2020, /** BT.601 colorspace - Y/CrCb 4:2:0 12-bit multi-planar. */ NvBufferColorFormat_NV21_12LE, /** BT.709 colorspace - YUV420 multi-planar. */ NvBufferColorFormat_YUV420_709, /** BT.709 colorspace - YUV420 ER multi-planar. */ NvBufferColorFormat_YUV420_709_ER, /** BT.709 colorspace - Y/CbCr 4:2:0 multi-planar. */ NvBufferColorFormat_NV12_709, /** BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar. */ NvBufferColorFormat_NV12_709_ER, /** BT.2020 colorspace - YUV420 multi-planar. */ NvBufferColorFormat_YUV420_2020, /** BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar. */ NvBufferColorFormat_NV12_2020, /** Optical flow */ NvBufferColorFormat_SignedR16G16, /** Optical flow SAD calculation Buffer format */ NvBufferColorFormat_A32, /** BT.601 colorspace - YUV444 multi-planar. */ NvBufferColorFormat_YUV444, /** 8-bit grayscale. */ NvBufferColorFormat_GRAY8, /** BT.601 colorspace - Y/CbCr 4:2:2 multi-planar. */ NvBufferColorFormat_NV16, /** BT.601 colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */ NvBufferColorFormat_NV16_10LE, /** BT.601 colorspace - Y/CbCr 4:4:4 multi-planar. */ NvBufferColorFormat_NV24, /** BT.601 colorspace - Y/CrCb 4:4:4 10-bit multi-planar. */ NvBufferColorFormat_NV24_10LE, /** BT.601_ER colorspace - Y/CbCr 4:2:2 multi-planar. */ NvBufferColorFormat_NV16_ER, /** BT.601_ER colorspace - Y/CbCr 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_ER, /** BT.709 colorspace - Y/CbCr 4:2:2 multi-planar. */ NvBufferColorFormat_NV16_709, /** BT.709 colorspace - Y/CbCr 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_709, /** BT.709_ER colorspace - Y/CbCr 4:2:2 multi-planar. */ NvBufferColorFormat_NV16_709_ER, /** BT.709_ER colorspace - Y/CbCr 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_709_ER, /** BT.709 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_10LE_709, /** BT.709 ER colorspace - Y/CbCr 10 bit 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_10LE_709_ER, /** BT.2020 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_10LE_2020, /** BT.2020 colorspace - Y/CbCr 12 bit 4:4:4 multi-planar. */ NvBufferColorFormat_NV24_12LE_2020, /** Non-linear RGB BT.709 colorspace - RGBA-10-10-10-2 planar. */ NvBufferColorFormat_RGBA_10_10_10_2_709, /** Non-linear RGB BT.2020 colorspace - RGBA-10-10-10-2 planar. */ NvBufferColorFormat_RGBA_10_10_10_2_2020, /** Non-linear RGB BT.709 colorspace - BGRA-10-10-10-2 planar. */ NvBufferColorFormat_BGRA_10_10_10_2_709, /** Non-linear RGB BT.2020 colorspace - BGRA-10-10-10-2 planar. */ NvBufferColorFormat_BGRA_10_10_10_2_2020, /** Invalid color format. */ NvBufferColorFormat_Invalid, } NvBufferColorFormat; /** * Defines video flip methods. */ typedef enum { /** Video flip none. */ NvBufferTransform_None, /** Video flip rotate 90 degree counter-clockwise. */ NvBufferTransform_Rotate90, /** Video flip rotate 180 degree. */ NvBufferTransform_Rotate180, /** Video flip rotate 270 degree counter-clockwise. */ NvBufferTransform_Rotate270, /** Video flip with respect to X-axis. */ NvBufferTransform_FlipX, /** Video flip with respect to Y-axis. */ NvBufferTransform_FlipY, /** Video flip transpose. */ NvBufferTransform_Transpose, /** Video flip inverse transpode. */ NvBufferTransform_InvTranspose, } NvBufferTransform_Flip; /** * Defines transform video filter types. */ typedef enum { /** transform filter nearest. */ NvBufferTransform_Filter_Nearest, /** transform filter bilinear. */ NvBufferTransform_Filter_Bilinear, /** transform filter 5 tap. */ NvBufferTransform_Filter_5_Tap, /** transform filter 10 tap. */ NvBufferTransform_Filter_10_Tap, /** transform filter smart. */ NvBufferTransform_Filter_Smart, /** transform filter nicest. */ NvBufferTransform_Filter_Nicest, } NvBufferTransform_Filter; /** * Defines flags to indicate for valid transform. */ typedef enum { /** transform flag to crop source rectangle. */ NVBUFFER_TRANSFORM_CROP_SRC = 1, /** transform flag to crop destination rectangle. */ NVBUFFER_TRANSFORM_CROP_DST = 1 << 1, /** transform flag to set filter type. */ NVBUFFER_TRANSFORM_FILTER = 1 << 2, /** transform flag to set flip method. */ NVBUFFER_TRANSFORM_FLIP = 1 << 3, } NvBufferTransform_Flag; /** * Defines flags that specify valid composition/blending operations. */ typedef enum { /** flag to set for composition. */ NVBUFFER_COMPOSITE = 1, /** flag to set for blending. */ NVBUFFER_BLEND = 1 << 1, /** composition flag to set filter type. */ NVBUFFER_COMPOSITE_FILTER = 1 << 2, } NvBufferComposite_Flag; /** * Holds parameters for buffer sync point object. * sync object params is simply a data structure containing [sync point ID,value] pair. * This can be used by clients to describe an event that might want to wait for. */ typedef struct _NvBufferSyncObjParams { uint32_t syncpointID; uint32_t value; }NvBufferSyncObjParams; /** * buffer sync point object. */ typedef struct _NvBufferSyncObjRec { NvBufferSyncObjParams insyncobj[NVBUF_MAX_SYNCOBJ_PARAMS]; uint32_t num_insyncobj; NvBufferSyncObjParams outsyncobj; uint32_t use_outsyncobj; }NvBufferSyncObj; /** * Holds composition background r,g,b colors. */ typedef struct { /** background color value for r. */ float r; /** background color value for g. */ float g; /** background color value for b. */ float b; }NvBufferCompositeBackground; /** * Holds coordinates for a rectangle. */ typedef struct { /** rectangle top. */ uint32_t top; /** rectangle left. */ uint32_t left; /** rectangle width. */ uint32_t width; /** rectangle height. */ uint32_t height; }NvBufferRect; /** * Holds an opaque NvBuffer session type required for parallel buffer * tranformations and compositions. Operations using a single session are * scheduled sequentially, after the previous operation finishes. Operations for * multiple sessions are scheduled in parallel. */ typedef struct _NvBufferSession * NvBufferSession; /** * Holds Chroma Subsampling parameters. */ typedef struct _NvBufferChromaSubSamplingParams { /** location settings */ uint8_t chromaLocHoriz; uint8_t chromaLocVert; }NvBufferChromaSubsamplingParams; #define NVBUF_CHROMA_SUBSAMPLING_PARAMS_DEFAULT \ { \ NVBUF_CHROMA_SUBSAMPLING_HORIZ_DEFAULT, \ NVBUF_CHROMA_SUBSAMPLING_VERT_DEFAULT \ } /** * Holds the input parameters for hardware buffer creation. */ typedef struct _NvBufferCreateParams { /** width of the buffer. */ int32_t width; /** height of the buffer. */ int32_t height; /** payload type of the buffer. */ NvBufferPayloadType payloadType; /** size of the memory.(Applicale for NvBufferPayload_MemHandle) */ int32_t memsize; /** layout of the buffer. */ NvBufferLayout layout; /** colorformat of the buffer. */ NvBufferColorFormat colorFormat; /** tag to associate with the buffer. */ NvBufferTag nvbuf_tag; }NvBufferCreateParams; /** * Holds parameters for a hardware buffer. */ typedef struct _NvBufferParams { /** Holds the DMABUF FD of the hardware buffer. */ uint32_t dmabuf_fd; /** pointer to hardware buffer memory. */ void *nv_buffer; /** payload type of the buffer. */ NvBufferPayloadType payloadType; /** size of the memory.(Applicale for NvBufferPayload_MemHandle) */ int32_t memsize; /** size of hardware buffer. */ uint32_t nv_buffer_size; /** video format type of hardware buffer. */ NvBufferColorFormat pixel_format; /** number of planes of hardware buffer. */ uint32_t num_planes; /** width of each planes of hardware buffer. */ uint32_t width[MAX_NUM_PLANES]; /** height of each planes of hardware buffer. */ uint32_t height[MAX_NUM_PLANES]; /** pitch of each planes of hardware buffer. */ uint32_t pitch[MAX_NUM_PLANES]; /** memory offset values of each video planes of hardware buffer. */ uint32_t offset[MAX_NUM_PLANES]; /** size of each vodeo planes of hardware buffer. */ uint32_t psize[MAX_NUM_PLANES]; /** layout type of each planes of hardware buffer. */ uint32_t layout[MAX_NUM_PLANES]; }NvBufferParams; /** * Holds extended parameters for a hardware buffer. */ typedef struct _NvBufferParamsEx { /** nvbuffer basic parameters. */ NvBufferParams params; /** offset in bytes from the start of the buffer to the first valid byte. (Applicale for NvBufferPayload_MemHandle) */ int32_t startofvaliddata; /** size of the valid data from the first to the last valid byte. (Applicale for NvBufferPayload_MemHandle) */ int32_t sizeofvaliddatainbytes; /** display scan format - progressive/interlaced. */ NvBufferDisplayScanFormat scanformat[MAX_NUM_PLANES]; /** offset of the second field for interlaced buffer. */ uint32_t secondfieldoffset[MAX_NUM_PLANES]; /** block height of the planes for blockLinear layout hardware buffer. */ uint32_t blockheightlog2[MAX_NUM_PLANES]; /** physical address of allocated planes. */ uint32_t physicaladdress[MAX_NUM_PLANES]; /** flags associated with planes */ uint64_t flags[MAX_NUM_PLANES]; /** metadata associated with the hardware buffer. */ void *payloadmetaInfo; /** chroma subsampling parameters */ NvBufferChromaSubsamplingParams chromaSubsampling; /** get buffer vpr information. */ bool is_protected; /** buffer sync point object parameters */ NvBufferSyncObj syncobj; /** reserved field. */ void *reserved; }NvBufferParamsEx; /** * Holds parameters related to compositing/blending. */ typedef struct _NvBufferCompositeParams { /** flag to indicate which of the composition/blending parameters are valid. */ uint32_t composite_flag; /** number of the input buffers to be composited. */ uint32_t input_buf_count; /** filters to use for composition. */ NvBufferTransform_Filter composite_filter[MAX_COMPOSITE_FRAME]; /** alpha values of input buffers for the blending. */ float dst_comp_rect_alpha[MAX_COMPOSITE_FRAME]; /** source rectangle coordinates of input buffers for composition. */ NvBufferRect src_comp_rect[MAX_COMPOSITE_FRAME]; /** destination rectangle coordinates of input buffers for composition. */ NvBufferRect dst_comp_rect[MAX_COMPOSITE_FRAME]; /** background color values for composition. */ NvBufferCompositeBackground composite_bgcolor; /** NvBufferSession to be used for composition. If NULL, the default session * is used. */ NvBufferSession session; }NvBufferCompositeParams; /** * Holds parameters for buffer transform functions. */ typedef struct _NvBufferTransformParams { /** flag to indicate which of the transform parameters are valid. */ uint32_t transform_flag; /** flip method. */ NvBufferTransform_Flip transform_flip; /** transform filter. */ NvBufferTransform_Filter transform_filter; /** source rectangle coordinates for crop opeartion. */ NvBufferRect src_rect; /** destination rectangle coordinates for crop opeartion. */ NvBufferRect dst_rect; /** NvBufferSession to be used for transform. If NULL, the default session * is used. */ NvBufferSession session; }NvBufferTransformParams; /** * This method can be used to wait on sync point ID. * * @param[in] syncobj_params sync point object parameters. * @param[in] timeout sync point wait timeout value. * * @returns 0 for success, -1 for failure */ int NvBufferSyncObjWait (NvBufferSyncObjParams *syncobj_params, unsigned int timeout); /** * This method can be used to get hardware Buffer struct size. * * @returns hardware Buffer struct size. */ int NvBufferGetSize (void); /** * Creates an instance of EGLImage from a DMABUF FD. * * @param[in] display An EGLDisplay object used during the creation * of the EGLImage. If NULL, nvbuf_utils() uses * its own instance of EGLDisplay. * @param[in] dmabuf_fd DMABUF FD of the buffer from which the EGLImage * is to be created. * * @returns `EGLImageKHR` for success, `NULL` for failure */ EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd); /** * Destroys an EGLImage object. * * @param[in] display An EGLDisplay object used to destroy the EGLImage. * If NULL, nvbuf_utils() uses its own instance of * EGLDisplay. * @param[in] eglImage The EGLImageKHR object to be destroyed. * * @returns 0 for success, -1 for failure */ int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage); /** * Allocates a hardware buffer (deprecated). * * @deprecated Use NvBufferCreateEx() instead. * @param[out] dmabuf_fd Returns the DMABUF FD of the hardware buffer. * @param[in] width Buffer width, in bytes. * @param[in] height Buffer height, in bytes. * @param[in] layout Layout of the buffer. * @param[in] colorFormat Color format of the buffer. * * @return 0 if successful, or -1 otherwise. */ int NvBufferCreate (int *dmabuf_fd, int width, int height, NvBufferLayout layout, NvBufferColorFormat colorFormat); /** * Allocates a hardware buffer. * * @param[out] dmabuf_fd Returns the DMABUF FD of the hardware buffer. * @param[in] input_params Input parameters for hardware buffer creation. * * @returns 0 for success, -1 for failure */ int NvBufferCreateEx (int *dmabuf_fd, NvBufferCreateParams *input_params); /** * Allocates a hardware buffer for interlace scan format. * * @param[out] dmabuf_fd Returns the DMABUF FD of the hardware buffer. * @param[in] input_params Input parameters for hardware buffer creation. * * @returns 0 for success, -1 for failure */ int NvBufferCreateInterlace (int *dmabuf_fd, NvBufferCreateParams *input_params); /** * Allocates a hardware buffer with a given chroma subsampling location. * * @param[in] dmabuf_fd DMABUF FD of the buffer. * @param[in] input_params Input parameters for hardware buffer creation. * @param[in] chromaSubsampling Chroma location parameters. * * @returns 0 for success, -1 for failure */ int NvBufferCreateWithChromaLoc (int *dmabuf_fd, NvBufferCreateParams *input_params, NvBufferChromaSubsamplingParams *chromaSubsampling); /** * Gets buffer parameters. * @param[in] dmabuf_fd `DMABUF FD` of buffer. * @param[out] params A pointer to the structure to fill with parameters. * * @returns 0 for success, -1 for failure. */ int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params); /** * Gets buffer extended parameters. * @param[in] dmabuf_fd `DMABUF FD` of buffer. * @param[out] exparams A pointer to the structure to fill with extended parameters. * * @returns 0 for success, -1 for failure. */ int NvBufferGetParamsEx (int dmabuf_fd, NvBufferParamsEx *exparams); /** * Destroys a hardware buffer. * @param[in] dmabuf_fd Specifies the `dmabuf_fd` `hw_buffer` to destroy. * * @returns 0 for success, -1 for failure. */ int NvBufferDestroy (int dmabuf_fd); /** * Extracts the `dmabuf_fd` from the hardware buffer. * @param[in] nvbuf Specifies the `hw_buffer`. * @param[out] dmabuf_fd Returns DMABUF FD of `hw_buffer`. * * @returns 0 for success, -1 for failure. */ int ExtractFdFromNvBuffer (void *nvbuf, int *dmabuf_fd); /** * Releases the `dmabuf_fd` buffer. * @see ExtractfdFromNvBuffer() * @param[in] dmabuf_fd Specifies the `dmabuf_fd` to release. * * @returns 0 for success, -1 for failure. */ int NvReleaseFd (int dmabuf_fd); /** * Syncs the hardware memory cache for the CPU. * * \sa NvBufferMemMap for the purpose of the function * * @param[in] dmabuf_fd DMABUF FD of buffer. * @param[in] plane video frame plane. * @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr); /** * Syncs the hardware memory cache for the CPU, API to be used for another process. * * \sa NvBufferMemMapEx for the purpose of the function * * @param[in] dmabuf_fd DMABUF FD of buffer. * @param[in] exparams extended parameters for a hardware buffer. * @param[in] plane video frame plane. * @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemSyncForCpuEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr); /** * Syncs the hardware memory cache for the device. * * \sa NvBufferMemMap for the purpose of the function * * @param[in] dmabuf_fd DMABUF FD of buffer. * @param[in] plane video frame plane. * @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemSyncForDevice (int dmabuf_fd, unsigned int plane, void **pVirtAddr); /** * Syncs the hardware memory cache for the device, API to be used for another process. * * \sa NvBufferMemMapEx for the purpose of the function * * @param[in] dmabuf_fd DMABUF FD of buffer. * @param[in] exparams extended parameters for a hardware buffer. * @param[in] plane video frame plane. * @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemSyncForDeviceEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr); /** * Gets the memory-mapped virtual address of the plane. * * The client must call NvBufferMemSyncForCpu() with the virtual address returned * by this function before accessing the mapped memory in CPU. * * After memory mapping is complete, mapped memory modification * must be coordinated between the CPU and hardware device as * follows: * - CPU: If the CPU modifies any mapped memory, the client must call * NvBufferMemSyncForDevice() before any hardware device accesses the memory. * - Hardware device: If the mapped memory is modified by any hardware device, * the client must call NvBufferMemSyncForCpu() before CPU accesses the memory. * * @param[in] dmabuf_fd DMABUF FD of buffer. * @param[in] plane video frame plane.(Applies to @ref NvBufferPayload_SurfArray.) * @param[in] memflag NvBuffer memory flag. * @param[out] pVirtAddr Virtual Address pointer of the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr); /** * Gets the memory-mapped virtual address of the plane, API to be used for another process. * * The client must call NvBufferMemSyncForCpuEx() with the virtual address returned * by this function before accessing the mapped memory in CPU in another process. * * After memory mapping is complete, mapped memory modification * must be coordinated between the CPU and hardware device as * follows: * - CPU: If the CPU modifies any mapped memory, the client must call * NvBufferMemSyncForDeviceEx() before any hardware device accesses the memory. * - Hardware device: If the mapped memory is modified by any hardware device, * the client must call NvBufferMemSyncForCpuEx() before CPU accesses the memory. * * @param[in] dmabuf_fd DMABUF FD of buffer. * @param[in] exparams extended parameters for a hardware buffer. * @param[in] plane video frame plane.(Applies to @ref NvBufferPayload_SurfArray.) * @param[in] memflag NvBuffer memory flag. * @param[out] pVirtAddr Virtual Address pointer of the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemMapEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr); /** * Unmaps the mapped virtual address of the plane. * * If the following conditions are both true, the client must call * NvBufferMemSyncForDevice() before unmapping the memory: * - Mapped memory was modified by the CPU. * - Mapped memory will be accessed by a hardware device. * * @param[in] dmabuf_fd DMABUF FD of the buffer. * @param[in] plane Video frame plane. Applies to * @ref NvBufferPayload_SurfArray. * @param[in] pVirtAddr Virtual address pointer to the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr); /** * Unmaps the mapped virtual address of the plane, API to be used for another process. * * If the following conditions are both true, the client must call * NvBufferMemSyncForDeviceEx() before unmapping the memory in another process: * - Mapped memory was modified by the CPU. * - Mapped memory will be accessed by a hardware device. * * @param[in] dmabuf_fd DMABUF FD of the buffer. * @param[in] exparams extended parameters for a hardware buffer. * @param[in] plane Video frame plane. Applies to * @ref NvBufferPayload_SurfArray. * @param[in] pVirtAddr Virtual address pointer to the memory-mapped plane. * * @returns 0 for success, -1 for failure. */ int NvBufferMemUnMapEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr); /** * Copies the NvBuffer plane contents to a raw buffer plane. * @param[in] dmabuf_fd DMABUF FD of NvBuffer. * @param[in] plane video frame plane. * @param[in] out_width aligned width of the raw data plane. * @param[in] out_height aligned height of the raw data plane. * @param[in] ptr pointer to the output raw plane data. * * @returns 0 for success, -1 for failure. */ int NvBuffer2Raw (int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr); /** * Copies raw buffer plane contents to an NvBuffer plane. * @param[in] ptr pointer to the input raw plane data. * @param[in] plane video frame plane. * @param[in] in_width aligned width of the raw data plane. * @param[in] in_height aligned height of the raw data plane. * @param[in] dmabuf_fd DMABUF FD of NvBuffer. * * @returns 0 for success, -1 for failure. */ int Raw2NvBuffer (unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd); /** * Creates a new NvBufferSession for parallel scheduling of * buffer transformations and compositions. * * @returns A session pointer, NULL for failure. */ NvBufferSession NvBufferSessionCreate(void); /** * Destroys an existing \ref NvBufferSession. * @param[in] session An existing NvBufferSession. */ void NvBufferSessionDestroy(NvBufferSession session); /** * Transforms one DMA buffer to another DMA buffer. * This function can support transforms for copying, scaling, fliping, rotating, and cropping. * @param[in] src_dmabuf_fd DMABUF FD of source buffer * @param[in] dst_dmabuf_fd DMABUF FD of destination buffer * @param[in] transform_params transform parameters * * @return 0 for sucess, -1 for failure. */ int NvBufferTransform (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params); /** * Transforms one DMA buffer to another DMA buffer, API to be used for another process. * This function can support transforms for copying, scaling, fliping, rotating, and cropping. * @param[in] src_dmabuf_fd DMABUF FD of source buffer * @param[in] input_params extended input parameters for a hardware buffer. * @param[in] dst_dmabuf_fd DMABUF FD of destination buffer * @param[in] output_params extended output parameters for a hardware buffer. * @param[in] transform_params transform parameters * * @return 0 for sucess, -1 for failure. */ int NvBufferTransformEx (int src_dmabuf_fd, NvBufferParamsEx *input_params, int dst_dmabuf_fd, NvBufferParamsEx *output_params, NvBufferTransformParams *transform_params); /** * Transforms one DMA buffer to another DMA buffer asyncroniously (non-blocking). * This function can support transforms for copying, scaling, fliping, rotating, and cropping. * @param[in] src_dmabuf_fd DMABUF FD of source buffer * @param[in] dst_dmabuf_fd DMABUF FD of destination buffer * @param[in] transform_params transform parameters * @param[in] syncobj nvbuffer sync point object * * @return 0 for sucess, -1 for failure. */ int NvBufferTransformAsync (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params, NvBufferSyncObj *syncobj); /** * \brief Composites multiple input DMA buffers to one output DMA buffer. * * This function can composite multiple input frames to one output. * * @param[in] src_dmabuf_fds An array of DMABUF FDs of source buffers. * These buffers are composited together. Output * is copied to the output buffer referenced by * @a dst_dmabuf_fd. * @param[in] dst_dmabuf_fd DMABUF FD of the compositing destination buffer. * @param[in] composite_params Compositing parameters. */ int NvBufferComposite (int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params); #ifdef __cplusplus } #endif /** @} */ #endif
34.193548
171
0.73188
[ "object", "transform" ]
6a6d46174318f6517422daaa9d66c820a10e7d52
21,511
h
C
src/SynthPopul/EstablishmentStruct.h
midas-isg/global-epidemic-simulator
00a481d20336ed1c8560d2ac7fabed3f634a0726
[ "Apache-2.0" ]
null
null
null
src/SynthPopul/EstablishmentStruct.h
midas-isg/global-epidemic-simulator
00a481d20336ed1c8560d2ac7fabed3f634a0726
[ "Apache-2.0" ]
null
null
null
src/SynthPopul/EstablishmentStruct.h
midas-isg/global-epidemic-simulator
00a481d20336ed1c8560d2ac7fabed3f634a0726
[ "Apache-2.0" ]
null
null
null
/* EstablishmentStruct.h, part of the Global Epidemic Simulation v1.0 BETA /* /* Copyright 2012, MRC Centre for Outbreak Analysis and Modelling /* /* 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. */ /* classes describing generic establishment and used to map hosts to establishments */ #ifndef ESTABLISHMENT_STRUCT #define ESTABLISHMENT_STRUCT #include "Country.h" #include "EstablishmentDistr.h" #ifdef _OPENMP #include "omp.h" #endif /* class describing generic establishment */ class Country::Establishment { public: double Lat; // Lat coordinate double Lon; // Lon coordinate unsigned int LndScnX; // X and Y coordinates of LandScan cell unsigned int LndScnY; unsigned int NumHosts; // number of hosts associated with Establishment unsigned int NumHostVacancs; // number of vacancies unsigned int NumStaff; // number of staff - people from different age group - associated with Establishment (e.g. staff at schools or nurseries) unsigned int NumStaffVacancs; // number of staff vacancies /* fills in host vacancy; returns the number of remaining host vacancies */ unsigned int FillHostVacancy(); /* fills in staff vacancy; returns the number of remaining staff vacancies */ unsigned int FillStaffVacancy(); }; /* model establishment size distribution vector */ class Country::MdESDVec { public: /* element of vector */ class MdESDVEl { public: unsigned int Size; // establishment size float Prob; // corresponding probability distribution vector value unsigned int NumEst; // number of establishments (size band value) }; unsigned int NumEls; // number of elements in vector MdESDVEl *V; // vector of ESDVEl elements /* default constructor; creates undefined vector */ MdESDVec(); /* constructor; creates empty vector based on input establishment size distribution vector */ /* ESDV: input establishment size distribution vector */ MdESDVec(ESDVec *pESDV); ~MdESDVec(); }; /* table of Establishment objects */ class Country::EstablishmentTbl { private: float ExtCoeff; unsigned int NumRecs; // number of nonempty records in Table unsigned int NumRecsMax; // max. allowed number of records in Table Country::Establishment *Table; // table of Establishment objects public: /* default constructor; creates undefined table */ EstablishmentTbl(); /* constructor; creates empty table of Establishment objects */ /* numEst: total number of establishments; extCoeff: extension coefficient for Table */ EstablishmentTbl(unsigned int TblSize, float extCoeff); ~EstablishmentTbl(); /* adds record in establishment table */ /* pEst: pointer to the record to be added */ void AddRec(Establishment *pEst); /* appends a table to an existing one */ void AppendTable(EstablishmentTbl *pEstTbl); /* gets the first empty record index in Table */ unsigned int GetFirstEmptyRecIndex(); /* resets table */ void ResetTable(); /* gets Establishment object out of Table */ /* estObjIndx: index of Establishment object (record); pEst: pointer to location in memory through which this object is returned */ void GetEstablishmentRec(unsigned int estObjIndx, Country::Establishment *pEst); /* gets establishment coordinates */ /* estObjIndx: establishment index; *pLat and *pLon: pointers to variables through which Lat and Lon are returned */ void GetEstablishmentCoords(unsigned int estObjIndx, double *pLat, double *pLon); /* gets X and Y indexes of the LandScan cell that contains the establishment */ /* estObjIndx: establishment index; *pLndScnX and *pLndScnY: pointers to the variables through which the indexes are returned */ void GetEstablishmentLndScnIndxs(unsigned int estObjIndx, unsigned int *pLndScnX, unsigned int *pLndScnY); /* assigns host to establishment; returns the number of remaining host vacancies */ /* estObjIndx: establishment index (establishment ID) */ unsigned int AssignHost(unsigned int estObjIndx); /* assigns staff member to establishment; returns the number of remaining staff vacancies */ /* estObjIndx: establishment index (establishment ID) */ unsigned int AssignStaff(unsigned int estObjIndx); /* gets the total number of establishments (number of records in Table) */ unsigned int GetNumEstablishments(); /* gets random unoccupied establishment */ unsigned int GetRndUnoccpdEstablishment(); /* modifies record in Table */ /* estObjIndx: establishment index; pEst: pointer to new Establishment object that replaces one with index estObjIndx */ void ModifyRec(unsigned int estObjIndx, Country::Establishment *pEst); /* computes model establishment size distribution */ Country::MdESDVec* CompModelEstSizeDistr(ESDVec *pESDV); }; /* class that describes mapping hosts to establishments */ class Country::HostToEstablishmentMap { private: /* class describing geographical patch - set of LandScan cells; these patches are used in rejection acceptance sampling */ class GeoPatch { public: /* vector of establishment indexes in the Establishment objects table (EstablishmentTblCl) associated with a given patch */ class EstablishmentIndxVec { public: class Indx { public: unsigned int ElIndx; // index of element in vector V (see below) unsigned int EstObjIndx; // establishment object index }; float ExtCoeff; // coefficient of extension (set to 0.5) unsigned int NumEls; // number of nonempty elements in V unsigned int NumElsMax; // max. capacity of V unsigned int *V; // vector of establishment indexes /* default constructor; creates undefined vector */ EstablishmentIndxVec(); /* constructor; creates empty vector with initial capacity EstIndxIniVecLngth and extension coefficient extCoeff */ EstablishmentIndxVec(unsigned int EstIndxIniVecLngth, float extCoeff); /* copy constructor */ EstablishmentIndxVec(const EstablishmentIndxVec& PIV); ~EstablishmentIndxVec(); /* assignment operator */ EstablishmentIndxVec operator=(const EstablishmentIndxVec& PIV2); /* adds the establishment index (in the table of establishment objects) into vector V */ /* returns the index (in V) of the added element */ /* estObjIndx: index in the table of establishment objects */ unsigned int AddEstablishmentIndx(unsigned int estObjIndx); /* gets establishment object index (can be the last one in V or a random one depending on implementation) */ void GetEstablishmentIndx(Indx *pIndx); /* removes the establishment index from vector V returning the number of remaining indexes */ /* pIndx: describes index of the element in V to be removed */ unsigned int RemoveEstablishmentIndx(Indx *pIndx); /* resets vector */ void Reset(); }; /* probability distribution vector - auxiliary distribution used in rejection-acceptance sampling */ class PDVec { public: /* element of probability distribution vector */ class PDVEl { public: unsigned int GeoPtchIndx; // geographical patch index double CProb; // corresponding value of the cumulative probability distribution }; unsigned int NumEls; // number of elements in vector V unsigned int NumElsMax; // max. capacity of V PDVEl *V; // vector of PDVEl elements /* default constructor; creates undefined vector */ PDVec(); /* constructor; creates empty vector of length PDVecLngth */ PDVec(unsigned int PDVecLngth); /* copy constructor */ PDVec(const PDVec& PDV); ~PDVec(); /* assignment operator */ PDVec operator=(const PDVec& PDV2); /* adds probability value to the cumulative probability distribution vector */ void AddProbVal(unsigned int geoPtchIndx, double probVal); /* normalizes cumulative probability vector */ void Normalize(); }; /* vector of indexes of LandScan cells filling given geographical patch */ class LndScnCellVec { public: unsigned int NumEls; // number of nonempty elements in V unsigned int NumElsMax; // max. capacity of V unsigned int *V; // vector of LandScan cell indexes /* constructor; creates empty vector */ LndScnCellVec(); /* copy constructor */ LndScnCellVec(const LndScnCellVec& LSCVec); ~LndScnCellVec(); /* assignment operator */ LndScnCellVec operator=(const LndScnCellVec& LSCVec2); /* adds LandScan cell index into vector */ void AddLandScanCellIndx(unsigned int LndScnCellIndx); }; unsigned int GPLndScnX; // X and Y patch coordinates represented as LandScan indexes of the upper left corner cell unsigned int GPLndScnY; EstablishmentIndxVec *PEstIndxV; // vector of establishment indexes in the establishment objects table (EstablishmentTbl) associated with a given patch PDVec *PPDV; // auxiliary cumulative probability distribution vector LndScnCellVec *PLSCVec; // vector of indexes of LandScan cells filling given geographical patch unsigned int NumRepHits; // number of repeated hits during rejection acceptance sampling unsigned int NumHostVacancs; // number of vacancies in the establishments located in a patch unsigned int NumStaffVacancs; // number of staff vacancies in those establishments /* default constructor; creates undefined GeoPatch object */ GeoPatch(); /* constructor; builds a GeoPatch object */ /* gpLndScnX and gpLndScnY: X and Y patch coordinates represented as LandScan indexes of the upper left corner cell */ /* estIndxVecIniLngth: initial length of the vector of establishment indexes EstablishmentIndxVec; estIndxVecExtCoeff: extension coefficient of that vector */ GeoPatch(unsigned int gpLndScnX, unsigned int gpLndScnY, unsigned int estIndxVecIniLngth, float estIndxVecExtCoeff); /* constructor; builds a GeoPatch object */ /* gpLndScnX and gpLndScnY: X and Y patch coordinates represented as LandScan indexes of the upper left corner cell */ GeoPatch(unsigned int gpLndScnX, unsigned int gpLndScnY); /* copy constructor */ GeoPatch(const GeoPatch& GP); ~GeoPatch(); /* assignment operator */ GeoPatch operator=(const GeoPatch& GP2); }; /* vector of geographical patches */ class GeoPatchVec { public: float ExtCoeff; // coefficient of extension (default set to 0.5) unsigned int NumEls; // number of elements in V (geographical patches) unsigned int NumEstPtchs; // number of geographical patches that contain establishments (these patches have indexes i = 0 ... (NumEstPtchs-1) in V) unsigned int NumAvailEstPtchs; // number of geographical patches that contain _unoccupied_ establishments (NumAvailEstPtchs < = NumEstPtchs) unsigned int NumElsMax; // max. capacity of V GeoPatch *V; // vector of GeoPatch elements /* default constructor; creates undefined vector */ GeoPatchVec(); /* constructor; creates empty vector with initial capacity gpPatchVecIniLngth and extension coefficient extCoeff */ GeoPatchVec(unsigned int gpPatchVecIniLngth, float extCoeff); ~GeoPatchVec(); /* adds GeoPatch object to V */ /* pGPtch: pointer to an object to be added */ /* returns index of the added geographical patch in V */ unsigned int AddGeoPatch(GeoPatch *pGPtch); /* returns pointer to geographical patch with index geoPatchIndx in vector V */ GeoPatch* GetGeoPatch(unsigned int geoPatchIndx); /* increments the counter of geographical patches with establishments */ void IncrEstPtchsCntr(); /* increments the counter of geographical patches with available establishments */ /* returns new value of counter */ unsigned int IncrAvailEstPtchsCntr(); /* decrements the counter of available geographical patches with establishments */ /* returns new value of counter */ unsigned int DecrAvailEstPtchsCntr(); /* resets the counter of geographical patches that contain establishments */ void ResetEstPtchsCntr(); }; /* matrix that contains indexes of geographical patches in GeoPatchVec vector */ /* used to map hosts to the corresponding patches */ class GeoPatchIndxMtrx { public: unsigned int XRef; // coordinates of the reference point - the start of the "local" geographical patch grid unsigned int YRef; // represented as a pair of LandScan indexes of the upper left LandScan cell in the upper left patch unsigned int Grnlty; // granularity of geographical patches (number of LandScan cells in each dimension) unsigned int DimX; // X and Y (column and row) dimensions of M unsigned int DimY; unsigned int **M; // matrix /* constructor; builds empty matrix */ GeoPatchIndxMtrx(unsigned int xRef, unsigned int yRef, unsigned int gpGrnlty, unsigned int dimX, unsigned int dimY); ~GeoPatchIndxMtrx(); /* calculates geographical patch index X for a LandScan cell with index LndScnX */ unsigned int LndScnXToX(unsigned int LndScnX); /* calculates geographical patch index Y for a LandScan cell with index LndScnY */ unsigned int LndScnYToY(unsigned int LndScnY); /* calculates X coordinate (LandScan X index of the LandScan cell in the upper left patch corner) of the geographical patch where the LandScan cell with X coordinate LndScnCellX is located */ unsigned int LndScnCellXToGPLdnScnX(unsigned int LndScnCellX); /* calculates Y coordinate (LandScan Y index of the LandScan cell in the upper left patch corner) of the geographical patch where the LandScan cell with Y coordinate LndScnCellY is located */ unsigned int LndScnCellYToGPLdnScnY(unsigned int LndScnCellY); /* returns distance between the geographical patches with indexes (x1, y1) and (x2, y2) */ /* pCLSCTbl: pointer to the LandScan cell table for the country */ double PatchDist(CntryLndScnCellTbl *pCLSCTbl, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2); }; /* table setting index reference between Establishment table and Host table */ class HostToEstIndexTbl { public: /* index entry */ class IndexEntry { public: unsigned int NumEls; // number of elements in index array Indx unsigned int NumElsMax; // number of elements in Indx - establishment capacity (number of hosts + staff) unsigned int *Indx; // array of host indexes (in Host table) /* default constructor */ IndexEntry(); /* constructor; builds empty index array of numElsMax elements */ IndexEntry(unsigned int numElsMax); ~IndexEntry(); /* adds host index into establishment index entry */ /* hostIndx: index of host in Host table */ void AddIndex(unsigned int hostIndx); /* extracts random host index from establishment index entry */ unsigned int ExtractRndIndex(); }; unsigned int NumElsMax; // max. capacity of table IndexEntry *Table; // pointer to array of index entries /* constructor; builds empty table of numElsMax entries */ HostToEstIndexTbl(unsigned int numElsMax); ~HostToEstIndexTbl(); /* adds empty index entry into table */ /* estIndx: establishment index in Table; estCapacty: establishment capacity */ void AddEmptyIndexEntry(unsigned int estIndx, unsigned int estCapacty); /* gets index entry */ /* estIndx: establishment index in Table */ IndexEntry* GetIndxEntry(unsigned int estIndx); }; GeoPatchVec *PGPVec; // vector of geographical patches GeoPatchIndxMtrx *PGPIndxMtrx; // matrix of geographical patch indexes HostToEstTravelDistrKernel *PHETDKernel; // pointer to the kernel function object containing different kernel function types PointerToKernFunc F; // pointer to the chosen kernel function HostToEstIndexTbl *PHEIndxTbl; // Host->Establishment index table /* (re)builds auxiliary probability distribution vectors, PDVec, for host vacancies from the current age group in each geographical patch */ void BuildHostPDVs(CntryLndScnCellTbl *pCLSCTbl); /* (re)builds auxiliary probability distribution vectors for _staff_ vacancies, PDVec, in each geographical patch */ void BuildStaffPDVs(CntryLndScnCellTbl *pCLSCTbl); /* samples a patch; used in the rejection-acceptance establishment sampling */ /* x and y are coordinates (indexes in GeoPatchIndxMtrx matrix) of geographical patch for which sampling is done */ unsigned int SamplePatch(unsigned int x, unsigned int y); /* creates Establishment object and adds it to Establishment table */ /* estGPIndx: index of a geographical patch (in the vector GeoPatchVec) where an establishment is to be located; */ /* pCLSCTbl: pointer to the LandScan cell table for the country; pESDV: pointer to the establishment size distribution vector; pEstTbl: pointer to the table of establishments */ void CreateEstablishment(unsigned int estGPIndx, CntryLndScnCellTbl *pCLSCTbl, ESDVec *pESDV, Country::EstablishmentTbl *pEstTbl); /* creates table of references between Establishment table and Host table */ void CreateHostToEstIndexTbl(Country::EstablishmentTbl *pEstTbl, Country::HostTbl *pHostTbl); /* deletes table of references created by the previous method */ void DeleteHostToEstIndexTbl(); public: /* constructor; builds geographical patch index matrix and vector of geographical patches for allocating HOSTS from the target age group to establishments */ /* pCLSCTbl: LandScan cell table for the country; GPGrnlty: granularity of geographical patches (number of LandScan cells in each dimension); pEstTbl: table of Establishment objects */ /* pHETDKernel: kernel function object */ HostToEstablishmentMap(CntryLndScnCellTbl *pCLSCTbl, unsigned int GPGrnlty, Country::EstablishmentTbl *pEstTbl, HostToEstTravelDistrKernel *pHETDKernel); /* constructor; builds geographical patch index matrix and vector of geographical patches for allocating STAFF (hosts from a selected age group, different from the target one) to establishments */ /* hosts are assumed to have been previously allocated to establishments */ /* pCLSCTbl: LandScan cell table for the country; GPGrnlty: granularity of geographical patches (number of LandScan cells in each dimension); pESDV: pointer to the establishment size distribution vector */ /* pEstTbl: table of Establishment objects; pHETDKernel: kernel function object */ HostToEstablishmentMap(CntryLndScnCellTbl *pCLSCTbl, unsigned int GPGrnlty, ESDVec *pESDV, Country::EstablishmentTbl *pEstTbl, HostToEstTravelDistrKernel *pHETDKernel); ~HostToEstablishmentMap(); /* assigns hosts to establishments */ /* pCLSCTbl: pointer to the LandScan cell table for the country; pHostTbl: pointer to the table of hosts; */ /* pHshldTbl: pointer to the Household table; pESDV: pointer to the establishment size distribution vector; pEstTbl: pointer to the table of establishments */ void AssignHostsToEstablishments(CntryLndScnCellTbl *pCLSCTbl, Country::HostTbl *pHostTbl, Country::HouseholdTbl *pHshldTbl, ESDVec *pESDV, Country::EstablishmentTbl *pEstTbl); /* assigns staff to establishments */ /* pCLSCTbl: pointer to the LandScan cell table for the country; pHostTbl: pointer to the table of hosts; */ /* pHshldTbl: pointer to the Household table; pESDV: pointer to the establishment size distribution vector; pEstTbl: pointer to the table of establishments */ void AssignStaffToEstablishments(CntryLndScnCellTbl *pCLSCTbl, Country::HostTbl *pHostTbl, Country::HouseholdTbl *pHshldTbl, ESDVec *pESDV, Country::EstablishmentTbl *pEstTbl); /* creates groups of hosts within establishments for current age group */ /* pHostTbl: pointer to the table of hosts, pESDV: pointer to the establishment size distribution vector, pEstTbl: pointer to the table of establishments */ void CreateHostGroups(Country::HostTbl *pHostTbl, ESDVec *pESDV, Country::EstablishmentTbl *pEstTbl); /* computes model host-to-establishment travel statistics */ /* pHostTbl: pointer to the table of hosts; pHshldTbl: pointer to the household table; pEstTbl: pointer to the table of establishments */ HETDVec* CompHostToEstablishmentTravelStat(Country::HostTbl *pHostTbl, Country::HouseholdTbl *pHshldTbl, Country::EstablishmentTbl *pEstTbl); /* computes model host-to-establishment travel statistics for specific age group */ /* pHostTbl: pointer to the table of hosts; pHshldTbl: pointer to the household table; pEstTbl: pointer to the table of establishments; */ /* pHETDKernel: pointer to host-to-establishment travel distribution kernel; ageGroupIndx: age group index */ HETDVec* CompHostToEstablishmentTravelStat(Country::HostTbl *pHostTbl, Country::HouseholdTbl *pHshldTbl, Country::EstablishmentTbl *pEstTbl, HostToEstTravelDistrKernel *pHETDKernel, unsigned short ageGroupIndx); }; #endif
42.936128
212
0.738552
[ "object", "vector", "model" ]
6a7635b1b8c69fe95534983587e9476974d330d7
3,100
h
C
Includes/Core/Utils/Samplers.h
utilForever/CubbyFlow-v1
d85c136d8eaa91ecce456c3356c7e578dda5d5bd
[ "MIT" ]
3
2020-04-15T13:41:16.000Z
2020-12-29T11:23:59.000Z
Includes/Core/Utils/Samplers.h
utilForever/CubbyFlow-v1
d85c136d8eaa91ecce456c3356c7e578dda5d5bd
[ "MIT" ]
null
null
null
Includes/Core/Utils/Samplers.h
utilForever/CubbyFlow-v1
d85c136d8eaa91ecce456c3356c7e578dda5d5bd
[ "MIT" ]
null
null
null
/************************************************************************* > File Name: Samplers.h > Project Name: CubbyFlow > Author: Chan-Ho Chris Ohk > Purpose: Sampler functions for CubbyFlow. > Created Time: 2017/06/21 > Copyright (c) 2018, Chan-Ho Chris Ohk *************************************************************************/ #ifndef CUBBYFLOW_SAMPLERS_H #define CUBBYFLOW_SAMPLERS_H #include <Core/Vector/Vector2.h> #include <Core/Vector/Vector3.h> namespace CubbyFlow { //! //! \brief Returns randomly sampled direction within a cone. //! //! For a given cone, defined by axis and angle, this function returns a sampled //! direction vector within the cone. //! //! \param[in] u1 First random sample. //! \param[in] u2 Second random sample. //! \param[in] axis The axis of the cone. //! \param[in] angle The angle of the cone. //! //! \tparam T Real number type. //! //! \return Sampled direction vector. //! template <typename T> inline Vector3<T> UniformSampleCone(T u1, T u2, const Vector3<T>& axis, T angle); //! //! \brief Returns randomly sampled point within a unit hemisphere. //! //! For a given unit hemisphere, defined by center normal vector, this function //! returns a point within the hemisphere. //! //! \param[in] u1 First random sample. //! \param[in] u2 Second random sample. //! \param[in] normal The center normal of the hemisphere. //! //! \tparam T Real number type. //! //! \return Sampled point. //! template <typename T> inline Vector3<T> UniformSampleHemisphere(T u1, T u2, const Vector3<T>& normal); //! //! \brief Returns weighted sampled point on a hemisphere. //! //! For a given hemisphere, defined by center normal vector, this function //! returns a point on the hemisphere, where the probability is cosine-weighted. //! //! \param[in] u1 First random sample. //! \param[in] u2 Second random sample. //! \param[in] normal The center normal of the hemisphere. //! //! \tparam T Real number type. //! //! \return Sampled point. //! template <typename T> inline Vector3<T> CosineWeightedSampleHemisphere(T u1, T u2, const Vector3<T>& normal); //! //! \brief Returns randomly a point on a sphere. //! //! For a given sphere, defined by center normal vector, this function returns a //! point on the sphere. //! //! \param[in] u1 First random sample. //! \param[in] u2 Second random sample. //! //! \tparam T Real number type. //! //! \return Sampled point. //! template <typename T> inline Vector3<T> UniformSampleSphere(T u1, T u2); //! //! \brief Returns randomly a point on a disk. //! //! For a given disk, this function returns a point on the disk. //! //! \param[in] u1 First random sample. //! \param[in] u2 Second random sample. //! //! \tparam T Real number type. //! //! \return Sampled point. //! template <typename T> inline Vector2<T> UniformSampleDisk(T u1, T u2); } #include <Core/Utils/Samplers-Impl.h> #endif
30.097087
88
0.612581
[ "vector" ]
ac90a76e2ad3ec66c7ead345a66392cd1d98df01
13,117
c
C
src/html/html_text_area_element.c
prepare/netsurf_libdom
62849e6851925a55817f68601fa69b3727422b40
[ "MIT" ]
null
null
null
src/html/html_text_area_element.c
prepare/netsurf_libdom
62849e6851925a55817f68601fa69b3727422b40
[ "MIT" ]
null
null
null
src/html/html_text_area_element.c
prepare/netsurf_libdom
62849e6851925a55817f68601fa69b3727422b40
[ "MIT" ]
null
null
null
/* * This file is part of libdom. * Licensed under the MIT License, * http://www.opensource.org/licenses/mit-license.php * Copyright 2012 Daniel Silverstone <dsilvers@netsurf-browser.org> */ #include <assert.h> #include <stdlib.h> #include <dom/html/html_text_area_element.h> #include "html/html_document.h" #include "html/html_text_area_element.h" #include "core/node.h" #include "core/attr.h" #include "utils/utils.h" static struct dom_element_protected_vtable _protect_vtable = { { DOM_NODE_PROTECT_VTABLE_HTML_TEXT_AREA_ELEMENT }, DOM_HTML_TEXT_AREA_ELEMENT_PROTECT_VTABLE }; /** * Create a dom_html_text_area_element object * * \param doc The document object * \param ele The returned element object * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_text_area_element_create(struct dom_html_document *doc, dom_string *namespace, dom_string *prefix, struct dom_html_text_area_element **ele) { struct dom_node_internal *node; *ele = malloc(sizeof(dom_html_text_area_element)); if (*ele == NULL) return DOM_NO_MEM_ERR; /* Set up vtables */ node = (struct dom_node_internal *) *ele; node->base.vtable = &_dom_html_element_vtable; node->vtable = &_protect_vtable; return _dom_html_text_area_element_initialise(doc, namespace, prefix, *ele); } /** * Initialise a dom_html_text_area_element object * * \param doc The document object * \param ele The dom_html_text_area_element object * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_text_area_element_initialise(struct dom_html_document *doc, dom_string *namespace, dom_string *prefix, struct dom_html_text_area_element *ele) { ele->form = NULL; ele->default_value = NULL; ele->default_value_set = false; ele->value = NULL; ele->value_set = false; return _dom_html_element_initialise(doc, &ele->base, doc->memoised[hds_TEXTAREA], namespace, prefix); } /** * Finalise a dom_html_text_area_element object * * \param ele The dom_html_text_area_element object */ void _dom_html_text_area_element_finalise(struct dom_html_text_area_element *ele) { if (ele->default_value != NULL) { dom_string_unref(ele->default_value); ele->default_value = NULL; ele->default_value_set = false; } if (ele->value != NULL) { dom_string_unref(ele->value); ele->value = NULL; ele->value_set = false; } _dom_html_element_finalise(&ele->base); } /** * Destroy a dom_html_text_area_element object * * \param ele The dom_html_text_area_element object */ void _dom_html_text_area_element_destroy(struct dom_html_text_area_element *ele) { _dom_html_text_area_element_finalise(ele); free(ele); } /*-----------------------------------------------------------------------*/ /* Public APIs */ /** * Get the disabled property * * \param ele The dom_html_text_area_element object * \param disabled The returned status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_get_disabled(dom_html_text_area_element *ele, bool *disabled) { return dom_html_element_get_bool_property(&ele->base, "disabled", SLEN("disabled"), disabled); } /** * Set the disabled property * * \param ele The dom_html_text_area_element object * \param disabled The status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_set_disabled(dom_html_text_area_element *ele, bool disabled) { return dom_html_element_set_bool_property(&ele->base, "disabled", SLEN("disabled"), disabled); } /** * Get the readOnly property * * \param ele The dom_html_text_area_element object * \param disabled The returned status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_get_read_only(dom_html_text_area_element *ele, bool *read_only) { return dom_html_element_get_bool_property(&ele->base, "readonly", SLEN("readonly"), read_only); } /** * Set the readOnly property * * \param ele The dom_html_text_area_element object * \param disabled The status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_set_read_only(dom_html_text_area_element *ele, bool read_only) { return dom_html_element_set_bool_property(&ele->base, "readonly", SLEN("readonly"), read_only); } /** * Get the defaultValue property * * \param ele The dom_html_text_area_element object * \param disabled The returned status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_get_default_value( dom_html_text_area_element *ele, dom_string **default_value) { dom_exception err; if (ele->default_value_set == false) { err = dom_node_get_text_content((dom_node *)ele, &ele->default_value); if (err == DOM_NO_ERR) { ele->default_value_set = true; } } *default_value = ele->default_value; if (*default_value != NULL) dom_string_ref(*default_value); return DOM_NO_ERR; } /** * Set the defaultValue property * * \param ele The dom_html_text_area_element object * \param disabled The status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_set_default_value( dom_html_text_area_element *ele, dom_string *default_value) { if (ele->default_value != NULL) dom_string_unref(ele->default_value); ele->default_value = default_value; ele->default_value_set = true; if (ele->default_value != NULL) dom_string_ref(ele->default_value); return DOM_NO_ERR; } /** * Get the value property * * \param ele The dom_html_text_area_element object * \param disabled The returned status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_get_value( dom_html_text_area_element *ele, dom_string **value) { dom_exception err; if (ele->value_set == false) { err = dom_node_get_text_content((dom_node *)ele, &ele->value); if (err == DOM_NO_ERR) { ele->default_value_set = true; if (ele->default_value_set == false) { ele->default_value_set = true; ele->default_value = ele->value; dom_string_ref(ele->default_value); } } } *value = ele->value; if (*value != NULL) dom_string_ref(*value); return DOM_NO_ERR; } /** * Set the value property * * \param ele The dom_html_text_area_element object * \param disabled The status * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_set_value( dom_html_text_area_element *ele, dom_string *value) { dom_exception err; if (ele->default_value_set == false) { err = dom_node_get_text_content((dom_node *)ele, &ele->default_value); if (err == DOM_NO_ERR) { ele->default_value_set = true; } } if (ele->value != NULL) dom_string_unref(ele->value); ele->value = value; ele->value_set = true; if (ele->value != NULL) dom_string_ref(ele->value); return DOM_NO_ERR; } /*------------------------------------------------------------------------*/ /* The protected virtual functions */ /* The virtual function used to parse attribute value, see src/core/element.c * for detail */ dom_exception _dom_html_text_area_element_parse_attribute(dom_element *ele, dom_string *name, dom_string *value, dom_string **parsed) { UNUSED(ele); UNUSED(name); dom_string_ref(value); *parsed = value; return DOM_NO_ERR; } /* The virtual destroy function, see src/core/node.c for detail */ void _dom_virtual_html_text_area_element_destroy(dom_node_internal *node) { _dom_html_text_area_element_destroy((struct dom_html_text_area_element *) node); } /* The virtual copy function, see src/core/node.c for detail */ dom_exception _dom_html_text_area_element_copy(dom_node_internal *old, dom_node_internal **copy) { return _dom_html_element_copy(old, copy); } /*-----------------------------------------------------------------------*/ /* API functions */ #define SIMPLE_GET(attr) \ dom_exception dom_html_text_area_element_get_##attr( \ dom_html_text_area_element *element, \ dom_string **attr) \ { \ dom_exception ret; \ dom_string *_memo_##attr; \ \ _memo_##attr = \ ((struct dom_html_document *) \ ((struct dom_node_internal *)element)->owner)->\ memoised[hds_##attr]; \ \ ret = dom_element_get_attribute(element, _memo_##attr, attr); \ \ return ret; \ } #define SIMPLE_SET(attr) \ dom_exception dom_html_text_area_element_set_##attr( \ dom_html_text_area_element *element, \ dom_string *attr) \ { \ dom_exception ret; \ dom_string *_memo_##attr; \ \ _memo_##attr = \ ((struct dom_html_document *) \ ((struct dom_node_internal *)element)->owner)->\ memoised[hds_##attr]; \ \ ret = dom_element_set_attribute(element, _memo_##attr, attr); \ \ return ret; \ } #define SIMPLE_GET_SET(attr) SIMPLE_GET(attr) SIMPLE_SET(attr) SIMPLE_GET_SET(access_key); SIMPLE_GET_SET(name); dom_exception dom_html_text_area_element_get_type( dom_html_text_area_element *text_area, dom_string **type) { dom_html_document *html = (dom_html_document *) ((dom_node_internal *)text_area)->owner; *type = html->memoised[hds_textarea]; dom_string_ref(*type); return DOM_NO_ERR; } dom_exception dom_html_text_area_element_get_tab_index( dom_html_text_area_element *text_area, int32_t *tab_index) { return dom_html_element_get_int32_t_property(&text_area->base, "tabindex", SLEN("tabindex"), tab_index); } dom_exception dom_html_text_area_element_set_tab_index( dom_html_text_area_element *text_area, uint32_t tab_index) { return dom_html_element_set_int32_t_property(&text_area->base, "tabindex", SLEN("tabindex"), tab_index); } dom_exception dom_html_text_area_element_get_cols( dom_html_text_area_element *text_area, int32_t *cols) { return dom_html_element_get_int32_t_property(&text_area->base, "cols", SLEN("cols"), cols); } dom_exception dom_html_text_area_element_set_cols( dom_html_text_area_element *text_area, uint32_t cols) { return dom_html_element_set_int32_t_property(&text_area->base, "cols", SLEN("cols"), cols); } dom_exception dom_html_text_area_element_get_rows( dom_html_text_area_element *text_area, int32_t *rows) { return dom_html_element_get_int32_t_property(&text_area->base, "rows", SLEN("rows"), rows); } dom_exception dom_html_text_area_element_set_rows( dom_html_text_area_element *text_area, uint32_t rows) { return dom_html_element_set_int32_t_property(&text_area->base, "rows", SLEN("rows"), rows); } dom_exception dom_html_text_area_element_get_form( dom_html_text_area_element *text_area, dom_html_form_element **form) { *form = text_area->form; if (*form != NULL) dom_node_ref(*form); return DOM_NO_ERR; } dom_exception _dom_html_text_area_element_set_form( dom_html_text_area_element *text_area, dom_html_form_element *form) { text_area->form = form; return DOM_NO_ERR; } /** * Blur this control * * \param ele The form object * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_blur(dom_html_text_area_element *ele) { struct dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); bool success = false; assert(doc != NULL); /* This event does not bubble & is Non-cancellable. Mentioned in w3 specs. More research is needed to prove why. */ return _dom_dispatch_generic_event((dom_document *) doc, (dom_event_target *) ele, doc->memoised[hds_blur], false, false, &success); } /** * Focus this control * * \param ele The form object * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_focus(dom_html_text_area_element *ele) { struct dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); bool success = false; assert(doc != NULL); /* This event does not bubble & is Non-cancellable. Mentioned in w3 specs. More research is needed to prove why. */ return _dom_dispatch_generic_event((dom_document *)doc, (dom_event_target *) ele, doc->memoised[hds_focus], false, false, &success); } /** * Select this control * * \param ele The form object * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception dom_html_text_area_element_select(dom_html_text_area_element *ele) { struct dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); bool success = false; assert(doc != NULL); /* This event bubbles & is non-cancelable. Mentioned in w3 specs. More research is needed to prove why. */ return _dom_dispatch_generic_event((dom_document *)doc, (dom_event_target *) ele, doc->memoised[hds_select], true, false, &success); }
26.934292
116
0.728292
[ "object" ]
ac978bb17a537e031a21cd7dc31f6a83e072af8f
3,374
h
C
Samples/HolographicDepthBasedImageStabilization/cpp/DepthBufferPlaneFinder/ApplyDepthWeights.h
aspexkz/aspex1
157c9eb6127947e71458e473eb796f9585bc248e
[ "MIT" ]
3
2018-11-08T07:00:42.000Z
2019-01-09T12:16:07.000Z
Samples/HolographicDepthBasedImageStabilization/cpp/DepthBufferPlaneFinder/ApplyDepthWeights.h
aspexkz/aspex1
157c9eb6127947e71458e473eb796f9585bc248e
[ "MIT" ]
4
2018-12-14T21:21:27.000Z
2019-01-07T20:15:17.000Z
Samples/HolographicDepthBasedImageStabilization/cpp/DepthBufferPlaneFinder/ApplyDepthWeights.h
aspexkz/aspex1
157c9eb6127947e71458e473eb796f9585bc248e
[ "MIT" ]
1
2022-02-12T06:05:02.000Z
2022-02-12T06:05:02.000Z
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // This code is licensed under the MIT License (MIT). // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* #pragma once #define DEPTH_ARRAY_SIZE (UINT16_MAX + 1) // Weights each pixel by using the depth value to look up a weight that is precomputed. __forceinline float WeightDepth(unsigned int const& depth, float const* depthWeightArray) { return depthWeightArray[depth]; } // Precomputes the depth weight. static void InitDepthCurveArray( float const& nearPlane, float const& farPlane, unsigned int const& invalidDepthValue, float* outDepthWeightArray) { // Set up constants. constexpr float maxDepthAsFloat = static_cast<float>(UINT16_MAX); constexpr float oneOverMaxDepthAsFloat = 1.f / maxDepthAsFloat; // Create a transform from depth space in integer form, to meters in floating-point. const float denom = -farPlane * nearPlane; const float fromOneOverZNearFarToOneOverZ = (farPlane - nearPlane) / denom; const float fromOneOverZNearFarToOneOverZCoefficient = farPlane / denom; for (unsigned int i = 0; i < DEPTH_ARRAY_SIZE; ++i) { // Convert to meters. const float oneOverZDepthSpace = static_cast<float>(i) * oneOverMaxDepthAsFloat; const float zInMeters = 1.0f / (oneOverZDepthSpace * fromOneOverZNearFarToOneOverZ - fromOneOverZNearFarToOneOverZCoefficient); // Here, we provide a simple weight function by using the square of the depth value, in meters. // This biases the result towards far-away objects. This is desirable because far-away objects // use less pixels, and we need a way to give them the same consideration in the plane fit as a // close object. If we do not do this, the plane will not be able to fit both close and far-away // objects at the same time, and in scenes where both are visible you will get a lot of color // separation on the far-away objects. outDepthWeightArray[i] = pow(zInMeters, 2); // You can also apply more complex equations to create the depth weights. This can be useful if // you know in advance how the depth buffer will be filled in, based on the content that your app // provides. // // For example, one of our test scenes did well with the following power curve. This provides a // heavy weight for far away pixels, just like the z^2 curve, but it uses a sharper transition to // the heavy region and has a falloff to the far plane. This operates in depth space, which has // a range of [0, 1]: // constexpr float minimumNonZeroValue = 0.00000001f; // outDepthWeightArray[i] = 2.f * oneOverZDepthSpace * (-pow(oneOverZDepthSpace, 32.f) + pow(oneOverZDepthSpace, 8.f)) + minimumNonZeroValue; // We disregard background pixels by giving them a weight of 0. if (i == invalidDepthValue) { outDepthWeightArray[i] = 0.f; } } }
47.521127
152
0.657676
[ "object", "transform" ]
aca6401bd9c1a9ad653e44aac9e130b282250116
23,578
h
C
Examples/MendeleySDKDemo/Pods/Headers/MendeleySDK/MDLDocument.h
mekentosj/MendeleySDK
9044d2ba20ef64ddfddc19efa7d9ea88faa62d5a
[ "MIT" ]
null
null
null
Examples/MendeleySDKDemo/Pods/Headers/MendeleySDK/MDLDocument.h
mekentosj/MendeleySDK
9044d2ba20ef64ddfddc19efa7d9ea88faa62d5a
[ "MIT" ]
null
null
null
Examples/MendeleySDKDemo/Pods/Headers/MendeleySDK/MDLDocument.h
mekentosj/MendeleySDK
9044d2ba20ef64ddfddc19efa7d9ea88faa62d5a
[ "MIT" ]
null
null
null
// // MDLDocument.h // // Copyright (c) 2012-2013 shazino (shazino SAS), http://www.shazino.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #import <Foundation/Foundation.h> extern NSString * const MDLDocumentTypeGeneric; @class MDLPublication; @class MDLCategory; @class MDLSubcategory; @class MDLGroup; @class MDLMendeleyAPIClient; /** `MDLDocument` represents a user’s document, as described by Mendeley. */ @interface MDLDocument : NSObject /** The document identifier, as generated by Mendeley. */ @property (copy, nonatomic) NSString *identifier; /** The document identifiers. */ @property (strong, nonatomic) NSDictionary *identifiers; /** The document DOI (Digital Object Identifier). */ @property (copy, nonatomic) NSString *DOI; /** The canonical identifier of the document. */ @property (copy, nonatomic) NSString *canonicalIdentifier; /** The PubMed identifier (PMID) of the document. */ @property (copy, nonatomic) NSString *PubMedIdentifier; /** The type of the document. This is `@"Generic"` by default. */ @property (copy, nonatomic) NSString *type; /** The title of the document. */ @property (copy, nonatomic) NSString *title; /** The abstract of the document. */ @property (copy, nonatomic) NSString *abstract; /** The Mendeley URL of the document. */ @property (strong, nonatomic) NSURL *mendeleyURL; /** The URL of the document. */ @property (strong, nonatomic) NSURL *URL; /** The authors of the document stored as MDLAuthor. */ @property (strong, nonatomic) NSArray *authors; /** The publication outlet of the document. */ @property (strong, nonatomic) MDLPublication *publicationOutlet; /** The publication of the document. */ @property (strong, nonatomic) MDLPublication *publication; /** The publisher of the document. */ @property (copy, nonatomic) NSString *publisher; /** The folder identifiers of the document. */ @property (copy, nonatomic) NSArray *foldersIdentifiers; /** The year of the document. */ @property (strong, nonatomic) NSNumber *year; /** The files of the document. */ @property (strong, nonatomic) NSArray *files; /** The group of the document, if it belongs to one. */ @property (strong, nonatomic) MDLGroup *group; /** The read status of the document */ @property (strong, nonatomic) NSNumber *read; /** The star status of the document */ @property (strong, nonatomic) NSNumber *starred; /** The authored status of the document */ @property (strong, nonatomic) NSNumber *authored; /** The deletion pending status of the document */ @property (strong, nonatomic) NSNumber *deletionPending; /** The discipline of the document. */ @property (copy, nonatomic) NSString *discipline; /** The subdiscipline of the document. */ @property (copy, nonatomic) NSString *subdiscipline; /** The institution of the document. */ @property (copy, nonatomic) NSString *institution; /** The volume of the document. */ @property (copy, nonatomic) NSString *volume; /** The issue of the document. */ @property (copy, nonatomic) NSString *issue; /** The pages of the document. */ @property (copy, nonatomic) NSString *pages; /** The notes of the document. */ @property (copy, nonatomic) NSString *notes; /** The keywords of the document. */ @property (strong, nonatomic) NSArray *keywords; /** The tags of the document. */ @property (strong, nonatomic) NSArray *tags; /** The cast of the document. */ @property (strong, nonatomic) NSArray *cast; /** The editors of the document. */ @property (strong, nonatomic) NSArray *editors; /** The producers of the document. */ @property (strong, nonatomic) NSArray *producers; /** The translators of the document. */ @property (strong, nonatomic) NSArray *translators; /** The added date of the document. */ @property (strong, nonatomic) NSDate *addedDate; /** The modified date of the document. */ @property (strong, nonatomic) NSDate *modifiedDate; /** The version of the document. */ @property (strong, nonatomic) NSNumber *version; /** The Open Access status of the document */ @property (strong, nonatomic) NSNumber *openAccess; /** A Boolean value that corresponds to whether the document is in the user library. */ @property (strong, nonatomic) NSNumber *inUserLibrary; @property (readonly) BOOL isInUserLibrary; /** Creates a `MDLDocument` and sends an API creation request using the shared client. @param title The title of the document. @param parameters Optional parameters of the document. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: the created document with its newly assigned document identifier. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @return The newly-initialized document, with document identifier = `nil`. @see [API documentation: User Library Create Document](http://apidocs.mendeley.com/home/user-specific-methods/user-library-create-document) */ + (MDLDocument *)createDocumentWithTitle:(NSString *)title parameters:(NSDictionary *)parameters success:(void (^)(MDLDocument *))success failure:(void (^)(NSError *))failure; /** Sends an API search request with generic terms using the shared client. @param terms The terms for the search query @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes five arguments: an array of `MDLDocument` objects for the match, the total number of results, the total number of pages, the index of the current page, and the number of items per page. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Search Terms](http://apidocs.mendeley.com/home/public-resources/search-terms) */ + (void)searchWithTerms:(NSString *)terms atPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *, NSUInteger, NSUInteger, NSUInteger, NSUInteger))success failure:(void (^)(NSError *))failure; /** Sends an API search request with specific terms using the shared client. @param genericTerms The terms for the search query @param authors The authors for the search query @param title The title for the search query @param year The year for the search query @param tags The tags for the search query @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes five arguments: an array of `MDLDocument` objects for the match, the total number of results, the total number of pages, the index of the current page, and the number of items per page. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Search Terms](http://apidocs.mendeley.com/home/public-resources/search-terms) */ + (void)searchWithGenericTerms:(NSString *)genericTerms authors:(NSString *)authors title:(NSString *)title year:(NSNumber *)year tags:(NSString *)tags atPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *, NSUInteger, NSUInteger, NSUInteger, NSUInteger))success failure:(void (^)(NSError *))failure; /** Sends a search tagged API request using the shared client. @param tag The tags for the search query @param category The category for the search query @param subcategory The subcategory for the search query @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes five arguments: an array of `MDLDocument` objects for the match, the total number of results, the total number of pages, the index of the current page, and the number of items per page. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Search Tagged](http://apidocs.mendeley.com/home/public-resources/search-tagged) */ + (void)searchTagged:(NSString *)tag category:(MDLCategory *)category subcategory:(MDLSubcategory *)subcategory atPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *, NSUInteger, NSUInteger, NSUInteger, NSUInteger))success failure:(void (^)(NSError *))failure; /** Sends a search authored API request using the shared client. @param name The name of the author for the search query @param year The year for the search query @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes five arguments: an array of `MDLDocument` objects for the match, the total number of results, the total number of pages, the index of the current page, and the number of items per page. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Search Authored](http://apidocs.mendeley.com/home/public-resources/search-authored) */ + (void)searchAuthoredWithName:(NSString *)name year:(NSNumber *)year atPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *, NSUInteger, NSUInteger, NSUInteger, NSUInteger))success failure:(void (^)(NSError *))failure; /** Sends a top documents (papers) API request using the shared client and fetches the response as an array of `MDLDocument`. @param categoryIdentifier If not `nil`, the identifier of the category, otherwise across all categories. @param upAndComing If true, results apply to ‘trending’ documents. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: an array of `MDLDocument` objects. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Stats Papers](http://apidocs.mendeley.com/home/public-resources/stats-papers) */ + (void)fetchTopDocumentsInPublicLibraryForCategory:(NSString *)categoryIdentifier upAndComing:(BOOL)upAndComing success:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure; /** Sends a user library API request using the shared client. @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes five arguments: an array of `MDLDocument` objects, the total number of results, the total number of pages, the index of the current page, and the number of items per page. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: User Library](http://apidocs.mendeley.com/home/user-specific-methods/user-library) */ + (void)fetchDocumentsInUserLibraryAtPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *, NSUInteger, NSUInteger, NSUInteger, NSUInteger))success failure:(void (^)(NSError *))failure; /** Sends a user authored API request using the shared client. @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes five arguments: an array of `MDLDocument` objects, the total number of results, the total number of pages, the index of the current page, and the number of items per page. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: User Authored](http://apidocs.mendeley.com/home/user-specific-methods/user-authored) */ + (void)fetchAuthoredDocumentsInUserLibraryAtPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *, NSUInteger, NSUInteger, NSUInteger, NSUInteger))success failure:(void (^)(NSError *))failure; /** Sends an API upload request using the shared client. Keep in mind that Mendeley only handles a limited number of file formats (.pdf, etc). @param fileURL The local URL for the file to upload. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes no argument. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: File Upload](http://apidocs.mendeley.com/home/user-specific-methods/file-upload) */ - (void)uploadFileAtURL:(NSURL *)fileURL success:(void (^)())success failure:(void (^)(NSError *))failure; /** Sends an API details request for the current document using the shared client. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: the current document with its newly assigned details. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Search details](http://apidocs.mendeley.com/home/public-resources/search-details) @see [API documentation: User Library Document Details](http://apidocs.mendeley.com/home/user-specific-methods/user-library-document-details) @see [API documentation: Group Document Details](http://apidocs.mendeley.com/home/user-specific-methods/group-document-details) */ - (void)fetchDetailsSuccess:(void (^)(MDLDocument *))success failure:(void (^)(NSError *))failure; /** Sends a related documents API request using the shared client. @param pageIndex The page index. `O` is first page. @param count The number of items returned per page. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: an array of `MDLDocument` objects. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Search Related](http://apidocs.mendeley.com/home/public-resources/search-related) */ - (void)fetchRelatedDocumentsAtPage:(NSUInteger)pageIndex count:(NSUInteger)count success:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure; /** Sends an update document API request using the shared client. @param read The read status. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: a `MDLDocument` object. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: User Library Update Document](http://apidocs.mendeley.com/home/user-specific-methods/user-library-update-document) */ - (void)markAsRead:(BOOL)read success:(void (^)(MDLDocument *))success failure:(void (^)(NSError *))failure; /** Sends an update document API request using the shared client. @param starred The starred status. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: a `MDLDocument` object. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: User Library Update Document](http://apidocs.mendeley.com/home/user-specific-methods/user-library-update-document) */ - (void)markAsStarred:(BOOL)starred success:(void (^)(MDLDocument *))success failure:(void (^)(NSError *))failure; /** Sends an import document API request using the shared client. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: a `NSString` for the identifier for the newly-created document. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: ‎User Library Create Document‎ > ‎By Canonical ID](http://apidocs.mendeley.com/home/user-specific-methods/user-library-create-document/by-canonical-id) */ - (void)importToUserLibrarySuccess:(void (^)(NSString *newDocumentIdentifier))success failure:(void (^)(NSError *))failure; /** Sends an update document API request using the shared client. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: a `MDLDocument` object. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: User Library Update Document](http://apidocs.mendeley.com/home/user-specific-methods/user-library-update-document) */ - (void)moveToTrashSuccess:(void (^)(MDLDocument *))success failure:(void (^)(NSError *))failure; /** Sends a delete document API request using the shared client. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes one argument: an array of `MDLDocument` objects. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes one argument: the `NSError` object describing the network or parsing error that occurred. @see [API documentation: Delete Document](http://apidocs.mendeley.com/home/user-specific-methods/user-library-remove-document) */ - (void)deleteSuccess:(void (^)())success failure:(void (^)(NSError *))failure; @end
45.342308
228
0.72996
[ "object" ]
acaece05710351576b415609aa0c736238781707
875
h
C
axProjects/SoundEditor/axAudioEnvelope.h
alxarsenault/axLib-1
aff63abebff118059d5daca80f06cc8464192c6d
[ "MIT" ]
1
2019-10-15T05:09:34.000Z
2019-10-15T05:09:34.000Z
axProjects/SoundEditor/axAudioEnvelope.h
EQ4/axLib
aff63abebff118059d5daca80f06cc8464192c6d
[ "MIT" ]
null
null
null
axProjects/SoundEditor/axAudioEnvelope.h
EQ4/axLib
aff63abebff118059d5daca80f06cc8464192c6d
[ "MIT" ]
1
2021-12-18T06:30:51.000Z
2021-12-18T06:30:51.000Z
#ifndef __AX_AUDIO_ENVELOPE__ #define __AX_AUDIO_ENVELOPE__ #define _USE_MATH_DEFINES #include <cmath> #include <iostream> #include <vector> #include <string> #include "axUtils.h" #include "axC++.h" //----------------------------------------------------------------------------- // Audio_Filter //----------------------------------------------------------------------------- class axAudioEnvelope { public: axAudioEnvelope(); axFloat Process(); void TriggerNote(); void ReleaseNote(); void SetAttack(const axFloat& value); void SetDecay(const axFloat& value); private: axFloat _attack, _sustain, _decay, _release; unsigned int _sr, _buffePos; unsigned int _nAttackSample, _nDecaySample, _nReleaseSample; bool _active; unsigned int SecToSample(double seconde); double LineInterpolation(double y1, double y2, double mu); }; #endif // __AX_AUDIO_ENVELOPE__
22.435897
79
0.628571
[ "vector" ]
acb994a5d6d1404eb754a157822919642357af62
2,124
h
C
Project/Temp/StagingArea/Data/il2cppOutput/mscorlib_Mono_Security_Cryptography_DSAManaged_Key2001522803MethodDeclarations.h
Yuunagi-Yu/NumberDisk
f1cf414dbfe8d0094d3ef11b37839f6caf58ae9f
[ "MIT" ]
null
null
null
Project/Temp/StagingArea/Data/il2cppOutput/mscorlib_Mono_Security_Cryptography_DSAManaged_Key2001522803MethodDeclarations.h
Yuunagi-Yu/NumberDisk
f1cf414dbfe8d0094d3ef11b37839f6caf58ae9f
[ "MIT" ]
null
null
null
Project/Temp/StagingArea/Data/il2cppOutput/mscorlib_Mono_Security_Cryptography_DSAManaged_Key2001522803MethodDeclarations.h
Yuunagi-Yu/NumberDisk
f1cf414dbfe8d0094d3ef11b37839f6caf58ae9f
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // Mono.Security.Cryptography.DSAManaged/KeyGeneratedEventHandler struct KeyGeneratedEventHandler_t2001522803; // System.Object struct Il2CppObject; // System.EventArgs struct EventArgs_t3289624707; // System.IAsyncResult struct IAsyncResult_t1999651008; // System.AsyncCallback struct AsyncCallback_t163412349; #include "codegen/il2cpp-codegen.h" #include "mscorlib_System_Object2689449295.h" #include "mscorlib_System_IntPtr2504060609.h" #include "mscorlib_System_EventArgs3289624707.h" #include "mscorlib_System_AsyncCallback163412349.h" // System.Void Mono.Security.Cryptography.DSAManaged/KeyGeneratedEventHandler::.ctor(System.Object,System.IntPtr) extern "C" void KeyGeneratedEventHandler__ctor_m553546121 (KeyGeneratedEventHandler_t2001522803 * __this, Il2CppObject * ___object0, IntPtr_t ___method1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.Cryptography.DSAManaged/KeyGeneratedEventHandler::Invoke(System.Object,System.EventArgs) extern "C" void KeyGeneratedEventHandler_Invoke_m4220935979 (KeyGeneratedEventHandler_t2001522803 * __this, Il2CppObject * ___sender0, EventArgs_t3289624707 * ___e1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.IAsyncResult Mono.Security.Cryptography.DSAManaged/KeyGeneratedEventHandler::BeginInvoke(System.Object,System.EventArgs,System.AsyncCallback,System.Object) extern "C" Il2CppObject * KeyGeneratedEventHandler_BeginInvoke_m3006764834 (KeyGeneratedEventHandler_t2001522803 * __this, Il2CppObject * ___sender0, EventArgs_t3289624707 * ___e1, AsyncCallback_t163412349 * ___callback2, Il2CppObject * ___object3, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.Cryptography.DSAManaged/KeyGeneratedEventHandler::EndInvoke(System.IAsyncResult) extern "C" void KeyGeneratedEventHandler_EndInvoke_m1587195139 (KeyGeneratedEventHandler_t2001522803 * __this, Il2CppObject * ___result0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
53.1
295
0.846516
[ "object" ]
acba7a0c8d9914ae87d045b41f4f3aafe450b0b5
4,155
h
C
Engine/Source/Runtime/Core/Public/UObject/FrameworkObjectVersion.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Source/Runtime/Core/Public/UObject/FrameworkObjectVersion.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Source/Runtime/Core/Public/UObject/FrameworkObjectVersion.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreTypes.h" #include "Misc/Guid.h" // Custom serialization version for changes made in Dev-Framework stream struct CORE_API FFrameworkObjectVersion { enum Type { // Before any version changes were made BeforeCustomVersionWasAdded = 0, // BodySetup's default instance collision profile is used by default when creating a new instance. UseBodySetupCollisionProfile, // Regenerate subgraph arrays correctly in animation blueprints to remove duplicates and add // missing graphs that appear read only when edited AnimBlueprintSubgraphFix, // Static and skeletal mesh sockets now use the specified scale MeshSocketScaleUtilization, // Attachment rules are now explicit in how they affect location, rotation and scale ExplicitAttachmentRules, // Moved compressed anim data from uasset to the DDC MoveCompressedAnimDataToTheDDC, // Some graph pins created using legacy code seem to have lost the RF_Transactional flag, // which causes issues with undo. Restore the flag at this version FixNonTransactionalPins, // Create new struct for SmartName, and use that for CurveName SmartNameRefactor, // Add Reference Skeleton to Rig AddSourceReferenceSkeletonToRig, // Refactor ConstraintInstance so that we have an easy way to swap behavior paramters ConstraintInstanceBehaviorParameters, // Pose Asset support mask per bone PoseAssetSupportPerBoneMask, // Physics Assets now use SkeletalBodySetup instead of BodySetup PhysAssetUseSkeletalBodySetup, // Remove SoundWave CompressionName RemoveSoundWaveCompressionName, // Switched render data for clothing over to unreal data, reskinned to the simulation mesh AddInternalClothingGraphicalSkinning, // Wheel force offset is now applied at the wheel instead of vehicle COM WheelOffsetIsFromWheel, // Move curve metadata to be saved in skeleton // Individual asset still saves some flag - i.e. disabled curve and editable or not, but // major flag - i.e. material types - moves to skeleton and handle in one place MoveCurveTypesToSkeleton, // Cache destructible overlaps on save CacheDestructibleOverlaps, // Added serialization of materials applied to geometry cache objects GeometryCacheMissingMaterials, // Switch static & skeletal meshes to calculate LODs based on resolution-independent screen size LODsUseResolutionIndependentScreenSize, // Blend space post load verification BlendSpacePostLoadSnapToGrid, // Addition of rate scales to blend space samples SupportBlendSpaceRateScale, // LOD hysteresis also needs conversion from the LODsUseResolutionIndependentScreenSize version LODHysteresisUseResolutionIndependentScreenSize, // AudioComponent override subtitle priority default change ChangeAudioComponentOverrideSubtitlePriorityDefault, // Serialize hard references to sound files when possible HardSoundReferences, // Enforce const correctness in Animation Blueprint function graphs EnforceConstInAnimBlueprintFunctionGraphs, // Upgrade the InputKeySelector to use a text style InputKeySelectorTextStyle, // Represent a pins container type as an enum not 3 independent booleans EdGraphPinContainerType, // Switch asset pins to store as string instead of hard object reference ChangeAssetPinsToString, // Fix Local Variables so that the properties are correctly flagged as blueprint visible LocalVariablesBlueprintVisible, // Stopped serializing UField_Next so that UFunctions could be serialized in dependently of a UClass // in order to allow us to do all UFunction loading in a single pass (after classes and CDOs are created): RemoveUField_Next, // Fix User Defined structs so that all members are correct flagged blueprint visible UserDefinedStructsBlueprintVisible, // -----<new versions can be added above this line>------------------------------------------------- VersionPlusOne, LatestVersion = VersionPlusOne - 1 }; // The GUID for this custom version number const static FGuid GUID; private: FFrameworkObjectVersion() {} };
34.338843
108
0.780746
[ "mesh", "geometry", "render", "object" ]
acc256342e81badaedb80d8c7d26102a93d5557d
15,611
h
C
ibtk/include/ibtk/HierarchyGhostCellInterpolation.h
hongk45/IBAMR
698d419fc6688470a8b9400822ba893da9d07ae2
[ "BSD-3-Clause" ]
null
null
null
ibtk/include/ibtk/HierarchyGhostCellInterpolation.h
hongk45/IBAMR
698d419fc6688470a8b9400822ba893da9d07ae2
[ "BSD-3-Clause" ]
1
2020-11-30T14:22:45.000Z
2020-12-01T21:28:24.000Z
ibtk/include/ibtk/HierarchyGhostCellInterpolation.h
hongk45/IBAMR
698d419fc6688470a8b9400822ba893da9d07ae2
[ "BSD-3-Clause" ]
null
null
null
// --------------------------------------------------------------------- // // Copyright (c) 2011 - 2019 by the IBAMR developers // All rights reserved. // // This file is part of IBAMR. // // IBAMR is free software and is distributed under the 3-clause BSD // license. The full text of the license can be found in the file // COPYRIGHT at the top level directory of IBAMR. // // --------------------------------------------------------------------- /////////////////////////////// INCLUDE GUARD //////////////////////////////// #ifndef included_IBTK_HierarchyGhostCellInterpolation #define included_IBTK_HierarchyGhostCellInterpolation /////////////////////////////// INCLUDES ///////////////////////////////////// #include <ibtk/config.h> #include "ibtk/CoarseFineBoundaryRefinePatchStrategy.h" #include "ibtk/ibtk_utilities.h" #include "BoxGeometryFillPattern.h" #include "CartesianGridGeometry.h" #include "CoarseFineBoundary.h" #include "CoarsenAlgorithm.h" #include "IntVector.h" #include "PatchHierarchy.h" #include "RefineAlgorithm.h" #include "VariableFillPattern.h" #include "tbox/DescribedClass.h" #include "tbox/Pointer.h" #include <memory> #include <ostream> #include <string> #include <vector> namespace IBTK { class CartCellRobinPhysBdryOp; class CartExtrapPhysBdryOp; class CartSideRobinPhysBdryOp; } // namespace IBTK namespace SAMRAI { namespace solv { template <int DIM> class RobinBcCoefStrategy; } // namespace solv namespace xfer { template <int DIM> class CoarsenPatchStrategy; template <int DIM> class CoarsenSchedule; template <int DIM> class RefinePatchStrategy; template <int DIM> class RefineSchedule; } // namespace xfer } // namespace SAMRAI /////////////////////////////// CLASS DEFINITION ///////////////////////////// namespace IBTK { /*! * \brief Class HierarchyGhostCellInterpolation encapsulates the operations * required to set ghost cell values at physical and coarse-fine boundaries * across a range of levels of a locally refined patch hierarchy. * * \note In cases where physical boundary conditions are set via extrapolation * from interior values, setting ghost cell values may require both coarsening * and refining. */ class HierarchyGhostCellInterpolation : public SAMRAI::tbox::DescribedClass { public: /*! * \brief Class * HierarchyGhostCellInterpolation::InterpolationTransactionComponent * encapsulates options for filling ghost cell values via class * HierarchyGhostCellInterpolation. */ class InterpolationTransactionComponent { public: friend class HierarchyGhostCellInterpolation; /*! * \brief Default constructor. */ inline InterpolationTransactionComponent( int data_idx = -1, const std::string& refine_op_name = "NONE", bool use_cf_bdry_interpolation = false, const std::string& coarsen_op_name = "NONE", const std::string& phys_bdry_extrap_type = "NONE", bool consistent_type_2_bdry = false, SAMRAI::solv::RobinBcCoefStrategy<NDIM>* robin_bc_coef = NULL, SAMRAI::tbox::Pointer<SAMRAI::xfer::VariableFillPattern<NDIM> > fill_pattern = NULL, const std::string& phys_bdry_type = "LINEAR") : d_dst_data_idx(data_idx), d_src_data_idx(data_idx), d_refine_op_name(refine_op_name), d_use_cf_bdry_interpolation(use_cf_bdry_interpolation), d_coarsen_op_name(coarsen_op_name), d_phys_bdry_extrap_type(phys_bdry_extrap_type), d_consistent_type_2_bdry(consistent_type_2_bdry), d_robin_bc_coefs(robin_bc_coef ? std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>(1, robin_bc_coef) : std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>()), d_fill_pattern(fill_pattern ? fill_pattern : new SAMRAI::xfer::BoxGeometryFillPattern<NDIM>()), d_phys_bdry_type(phys_bdry_type) { // intentionally blank return; } // InterpolationTransactionComponent /*! * \brief Alternate constructor. */ inline InterpolationTransactionComponent( int data_idx, const std::string& refine_op_name, bool use_cf_bdry_interpolation, const std::string& coarsen_op_name, const std::string& phys_bdry_extrap_type, bool consistent_type_2_bdry, const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& robin_bc_coefs, SAMRAI::tbox::Pointer<SAMRAI::xfer::VariableFillPattern<NDIM> > fill_pattern = NULL, const std::string& phys_bdry_type = "LINEAR") : d_dst_data_idx(data_idx), d_src_data_idx(data_idx), d_refine_op_name(refine_op_name), d_use_cf_bdry_interpolation(use_cf_bdry_interpolation), d_coarsen_op_name(coarsen_op_name), d_phys_bdry_extrap_type(phys_bdry_extrap_type), d_consistent_type_2_bdry(consistent_type_2_bdry), d_robin_bc_coefs(robin_bc_coefs), d_fill_pattern(fill_pattern ? fill_pattern : new SAMRAI::xfer::BoxGeometryFillPattern<NDIM>()), d_phys_bdry_type(phys_bdry_type) { // intentionally blank return; } // InterpolationTransactionComponent /*! * \brief Alternate constructor. */ inline InterpolationTransactionComponent( int dst_data_idx, int src_data_idx, const std::string& refine_op_name, bool use_cf_bdry_interpolation, const std::string& coarsen_op_name, const std::string& phys_bdry_extrap_type, bool consistent_type_2_bdry, SAMRAI::solv::RobinBcCoefStrategy<NDIM>* robin_bc_coef, SAMRAI::tbox::Pointer<SAMRAI::xfer::VariableFillPattern<NDIM> > fill_pattern = NULL, const std::string& phys_bdry_type = "LINEAR") : d_dst_data_idx(dst_data_idx), d_src_data_idx(src_data_idx), d_refine_op_name(refine_op_name), d_use_cf_bdry_interpolation(use_cf_bdry_interpolation), d_coarsen_op_name(coarsen_op_name), d_phys_bdry_extrap_type(phys_bdry_extrap_type), d_consistent_type_2_bdry(consistent_type_2_bdry), d_robin_bc_coefs(robin_bc_coef ? std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>(1, robin_bc_coef) : std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>()), d_fill_pattern(fill_pattern ? fill_pattern : new SAMRAI::xfer::BoxGeometryFillPattern<NDIM>()), d_phys_bdry_type(phys_bdry_type) { // intentionally blank return; } // InterpolationTransactionComponent /*! * \brief Alternate constructor. */ inline InterpolationTransactionComponent( int dst_data_idx, int src_data_idx, const std::string& refine_op_name, bool use_cf_bdry_interpolation, const std::string& coarsen_op_name, const std::string& phys_bdry_extrap_type, bool consistent_type_2_bdry, const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& robin_bc_coefs, SAMRAI::tbox::Pointer<SAMRAI::xfer::VariableFillPattern<NDIM> > fill_pattern = NULL, const std::string& phys_bdry_type = "LINEAR") : d_dst_data_idx(dst_data_idx), d_src_data_idx(src_data_idx), d_refine_op_name(refine_op_name), d_use_cf_bdry_interpolation(use_cf_bdry_interpolation), d_coarsen_op_name(coarsen_op_name), d_phys_bdry_extrap_type(phys_bdry_extrap_type), d_consistent_type_2_bdry(consistent_type_2_bdry), d_robin_bc_coefs(robin_bc_coefs), d_fill_pattern(fill_pattern ? fill_pattern : new SAMRAI::xfer::BoxGeometryFillPattern<NDIM>()), d_phys_bdry_type(phys_bdry_type) { // intentionally blank return; } // InterpolationTransactionComponent /*! * \brief Copy constructor. * * \param from The value to copy to this object. */ inline InterpolationTransactionComponent(const InterpolationTransactionComponent& from) : d_dst_data_idx(from.d_dst_data_idx), d_src_data_idx(from.d_src_data_idx), d_refine_op_name(from.d_refine_op_name), d_use_cf_bdry_interpolation(from.d_use_cf_bdry_interpolation), d_coarsen_op_name(from.d_coarsen_op_name), d_phys_bdry_extrap_type(from.d_phys_bdry_extrap_type), d_consistent_type_2_bdry(from.d_consistent_type_2_bdry), d_robin_bc_coefs(from.d_robin_bc_coefs), d_fill_pattern(from.d_fill_pattern), d_phys_bdry_type(from.d_phys_bdry_type) { // intentionally blank return; } // InterpolationTransactionComponent /*! * \brief Assignment operator. * * \param that The value to assign to this object. * * \return A reference to this object. */ inline InterpolationTransactionComponent& operator=(const InterpolationTransactionComponent& that) { if (this != &that) { d_dst_data_idx = that.d_dst_data_idx; d_src_data_idx = that.d_src_data_idx; d_refine_op_name = that.d_refine_op_name; d_use_cf_bdry_interpolation = that.d_use_cf_bdry_interpolation; d_coarsen_op_name = that.d_coarsen_op_name; d_phys_bdry_extrap_type = that.d_phys_bdry_extrap_type; d_consistent_type_2_bdry = that.d_consistent_type_2_bdry; d_robin_bc_coefs = that.d_robin_bc_coefs; d_fill_pattern = that.d_fill_pattern; d_phys_bdry_type = that.d_phys_bdry_type; } return *this; } // operator= /*! * \brief Destructor. */ inline ~InterpolationTransactionComponent() { // intentionally blank return; } // ~InterpolationTransactionComponent // Data. int d_dst_data_idx, d_src_data_idx; std::string d_refine_op_name; bool d_use_cf_bdry_interpolation; std::string d_coarsen_op_name; std::string d_phys_bdry_extrap_type; bool d_consistent_type_2_bdry; std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*> d_robin_bc_coefs; SAMRAI::tbox::Pointer<SAMRAI::xfer::VariableFillPattern<NDIM> > d_fill_pattern; std::string d_phys_bdry_type; }; /*! * \brief Default constructor. */ HierarchyGhostCellInterpolation(); /*! * \brief Destructor. */ virtual ~HierarchyGhostCellInterpolation(); /*! * \brief Specify whether the boundary conditions are homogeneous. */ void setHomogeneousBc(bool homogeneous_bc); /*! * \brief Setup the hierarchy ghost cell interpolation operator to perform * the specified interpolation transactions on the specified patch * hierarchy. */ void initializeOperatorState(InterpolationTransactionComponent transaction_comp, SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM> > hierarchy, int coarsest_ln = -1, int finest_ln = -1); /*! * \brief Setup the hierarchy ghost cell interpolation operator to perform * the specified collection of interpolation transactions on the specified * patch hierarchy. */ void initializeOperatorState(const std::vector<InterpolationTransactionComponent>& transaction_comps, SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM> > hierarchy, int coarsest_ln = -1, int finest_ln = -1); /*! * \brief Reset transaction component with the interpolation operator. */ void resetTransactionComponent(const InterpolationTransactionComponent& transaction_comps); /*! * \brief Reset transaction components with the interpolation operator. */ void resetTransactionComponents(const std::vector<InterpolationTransactionComponent>& transaction_comps); /*! * \brief Reinitialize operator state following, e.g., a regridding operation. */ void reinitializeOperatorState(SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM> > hierarchy); /*! * \brief Clear all cached data. */ void deallocateOperatorState(); /*! * \brief Fill coarse-fine boundary and physical boundary ghost cells on all * levels of the patch hierarchy. */ void fillData(double fill_time); protected: private: /*! * \brief Copy constructor. * * \note This constructor is not implemented and should not be used. * * \param from The value to copy to this object. */ HierarchyGhostCellInterpolation(const HierarchyGhostCellInterpolation& from) = delete; /*! * \brief Assignment operator. * * \note This operator is not implemented and should not be used. * * \param that The value to assign to this object. * * \return A reference to this object. */ HierarchyGhostCellInterpolation& operator=(const HierarchyGhostCellInterpolation& that) = delete; // Boolean indicating whether the operator is initialized. bool d_is_initialized = false; // Boolean indicating whether the operator should use homogeneous Robin // boundary conditions (when applicable). bool d_homogeneous_bc = false; // The component interpolation operations to perform. std::vector<InterpolationTransactionComponent> d_transaction_comps; // Hierarchy configuration. SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM> > d_hierarchy; SAMRAI::tbox::Pointer<SAMRAI::geom::CartesianGridGeometry<NDIM> > d_grid_geom; int d_coarsest_ln = IBTK::invalid_level_number, d_finest_ln = IBTK::invalid_level_number; // Cached communications algorithms and schedules. SAMRAI::tbox::Pointer<SAMRAI::xfer::CoarsenAlgorithm<NDIM> > d_coarsen_alg; std::unique_ptr<SAMRAI::xfer::CoarsenPatchStrategy<NDIM> > d_coarsen_strategy; std::vector<SAMRAI::tbox::Pointer<SAMRAI::xfer::CoarsenSchedule<NDIM> > > d_coarsen_scheds; SAMRAI::tbox::Pointer<SAMRAI::xfer::RefineAlgorithm<NDIM> > d_refine_alg; std::unique_ptr<SAMRAI::xfer::RefinePatchStrategy<NDIM> > d_refine_strategy; std::vector<SAMRAI::tbox::Pointer<SAMRAI::xfer::RefineSchedule<NDIM> > > d_refine_scheds; // Cached coarse-fine boundary and physical boundary condition handlers. std::vector<SAMRAI::tbox::Pointer<CoarseFineBoundaryRefinePatchStrategy> > d_cf_bdry_ops; std::vector<SAMRAI::tbox::Pointer<CartExtrapPhysBdryOp> > d_extrap_bc_ops; std::vector<SAMRAI::tbox::Pointer<CartCellRobinPhysBdryOp> > d_cc_robin_bc_ops; std::vector<SAMRAI::tbox::Pointer<CartSideRobinPhysBdryOp> > d_sc_robin_bc_ops; }; } // namespace IBTK ////////////////////////////////////////////////////////////////////////////// #endif //#ifndef included_IBTK_HierarchyGhostCellInterpolation
39.421717
120
0.646659
[ "object", "vector" ]
acc7373e86fe5d1ff2b389d090c8655381b3d325
1,412
h
C
deprecated/include/Graphics/Diagnostics/DebugTextRenderer.h
Arzana/Plutonium
5a17c93e5072ac291b96347a4df196e1609fabe2
[ "MIT" ]
4
2019-03-21T16:02:03.000Z
2020-04-09T08:53:29.000Z
deprecated/include/Graphics/Diagnostics/DebugTextRenderer.h
Arzana/Plutonium
5a17c93e5072ac291b96347a4df196e1609fabe2
[ "MIT" ]
24
2018-04-06T08:25:17.000Z
2020-10-19T11:01:09.000Z
deprecated/include/Graphics/Diagnostics/DebugTextRenderer.h
Arzana/Plutonium
5a17c93e5072ac291b96347a4df196e1609fabe2
[ "MIT" ]
null
null
null
#pragma once #include "Graphics\Color.h" #include "Graphics\Diagnostics\DebugRenderer.h" namespace Plutonium { class FontRenderer; /* Provides ease of use debug text functionality. */ class DebugFontRenderer : public DebugRenderer { public: /* Initializes a new instance of a debug font renderer. */ DebugFontRenderer(_In_ Game *game, _In_ const char *font, _In_ const char *vrtxShdr, _In_ const char *fragShdr, _In_ int loadWeight, _In_opt_ Vector2 resetPos = Vector2::Zero(), _In_opt_ Vector2 moveMod = Vector2::UnitY()); DebugFontRenderer(_In_ const DebugFontRenderer &value) = delete; DebugFontRenderer(_In_ DebugFontRenderer &&value) = delete; _Check_return_ DebugFontRenderer& operator =(_In_ const DebugFontRenderer &other) = delete; _Check_return_ DebugFontRenderer& operator =(_In_ DebugFontRenderer &&other) = delete; /* Adds a string to the font renderer to be rendered in the next frame at the debug text position. */ inline void AddDebugString(_In_ const std::string &str, _In_ Color clr = Color::White()) { AddDebugString(str.c_str(), clr); } /* Adds a string to the font renderer to be rendered in the next frame at the debug text position. */ void AddDebugString(_In_ const char *str, _In_ Color clr = Color::White()); protected: FontRenderer *renderer; virtual void Render(_In_ float dt) override; virtual void Finalize(void) override; }; }
39.222222
225
0.746459
[ "render" ]
acc792ac85db5f26660bfb7a06c819364b8c8823
7,927
h
C
test/e2e/test_master/podofo/doc/PdfElement.h
BlueCannonBall/cppparser
9ae5f0c21268be6696532cf5b90c0384d6eb4940
[ "MIT" ]
50
2018-01-12T14:32:26.000Z
2022-03-30T10:36:30.000Z
test/e2e/test_master/podofo/doc/PdfElement.h
BlueCannonBall/cppparser
9ae5f0c21268be6696532cf5b90c0384d6eb4940
[ "MIT" ]
8
2021-02-18T14:52:08.000Z
2022-03-09T08:51:39.000Z
test/e2e/test_master/podofo/doc/PdfElement.h
BlueCannonBall/cppparser
9ae5f0c21268be6696532cf5b90c0384d6eb4940
[ "MIT" ]
12
2019-04-02T11:51:47.000Z
2022-03-07T11:07:39.000Z
/*************************************************************************** * Copyright (C) 2006 by Dominik Seichter * * domseichter@web.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library 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. * * * * In addition, as a special exception, the copyright holders give * * permission to link the code of portions of this program with the * * OpenSSL library under certain conditions as described in each * * individual source file, and distribute linked combinations * * including the two. * * You must obey the GNU General Public License in all respects * * for all of the code used other than OpenSSL. If you modify * * file(s) with this exception, you may extend this exception to your * * version of the file(s), but you are not obligated to do so. If you * * do not wish to do so, delete this exception statement from your * * version. If you delete this exception statement from all source * * files in the program, then also delete it here. * ***************************************************************************/ #ifndef _PDF_ELEMENT_H_ # define _PDF_ELEMENT_H_ # include "podofo/base/PdfDefines.h" # include "podofo/base/PdfObject.h" namespace PoDoFo { class PdfStreamedDocument; class PdfVecObjects; /** PdfElement is a common base class for all elements * in a PDF file. For example pages, action and annotations. * * Every PDF element has one PdfObject and provides an easier * interface to modify the contents of the dictionary. * * A PdfElement base class can be created from an existing PdfObject * or created from scratch. In the later case, the PdfElement creates * a PdfObject and adds it to a vector of objects. * * A PdfElement cannot be created directly. Use one * of the subclasses which implement real functionallity. * * \see PdfPage \see PdfAction \see PdfAnnotation */ class PODOFO_DOC_API PdfElement { public: virtual ~PdfElement(); /** Get access to the internal object * \returns the internal PdfObject */ inline PdfObject* GetObject(); /** Get access to the internal object * This is an overloaded member function. * * \returns the internal PdfObject */ inline const PdfObject* GetObject() const; protected: /** Creates a new PdfElement * \param pszType type entry of the elements object * \param pParent parent vector of objects. * Add a newly created object to this vector. */ PdfElement(const char* pszType, PdfVecObjects* pParent); /** Creates a new PdfElement * \param pszType type entry of the elements object * \param pParent parent PdfDocument. * Add a newly created object to this vector. */ PdfElement(const char* pszType, PdfDocument* pParent); /** Create a PdfElement from an existing PdfObject * The object must be a dictionary. * * \param pszType type entry of the elements object. * Throws an exception if the type in the * PdfObject differs from pszType. * \param pObject pointer to the PdfObject that is modified * by this PdfElement */ PdfElement(const char* pszType, PdfObject* pObject); /** Create a PdfElement from an existing PdfObject * The object might be of any data type, * PdfElement will throw an exception if the PdfObject * if not of the same datatype as the expected one. * This is necessary in rare cases. E.g. in PdfContents. * * \param eExpectedDataType the expected datatype of this object * \param pObject pointer to the PdfObject that is modified * by this PdfElement */ PdfElement(EPdfDataType eExpectedDataType, PdfObject* pObject); /** Convert an enum or index to its string representation * which can be written to the PDF file. * * This is a helper function for various PdfElement * subclasses that need strings and enums for their * SubTypes keys. * * \param i the index or enum value * \param ppTypes an array of strings containing * the string mapping of the index * \param lLen the length of the string array * * \returns the string representation or NULL for * values out of range */ const char* TypeNameForIndex(int i, const char** ppTypes, long lLen) const; /** Convert a string type to an array index or enum. * * This is a helper function for various PdfElement * subclasses that need strings and enums for their * SubTypes keys. * * \param pszType the type as string * \param ppTypes an array of strings containing * the string mapping of the index * \param lLen the length of the string array * \param nUnknownValue the value that is returned when the type is unknown * * \returns the index of the string in the array */ int TypeNameToIndex(const char* pszType, const char** ppTypes, long lLen, int nUnknownValue) const; /** Create a PdfObject in the parent of this PdfElement which * might either be a PdfStreamedDocument, a PdfDocument or * a PdfVecObjects * * Use this function in an own subclass of PdfElement to create new * PdfObjects. * * \param pszType an optional /Type key of the created object * * \returns a PdfObject which is owned by the parent */ PdfObject* CreateObject(const char* pszType = NULL); /** Get access to the internal object. * Use this method if you need access to the internal * object in a const-method without having to do a const cast. * * \returns the internal PdfObject */ inline PdfObject* GetNonConstObject() const; private: PdfObject* m_pObject; }; // ----------------------------------------------------- // // ----------------------------------------------------- inline PdfObject* PdfElement::GetObject() { return m_pObject; } // ----------------------------------------------------- // // ----------------------------------------------------- inline const PdfObject* PdfElement::GetObject() const { return m_pObject; } // ----------------------------------------------------- // // ----------------------------------------------------- inline PdfObject* PdfElement::GetNonConstObject() const { return const_cast<PdfElement*>(this)->m_pObject; } } #endif
44.038889
103
0.572852
[ "object", "vector" ]
accd76a16caa390f9d5920606621416bd3524261
2,844
h
C
lmctfy/controllers/eventfd_notifications.h
claytonbrown/lmctfy
94729318edb06f7d149f67581a07a4c70ed29250
[ "Apache-2.0" ]
1,145
2015-01-01T22:07:47.000Z
2022-03-30T19:19:23.000Z
lmctfy/controllers/eventfd_notifications.h
claytonbrown/lmctfy
94729318edb06f7d149f67581a07a4c70ed29250
[ "Apache-2.0" ]
9
2015-01-09T08:50:27.000Z
2020-02-11T09:16:20.000Z
lmctfy/controllers/eventfd_notifications.h
claytonbrown/lmctfy
94729318edb06f7d149f67581a07a4c70ed29250
[ "Apache-2.0" ]
123
2015-01-02T12:10:08.000Z
2021-10-12T02:49:48.000Z
// Copyright 2014 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef SRC_CONTROLLERS_EVENTFD_NOTIFICATIONS_H_ #define SRC_CONTROLLERS_EVENTFD_NOTIFICATIONS_H_ #include <memory> #include <string> using ::std::string; #include <vector> #include "base/callback.h" #include "base/macros.h" #include "util/eventfd_listener.h" #include "lmctfy/active_notifications.h" #include "util/task/status.h" #include "util/task/statusor.h" namespace containers { namespace lmctfy { class EventReceiver; // Registers and handles eventfd-based notifications. Specifically, those build // around the cgroups interface. // // Class is thread-safe. class EventFdNotifications { public: typedef Callback1< ::util::Status> EventCallback; // Takes ownersip of event_listener. Does not take ownership of // active_notifications. EventFdNotifications(ActiveNotifications *active_notifications, ::util::EventfdListener *event_listener); virtual ~EventFdNotifications(); // Registers an eventfd-based notification for the specified cgroup control // file. // // Arguments: // cgroup_basepath: The base path to the cgroup_file specified (e.g.: // /dev/cgroup/memory/test). // cgroup_file: The cgroup control file for which to register a // notifications (e.g.: memory.oom_control). // args: The arguments to the event being registered (if any). // callback: The callback to use for event notifications. Must not be a // nullptr and must be a permanent callback. // Return: // StatusOr: The status of the operations. Iff OK, it is populated with the // Handler of the registered notification. virtual ::util::StatusOr<ActiveNotifications::Handle> RegisterNotification( const string &cgroup_basepath, const string &cgroup_file, const string &args, EventCallback *callback); private: // Active notifications. ActiveNotifications *active_notifications_; // Listener for eventfd-based notifications. ::std::unique_ptr< ::util::EventfdListener> event_listener_; // Created event receivers. ::std::vector<EventReceiver *> event_receivers_; DISALLOW_COPY_AND_ASSIGN(EventFdNotifications); }; } // namespace lmctfy } // namespace containers #endif // SRC_CONTROLLERS_EVENTFD_NOTIFICATIONS_H_
33.857143
79
0.740858
[ "vector" ]
accf6ea8a34fa7b1fe595917b11b63a7c9278df3
7,469
h
C
device/bluetooth/adapter.h
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
device/bluetooth/adapter.h
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
device/bluetooth/adapter.h
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2016 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 DEVICE_BLUETOOTH_ADAPTER_H_ #define DEVICE_BLUETOOTH_ADAPTER_H_ #include <memory> #include <string> #include <tuple> #include <vector> #include "base/memory/ref_counted.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_advertisement.h" #include "device/bluetooth/bluetooth_gatt_connection.h" #include "device/bluetooth/public/cpp/bluetooth_uuid.h" #include "device/bluetooth/public/mojom/adapter.mojom.h" #include "device/bluetooth/public/mojom/device.mojom-forward.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote_set.h" namespace bluetooth { // Implementation of Mojo Adapter located in // device/bluetooth/public/mojom/adapter.mojom. // It handles requests for Bluetooth adapter capabilities // and devices and uses the platform abstraction of device/bluetooth. class Adapter : public mojom::Adapter, public device::BluetoothAdapter::Observer { public: explicit Adapter(scoped_refptr<device::BluetoothAdapter> adapter); Adapter(const Adapter&) = delete; Adapter& operator=(const Adapter&) = delete; ~Adapter() override; // mojom::Adapter overrides: void ConnectToDevice(const std::string& address, ConnectToDeviceCallback callback) override; void GetDevices(GetDevicesCallback callback) override; void GetInfo(GetInfoCallback callback) override; void AddObserver(mojo::PendingRemote<mojom::AdapterObserver> observer, AddObserverCallback callback) override; void RegisterAdvertisement(const device::BluetoothUUID& service_uuid, const std::vector<uint8_t>& service_data, bool use_scan_response, RegisterAdvertisementCallback callback) override; void SetDiscoverable(bool discoverable, SetDiscoverableCallback callback) override; void SetName(const std::string& name, SetNameCallback callback) override; void StartDiscoverySession(const std::string& client_name, StartDiscoverySessionCallback callback) override; void ConnectToServiceInsecurely( const std::string& address, const device::BluetoothUUID& service_uuid, ConnectToServiceInsecurelyCallback callback) override; void CreateRfcommServiceInsecurely( const std::string& service_name, const device::BluetoothUUID& service_uuid, CreateRfcommServiceInsecurelyCallback callback) override; // device::BluetoothAdapter::Observer overrides: void AdapterPresentChanged(device::BluetoothAdapter* adapter, bool present) override; void AdapterPoweredChanged(device::BluetoothAdapter* adapter, bool powered) override; void AdapterDiscoverableChanged(device::BluetoothAdapter* adapter, bool discoverable) override; void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, bool discovering) override; void DeviceAdded(device::BluetoothAdapter* adapter, device::BluetoothDevice* device) override; void DeviceChanged(device::BluetoothAdapter* adapter, device::BluetoothDevice* device) override; void DeviceRemoved(device::BluetoothAdapter* adapter, device::BluetoothDevice* device) override; void GattServicesDiscovered(device::BluetoothAdapter* adapter, device::BluetoothDevice* device) override; // Permit untrusted clients to initiate outgoing connections, or listen on // incoming connections, with |service_uuid|. void AllowConnectionsForUuid(const device::BluetoothUUID& service_uuid); private: struct ConnectToServiceRequestDetails { ConnectToServiceRequestDetails(const std::string& address, const device::BluetoothUUID& service_uuid, const base::Time& time_requested, ConnectToServiceInsecurelyCallback callback); ~ConnectToServiceRequestDetails(); std::string address; device::BluetoothUUID service_uuid; base::Time time_requested; ConnectToServiceInsecurelyCallback callback; }; void OnDeviceFetchedForInsecureServiceConnection( int request_id, device::BluetoothDevice* device); void ProcessPendingInsecureServiceConnectionRequest( const std::string& address, device::BluetoothDevice* device); void OnGattConnect( ConnectToDeviceCallback callback, std::unique_ptr<device::BluetoothGattConnection> connection, absl::optional<device::BluetoothDevice::ConnectErrorCode> error_code); void OnRegisterAdvertisement( RegisterAdvertisementCallback callback, scoped_refptr<device::BluetoothAdvertisement> advertisement); void OnRegisterAdvertisementError( RegisterAdvertisementCallback callback, device::BluetoothAdvertisement::ErrorCode error_code); void OnSetDiscoverable(SetDiscoverableCallback callback); void OnSetDiscoverableError(SetDiscoverableCallback callback); void OnSetName(SetNameCallback callback); void OnSetNameError(SetNameCallback callback); void OnStartDiscoverySession( StartDiscoverySessionCallback callback, std::unique_ptr<device::BluetoothDiscoverySession> session); void OnDiscoverySessionError(StartDiscoverySessionCallback callback); void OnConnectToService(int request_id, scoped_refptr<device::BluetoothSocket> socket); void OnConnectToServiceError(int request_id, const std::string& message); void OnCreateRfcommServiceInsecurely( CreateRfcommServiceInsecurelyCallback callback, scoped_refptr<device::BluetoothSocket> socket); void OnCreateRfcommServiceInsecurelyError( CreateRfcommServiceInsecurelyCallback callback, const std::string& message); void ExecuteConnectToServiceCallback(int request_id, mojom::ConnectToServiceResultPtr result); // The current Bluetooth adapter. scoped_refptr<device::BluetoothAdapter> adapter_; // The adapter observers that listen to this service. mojo::RemoteSet<mojom::AdapterObserver> observers_; // Keeps track of details about pending ConnectToService requests while async // operations are in progress. This includes details about the caller and // service as well as the callback. Requests will wait here in three cases: // * device::BluetoothAdapter::ConnectDevice() // * device::BluetoothDevice::ConnectToServiceInsecurely() // * device's services have not completed discovery base::flat_map<int, std::unique_ptr<ConnectToServiceRequestDetails>> connect_to_service_request_map_; // Ids of ConnectToServiceRequestDetails that are awaiting the completion of // service discovery for the given device. std::vector<int> connect_to_service_requests_pending_discovery_; // Allowed UUIDs for untrusted clients to initiate outgoing connections, or // listen on incoming connections. std::set<device::BluetoothUUID> allowed_uuids_; int next_request_id_ = 0; base::WeakPtrFactory<Adapter> weak_ptr_factory_{this}; }; } // namespace bluetooth #endif // DEVICE_BLUETOOTH_ADAPTER_H_
42.68
80
0.736779
[ "vector" ]
acdea7d84dbadf50e03f33dece646ce6a8cc9293
6,926
h
C
neo/d3xp/script/Script_Compiler.h
vic3t3chn0/OpenKrown
201c8fb6895cb0439e39c984d2fbc2c2eaf185b4
[ "MIT" ]
1
2018-11-07T22:44:23.000Z
2018-11-07T22:44:23.000Z
neo/d3xp/script/Script_Compiler.h
vic3t3chn0/OpenKrown
201c8fb6895cb0439e39c984d2fbc2c2eaf185b4
[ "MIT" ]
null
null
null
neo/d3xp/script/Script_Compiler.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. Copyright (C) 2012 Robert Beckebans 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 __SCRIPT_COMPILER_H__ #define __SCRIPT_COMPILER_H__ const char* const RESULT_STRING = "<RESULT>"; typedef struct opcode_s { // RB begin const char* name; const char* opname; // RB end int priority; bool rightAssociative; idVarDef* type_a; idVarDef* type_b; idVarDef* type_c; } opcode_t; // These opcodes are no longer necessary: // OP_PUSH_OBJ: // OP_PUSH_OBJENT: enum { OP_RETURN, OP_UINC_F, OP_UINCP_F, OP_UDEC_F, OP_UDECP_F, OP_COMP_F, OP_MUL_F, OP_MUL_V, OP_MUL_FV, OP_MUL_VF, OP_DIV_F, OP_MOD_F, OP_ADD_F, OP_ADD_V, OP_ADD_S, OP_ADD_FS, OP_ADD_SF, OP_ADD_VS, OP_ADD_SV, OP_SUB_F, OP_SUB_V, OP_EQ_F, OP_EQ_V, OP_EQ_S, OP_EQ_E, OP_EQ_EO, OP_EQ_OE, OP_EQ_OO, OP_NE_F, OP_NE_V, OP_NE_S, OP_NE_E, OP_NE_EO, OP_NE_OE, OP_NE_OO, OP_LE, OP_GE, OP_LT, OP_GT, OP_INDIRECT_F, OP_INDIRECT_V, OP_INDIRECT_S, OP_INDIRECT_ENT, OP_INDIRECT_BOOL, OP_INDIRECT_OBJ, OP_ADDRESS, OP_EVENTCALL, OP_OBJECTCALL, OP_SYSCALL, OP_STORE_F, OP_STORE_V, OP_STORE_S, OP_STORE_ENT, OP_STORE_BOOL, OP_STORE_OBJENT, OP_STORE_OBJ, OP_STORE_ENTOBJ, OP_STORE_FTOS, OP_STORE_BTOS, OP_STORE_VTOS, OP_STORE_FTOBOOL, OP_STORE_BOOLTOF, OP_STOREP_F, OP_STOREP_V, OP_STOREP_S, OP_STOREP_ENT, OP_STOREP_FLD, OP_STOREP_BOOL, OP_STOREP_OBJ, OP_STOREP_OBJENT, OP_STOREP_FTOS, OP_STOREP_BTOS, OP_STOREP_VTOS, OP_STOREP_FTOBOOL, OP_STOREP_BOOLTOF, OP_UMUL_F, OP_UMUL_V, OP_UDIV_F, OP_UDIV_V, OP_UMOD_F, OP_UADD_F, OP_UADD_V, OP_USUB_F, OP_USUB_V, OP_UAND_F, OP_UOR_F, OP_NOT_BOOL, OP_NOT_F, OP_NOT_V, OP_NOT_S, OP_NOT_ENT, OP_NEG_F, OP_NEG_V, OP_INT_F, OP_IF, OP_IFNOT, OP_CALL, OP_THREAD, OP_OBJTHREAD, OP_PUSH_F, OP_PUSH_V, OP_PUSH_S, OP_PUSH_ENT, OP_PUSH_OBJ, OP_PUSH_OBJENT, OP_PUSH_FTOS, OP_PUSH_BTOF, OP_PUSH_FTOB, OP_PUSH_VTOS, OP_PUSH_BTOS, OP_GOTO, OP_AND, OP_AND_BOOLF, OP_AND_FBOOL, OP_AND_BOOLBOOL, OP_OR, OP_OR_BOOLF, OP_OR_FBOOL, OP_OR_BOOLBOOL, OP_BITAND, OP_BITOR, OP_BREAK, // placeholder op. not used in final code OP_CONTINUE, // placeholder op. not used in final code NUM_OPCODES }; class idCompiler { private: static bool punctuationValid[ 256 ]; // RB begin static const char* punctuation[]; // RB end idParser parser; idParser* parserPtr; idToken token; idTypeDef* immediateType; eval_t immediate; bool eof; bool console; bool callthread; int braceDepth; int loopDepth; int currentLineNumber; int currentFileNumber; int errorCount; idVarDef* scope; // the function being parsed, or NULL const idVarDef* basetype; // for accessing fields float Divide( float numerator, float denominator ); void Error( VERIFY_FORMAT_STRING const char* error, ... ) const; void Warning( VERIFY_FORMAT_STRING const char* message, ... ) const; idVarDef* OptimizeOpcode( const opcode_t* op, idVarDef* var_a, idVarDef* var_b ); idVarDef* EmitOpcode( const opcode_t* op, idVarDef* var_a, idVarDef* var_b ); idVarDef* EmitOpcode( int op, idVarDef* var_a, idVarDef* var_b ); bool EmitPush( idVarDef* expression, const idTypeDef* funcArg ); void NextToken(); void ExpectToken( const char* string ); bool CheckToken( const char* string ); void ParseName( idStr& name ); void SkipOutOfFunction(); void SkipToSemicolon(); idTypeDef* CheckType(); idTypeDef* ParseType(); idVarDef* FindImmediate( const idTypeDef* type, const eval_t* eval, const char* string ) const; idVarDef* GetImmediate( idTypeDef* type, const eval_t* eval, const char* string ); idVarDef* VirtualFunctionConstant( idVarDef* func ); idVarDef* SizeConstant( int size ); idVarDef* JumpConstant( int value ); idVarDef* JumpDef( int jumpfrom, int jumpto ); idVarDef* JumpTo( int jumpto ); idVarDef* JumpFrom( int jumpfrom ); idVarDef* ParseImmediate(); idVarDef* EmitFunctionParms( int op, idVarDef* func, int startarg, int startsize, idVarDef* object ); idVarDef* ParseFunctionCall( idVarDef* func ); idVarDef* ParseObjectCall( idVarDef* object, idVarDef* func ); idVarDef* ParseEventCall( idVarDef* object, idVarDef* func ); idVarDef* ParseSysObjectCall( idVarDef* func ); idVarDef* LookupDef( const char* name, const idVarDef* baseobj ); idVarDef* ParseValue(); idVarDef* GetTerm(); bool TypeMatches( etype_t type1, etype_t type2 ) const; idVarDef* GetExpression( int priority ); idTypeDef* GetTypeForEventArg( char argType ); void PatchLoop( int start, int continuePos ); void ParseReturnStatement(); void ParseWhileStatement(); void ParseForStatement(); void ParseDoWhileStatement(); void ParseIfStatement(); void ParseStatement(); void ParseObjectDef( const char* objname ); idTypeDef* ParseFunction( idTypeDef* returnType, const char* name ); void ParseFunctionDef( idTypeDef* returnType, const char* name ); void ParseVariableDef( idTypeDef* type, const char* name ); void ParseEventDef( idTypeDef* type, const char* name ); void ParseDefs(); void ParseNamespace( idVarDef* newScope ); public : // RB: added const static const opcode_t opcodes[]; // RB end idCompiler(); void CompileFile( const char* text, const char* filename, bool console ); }; #endif /* !__SCRIPT_COMPILER_H__ */
23.965398
366
0.726393
[ "object" ]
38ffe6478cd3dc1d8a74f4c264b9433776739b26
602
h
C
Source/Engine/Core/System/BinaryWriter.h
KaiH0717/Kaguya
6bdcac77984e3d359ea2fabe926dd44a467dde68
[ "MIT" ]
176
2020-10-31T21:28:27.000Z
2022-01-22T12:15:38.000Z
Source/Engine/Core/System/BinaryWriter.h
flygod1159/Kaguya
47dbb3940110ed490d0b70eed31383cfc82bc8df
[ "MIT" ]
null
null
null
Source/Engine/Core/System/BinaryWriter.h
flygod1159/Kaguya
47dbb3940110ed490d0b70eed31383cfc82bc8df
[ "MIT" ]
9
2020-12-25T01:12:48.000Z
2022-01-13T16:28:43.000Z
#pragma once #include "FileStream.h" class BinaryWriter { public: explicit BinaryWriter(FileStream& Stream); void Write(const void* Data, size_t SizeInBytes) const; template<typename T> void Write(const T& Object) const { Write(&Object, sizeof(T)); } template<> void Write<std::string>(const std::string& Object) const { Write(Object.data(), static_cast<UINT>(Object.size() * sizeof(char))); } template<> void Write<std::wstring>(const std::wstring& Object) const { Write(Object.data(), static_cast<UINT>(Object.size() * sizeof(wchar_t))); } private: FileStream& Stream; };
18.8125
75
0.700997
[ "object" ]
ac08267c3a8bc699e5beb58f2179eda04e7ec81d
4,075
h
C
aws-cpp-sdk-glue/include/aws/glue/model/TaskRunSortCriteria.h
lintonv/aws-sdk-cpp
15e19c265ffce19d2046b18aa1b7307fc5377e58
[ "Apache-2.0" ]
1
2022-02-12T08:09:30.000Z
2022-02-12T08:09:30.000Z
aws-cpp-sdk-glue/include/aws/glue/model/TaskRunSortCriteria.h
lintonv/aws-sdk-cpp
15e19c265ffce19d2046b18aa1b7307fc5377e58
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-glue/include/aws/glue/model/TaskRunSortCriteria.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2022-03-23T15:17:18.000Z
2022-03-23T15:17:18.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/glue/Glue_EXPORTS.h> #include <aws/glue/model/TaskRunSortColumnType.h> #include <aws/glue/model/SortDirectionType.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace Glue { namespace Model { /** * <p>The sorting criteria that are used to sort the list of task runs for the * machine learning transform.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/glue-2017-03-31/TaskRunSortCriteria">AWS * API Reference</a></p> */ class AWS_GLUE_API TaskRunSortCriteria { public: TaskRunSortCriteria(); TaskRunSortCriteria(Aws::Utils::Json::JsonView jsonValue); TaskRunSortCriteria& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The column to be used to sort the list of task runs for the machine learning * transform.</p> */ inline const TaskRunSortColumnType& GetColumn() const{ return m_column; } /** * <p>The column to be used to sort the list of task runs for the machine learning * transform.</p> */ inline bool ColumnHasBeenSet() const { return m_columnHasBeenSet; } /** * <p>The column to be used to sort the list of task runs for the machine learning * transform.</p> */ inline void SetColumn(const TaskRunSortColumnType& value) { m_columnHasBeenSet = true; m_column = value; } /** * <p>The column to be used to sort the list of task runs for the machine learning * transform.</p> */ inline void SetColumn(TaskRunSortColumnType&& value) { m_columnHasBeenSet = true; m_column = std::move(value); } /** * <p>The column to be used to sort the list of task runs for the machine learning * transform.</p> */ inline TaskRunSortCriteria& WithColumn(const TaskRunSortColumnType& value) { SetColumn(value); return *this;} /** * <p>The column to be used to sort the list of task runs for the machine learning * transform.</p> */ inline TaskRunSortCriteria& WithColumn(TaskRunSortColumnType&& value) { SetColumn(std::move(value)); return *this;} /** * <p>The sort direction to be used to sort the list of task runs for the machine * learning transform.</p> */ inline const SortDirectionType& GetSortDirection() const{ return m_sortDirection; } /** * <p>The sort direction to be used to sort the list of task runs for the machine * learning transform.</p> */ inline bool SortDirectionHasBeenSet() const { return m_sortDirectionHasBeenSet; } /** * <p>The sort direction to be used to sort the list of task runs for the machine * learning transform.</p> */ inline void SetSortDirection(const SortDirectionType& value) { m_sortDirectionHasBeenSet = true; m_sortDirection = value; } /** * <p>The sort direction to be used to sort the list of task runs for the machine * learning transform.</p> */ inline void SetSortDirection(SortDirectionType&& value) { m_sortDirectionHasBeenSet = true; m_sortDirection = std::move(value); } /** * <p>The sort direction to be used to sort the list of task runs for the machine * learning transform.</p> */ inline TaskRunSortCriteria& WithSortDirection(const SortDirectionType& value) { SetSortDirection(value); return *this;} /** * <p>The sort direction to be used to sort the list of task runs for the machine * learning transform.</p> */ inline TaskRunSortCriteria& WithSortDirection(SortDirectionType&& value) { SetSortDirection(std::move(value)); return *this;} private: TaskRunSortColumnType m_column; bool m_columnHasBeenSet; SortDirectionType m_sortDirection; bool m_sortDirectionHasBeenSet; }; } // namespace Model } // namespace Glue } // namespace Aws
32.086614
133
0.684172
[ "model", "transform" ]
ac082b1e3e1c5445d26fb2a44d4e800cd165c5da
1,917
h
C
content/browser/devtools/protocol/frame_recorder.h
kjthegod/chromium
cf940f7f418436b77e15b1ea23e6fa100ca1c91a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2019-11-28T10:46:52.000Z
2019-11-28T10:46:52.000Z
content/browser/devtools/protocol/frame_recorder.h
kjthegod/chromium
cf940f7f418436b77e15b1ea23e6fa100ca1c91a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
content/browser/devtools/protocol/frame_recorder.h
kjthegod/chromium
cf940f7f418436b77e15b1ea23e6fa100ca1c91a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2015-03-27T11:15:39.000Z
2016-08-17T14:19:56.000Z
// 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 CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_ #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_ #include <string> #include <vector> #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "content/browser/devtools/protocol/devtools_protocol_handler.h" #include "content/public/browser/readback_types.h" class SkBitmap; namespace content { class RenderViewHostImpl; namespace devtools { namespace page { class FrameRecorder { public: using Response = DevToolsProtocolClient::Response; using StopRecordingFramesCallback = base::Callback<void(scoped_refptr<StopRecordingFramesResponse>)>; explicit FrameRecorder(); virtual ~FrameRecorder(); Response StartRecordingFrames(int max_frame_count); Response StopRecordingFrames(StopRecordingFramesCallback callback); void SetRenderViewHost(RenderViewHostImpl* host); void OnSwapCompositorFrame(); private: enum State { Ready, Recording, Encoding }; void FrameCaptured(const SkBitmap& bitmap, ReadbackResponse response); void FrameEncoded(double timestamp, const std::string& encoded_frame); void MaybeSendResponse(); RenderViewHostImpl* host_; State state_; StopRecordingFramesCallback callback_; size_t inflight_requests_count_; size_t max_frame_count_; size_t captured_frames_count_; base::Time last_captured_frame_timestamp_; std::vector<scoped_refptr<devtools::page::RecordedFrame>> frames_; base::WeakPtrFactory<FrameRecorder> weak_factory_; DISALLOW_COPY_AND_ASSIGN(FrameRecorder); }; } // namespace page } // namespace devtools } // namespace content #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_
26.625
73
0.793427
[ "vector" ]
ac0ea681aef4ef3d3eba9a7e1d13191ebc9963ef
5,382
h
C
c/PBP_net/network.h
DoktorBotti/Probabilistic-Backpropagation
56c9ca818f88fd11e4c38585eefaceb3c28e2184
[ "BSD-3-Clause" ]
200
2015-03-18T20:23:41.000Z
2022-02-16T15:13:01.000Z
c/PBP_net/network.h
DoktorBotti/Probabilistic-Backpropagation
56c9ca818f88fd11e4c38585eefaceb3c28e2184
[ "BSD-3-Clause" ]
1
2018-07-09T11:55:07.000Z
2018-07-09T11:55:07.000Z
c/PBP_net/network.h
DoktorBotti/Probabilistic-Backpropagation
56c9ca818f88fd11e4c38585eefaceb3c28e2184
[ "BSD-3-Clause" ]
74
2015-03-25T16:17:38.000Z
2021-12-28T11:25:41.000Z
/* * Module that implements in c a Bayesian network trained with probabilistic * backpropagation (PBP). * * Author: Jose Miguel Hernandez Lobato * Date: 10 March 2015 * */ #ifndef __NETWORK #define __NETWORK /* Structure with all the info for the network */ typedef struct { int n_hidden_layers; /* The number of hidden layers */ int *neurons_per_layer; /* The number of neurons per layer without bias */ int *linear; /* Type of activation function in each layer */ double *scaling_a; /* Scaling of the activation function per layer */ int size_w; /* Size of weight vector */ int size_a; /* Size of activation vector */ int size_z; /* Size of non-linear activation vector */ int *start_w; /* The starting position for weight array per layer */ int *start_a; /* The starting position for activation array per layer */ int *start_z; /* The starting position for non-linear activation array */ /* The parameters of the posterior approximation */ double a_noise; /* First parameter for Gamma on noise */ double b_noise; /* Second parameter for Gamma on noise */ double a_prior; /* First parameter for Gamma on the prior */ double b_prior; /* Second parameter for Gamma on the prior */ double *sample_w; /* A sample from the weights */ double *m_w; /* The mean for the weights */ double *m_w_new; /* The new mean for the weights */ double *m_w_squared; /* The mean for the weights squared */ double *v_w; /* The variances for the weights */ double *v_w_new; /* The new variances for the weights */ /* Variables needed for the forward pass */ double *m_z; /* The mean for the neural output */ double *m_z_squared; /* The mean for the neural output squared */ double *m_z_scaled; /* The mean for the neural output scaled */ double *v_z; /* The variance for the neural output */ double *v_z_scaled; /* The variance for the neural output */ double *m_a; /* The mean for the activation */ double *v_a; /* The variance for activation */ double *alpha; /* The alpha for the neurons */ double *gamma; /* The gamma for the neurons */ /* Variables needed for the backward pass */ double *delta_m; /* The delta_m for the neurons */ double *delta_v; /* The delta_v for the neurons */ double *dm_z_d_m_a; /* Auxiliary variables for the gradient */ double *dv_z_d_m_a; /* Auxiliary variables for the gradient */ double *dm_z_d_v_a; /* Auxiliary variables for the gradient */ double *dv_z_d_v_a; /* Auxiliary variables for the gradient */ double *dm_a_d_m_a; /* Auxiliary variables for the gradient */ double *dv_a_d_m_a; /* Auxiliary variables for the gradient */ double *dm_a_d_v_a; /* Auxiliary variables for the gradient */ double *dv_a_d_v_a; /* Auxiliary variables for the gradient */ double *dm_a_d_m_z; /* Auxiliary variables for the gradient */ double *dv_a_d_m_z; /* Auxiliary variables for the gradient */ double *dm_a_d_v_z; /* Auxiliary variables for the gradient */ double *dv_a_d_v_z; /* Auxiliary variables for the gradient */ double *dm_a_d_m_w; /* Auxiliary variables for the gradient */ double *dv_a_d_m_w; /* Auxiliary variables for the gradient */ double *dm_a_d_v_w; /* Auxiliary variables for the gradient */ double *dv_a_d_v_w; /* Auxiliary variables for the gradient */ double *grad_m_w; /* The gradient for mean of the weights */ double *grad_v_w; /* The gradient for the variances of the weights */ /* Variables needed for refining the prior */ double *m_w_hat_nat; /* The 1st nat. param. for the prior approximation */ double *v_w_hat_nat; /* The 2st nat. param. for the prior approximation */ double *a_w_hat_nat; /* The 1st parameter for the prior approximation */ double *b_w_hat_nat; /* The 2nd parameter for the prior approximation */ double *m_w_old; /* The old mean for the weights */ double *v_w_old; /* The old variances for the weights */ } NETWORK; NETWORK *init_network(int *size_hidden_layers, int n_hidden_layers, int d, double *random_noise); void destroy_network(NETWORK * network); NETWORK *predict(NETWORK *network, double *x_test, double *m_test, double *v_test, double *v_noise, int n_datapoints, int d); NETWORK *one_learning_epoch(NETWORK *network, double *x, double *y, int n_datapoints, int d, int *permutation); void get_params(NETWORK *n, double *sample_w_out, double *m_w_out, double *v_w_out, double *m_w_hat_nat_out, double *v_w_hat_nat_out, double *a_w_hat_nat_out, double *b_w_hat_nat_out, double *a_noise_out, double *b_noise_out, double *a_prior_out, double *b_prior_out, int *neurons_per_layer_out); void get_size_params(NETWORK *n, int *size_weihts, int *n_layers); void set_params(NETWORK *n, double *sample_w_in, double *m_w_in, double *v_w_in, double *m_w_hat_nat_in, double *v_w_hat_nat_in, double *a_w_hat_nat_in, double *b_w_hat_nat_in, double a_noise_in, double b_noise_in, double a_prior_in, double b_prior_in); NETWORK *predict_deterministic(NETWORK *n, double *x_test, double *y_test, int n_datapoints, int d); #endif
50.773585
133
0.679859
[ "vector" ]
ac14afb8cad1bf8e7d1a1452ef24fa6012cc43eb
747
h
C
kiln/engine/Classes/Components/headers/MovementComponent.h
kilnengine/Engine
eab20bb707b63e610394ec9a00c6a3957c141193
[ "MIT" ]
1
2020-01-12T02:45:05.000Z
2020-01-12T02:45:05.000Z
kiln/engine/Classes/Components/headers/MovementComponent.h
kilnengine/Engine
eab20bb707b63e610394ec9a00c6a3957c141193
[ "MIT" ]
null
null
null
kiln/engine/Classes/Components/headers/MovementComponent.h
kilnengine/Engine
eab20bb707b63e610394ec9a00c6a3957c141193
[ "MIT" ]
null
null
null
#pragma once #include "Component.h" #include "kiln/engine/Utils/Math/Vector.h" #include "kiln/engine/Utils/Math/Scalar.h" #define Vec KMath::Vector::Vector<float> enum Direction { Up, Down, Left, Right }; class MovementComponent : public Component { public: MovementComponent(); MovementComponent(Entity* owner); void consumeDirection(const Vec& vector); void consumeDirection(const Direction& direction); Vec getVelocity() const; virtual void start() override {}; virtual void tick(float deltaTime) override; private: void updatePosition(float deltaTime); // pixels per second Vec velocity = {0.f, 0.f}; Vec accumulatedDirection = {0.f, 0.f}; float maxVelocity = 500.f; float maxAcceleration = 1500.f; };
20.75
52
0.720214
[ "vector" ]
ac1897d2199e08bfae5db5df4a66d70866d22355
454
h
C
dependencies/PyMesh/src/Attributes/VertexVolumeAttribute.h
aprieels/3D-watermarking-spectral-decomposition
dcab78857d0bb201563014e58900917545ed4673
[ "MIT" ]
5
2018-06-04T19:52:02.000Z
2022-01-22T09:04:00.000Z
dependencies/PyMesh/src/Attributes/VertexVolumeAttribute.h
aprieels/3D-watermarking-spectral-decomposition
dcab78857d0bb201563014e58900917545ed4673
[ "MIT" ]
null
null
null
dependencies/PyMesh/src/Attributes/VertexVolumeAttribute.h
aprieels/3D-watermarking-spectral-decomposition
dcab78857d0bb201563014e58900917545ed4673
[ "MIT" ]
null
null
null
/* This file is part of PyMesh. Copyright (c) 2015 by Qingnan Zhou */ #pragma once #include "MeshAttribute.h" namespace PyMesh { class VertexVolumeAttribute : public MeshAttribute { public: VertexVolumeAttribute(const std::string& name) : MeshAttribute(name) {} virtual ~VertexVolumeAttribute() {} public: virtual void compute_from_mesh(Mesh& mesh); private: VectorF& get_voxel_volumes(Mesh& mesh); }; }
21.619048
79
0.685022
[ "mesh" ]
ac2877d40f8a563fe76a266b175c35ae40f47e13
9,040
h
C
linux_packages/source/hypre-2.9.0b/src/babel-runtime/python/sidl_DFinder_Module.h
pangkeji/warp3d
8b273b337e557f734298940a63291697cd561d02
[ "NCSA" ]
75
2015-07-06T18:14:20.000Z
2022-01-24T02:54:32.000Z
linux_packages/source/hypre-2.9.0b/src/babel-runtime/python/sidl_DFinder_Module.h
pangkeji/warp3d
8b273b337e557f734298940a63291697cd561d02
[ "NCSA" ]
15
2017-04-07T18:09:58.000Z
2022-02-28T01:48:33.000Z
linux_packages/source/hypre-2.9.0b/src/babel-runtime/python/sidl_DFinder_Module.h
pangkeji/warp3d
8b273b337e557f734298940a63291697cd561d02
[ "NCSA" ]
41
2015-05-24T23:24:54.000Z
2021-12-13T22:07:45.000Z
/* * File: sidl_DFinder_Module.h * Symbol: sidl.DFinder-v0.9.15 * Symbol Type: class * Babel Version: 1.0.4 * Release: $Name: V2-9-0b $ * Revision: @(#) $Id: sidl_DFinder_Module.h,v 1.6 2007/09/27 19:35:22 painter Exp $ * Description: expose a constructor for the Python wrapper * * Copyright (c) 2000-2002, The Regents of the University of California. * Produced at the Lawrence Livermore National Laboratory. * Written by the Components Team <components@llnl.gov> * All rights reserved. * * This file is part of Babel. For more information, see * http://www.llnl.gov/CASC/components/. Please read the COPYRIGHT file * for Our Notice and the LICENSE file for the GNU Lesser General Public * License. * * 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) version 2.1 dated February 1999. * * 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 terms and * conditions of the GNU Lesser General Public License for more details. * * You should have recieved a copy of the GNU Lesser 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 * * WARNING: Automatically generated; only changes within splicers preserved * */ /* * THIS CODE IS AUTOMATICALLY GENERATED BY THE BABEL * COMPILER. DO NOT EDIT THIS! * * External clients need an entry point to wrap a pointer * to an instance of sidl.DFinder. * This header files defines two methods that such clients * will need. * sidl_DFinder__import * This should be called in the client's init * module method. * sidl_DFinder__wrap * This will wrap an IOR in a Python object. */ #ifndef included_sidl_DFinder_MODULE #define included_sidl_DFinder_MODULE #include <Python.h> #include "sidlType.h" #ifdef HAVE_PTHREAD #include <pthread.h> #endif /* HAVE_PTHREAD */ #ifdef __cplusplus extern "C" { #endif struct sidl__array; /* Forward declaration of IOR structure */ struct sidl_DFinder__object; struct sidl_DFinder__array; struct sidl_BaseInterface__object; #define sidl_DFinder__wrap_NUM 0 #define sidl_DFinder__wrap_RETURN PyObject * #define sidl_DFinder__wrap_PROTO (struct sidl_DFinder__object *sidlobj) #define sidl_DFinder__convert_NUM 1 #define sidl_DFinder__convert_RETURN int #define sidl_DFinder__convert_PROTO (PyObject *obj, struct sidl_DFinder__object **sidlobj) #define sidl_DFinder__convert_python_array_NUM 2 #define sidl_DFinder__convert_python_array_RETURN int #define sidl_DFinder__convert_python_array_PROTO (PyObject *obj, struct sidl_DFinder__array **sidlarray) #define sidl_DFinder__convert_sidl_array_NUM 3 #define sidl_DFinder__convert_sidl_array_RETURN PyObject * #define sidl_DFinder__convert_sidl_array_PROTO (struct sidl__array *sidlarray) #define sidl_DFinder__weakRef_NUM 4 #define sidl_DFinder__weakRef_RETURN PyObject * #define sidl_DFinder__weakRef_PROTO (struct sidl_DFinder__object *sidlobj) #define sidl_DFinder_deref_NUM 5 #define sidl_DFinder_deref_RETURN void #define sidl_DFinder_deref_PROTO (struct sidl_DFinder__object *sidlobj) #define sidl_DFinder__newRef_NUM 6 #define sidl_DFinder__newRef_RETURN PyObject * #define sidl_DFinder__newRef_PROTO (struct sidl_DFinder__object *sidlobj) #define sidl_DFinder__addRef_NUM 7 #define sidl_DFinder__addRef_RETURN void #define sidl_DFinder__addRef_PROTO (struct sidl_DFinder__object *sidlobj) #define sidl_DFinder_PyType_NUM 8 #define sidl_DFinder_PyType_RETURN PyTypeObject * #define sidl_DFinder_PyType_PROTO (void) #define sidl_DFinder__connectI_NUM 9 #define sidl_DFinder__connectI_RETURN struct sidl_DFinder__object* #define sidl_DFinder__connectI_PROTO (const char* url, sidl_bool ar, struct sidl_BaseInterface__object ** _ex) #define sidl_DFinder__rmicast_NUM 10 #define sidl_DFinder__rmicast_RETURN struct sidl_DFinder__object* #define sidl_DFinder__rmicast_PROTO (void* bi, struct sidl_BaseInterface__object ** _ex) #define sidl_DFinder__API_NUM 11 #ifdef sidl_DFinder_INTERNAL #define sidl_DFinder__import() ; /* * This declaration is not for clients. */ static sidl_DFinder__wrap_RETURN sidl_DFinder__wrap sidl_DFinder__wrap_PROTO; static sidl_DFinder__convert_RETURN sidl_DFinder__convert sidl_DFinder__convert_PROTO; static sidl_DFinder__convert_python_array_RETURN sidl_DFinder__convert_python_array sidl_DFinder__convert_python_array_PROTO; static sidl_DFinder__convert_sidl_array_RETURN sidl_DFinder__convert_sidl_array sidl_DFinder__convert_sidl_array_PROTO; static sidl_DFinder__weakRef_RETURN sidl_DFinder__weakRef sidl_DFinder__weakRef_PROTO; static sidl_DFinder_deref_RETURN sidl_DFinder_deref sidl_DFinder_deref_PROTO; static sidl_DFinder__newRef_RETURN sidl_DFinder__newRef sidl_DFinder__newRef_PROTO; static sidl_DFinder__addRef_RETURN sidl_DFinder__addRef sidl_DFinder__addRef_PROTO; static sidl_DFinder_PyType_RETURN sidl_DFinder_PyType sidl_DFinder_PyType_PROTO; #else static void **sidl_DFinder__API = NULL; #define sidl_DFinder__wrap \ (*((sidl_DFinder__wrap_RETURN (*) \ sidl_DFinder__wrap_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__wrap_NUM]))) #define sidl_DFinder__convert \ (*((sidl_DFinder__convert_RETURN (*) \ sidl_DFinder__convert_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__convert_NUM]))) #define sidl_DFinder__convert_python_array \ (*((sidl_DFinder__convert_python_array_RETURN (*) \ sidl_DFinder__convert_python_array_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__convert_python_array_NUM]))) #define sidl_DFinder__convert_sidl_array \ (*((sidl_DFinder__convert_sidl_array_RETURN (*) \ sidl_DFinder__convert_sidl_array_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__convert_sidl_array_NUM]))) #define sidl_DFinder__weakRef \ (*((sidl_DFinder__weakRef_RETURN (*) \ sidl_DFinder__weakRef_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__weakRef_NUM]))) #define sidl_DFinder_deref \ (*((sidl_DFinder_deref_RETURN (*) \ sidl_DFinder_deref_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder_deref_NUM]))) #define sidl_DFinder__newRef \ (*((sidl_DFinder__newRef_RETURN (*) \ sidl_DFinder__newRef_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__newRef_NUM]))) #define sidl_DFinder__addRef \ (*((sidl_DFinder__addRef_RETURN (*) \ sidl_DFinder__addRef_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__addRef_NUM]))) #define sidl_DFinder_PyType \ (*((sidl_DFinder_PyType_RETURN (*) \ sidl_DFinder_PyType_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder_PyType_NUM]))) #define sidl_DFinder__connectI \ (*((sidl_DFinder__connectI_RETURN (*) \ sidl_DFinder__connectI_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__connectI_NUM]))) #define sidl_DFinder__rmicast \ (*((sidl_DFinder__rmicast_RETURN (*) \ sidl_DFinder__rmicast_PROTO) \ (sidl_DFinder__API \ [sidl_DFinder__rmicast_NUM]))) #ifdef HAVE_PTHREAD #define sidl_DFinder__import() \ { \ pthread_mutex_t __sidl_pyapi_mutex = PTHREAD_MUTEX_INITIALIZER; \ pthread_mutex_lock(&__sidl_pyapi_mutex); \ if (!sidl_DFinder__API) { \ PyObject *module = PyImport_ImportModule("sidl.DFinder"); \ if (module != NULL) { \ PyObject *module_dict = PyModule_GetDict(module); \ PyObject *c_api_object = \ PyDict_GetItemString(module_dict, "_C_API"); \ if (c_api_object && PyCObject_Check(c_api_object)) { \ sidl_DFinder__API = \ (void **)PyCObject_AsVoidPtr(c_api_object); \ } \ else { fprintf(stderr, "babel: sidl_DFinder__import failed to lookup _C_API (%p %p %s).\n", c_api_object, c_api_object ? c_api_object->ob_type : NULL, c_api_object ? c_api_object->ob_type->tp_name : ""); }\ Py_DECREF(module); \ } else { fprintf(stderr, "babel: sidl_DFinder__import failed to import its module.\n"); }\ }\ pthread_mutex_unlock(&__sidl_pyapi_mutex); \ pthread_mutex_destroy(&__sidl_pyapi_mutex); \ } #else /* !HAVE_PTHREAD */ #define sidl_DFinder__import() \ if (!sidl_DFinder__API) { \ PyObject *module = PyImport_ImportModule("sidl.DFinder"); \ if (module != NULL) { \ PyObject *module_dict = PyModule_GetDict(module); \ PyObject *c_api_object = \ PyDict_GetItemString(module_dict, "_C_API"); \ if (c_api_object && PyCObject_Check(c_api_object)) { \ sidl_DFinder__API = \ (void **)PyCObject_AsVoidPtr(c_api_object); \ } \ else { fprintf(stderr, "babel: sidl_DFinder__import failed to lookup _C_API (%p %p %s).\n", c_api_object, c_api_object ? c_api_object->ob_type : NULL, c_api_object ? c_api_object->ob_type->tp_name : ""); }\ Py_DECREF(module); \ } else { fprintf(stderr, "babel: sidl_DFinder__import failed to import its module.\n"); }\ } #endif /* HAVE_PTHREAD */ #endif #ifdef __cplusplus } #endif #endif
32.285714
212
0.777212
[ "object" ]
ac348ce6d3e6fcc2c5c0be69283c876d039b4676
1,900
h
C
components/mirroring/service/wifi_status_monitor.h
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
components/mirroring/service/wifi_status_monitor.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
components/mirroring/service/wifi_status_monitor.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright 2018 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_MIRRORING_SERVICE_WIFI_STATUS_MONITOR_H_ #define COMPONENTS_MIRRORING_SERVICE_WIFI_STATUS_MONITOR_H_ #include <vector> #include "base/containers/circular_deque.h" #include "base/macros.h" #include "base/time/time.h" #include "base/timer/timer.h" namespace mirroring { class MessageDispatcher; struct ReceiverResponse; struct WifiStatus { double snr; int32_t speed; // The current WiFi speed. base::Time timestamp; // Recording time of this status. }; // Periodically sends requests to the Cast device for WiFi network status // updates, processes responses, and maintains a recent history of data points. // This data can be included in feedback logs to help identify and diagnose // issues related to lousy network performance. class WifiStatusMonitor { public: // |message_dispatcher| must keep alive during the lifetime of this class. WifiStatusMonitor(int32_t session_id, MessageDispatcher* message_dispatcher); ~WifiStatusMonitor(); // Gets the recorded status and clear |recent_status_|. std::vector<WifiStatus> GetRecentValues(); // Sends GET_STATUS message to receiver. void QueryStatus(); // Callback for the STATUS_RESPONSE message. Records the WiFi status reported // by receiver. void RecordStatus(const ReceiverResponse& response); private: const int32_t session_id_; MessageDispatcher* const message_dispatcher_; // Outlives this class. base::RepeatingTimer query_timer_; // Stores the recent status. Will be reset when GetRecentValues() is called. base::circular_deque<WifiStatus> recent_status_; DISALLOW_COPY_AND_ASSIGN(WifiStatusMonitor); }; } // namespace mirroring #endif // COMPONENTS_MIRRORING_SERVICE_WIFI_STATUS_MONITOR_H_
30.645161
79
0.778421
[ "vector" ]
ac3c2fb12791b42ecc502397b1f990bc1afb26ed
1,088
h
C
01_vulkanTriangle/app/src/main/jni/memory_pool.h
damonwy/vk_launcher
ac06969c3429c5b1a49245ee75a275afa22480c8
[ "MIT" ]
null
null
null
01_vulkanTriangle/app/src/main/jni/memory_pool.h
damonwy/vk_launcher
ac06969c3429c5b1a49245ee75a275afa22480c8
[ "MIT" ]
null
null
null
01_vulkanTriangle/app/src/main/jni/memory_pool.h
damonwy/vk_launcher
ac06969c3429c5b1a49245ee75a275afa22480c8
[ "MIT" ]
null
null
null
#pragma once //#include "taichi/common/core.h" #include "unified_allocator.h" #define TI_RUNTIME_HOST #include "mem_request.h" #include <mutex> #include <vector> #include <memory> #include <thread> //class Program; // A memory pool that runs on the host class MemoryPool { public: std::vector<std::unique_ptr<UnifiedAllocator>> allocators; static constexpr std::size_t default_allocator_size = 1 << 30; // 1 GB per allocator bool terminating, killed; std::mutex mut; std::mutex mut_allocators; std::unique_ptr<std::thread> th; int processed_tail; bool use_unified_memory; // Program *prog; MemRequestQueue *queue; void *cuda_stream{nullptr}; MemoryPool(); template <typename T> T fetch(volatile void *ptr); template <typename T> void push(volatile T *dest, const T &val); void *allocate(std::size_t size, std::size_t alignment); void set_queue(MemRequestQueue *queue); void daemon(); void terminate(); ~MemoryPool(); private: static constexpr bool use_cuda_stream = false; };
20.528302
62
0.682904
[ "vector" ]