hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
fdb380a7faff6b46037e6abefb69c8c43cf5ae72
1,917
h
C
mame/src/mame/includes/armedf.h
clobber/MAME-OS-X
ca11d0e946636bda042b6db55c82113e5722fc08
[ "MIT" ]
15
2015-03-03T23:15:57.000Z
2021-11-12T07:09:24.000Z
mame/src/mame/includes/armedf.h
clobber/MAME-OS-X
ca11d0e946636bda042b6db55c82113e5722fc08
[ "MIT" ]
null
null
null
mame/src/mame/includes/armedf.h
clobber/MAME-OS-X
ca11d0e946636bda042b6db55c82113e5722fc08
[ "MIT" ]
8
2015-07-07T16:40:44.000Z
2020-08-18T06:57:29.000Z
class armedf_state : public driver_device { public: armedf_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) { } /* memory pointers */ UINT8 * m_text_videoram; UINT16 * m_bg_videoram; UINT16 * m_fg_videoram; UINT16 * m_spr_pal_clut; UINT16 m_legion_cmd[4]; // legiono only! // UINT16 * m_spriteram; // currently this uses generic buffered_spriteram // UINT16 * m_paletteram; // currently this uses generic palette handling /* video-related */ tilemap_t *m_bg_tilemap; tilemap_t *m_fg_tilemap; tilemap_t *m_tx_tilemap; UINT16 m_scroll_msb; UINT16 m_vreg; UINT16 m_fg_scrollx; UINT16 m_fg_scrolly; UINT16 m_bg_scrollx; UINT16 m_bg_scrolly; int m_scroll_type; int m_sprite_offy; int m_old_mcu_mode; int m_waiting_msb; }; class bigfghtr_state : public armedf_state { public: bigfghtr_state(const machine_config &mconfig, device_type type, const char *tag) : armedf_state(mconfig, type, tag) { } UINT16 * m_sharedram; /* misc */ int m_read_latch; UINT8 m_mcu_input_snippet; UINT8 m_mcu_jsr_snippet; }; /*----------- defined in video/armedf.c -----------*/ SCREEN_UPDATE( armedf ); SCREEN_EOF( armedf ); VIDEO_START( armedf ); VIDEO_START( terraf ); WRITE16_HANDLER( armedf_bg_videoram_w ); WRITE16_HANDLER( armedf_fg_videoram_w ); READ8_HANDLER( armedf_text_videoram_r ); WRITE8_HANDLER( armedf_text_videoram_w ); READ8_HANDLER( nb1414m4_text_videoram_r ); WRITE8_HANDLER( nb1414m4_text_videoram_w ); WRITE16_HANDLER( terraf_fg_scrollx_w ); WRITE16_HANDLER( terraf_fg_scrolly_w ); WRITE16_HANDLER( terraf_fg_scroll_msb_arm_w ); WRITE16_HANDLER( armedf_fg_scrollx_w ); WRITE16_HANDLER( armedf_fg_scrolly_w ); WRITE16_HANDLER( armedf_bg_scrollx_w ); WRITE16_HANDLER( armedf_bg_scrolly_w );
28.61194
82
0.72144
45797ddb6a46a91f20206c593f0295443df455b1
7,827
h
C
System/Library/PrivateFrameworks/AudioServerDriver.framework/ASDClockDevice.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
1
2020-11-11T06:05:23.000Z
2020-11-11T06:05:23.000Z
System/Library/PrivateFrameworks/AudioServerDriver.framework/ASDClockDevice.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/AudioServerDriver.framework/ASDClockDevice.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.5 * on Tuesday, November 10, 2020 at 10:17:45 PM Mountain Standard Time * Operating System: Version 14.2 (Build 18K57) * Image Source: /System/Library/PrivateFrameworks/AudioServerDriver.framework/AudioServerDriver * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ #import <AudioServerDriver/AudioServerDriver-Structs.h> #import <AudioServerDriver/ASDObject.h> @protocol OS_dispatch_queue, OS_dispatch_semaphore, ASDDeviceConfigurationChangeDelegate; @class NSMutableArray, NSObject, NSArray, NSString; @interface ASDClockDevice : ASDObject { NSMutableArray* _controls; NSObject*<OS_dispatch_queue> _controlQueue; double _samplingRate; NSArray* _samplingRates; NSObject*<OS_dispatch_queue> _sampleRateQueue; long long _ioReferenceCount; NSObject*<OS_dispatch_queue> _ioReferenceQueue; NSString* _deviceName; unsigned _timestampPeriod; unsigned _transportType; unsigned _clockDomain; unsigned _clockAlgorithm; BOOL _clockIsStable; NSObject*<OS_dispatch_semaphore> _wakeSemaphore; BOOL _isAlive; BOOL _isRunning; unsigned _inputLatency; unsigned _outputLatency; /*^block*/id _getZeroTimestampBlockUnretained; /*^block*/id _beginIOOperationBlockUnretained; /*^block*/id _endIOOperationBlockUnretained; BOOL _hidden; BOOL _canChangeDeviceName; NSString* _deviceUID; NSString* _modelUID; NSString* _manufacturerName; NSString* _modelName; /*^block*/id _getZeroTimestampBlock; /*^block*/id _beginIOOperationBlock; /*^block*/id _endIOOperationBlock; id<ASDDeviceConfigurationChangeDelegate> _configurationChangeDelegate; } @property (nonatomic,copy) id beginIOOperationBlock; //@synthesize beginIOOperationBlock=_beginIOOperationBlock - In the implementation block @property (nonatomic,copy) id endIOOperationBlock; //@synthesize endIOOperationBlock=_endIOOperationBlock - In the implementation block @property (assign,nonatomic,__weak) id<ASDDeviceConfigurationChangeDelegate> configurationChangeDelegate; //@synthesize configurationChangeDelegate=_configurationChangeDelegate - In the implementation block @property (nonatomic,readonly) /*^block*/id* getZeroTimestampBlockUnretainedPtr; @property (nonatomic,readonly) /*^block*/id* beginIOOperationBlockUnretainedPtr; @property (nonatomic,readonly) /*^block*/id* endIOOperationBlockUnretainedPtr; @property (nonatomic,copy) NSString * deviceName; @property (nonatomic,copy,readonly) NSString * deviceUID; //@synthesize deviceUID=_deviceUID - In the implementation block @property (nonatomic,copy) NSString * modelUID; //@synthesize modelUID=_modelUID - In the implementation block @property (nonatomic,copy) NSString * manufacturerName; //@synthesize manufacturerName=_manufacturerName - In the implementation block @property (nonatomic,copy) NSString * modelName; //@synthesize modelName=_modelName - In the implementation block @property (assign,nonatomic) double samplingRate; @property (nonatomic,copy) NSArray * samplingRates; @property (assign,getter=isHidden,nonatomic) BOOL hidden; //@synthesize hidden=_hidden - In the implementation block @property (assign,nonatomic) BOOL canChangeDeviceName; //@synthesize canChangeDeviceName=_canChangeDeviceName - In the implementation block @property (assign,nonatomic) unsigned timestampPeriod; @property (assign,nonatomic) unsigned inputLatency; @property (assign,nonatomic) unsigned outputLatency; @property (getter=isRunning,nonatomic,readonly) BOOL running; @property (nonatomic,retain,readonly) NSObject*<OS_dispatch_queue> ioReferenceQueue; @property (assign,nonatomic) unsigned transportType; @property (assign,nonatomic) unsigned clockDomain; @property (assign,nonatomic) unsigned clockAlgorithm; @property (assign,nonatomic) BOOL clockIsStable; @property (nonatomic,copy) id getZeroTimestampBlock; //@synthesize getZeroTimestampBlock=_getZeroTimestampBlock - In the implementation block -(void)dealloc; -(BOOL)isRunning; -(unsigned)objectClass; -(NSString *)deviceName; -(void)setDeviceName:(NSString *)arg1 ; -(unsigned)transportType; -(void)setTransportType:(unsigned)arg1 ; -(BOOL)isHidden; -(void)setHidden:(BOOL)arg1 ; -(NSString *)manufacturerName; -(unsigned)outputLatency; -(unsigned)inputLatency; -(BOOL)hasProperty:(const AudioObjectPropertyAddress*)arg1 ; -(id)controls; -(void)systemWillSleep; -(NSString *)deviceUID; -(int)removeClient:(const AudioServerPlugInClientInfo*)arg1 ; -(NSString *)modelName; -(void)setModelName:(NSString *)arg1 ; -(void)setManufacturerName:(NSString *)arg1 ; -(int)addClient:(const AudioServerPlugInClientInfo*)arg1 ; -(NSArray *)samplingRates; -(id)initWithPlugin:(id)arg1 ; -(id)diagnosticDescriptionWithIndent:(id)arg1 walkTree:(BOOL)arg2 ; -(NSString *)modelUID; -(unsigned)clockDomain; -(unsigned)dataSizeForProperty:(const AudioObjectPropertyAddress*)arg1 withQualifierSize:(unsigned)arg2 andQualifierData:(const void*)arg3 ; -(BOOL)getProperty:(const AudioObjectPropertyAddress*)arg1 withQualifierSize:(unsigned)arg2 qualifierData:(const void*)arg3 dataSize:(unsigned*)arg4 andData:(void*)arg5 forClient:(int)arg6 ; -(id)driverClassName; -(unsigned)timestampPeriod; -(double)samplingRate; -(void)systemHasPoweredOn; -(void)setSamplingRate:(double)arg1 ; -(void)requestConfigurationChange:(/*^block*/id)arg1 ; -(/*^block*/id*)getZeroTimestampBlockUnretainedPtr; -(/*^block*/id*)beginIOOperationBlockUnretainedPtr; -(/*^block*/id*)endIOOperationBlockUnretainedPtr; -(void)performConfigurationChange:(void*)arg1 ; -(BOOL)isPropertySettable:(const AudioObjectPropertyAddress*)arg1 ; -(BOOL)setProperty:(const AudioObjectPropertyAddress*)arg1 withQualifierSize:(unsigned)arg2 qualifierData:(const void*)arg3 dataSize:(unsigned)arg4 andData:(const void*)arg5 forClient:(int)arg6 ; -(int)startIOForClient:(unsigned)arg1 ; -(int)stopIOForClient:(unsigned)arg1 ; -(void)setModelUID:(NSString *)arg1 ; -(unsigned)clockAlgorithm; -(BOOL)clockIsStable; -(BOOL)canChangeDeviceName; -(BOOL)changeDeviceName:(id)arg1 ; -(BOOL)changeSamplingRate:(double)arg1 ; -(id<ASDDeviceConfigurationChangeDelegate>)configurationChangeDelegate; -(int)performStartIO; -(int)performStopIO; -(id)getZeroTimestampBlock; -(id)beginIOOperationBlock; -(id)endIOOperationBlock; -(void)_updateTimestampPeriod:(double)arg1 ; -(void)_updateSafetyOffsets:(double)arg1 ; -(id)initWithDeviceUID:(id)arg1 withPlugin:(id)arg2 ; -(void)addControl:(id)arg1 ; -(void)removeControl:(id)arg1 ; -(void)setSamplingRates:(NSArray *)arg1 ; -(void)setTimestampPeriod:(unsigned)arg1 ; -(void)updateTimestampPeriod; -(NSObject*<OS_dispatch_queue>)ioReferenceQueue; -(void)setInputLatency:(unsigned)arg1 ; -(void)setOutputLatency:(unsigned)arg1 ; -(void)setClockDomain:(unsigned)arg1 ; -(void)setClockAlgorithm:(unsigned)arg1 ; -(void)setClockIsStable:(BOOL)arg1 ; -(void)setGetZeroTimestampBlock:(id)arg1 ; -(void)setBeginIOOperationBlock:(id)arg1 ; -(void)setEndIOOperationBlock:(id)arg1 ; -(void)setCanChangeDeviceName:(BOOL)arg1 ; -(void)setConfigurationChangeDelegate:(id<ASDDeviceConfigurationChangeDelegate>)arg1 ; @end
51.834437
219
0.730931
04a60e5937acfec7fe4672360b8224887c492c97
3,828
c
C
src/context/comm_sizef.c
RWTH-OS/MP-MPICH
f2ae296477bb9d812fda587221b3419c09f85b4a
[ "mpich2" ]
null
null
null
src/context/comm_sizef.c
RWTH-OS/MP-MPICH
f2ae296477bb9d812fda587221b3419c09f85b4a
[ "mpich2" ]
null
null
null
src/context/comm_sizef.c
RWTH-OS/MP-MPICH
f2ae296477bb9d812fda587221b3419c09f85b4a
[ "mpich2" ]
1
2021-01-23T11:01:01.000Z
2021-01-23T11:01:01.000Z
/* comm_size.c */ /* Custom Fortran interface file */ #include "mpiimpl.h" #if defined(MPI_BUILD_PROFILING) || defined(HAVE_WEAK_SYMBOLS) #if defined(HAVE_WEAK_SYMBOLS) #if defined(HAVE_PRAGMA_WEAK) #if defined(FORTRANCAPS) #pragma weak MPI_COMM_SIZE = PMPI_COMM_SIZE EXPORT_MPI_API void MPI_COMM_SIZE ( MPI_Fint *, MPI_Fint *, MPI_Fint * ); #elif defined(FORTRANDOUBLEUNDERSCORE) #pragma weak mpi_comm_size__ = pmpi_comm_size__ EXPORT_MPI_API void mpi_comm_size__ ( MPI_Fint *, MPI_Fint *, MPI_Fint * ); #elif !defined(FORTRANUNDERSCORE) #pragma weak mpi_comm_size = pmpi_comm_size EXPORT_MPI_API void mpi_comm_size ( MPI_Fint *, MPI_Fint *, MPI_Fint * ); #else #pragma weak mpi_comm_size_ = pmpi_comm_size_ EXPORT_MPI_API void mpi_comm_size_ ( MPI_Fint *, MPI_Fint *, MPI_Fint * ); #endif #elif defined(HAVE_ATTRIBUTE_WEAK) #if defined(FORTRANCAPS) EXPORT_MPI_API void MPI_COMM_SIZE ( MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__ ((weak, alias ("PMPI_COMM_SIZE"))); #elif defined(FORTRANDOUBLEUNDERSCORE) EXPORT_MPI_API void mpi_comm_size__ ( MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__ ((weak, alias ("pmpi_comm_size__"))); #elif !defined(FORTRANUNDERSCORE) EXPORT_MPI_API void mpi_comm_size ( MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__ ((weak, alias ("pmpi_comm_size"))); #else EXPORT_MPI_API void mpi_comm_size_ ( MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__ ((weak, alias ("pmpi_comm_size_"))); #endif #elif defined(HAVE_PRAGMA_HP_SEC_DEF) #if defined(FORTRANCAPS) #pragma _HP_SECONDARY_DEF PMPI_COMM_SIZE MPI_COMM_SIZE #elif defined(FORTRANDOUBLEUNDERSCORE) #pragma _HP_SECONDARY_DEF pmpi_comm_size__ mpi_comm_size__ #elif !defined(FORTRANUNDERSCORE) #pragma _HP_SECONDARY_DEF pmpi_comm_size mpi_comm_size #else #pragma _HP_SECONDARY_DEF pmpi_comm_size_ mpi_comm_size_ #endif #elif defined(HAVE_PRAGMA_CRI_DUP) #if defined(FORTRANCAPS) #pragma _CRI duplicate MPI_COMM_SIZE as PMPI_COMM_SIZE #elif defined(FORTRANDOUBLEUNDERSCORE) #pragma _CRI duplicate mpi_comm_size__ as pmpi_comm_size__ #elif !defined(FORTRANUNDERSCORE) #pragma _CRI duplicate mpi_comm_size as pmpi_comm_size #else #pragma _CRI duplicate mpi_comm_size_ as pmpi_comm_size_ #endif /* end of weak pragmas */ #endif /* #if defined(HAVE_PRAGMA_WEAK)*/ /* Include mapping from MPI->PMPI */ #include "mpiprof.h" /* Insert the prototypes for the PMPI routines */ #undef __MPI_BINDINGS #include "binding.h" #endif /*#if defined(HAVE_WEAK_SYMBOLS)*/ #ifdef FORTRANCAPS #define mpi_comm_size_ PMPI_COMM_SIZE #elif defined(FORTRANDOUBLEUNDERSCORE) #define mpi_comm_size_ pmpi_comm_size__ #elif !defined(FORTRANUNDERSCORE) #define mpi_comm_size_ pmpi_comm_size #else #define mpi_comm_size_ pmpi_comm_size_ #endif #else /*#if defined(MPI_BUILD_PROFILING) || defined(HAVE_WEAK_SYMBOLS)*/ #ifdef FORTRANCAPS #define mpi_comm_size_ MPI_COMM_SIZE #elif defined(FORTRANDOUBLEUNDERSCORE) #define mpi_comm_size_ mpi_comm_size__ #elif !defined(FORTRANUNDERSCORE) #define mpi_comm_size_ mpi_comm_size #endif #endif /*#if defined(MPI_BUILD_PROFILING) || defined(HAVE_WEAK_SYMBOLS)*/ /* Prototype to suppress warnings about missing prototypes */ EXPORT_MPI_API void FORTRAN_API mpi_comm_size_ ANSI_ARGS(( MPI_Fint *, MPI_Fint *, MPI_Fint * )); EXPORT_MPI_API void FORTRAN_API mpi_comm_size_ ( MPI_Fint *comm, MPI_Fint *size, MPI_Fint *__ierr ) { int l_size; *__ierr = MPI_Comm_size( MPI_Comm_f2c(*comm), &l_size ); *size = (MPI_Fint)l_size; }
36.807692
99
0.717607
a9ee72a41d3652d607235031592a17ee1a7be422
4,548
c
C
scipy/special/cephes/kn.c
Ennosigaeon/scipy
2d872f7cf2098031b9be863ec25e366a550b229c
[ "BSD-3-Clause" ]
9,095
2015-01-02T18:24:23.000Z
2022-03-31T20:35:31.000Z
scipy/special/cephes/kn.c
Ennosigaeon/scipy
2d872f7cf2098031b9be863ec25e366a550b229c
[ "BSD-3-Clause" ]
11,500
2015-01-01T01:15:30.000Z
2022-03-31T23:07:35.000Z
scipy/special/cephes/kn.c
Ennosigaeon/scipy
2d872f7cf2098031b9be863ec25e366a550b229c
[ "BSD-3-Clause" ]
5,838
2015-01-05T11:56:42.000Z
2022-03-31T23:21:19.000Z
/* kn.c * * Modified Bessel function, third kind, integer order * * * * SYNOPSIS: * * double x, y, kn(); * int n; * * y = kn( n, x ); * * * * DESCRIPTION: * * Returns modified Bessel function of the third kind * of order n of the argument. * * The range is partitioned into the two intervals [0,9.55] and * (9.55, infinity). An ascending power series is used in the * low range, and an asymptotic expansion in the high range. * * * * ACCURACY: * * Relative error: * arithmetic domain # trials peak rms * IEEE 0,30 90000 1.8e-8 3.0e-10 * * Error is high only near the crossover point x = 9.55 * between the two expansions used. */ /* * Cephes Math Library Release 2.8: June, 2000 * Copyright 1984, 1987, 1988, 2000 by Stephen L. Moshier */ /* * Algorithm for Kn. * n-1 * -n - (n-k-1)! 2 k * K (x) = 0.5 (x/2) > -------- (-x /4) * n - k! * k=0 * * inf. 2 k * n n - (x /4) * + (-1) 0.5(x/2) > {p(k+1) + p(n+k+1) - 2log(x/2)} --------- * - k! (n+k)! * k=0 * * where p(m) is the psi function: p(1) = -EUL and * * m-1 * - * p(m) = -EUL + > 1/k * - * k=1 * * For large x, * 2 2 2 * u-1 (u-1 )(u-3 ) * K (z) = sqrt(pi/2z) exp(-z) { 1 + ------- + ------------ + ...} * v 1 2 * 1! (8z) 2! (8z) * asymptotically, where * * 2 * u = 4 v . * */ #include "mconf.h" #include <float.h> #define EUL 5.772156649015328606065e-1 #define MAXFAC 31 extern double MACHEP, MAXLOG; double kn(nn, x) int nn; double x; { double k, kf, nk1f, nkf, zn, t, s, z0, z; double ans, fn, pn, pk, zmn, tlg, tox; int i, n; if (nn < 0) n = -nn; else n = nn; if (n > MAXFAC) { overf: sf_error("kn", SF_ERROR_OVERFLOW, NULL); return (NPY_INFINITY); } if (x <= 0.0) { if (x < 0.0) { sf_error("kn", SF_ERROR_DOMAIN, NULL); return NPY_NAN; } else { sf_error("kn", SF_ERROR_SINGULAR, NULL); return NPY_INFINITY; } } if (x > 9.55) goto asymp; ans = 0.0; z0 = 0.25 * x * x; fn = 1.0; pn = 0.0; zmn = 1.0; tox = 2.0 / x; if (n > 0) { /* compute factorial of n and psi(n) */ pn = -EUL; k = 1.0; for (i = 1; i < n; i++) { pn += 1.0 / k; k += 1.0; fn *= k; } zmn = tox; if (n == 1) { ans = 1.0 / x; } else { nk1f = fn / n; kf = 1.0; s = nk1f; z = -z0; zn = 1.0; for (i = 1; i < n; i++) { nk1f = nk1f / (n - i); kf = kf * i; zn *= z; t = nk1f * zn / kf; s += t; if ((DBL_MAX - fabs(t)) < fabs(s)) goto overf; if ((tox > 1.0) && ((DBL_MAX / tox) < zmn)) goto overf; zmn *= tox; } s *= 0.5; t = fabs(s); if ((zmn > 1.0) && ((DBL_MAX / zmn) < t)) goto overf; if ((t > 1.0) && ((DBL_MAX / t) < zmn)) goto overf; ans = s * zmn; } } tlg = 2.0 * log(0.5 * x); pk = -EUL; if (n == 0) { pn = pk; t = 1.0; } else { pn = pn + 1.0 / n; t = 1.0 / fn; } s = (pk + pn - tlg) * t; k = 1.0; do { t *= z0 / (k * (k + n)); pk += 1.0 / k; pn += 1.0 / (k + n); s += (pk + pn - tlg) * t; k += 1.0; } while (fabs(t / s) > MACHEP); s = 0.5 * s / zmn; if (n & 1) s = -s; ans += s; return (ans); /* Asymptotic expansion for Kn(x) */ /* Converges to 1.4e-17 for x > 18.4 */ asymp: if (x > MAXLOG) { sf_error("kn", SF_ERROR_UNDERFLOW, NULL); return (0.0); } k = n; pn = 4.0 * k * k; pk = 1.0; z0 = 8.0 * x; fn = 1.0; t = 1.0; s = t; nkf = NPY_INFINITY; i = 0; do { z = pn - pk * pk; t = t * z / (fn * z0); nk1f = fabs(t); if ((i >= n) && (nk1f > nkf)) { goto adone; } nkf = nk1f; s += t; fn += 1.0; pk += 2.0; i += 1; } while (fabs(t / s) > MACHEP); adone: ans = exp(-x) * sqrt(NPY_PI / (2.0 * x)) * s; return (ans); }
19.109244
68
0.380607
a641340888d11b393c1e7aa7c53f5614ea0d66cb
14,020
h
C
dlls/wininet/internet.h
84KaliPleXon3/wine-wine
d6a59f755eff0a6f05dc7b4b375ea96c21e7a0b1
[ "MIT" ]
20
2015-03-12T09:04:07.000Z
2022-01-28T22:50:46.000Z
dlls/wininet/internet.h
84KaliPleXon3/wine-wine
d6a59f755eff0a6f05dc7b4b375ea96c21e7a0b1
[ "MIT" ]
null
null
null
dlls/wininet/internet.h
84KaliPleXon3/wine-wine
d6a59f755eff0a6f05dc7b4b375ea96c21e7a0b1
[ "MIT" ]
10
2016-07-19T05:39:39.000Z
2021-08-05T09:09:27.000Z
/* * Wininet * * Copyright 1999 Corel Corporation * * Ulrich Czekalla * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef _WINE_INTERNET_H_ #define _WINE_INTERNET_H_ #ifndef __WINE_CONFIG_H # error You must include config.h to use this header #endif #include "wine/unicode.h" #include "wine/list.h" #include <time.h> #ifdef HAVE_NETDB_H # include <netdb.h> #endif #ifdef HAVE_NETINET_IN_H # include <sys/types.h> # include <netinet/in.h> #endif #ifdef HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #if !defined(__MINGW32__) && !defined(_MSC_VER) #define closesocket close #define ioctlsocket ioctl #endif /* __MINGW32__ */ #include "winineti.h" extern HMODULE WININET_hModule DECLSPEC_HIDDEN; #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 46 #endif typedef struct { WCHAR *name; INTERNET_PORT port; BOOL is_https; struct sockaddr_storage addr; socklen_t addr_len; char addr_str[INET6_ADDRSTRLEN]; WCHAR *scheme_host_port; const WCHAR *host_port; const WCHAR *canon_host_port; LONG ref; DWORD security_flags; const CERT_CHAIN_CONTEXT *cert_chain; struct list entry; struct list conn_pool; } server_t; void server_addref(server_t*) DECLSPEC_HIDDEN; void server_release(server_t*) DECLSPEC_HIDDEN; typedef enum { COLLECT_TIMEOUT, COLLECT_CONNECTIONS, COLLECT_CLEANUP } collect_type_t; BOOL collect_connections(collect_type_t) DECLSPEC_HIDDEN; /* used for netconnection.c stuff */ typedef struct { int socket; BOOL secure; CtxtHandle ssl_ctx; SecPkgContext_StreamSizes ssl_sizes; server_t *server; char *ssl_buf; char *extra_buf; size_t extra_len; char *peek_msg; char *peek_msg_mem; size_t peek_len; DWORD security_flags; BOOL mask_errors; BOOL keep_alive; DWORD64 keep_until; struct list pool_entry; } netconn_t; BOOL is_valid_netconn(netconn_t *) DECLSPEC_HIDDEN; void close_netconn(netconn_t *) DECLSPEC_HIDDEN; static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len) { return HeapAlloc(GetProcessHeap(), 0, len); } static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len) { return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); } static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len) { return HeapReAlloc(GetProcessHeap(), 0, mem, len); } static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len) { return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len); } static inline BOOL heap_free(void *mem) { return HeapFree(GetProcessHeap(), 0, mem); } static inline LPWSTR heap_strdupW(LPCWSTR str) { LPWSTR ret = NULL; if(str) { DWORD size; size = (strlenW(str)+1)*sizeof(WCHAR); ret = heap_alloc(size); if(ret) memcpy(ret, str, size); } return ret; } static inline char *heap_strdupA(const char *str) { char *ret = NULL; if(str) { DWORD size = strlen(str)+1; ret = heap_alloc(size); if(ret) memcpy(ret, str, size); } return ret; } static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len) { LPWSTR ret; UINT len; if(!str) return NULL; for(len=0; len<max_len; len++) if(str[len] == '\0') break; ret = heap_alloc(sizeof(WCHAR)*(len+1)); if(ret) { memcpy(ret, str, sizeof(WCHAR)*len); ret[len] = '\0'; } return ret; } static inline WCHAR *heap_strdupAtoW(const char *str) { LPWSTR ret = NULL; if(str) { DWORD len; len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); ret = heap_alloc(len*sizeof(WCHAR)); if(ret) MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); } return ret; } static inline char *heap_strdupWtoA(LPCWSTR str) { char *ret = NULL; if(str) { DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); ret = heap_alloc(size); if(ret) WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); } return ret; } static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA) { dataA->dwFileAttributes = dataW->dwFileAttributes; dataA->ftCreationTime = dataW->ftCreationTime; dataA->ftLastAccessTime = dataW->ftLastAccessTime; dataA->ftLastWriteTime = dataW->ftLastWriteTime; dataA->nFileSizeHigh = dataW->nFileSizeHigh; dataA->nFileSizeLow = dataW->nFileSizeLow; dataA->dwReserved0 = dataW->dwReserved0; dataA->dwReserved1 = dataW->dwReserved1; WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1, dataA->cFileName, sizeof(dataA->cFileName), NULL, NULL); WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1, dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName), NULL, NULL); } typedef enum { WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET, WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP, WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER, WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP, WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE, WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND, WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST, } WH_TYPE; #define INET_OPENURL 0x0001 #define INET_CALLBACKW 0x0002 typedef struct { LONG ref; HANDLE file_handle; WCHAR *file_name; BOOL is_committed; } req_file_t; typedef struct _object_header_t object_header_t; typedef struct { void (*Destroy)(object_header_t*); void (*CloseConnection)(object_header_t*); DWORD (*QueryOption)(object_header_t*,DWORD,void*,DWORD*,BOOL); DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD); DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*); DWORD (*ReadFileEx)(object_header_t*,void*,DWORD,DWORD*,DWORD,DWORD_PTR); DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*); DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR); DWORD (*FindNextFileW)(object_header_t*,void*); DWORD (*LockRequestFile)(object_header_t*,req_file_t**); } object_vtbl_t; #define INTERNET_HANDLE_IN_USE 1 struct _object_header_t { WH_TYPE htype; const object_vtbl_t *vtbl; HINTERNET hInternet; BOOL valid_handle; DWORD dwFlags; DWORD_PTR dwContext; DWORD dwError; ULONG ErrorMask; DWORD dwInternalFlags; LONG refs; INTERNET_STATUS_CALLBACK lpfnStatusCB; struct list entry; struct list children; }; typedef struct { object_header_t hdr; LPWSTR agent; LPWSTR proxy; LPWSTR proxyBypass; LPWSTR proxyUsername; LPWSTR proxyPassword; DWORD accessType; DWORD connect_timeout; } appinfo_t; typedef struct { object_header_t hdr; appinfo_t *appInfo; LPWSTR hostName; /* the final destination of the request */ LPWSTR userName; LPWSTR password; INTERNET_PORT hostPort; /* the final destination port of the request */ DWORD connect_timeout; DWORD send_timeout; DWORD receive_timeout; } http_session_t; #define HDR_ISREQUEST 0x0001 #define HDR_COMMADELIMITED 0x0002 #define HDR_SEMIDELIMITED 0x0004 typedef struct { LPWSTR lpszField; LPWSTR lpszValue; WORD wFlags; WORD wCount; } HTTPHEADERW, *LPHTTPHEADERW; struct HttpAuthInfo; typedef struct data_stream_vtbl_t data_stream_vtbl_t; typedef struct { const data_stream_vtbl_t *vtbl; } data_stream_t; typedef struct { data_stream_t data_stream; DWORD content_length; DWORD content_read; } netconn_stream_t; #define READ_BUFFER_SIZE 8192 typedef struct { object_header_t hdr; http_session_t *session; server_t *server; server_t *proxy; LPWSTR path; LPWSTR verb; netconn_t *netconn; DWORD security_flags; DWORD connect_timeout; DWORD send_timeout; DWORD receive_timeout; LPWSTR version; DWORD status_code; LPWSTR statusText; DWORD bytesToWrite; DWORD bytesWritten; HTTPHEADERW *custHeaders; DWORD nCustHeaders; FILETIME last_modified; HANDLE hCacheFile; req_file_t *req_file; FILETIME expires; struct HttpAuthInfo *authInfo; struct HttpAuthInfo *proxyAuthInfo; CRITICAL_SECTION read_section; /* section to protect the following fields */ DWORD contentLength; /* total number of bytes to be read */ BOOL read_chunked; /* are we reading in chunked mode? */ BOOL read_gzip; /* are we reading in gzip mode? */ DWORD read_pos; /* current read position in read_buf */ DWORD read_size; /* valid data size in read_buf */ BYTE read_buf[READ_BUFFER_SIZE]; /* buffer for already read but not returned data */ BOOL decoding; data_stream_t *data_stream; netconn_stream_t netconn_stream; } http_request_t; typedef struct task_header_t task_header_t; typedef void (*async_task_proc_t)(task_header_t*); struct task_header_t { async_task_proc_t proc; object_header_t *hdr; }; void *alloc_async_task(object_header_t*,async_task_proc_t,size_t) DECLSPEC_HIDDEN; void *alloc_object(object_header_t*,const object_vtbl_t*,size_t) DECLSPEC_HIDDEN; object_header_t *get_handle_object( HINTERNET hinternet ) DECLSPEC_HIDDEN; object_header_t *WININET_AddRef( object_header_t *info ) DECLSPEC_HIDDEN; BOOL WININET_Release( object_header_t *info ) DECLSPEC_HIDDEN; DWORD INET_QueryOption(object_header_t*,DWORD,void*,DWORD*,BOOL) DECLSPEC_HIDDEN; DWORD INET_SetOption(object_header_t*,DWORD,void*,DWORD) DECLSPEC_HIDDEN; time_t ConvertTimeString(LPCWSTR asctime) DECLSPEC_HIDDEN; HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags) DECLSPEC_HIDDEN; DWORD HTTP_Connect(appinfo_t*,LPCWSTR, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags, HINTERNET*) DECLSPEC_HIDDEN; BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort, struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN; DWORD get_cookie(const WCHAR*,const WCHAR*,WCHAR*,DWORD*) DECLSPEC_HIDDEN; BOOL set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN; void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN; DWORD INTERNET_GetLastError(void) DECLSPEC_HIDDEN; DWORD INTERNET_AsyncCall(task_header_t*) DECLSPEC_HIDDEN; LPSTR INTERNET_GetResponseBuffer(void) DECLSPEC_HIDDEN; LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen) DECLSPEC_HIDDEN; VOID SendAsyncCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN; VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN; BOOL INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto, WCHAR *foundProxy, DWORD *foundProxyLen) DECLSPEC_HIDDEN; typedef enum { BLOCKING_ALLOW, BLOCKING_DISALLOW, BLOCKING_WAITALL } blocking_mode_t; DWORD create_netconn(BOOL,server_t*,DWORD,BOOL,DWORD,netconn_t**) DECLSPEC_HIDDEN; void free_netconn(netconn_t*) DECLSPEC_HIDDEN; void NETCON_unload(void) DECLSPEC_HIDDEN; DWORD NETCON_secure_connect(netconn_t*,server_t*) DECLSPEC_HIDDEN; DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, int *sent /* out */) DECLSPEC_HIDDEN; DWORD NETCON_recv(netconn_t*,void*,size_t,blocking_mode_t,int*) DECLSPEC_HIDDEN; BOOL NETCON_query_data_available(netconn_t *connection, DWORD *available) DECLSPEC_HIDDEN; BOOL NETCON_is_alive(netconn_t*) DECLSPEC_HIDDEN; LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN; int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN; DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN; int sock_get_error(int) DECLSPEC_HIDDEN; server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL); DWORD create_req_file(const WCHAR*,req_file_t**) DECLSPEC_HIDDEN; void req_file_release(req_file_t*) DECLSPEC_HIDDEN; static inline req_file_t *req_file_addref(req_file_t *req_file) { InterlockedIncrement(&req_file->ref); return req_file; } BOOL init_urlcache(void) DECLSPEC_HIDDEN; void free_urlcache(void) DECLSPEC_HIDDEN; void free_cookie(void) DECLSPEC_HIDDEN; #define MAX_REPLY_LEN 0x5B4 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */ typedef struct { DWORD val; const char* name; } wininet_flag_info; /* Undocumented security flags */ #define _SECURITY_FLAG_CERT_REV_FAILED 0x00800000 #define _SECURITY_FLAG_CERT_INVALID_CA 0x01000000 #define _SECURITY_FLAG_CERT_INVALID_CN 0x02000000 #define _SECURITY_FLAG_CERT_INVALID_DATE 0x04000000 #define _SECURITY_ERROR_FLAGS_MASK \ (_SECURITY_FLAG_CERT_REV_FAILED \ |_SECURITY_FLAG_CERT_INVALID_CA \ |_SECURITY_FLAG_CERT_INVALID_CN \ |_SECURITY_FLAG_CERT_INVALID_DATE) #endif /* _WINE_INTERNET_H_ */
28.15261
124
0.731883
45f9d89cffaeb56fc90a7bc8655b7d7a282d367c
1,658
c
C
Blik2D/addon/openssl-1.1.0c_for_blik/crypto/asn1/a_dup.c
BonexGu/Blik2D
8e0592787e5c8e8a28682d0e1826b8223eae5983
[ "MIT" ]
13
2017-02-22T02:20:06.000Z
2018-06-06T04:18:03.000Z
Blik2D/addon/openssl-1.1.0c_for_blik/crypto/asn1/a_dup.c
BonexGu/Blik2D
8e0592787e5c8e8a28682d0e1826b8223eae5983
[ "MIT" ]
null
null
null
Blik2D/addon/openssl-1.1.0c_for_blik/crypto/asn1/a_dup.c
BonexGu/Blik2D
8e0592787e5c8e8a28682d0e1826b8223eae5983
[ "MIT" ]
null
null
null
/* * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include <stdio.h> #include BLIK_OPENSSL_U_internal__cryptlib_h //original-code:"internal/cryptlib.h" #include BLIK_OPENSSL_V_openssl__asn1_h //original-code:<openssl/asn1.h> #ifndef NO_OLD_ASN1 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x) { unsigned char *b, *p; const unsigned char *p2; int i; char *ret; if (x == NULL) return (NULL); i = i2d(x, NULL); b = OPENSSL_malloc(i + 10); if (b == NULL) { ASN1err(ASN1_F_ASN1_DUP, ERR_R_MALLOC_FAILURE); return (NULL); } p = b; i = i2d(x, &p); p2 = b; ret = d2i(NULL, &p2, i); OPENSSL_free(b); return (ret); } #endif /* * ASN1_ITEM version of dup: this follows the model above except we don't * need to allocate the buffer. At some point this could be rewritten to * directly dup the underlying structure instead of doing and encode and * decode. */ void *ASN1_item_dup(const ASN1_ITEM *it, void *x) { unsigned char *b = NULL; const unsigned char *p; long i; void *ret; if (x == NULL) return (NULL); i = ASN1_item_i2d(x, &b, it); if (b == NULL) { ASN1err(ASN1_F_ASN1_ITEM_DUP, ERR_R_MALLOC_FAILURE); return (NULL); } p = b; ret = ASN1_item_d2i(NULL, &p, i, it); OPENSSL_free(b); return (ret); }
24.028986
82
0.639324
c8bd1fc0ec136f98394f1e04def419bc5b606899
2,092
h
C
example-basic-move/src/ofApp.h
kylemcdonald/ofxRobotArm
250b21bd22031a1cecb5aed0b87d282f8bc4ac80
[ "Info-ZIP" ]
5
2017-01-25T00:19:50.000Z
2018-04-04T03:28:55.000Z
example-basic-move/src/ofApp.h
kylemcdonald/ofxRobotArm
250b21bd22031a1cecb5aed0b87d282f8bc4ac80
[ "Info-ZIP" ]
null
null
null
example-basic-move/src/ofApp.h
kylemcdonald/ofxRobotArm
250b21bd22031a1cecb5aed0b87d282f8bc4ac80
[ "Info-ZIP" ]
2
2017-12-10T22:42:41.000Z
2019-03-12T02:16:27.000Z
#pragma once //-------------------------------------------------------------- // // // Basic Move Example // // //-------------------------------------------------------------- #include "ofMain.h" #include "ofxGui.h" #include "ofxGizmo.h" #include "RobotController.h" #include "RobotParameters.h" #include "URIKFast.h" #include "RobotArmSafety.h" #define N_CAMERAS 2 class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(int x, int y); void mouseExited(int x, int y); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); URIKFast kinematics; ofxRobotArm::RobotArmSafety safety; ofxRobotArm::RobotController robot; ofxRobotArm::RobotParameters parameters; ofxGizmo gizmo; ofNode tcpNode; ofParameterGroup appParams; ofParameter<bool> codeGesture; bool lastCodeGesture; Joint previousTCP; void setupViewports(); void setupGUI(); void positionGUI(); void drawGUI(); ofxPanel panel; ofxPanel panelJoints; ofxPanel panelTargetJoints; ofxPanel panelJointsIK; ofxPanel panelJointsSpeed; void moveTCP(); // 3D Navigation void updateActiveCamera(); vector<ofEasyCam*> cams; ofRectangle viewportReal; ofRectangle viewportSim; vector<ofMatrix4x4> savedCamMats; vector<string> viewportLabels; int activeCam; /** Use hotkeys to cyle through preset viewports. @param key '1' = Top View <br/> '2' = Left View <br/> '3' = Front View <br/> '4' = Perspective <br/> */ void handleViewportPresets(int key); /// Highlights the active viewport. void hightlightViewports(); };
22.494624
64
0.600382
4e554ed55ea6c0bc419c0276fc47827d86546d79
817
c
C
EXAMS/2019-02-18/q3.c
samueleallegranza/polimi-info
66947c3c5b4a8d14def53194ee7d6b0f6088ffb6
[ "MIT" ]
null
null
null
EXAMS/2019-02-18/q3.c
samueleallegranza/polimi-info
66947c3c5b4a8d14def53194ee7d6b0f6088ffb6
[ "MIT" ]
null
null
null
EXAMS/2019-02-18/q3.c
samueleallegranza/polimi-info
66947c3c5b4a8d14def53194ee7d6b0f6088ffb6
[ "MIT" ]
null
null
null
#include <stdio.h> #define NCOL 10 #define NROW 3 void find_mat_sum(int [][NCOL], int, int, int, int *, int *); int main(int argc, char * argv[]) { int mat[NROW][NCOL] = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, }; int r, c; find_mat_sum(mat, 29, NROW, NCOL, &r, &c); printf("%d - %d\n", r, c); return 0; } void find_mat_sum(int mat[][NCOL], int val, int r, int c, int *res_c, int *res_r){ int i, j, sum; sum = 0; for(i=0; i<r && (sum<=val); i++) for(j=0; j<c && (sum<=val); j++) sum += mat[i][j]; if(sum <= val) { i = -1; j = -1; } else { i--; j--; } *res_r = i; *res_c = j; }
20.425
83
0.396573
ec6fe9c9b150d62e5bec4adda7b1866450f5ecc2
752
h
C
Libraries/VvWidgets/vvDescriptorStyleDelegate.h
PinkDiamond1/vivia
70f7fbed4b33b14d34de35c69b2b14df3514d720
[ "BSD-3-Clause" ]
14
2016-09-16T12:33:05.000Z
2021-02-14T02:16:33.000Z
Libraries/VvWidgets/vvDescriptorStyleDelegate.h
PinkDiamond1/vivia
70f7fbed4b33b14d34de35c69b2b14df3514d720
[ "BSD-3-Clause" ]
44
2016-10-06T22:12:57.000Z
2021-01-07T19:39:07.000Z
Libraries/VvWidgets/vvDescriptorStyleDelegate.h
PinkDiamond1/vivia
70f7fbed4b33b14d34de35c69b2b14df3514d720
[ "BSD-3-Clause" ]
17
2015-06-30T13:41:47.000Z
2021-11-22T17:38:48.000Z
// This file is part of ViViA, and is distributed under the // OSI-approved BSD 3-Clause License. See top-level LICENSE file or // https://github.com/Kitware/vivia/blob/master/LICENSE for details. #ifndef __vvDescriptorStyleDelegate_h #define __vvDescriptorStyleDelegate_h #include <qtFlagListDelegate.h> #include <vgExport.h> #include "vvDescriptorStyle.h" VV_WIDGETS_EXPORT_TEMPLATE template class VV_WIDGETS_EXPORT qtFlagListDelegate <vvDescriptorStyle::StyleFlag, vvDescriptorStyle::Styles>; class VV_WIDGETS_EXPORT vvDescriptorStyleDelegate : public qtFlagListDelegate <vvDescriptorStyle::StyleFlag, vvDescriptorStyle::Styles> { Q_OBJECT public: vvDescriptorStyleDelegate(QObject* parent = 0); }; #endif
26.857143
77
0.781915
26405760553e180023a306c85791544f390b4720
385
c
C
c/wrapper.c
bheckel/code
98309e8aa145901e49460546643c911eaaff54e6
[ "Apache-2.0" ]
1
2019-08-11T00:39:34.000Z
2019-08-11T00:39:34.000Z
c/wrapper.c
bheckel/code
98309e8aa145901e49460546643c911eaaff54e6
[ "Apache-2.0" ]
null
null
null
c/wrapper.c
bheckel/code
98309e8aa145901e49460546643c911eaaff54e6
[ "Apache-2.0" ]
1
2020-07-28T05:58:47.000Z
2020-07-28T05:58:47.000Z
// Allow a Perl program to run under a different uid (setuid). // Assumes /webshop/bin/cadfile_copy.pl exists and uses Perl's $ARGV[0] and // $ARGV[1]. #include <stdio.h> int main(int argc, char *argv[]) { int rc = execl("/webshop/bin/cadfile_copy.pl", "cadfile_copy.pl", argv[1], argv[2], NULL); if ( rc == 0 ) { return 0; } else { return 1; } }
22.647059
75
0.592208
ebe52ff34d541a6e850ec4f0709ea5d250641e44
4,656
h
C
src/geohash.h
zh1029/redis
f3dd33489834de01392dfed8e0ad5e2e8de0894d
[ "BSD-3-Clause" ]
4,587
2019-02-26T06:59:21.000Z
2021-03-02T20:54:42.000Z
src/geohash.h
zh1029/redis
f3dd33489834de01392dfed8e0ad5e2e8de0894d
[ "BSD-3-Clause" ]
269
2019-02-27T19:20:05.000Z
2021-03-02T06:06:40.000Z
src/geohash.h
zh1029/redis
f3dd33489834de01392dfed8e0ad5e2e8de0894d
[ "BSD-3-Clause" ]
297
2019-02-26T22:37:53.000Z
2021-02-24T03:06:13.000Z
/* * Copyright (c) 2013-2014, yinqiwen <yinqiwen@gmail.com> * Copyright (c) 2014, Matt Stancliff <matt@genges.com>. * Copyright (c) 2015, Salvatore Sanfilippo <antirez@gmail.com>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Redis nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef GEOHASH_H_ #define GEOHASH_H_ #include <stddef.h> #include <stdint.h> #include <stdint.h> #if defined(__cplusplus) extern "C" { #endif #define HASHISZERO(r) (!(r).bits && !(r).step) #define RANGEISZERO(r) (!(r).max && !(r).min) #define RANGEPISZERO(r) (r == NULL || RANGEISZERO(*r)) #define GEO_STEP_MAX 26 /* 26*2 = 52 bits. */ /* Limits from EPSG:900913 / EPSG:3785 / OSGEO:41001 */ #define GEO_LAT_MIN -85.05112878 #define GEO_LAT_MAX 85.05112878 #define GEO_LONG_MIN -180 #define GEO_LONG_MAX 180 typedef enum { GEOHASH_NORTH = 0, GEOHASH_EAST, GEOHASH_WEST, GEOHASH_SOUTH, GEOHASH_SOUTH_WEST, GEOHASH_SOUTH_EAST, GEOHASH_NORT_WEST, GEOHASH_NORT_EAST } GeoDirection; typedef struct { uint64_t bits; uint8_t step; } GeoHashBits; typedef struct { double min; double max; } GeoHashRange; typedef struct { GeoHashBits hash; GeoHashRange longitude; GeoHashRange latitude; } GeoHashArea; typedef struct { GeoHashBits north; GeoHashBits east; GeoHashBits west; GeoHashBits south; GeoHashBits north_east; GeoHashBits south_east; GeoHashBits north_west; GeoHashBits south_west; } GeoHashNeighbors; #define CIRCULAR_TYPE 1 #define RECTANGLE_TYPE 2 typedef struct { int type; /* search type */ double xy[2]; /* search center point, xy[0]: lon, xy[1]: lat */ double conversion; /* km: 1000 */ double bounds[4]; /* bounds[0]: min_lon, bounds[1]: min_lat * bounds[2]: max_lon, bounds[3]: max_lat */ union { /* CIRCULAR_TYPE */ double radius; /* RECTANGLE_TYPE */ struct { double height; double width; } r; } t; } GeoShape; /* * 0:success * -1:failed */ void geohashGetCoordRange(GeoHashRange *long_range, GeoHashRange *lat_range); int geohashEncode(const GeoHashRange *long_range, const GeoHashRange *lat_range, double longitude, double latitude, uint8_t step, GeoHashBits *hash); int geohashEncodeType(double longitude, double latitude, uint8_t step, GeoHashBits *hash); int geohashEncodeWGS84(double longitude, double latitude, uint8_t step, GeoHashBits *hash); int geohashDecode(const GeoHashRange long_range, const GeoHashRange lat_range, const GeoHashBits hash, GeoHashArea *area); int geohashDecodeType(const GeoHashBits hash, GeoHashArea *area); int geohashDecodeWGS84(const GeoHashBits hash, GeoHashArea *area); int geohashDecodeAreaToLongLat(const GeoHashArea *area, double *xy); int geohashDecodeToLongLatType(const GeoHashBits hash, double *xy); int geohashDecodeToLongLatWGS84(const GeoHashBits hash, double *xy); int geohashDecodeToLongLatMercator(const GeoHashBits hash, double *xy); void geohashNeighbors(const GeoHashBits *hash, GeoHashNeighbors *neighbors); #if defined(__cplusplus) } #endif #endif /* GEOHASH_H_ */
33.73913
80
0.717354
23d01079b5694433e9d6781cd635956050dd01ce
441
h
C
core/src/Graphics/LLGIWindow.h
argoNism/Altseed2
7e23b041f74b56941c78f15d6758eca491c4949c
[ "MIT" ]
null
null
null
core/src/Graphics/LLGIWindow.h
argoNism/Altseed2
7e23b041f74b56941c78f15d6758eca491c4949c
[ "MIT" ]
null
null
null
core/src/Graphics/LLGIWindow.h
argoNism/Altseed2
7e23b041f74b56941c78f15d6758eca491c4949c
[ "MIT" ]
null
null
null
#pragma once #include "../Common/PlatformIncludes.h" #include "LLGI.Base.h" namespace altseed { class LLGIWindow : public LLGI::Window { private: GLFWwindow* glfwWindow; public: LLGIWindow(GLFWwindow* glfwWindow_); void* GetNativePtr(int32_t index) override; LLGI::Vec2I GetWindowSize() const override; bool OnNewFrame() override { return glfwWindowShouldClose(glfwWindow) == GL_FALSE; } }; } // namespace altseed
22.05
88
0.727891
d84a8afecc7ab401e0dc29eab4ac4133dcaa7bc8
3,516
h
C
aws-cpp-sdk-support/include/aws/support/model/DescribeTrustedAdvisorCheckRefreshStatusesResult.h
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
2
2019-03-11T15:50:55.000Z
2020-02-27T11:40:27.000Z
aws-cpp-sdk-support/include/aws/support/model/DescribeTrustedAdvisorCheckRefreshStatusesResult.h
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
18
2018-05-15T16:41:07.000Z
2018-05-21T00:46:30.000Z
aws-cpp-sdk-support/include/aws/support/model/DescribeTrustedAdvisorCheckRefreshStatusesResult.h
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
1
2019-01-18T13:03:55.000Z
2019-01-18T13:03:55.000Z
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/support/Support_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/support/model/TrustedAdvisorCheckRefreshStatus.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace Support { namespace Model { /** * <p>The statuses of the Trusted Advisor checks returned by the * <a>DescribeTrustedAdvisorCheckRefreshStatuses</a> operation.</p><p><h3>See * Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/support-2013-04-15/DescribeTrustedAdvisorCheckRefreshStatusesResponse">AWS * API Reference</a></p> */ class AWS_SUPPORT_API DescribeTrustedAdvisorCheckRefreshStatusesResult { public: DescribeTrustedAdvisorCheckRefreshStatusesResult(); DescribeTrustedAdvisorCheckRefreshStatusesResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); DescribeTrustedAdvisorCheckRefreshStatusesResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline const Aws::Vector<TrustedAdvisorCheckRefreshStatus>& GetStatuses() const{ return m_statuses; } /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline void SetStatuses(const Aws::Vector<TrustedAdvisorCheckRefreshStatus>& value) { m_statuses = value; } /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline void SetStatuses(Aws::Vector<TrustedAdvisorCheckRefreshStatus>&& value) { m_statuses = std::move(value); } /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline DescribeTrustedAdvisorCheckRefreshStatusesResult& WithStatuses(const Aws::Vector<TrustedAdvisorCheckRefreshStatus>& value) { SetStatuses(value); return *this;} /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline DescribeTrustedAdvisorCheckRefreshStatusesResult& WithStatuses(Aws::Vector<TrustedAdvisorCheckRefreshStatus>&& value) { SetStatuses(std::move(value)); return *this;} /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline DescribeTrustedAdvisorCheckRefreshStatusesResult& AddStatuses(const TrustedAdvisorCheckRefreshStatus& value) { m_statuses.push_back(value); return *this; } /** * <p>The refresh status of the specified Trusted Advisor checks.</p> */ inline DescribeTrustedAdvisorCheckRefreshStatusesResult& AddStatuses(TrustedAdvisorCheckRefreshStatus&& value) { m_statuses.push_back(std::move(value)); return *this; } private: Aws::Vector<TrustedAdvisorCheckRefreshStatus> m_statuses; }; } // namespace Model } // namespace Support } // namespace Aws
36.625
176
0.74289
8c610c2c9cb67b6bf86ff2cd71db68272e1b23d2
1,479
h
C
ecs/include/huaweicloud/ecs/v2/model/ShowServerGroupResponse.h
yangzhaofeng/huaweicloud-sdk-cpp-v3
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
[ "Apache-2.0" ]
5
2021-03-03T08:23:43.000Z
2022-02-16T02:16:39.000Z
ecs/include/huaweicloud/ecs/v2/model/ShowServerGroupResponse.h
yangzhaofeng/huaweicloud-sdk-cpp-v3
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
[ "Apache-2.0" ]
null
null
null
ecs/include/huaweicloud/ecs/v2/model/ShowServerGroupResponse.h
yangzhaofeng/huaweicloud-sdk-cpp-v3
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
[ "Apache-2.0" ]
7
2021-02-26T13:53:35.000Z
2022-03-18T02:36:43.000Z
#ifndef HUAWEICLOUD_SDK_ECS_V2_MODEL_ShowServerGroupResponse_H_ #define HUAWEICLOUD_SDK_ECS_V2_MODEL_ShowServerGroupResponse_H_ #include <huaweicloud/ecs/v2/EcsExport.h> #include <huaweicloud/core/utils/ModelBase.h> #include <huaweicloud/core/http/HttpResponse.h> #include <huaweicloud/ecs/v2/model/ShowServerGroupResult.h> namespace HuaweiCloud { namespace Sdk { namespace Ecs { namespace V2 { namespace Model { using namespace HuaweiCloud::Sdk::Core::Utils; using namespace HuaweiCloud::Sdk::Core::Http; /// <summary> /// Response Object /// </summary> class HUAWEICLOUD_ECS_V2_EXPORT ShowServerGroupResponse : public ModelBase, public HttpResponse { public: ShowServerGroupResponse(); virtual ~ShowServerGroupResponse(); ///////////////////////////////////////////// /// ModelBase overrides void validate() override; web::json::value toJson() const override; bool fromJson(const web::json::value& json) override; ///////////////////////////////////////////// /// ShowServerGroupResponse members /// <summary> /// /// </summary> ShowServerGroupResult getServerGroup() const; bool serverGroupIsSet() const; void unsetserverGroup(); void setServerGroup(const ShowServerGroupResult& value); protected: ShowServerGroupResult serverGroup_; bool serverGroupIsSet_; #ifdef RTTR_FLAG RTTR_ENABLE() #endif }; } } } } } #endif // HUAWEICLOUD_SDK_ECS_V2_MODEL_ShowServerGroupResponse_H_
21.434783
65
0.701149
1b137c38d1e4819676bc35da8d0990742bf7f245
720
c
C
Uebungen/AddressVerwaltung_SortEngine.c
iwanbolzern/microcontroller-c
1b408b1269987479d24e98e9f193e58d9bc3dcfe
[ "MIT" ]
null
null
null
Uebungen/AddressVerwaltung_SortEngine.c
iwanbolzern/microcontroller-c
1b408b1269987479d24e98e9f193e58d9bc3dcfe
[ "MIT" ]
null
null
null
Uebungen/AddressVerwaltung_SortEngine.c
iwanbolzern/microcontroller-c
1b408b1269987479d24e98e9f193e58d9bc3dcfe
[ "MIT" ]
null
null
null
#include "AddressVerwaltung_Address.h" #include "AddressVerwaltung_DataHolder.h" #include <stdlib.h> int sort(AddressPtr_t** sortedAddresses, int(*sortFuntion)(const void* elem1, const void* elem2)) { int size = getAddresses(sortedAddresses); qsort(*sortedAddresses, size, sizeof(AddressPtr_t), sortFuntion); return size; } int byName(const AddressPtr_t* elem1, const AddressPtr_t* elem2) { return strcmp((*elem1)->name, (*elem2)->name); } int byStreet(const AddressPtr_t* elem1, const AddressPtr_t* elem2) { return strcmp((*elem1)->street, (*elem2)->street); } int byCity(const AddressPtr_t* elem1, const AddressPtr_t* elem2) { return strcmp((*elem1)->city, (*elem2)->city); }
25.714286
99
0.709722
e7c07b4d7846744981e644c08ee3dd5066fc5be3
3,528
h
C
Source/xsite_ue/include/vrpn_Sound_A3D.h
bnlrnz/xsite_ue
574e9336a3bdc031543d74d3b74c4b5ac37f4300
[ "MIT" ]
1
2021-10-20T22:55:12.000Z
2021-10-20T22:55:12.000Z
vrpn/server_src/aureal_sound_server/vrpn_Sound_A3D.h
deakinshaun/UniCAVE-Deakin
8dc184d7dd598d4554627b8564cae99975ef3dc2
[ "MIT" ]
null
null
null
vrpn/server_src/aureal_sound_server/vrpn_Sound_A3D.h
deakinshaun/UniCAVE-Deakin
8dc184d7dd598d4554627b8564cae99975ef3dc2
[ "MIT" ]
null
null
null
#ifndef VRPN_SOUND_A3D_H #define VRPN_SOUND_A3D_H #ifdef _WIN32 #include "vrpn_Shared.h" #include <objbase.h> #include <stdlib.h> #include <cguid.h> #include <initguid.h> #include "ia3dutil.h" #include "ia3dapi.h" #include "vrpn_Sound.h" #include "quat.h" #include "string.h" #include <conio.h> class vrpn_Sound_Server_A3D : public vrpn_Sound_Server { public: vrpn_Sound_Server_A3D(const char * name, vrpn_Connection * c, HWND hWin); ~vrpn_Sound_Server_A3D(); void playSound(vrpn_SoundID id, vrpn_int32 repeat, vrpn_SoundDef soundDef); void stopSound(vrpn_SoundID id); void loadSoundLocal(char* filename, vrpn_SoundID id, vrpn_SoundDef soundDef); void loadSoundRemote(char* file, vrpn_SoundID id, vrpn_SoundDef soundDef); // not supported void unloadSound(vrpn_SoundID id); void changeSoundStatus(vrpn_SoundID id, vrpn_SoundDef soundDef); void setListenerPose(vrpn_PoseDef pose); void setListenerVelocity(vrpn_float64 *velocity); void setSoundPose(vrpn_SoundID id, vrpn_PoseDef pose); void setSoundVelocity(vrpn_SoundID id, vrpn_float64 *velocity); void setSoundDistInfo(vrpn_SoundID id, vrpn_float64 *distinfo); void setSoundConeInfo(vrpn_SoundID id, vrpn_float64 *coneinfo); void setSoundDoplerFactor(vrpn_SoundID id, vrpn_float64 doplerfactor); void setSoundEqValue(vrpn_SoundID id, vrpn_float64 eqvalue); void setSoundPitch(vrpn_SoundID id, vrpn_float64 pitch); void setSoundVolume(vrpn_SoundID id, vrpn_float64 volume); void loadModelLocal(const char * filename); void loadModelRemote(); // not supported void loadPolyQuad(vrpn_QuadDef * quad); void loadPolyTri(vrpn_TriDef * tri); void loadMaterial(vrpn_MaterialDef * material, vrpn_int32 id); void setPolyQuadVertices(vrpn_float64 vertices[4][3], const vrpn_int32 id); void setPolyTriVertices(vrpn_float64 vertices[3][3], const vrpn_int32 id); void setPolyOF(vrpn_float64 OF, vrpn_int32 tag); void setPolyMaterial(const char * material, vrpn_int32 tag); void mainloop(); bool noSounds(void); void stopAllSounds(); void shutDown(); vrpn_float64 GetCurrentVolume(const vrpn_int32 CurrentSoundId); void GetLastError(char * buf); vrpn_int32 GetCurrentPlaybackRate(const vrpn_int32 CurrentSoundId); void GetCurrentPosition(const vrpn_int32 CurrentSoundId, float* X_val, float* Y_val, float* Z_val); void GetListenerPosition(float* X_val, float* Y_val, float* Z_val); void GetCurrentDistances(const vrpn_int32 CurrentSoundId, float* FMin, float* FMax); void GetListenerOrientation(float* X_val, float *Y_val, float *Z_val); void GetCurrentOrientation(const vrpn_int32 CurrentSoundId,float *X_val, float *Y_val, float *Z_val); vrpn_int32 LastSoundId; //ID of last played sound private: // these are specific to A3D 3.0 IA3d5 * a3droot; IA3dListener * a3dlis; IA3dSource2 ** a3dsamples; IA3dGeom2 * a3dgeom; HRESULT lasterror; // the idea of a map is to have a way to go from the unique id being passed in // by the user to an internal identifier... vrpn_int32 maxSounds; vrpn_int32 numSounds; vrpn_int32 soundMap[MAX_NUMBER_SOUNDS]; vrpn_int32 maxMaterials; vrpn_int32 numMaterials; vrpn_int32 materialMap[MAX_NUMBER_MATERIALS]; IA3dMaterial * materials[MAX_NUMBER_MATERIALS]; char mat_names[MAX_NUMBER_MATERIALS][MAX_MATERIAL_NAME_LENGTH]; vrpn_int32 numconnections; // number of times server has been connected to.. }; #endif //_WIN32 #endif
36.371134
110
0.757937
1b6ba21492a62b779c49406881a12f30871afb56
8,496
c
C
src/signature.c
saurik/libgit2
b60deb0235404367af61e3d3638dfe88c13b0e7c
[ "Apache-2.0" ]
5
2018-01-21T12:15:21.000Z
2021-09-17T05:44:28.000Z
src/signature.c
saurik/libgit2
b60deb0235404367af61e3d3638dfe88c13b0e7c
[ "Apache-2.0" ]
null
null
null
src/signature.c
saurik/libgit2
b60deb0235404367af61e3d3638dfe88c13b0e7c
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2009-2012 the libgit2 contributors * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "signature.h" #include "repository.h" #include "git2/common.h" void git_signature_free(git_signature *sig) { if (sig == NULL) return; git__free(sig->name); sig->name = NULL; git__free(sig->email); sig->email = NULL; git__free(sig); } static const char *skip_leading_spaces(const char *buffer, const char *buffer_end) { while (*buffer == ' ' && buffer < buffer_end) buffer++; return buffer; } static const char *skip_trailing_spaces(const char *buffer_start, const char *buffer_end) { while (*buffer_end == ' ' && buffer_end > buffer_start) buffer_end--; return buffer_end; } static int process_trimming(const char *input, char **storage, const char *input_end, int fail_when_empty) { const char *left, *right; int trimmed_input_length; left = skip_leading_spaces(input, input_end); right = skip_trailing_spaces(input, input_end - 1); if (right < left) { if (fail_when_empty) return git__throw(GIT_EINVALIDARGS, "Failed to trim. Input is either empty or only contains spaces"); else right = left - 1; } trimmed_input_length = right - left + 1; *storage = git__malloc(trimmed_input_length + 1); if (*storage == NULL) return GIT_ENOMEM; memcpy(*storage, left, trimmed_input_length); (*storage)[trimmed_input_length] = 0; return GIT_SUCCESS; } int git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset) { int error; git_signature *p = NULL; assert(name && email); *sig_out = NULL; if ((p = git__malloc(sizeof(git_signature))) == NULL) { error = GIT_ENOMEM; goto cleanup; } memset(p, 0x0, sizeof(git_signature)); error = process_trimming(name, &p->name, name + strlen(name), 1); if (error < GIT_SUCCESS) { git__rethrow(GIT_EINVALIDARGS, "Failed to create signature. 'name' argument is invalid"); goto cleanup; } error = process_trimming(email, &p->email, email + strlen(email), 1); if (error < GIT_SUCCESS) { git__rethrow(GIT_EINVALIDARGS, "Failed to create signature. 'email' argument is invalid"); goto cleanup; } p->when.time = time; p->when.offset = offset; *sig_out = p; return error; cleanup: git_signature_free(p); return error; } git_signature *git_signature_dup(const git_signature *sig) { git_signature *new; if (git_signature_new(&new, sig->name, sig->email, sig->when.time, sig->when.offset) < GIT_SUCCESS) return NULL; return new; } int git_signature_now(git_signature **sig_out, const char *name, const char *email) { int error; time_t now; time_t offset; struct tm *utc_tm, *local_tm; git_signature *sig; #ifndef GIT_WIN32 struct tm _utc, _local; #endif *sig_out = NULL; time(&now); /** * On Win32, `gmtime_r` doesn't exist but * `gmtime` is threadsafe, so we can use that */ #ifdef GIT_WIN32 utc_tm = gmtime(&now); local_tm = localtime(&now); #else utc_tm = gmtime_r(&now, &_utc); local_tm = localtime_r(&now, &_local); #endif offset = mktime(local_tm) - mktime(utc_tm); offset /= 60; /* mktime takes care of setting tm_isdst correctly */ if (local_tm->tm_isdst) offset += 60; if ((error = git_signature_new(&sig, name, email, now, (int)offset)) < GIT_SUCCESS) return error; *sig_out = sig; return error; } static int parse_timezone_offset(const char *buffer, int *offset_out) { int dec_offset; int mins, hours, offset; const char *offset_start; const char *offset_end; offset_start = buffer; if (*offset_start == '\n') { *offset_out = 0; return GIT_SUCCESS; } if (offset_start[0] != '-' && offset_start[0] != '+') return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. It doesn't start with '+' or '-'"); if (offset_start[1] < '0' || offset_start[1] > '9') return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset."); if (git__strtol32(&dec_offset, offset_start + 1, &offset_end, 10) < GIT_SUCCESS) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. It isn't a number"); if (offset_end - offset_start != 5) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Invalid length"); if (dec_offset > 1400) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Value too large"); hours = dec_offset / 100; mins = dec_offset % 100; if (hours > 14) // see http://www.worldtimezone.com/faq.html return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Hour value too large"); if (mins > 59) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse TZ offset. Minute value too large"); offset = (hours * 60) + mins; if (offset_start[0] == '-') offset *= -1; *offset_out = offset; return GIT_SUCCESS; } static int process_next_token(const char **buffer_out, char **storage, const char *token_end, const char *right_boundary) { int error = process_trimming(*buffer_out, storage, token_end, 0); if (error < GIT_SUCCESS) return error; *buffer_out = token_end + 1; if (*buffer_out > right_boundary) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Signature too short"); return GIT_SUCCESS; } static const char *scan_for_previous_token(const char *buffer, const char *left_boundary) { const char *start; if (buffer <= left_boundary) return NULL; start = skip_trailing_spaces(left_boundary, buffer); /* Search for previous occurence of space */ while (start[-1] != ' ' && start > left_boundary) start--; return start; } static int parse_time(git_time_t *time_out, const char *buffer) { int time; int error; if (*buffer == '+' || *buffer == '-') return git__throw(GIT_ERROR, "Failed while parsing time. '%s' rather look like a timezone offset.", buffer); error = git__strtol32(&time, buffer, &buffer, 10); if (error < GIT_SUCCESS) return error; *time_out = (git_time_t)time; return GIT_SUCCESS; } int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender) { const char *buffer = *buffer_out; const char *line_end, *name_end, *email_end, *tz_start, *time_start; int error = GIT_SUCCESS; memset(sig, 0x0, sizeof(git_signature)); if ((line_end = memchr(buffer, ender, buffer_end - buffer)) == NULL) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. No newline given"); if (header) { const size_t header_len = strlen(header); if (memcmp(buffer, header, header_len) != 0) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Expected prefix '%s' doesn't match actual", header); buffer += header_len; } if (buffer > line_end) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Signature too short"); if ((name_end = strchr(buffer, '<')) == NULL) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Cannot find '<' in signature"); if ((email_end = strchr(name_end, '>')) == NULL) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Cannot find '>' in signature"); if (email_end < name_end) return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Malformed e-mail"); error = process_next_token(&buffer, &sig->name, name_end, line_end); if (error < GIT_SUCCESS) return error; error = process_next_token(&buffer, &sig->email, email_end, line_end); if (error < GIT_SUCCESS) return error; tz_start = scan_for_previous_token(line_end - 1, buffer); if (tz_start == NULL) goto clean_exit; /* No timezone nor date */ time_start = scan_for_previous_token(tz_start - 1, buffer); if (time_start == NULL || parse_time(&sig->when.time, time_start) < GIT_SUCCESS) { /* The tz_start might point at the time */ parse_time(&sig->when.time, tz_start); goto clean_exit; } if (parse_timezone_offset(tz_start, &sig->when.offset) < GIT_SUCCESS) { sig->when.time = 0; /* Bogus timezone, we reset the time */ } clean_exit: *buffer_out = line_end + 1; return GIT_SUCCESS; } void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig) { int offset, hours, mins; char sign; offset = sig->when.offset; sign = (sig->when.offset < 0) ? '-' : '+'; if (offset < 0) offset = -offset; hours = offset / 60; mins = offset % 60; git_buf_printf(buf, "%s%s <%s> %u %c%02d%02d\n", header ? header : "", sig->name, sig->email, (unsigned)sig->when.time, sign, hours, mins); }
25.136095
120
0.703861
f06ebf90171737189f7c2fb7e5ee5ba88f766515
1,779
h
C
include/org/mockito/internal/configuration/SpyAnnotationEngine.h
iFindTA/PBJ2Objc
014bd0f99b129cb094ee35e472802fd38c5c0f87
[ "MIT" ]
null
null
null
include/org/mockito/internal/configuration/SpyAnnotationEngine.h
iFindTA/PBJ2Objc
014bd0f99b129cb094ee35e472802fd38c5c0f87
[ "MIT" ]
null
null
null
include/org/mockito/internal/configuration/SpyAnnotationEngine.h
iFindTA/PBJ2Objc
014bd0f99b129cb094ee35e472802fd38c5c0f87
[ "MIT" ]
null
null
null
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: /Users/free6om/Documents/open-source/j2objc/j2objc/testing/mockito/build_result/java/org/mockito/internal/configuration/SpyAnnotationEngine.java // #ifndef _OrgMockitoInternalConfigurationSpyAnnotationEngine_H_ #define _OrgMockitoInternalConfigurationSpyAnnotationEngine_H_ #include "J2ObjC_header.h" #include "org/mockito/configuration/AnnotationEngine.h" @class IOSClass; @class IOSObjectArray; @class JavaLangReflectField; @protocol JavaLangAnnotationAnnotation; @interface OrgMockitoInternalConfigurationSpyAnnotationEngine : NSObject < OrgMockitoConfigurationAnnotationEngine > #pragma mark Public - (instancetype)init; - (id)createMockForWithJavaLangAnnotationAnnotation:(id<JavaLangAnnotationAnnotation>)annotation withJavaLangReflectField:(JavaLangReflectField *)field; - (void)processWithIOSClass:(IOSClass *)context withId:(id)testInstance; #pragma mark Package-Private - (void)assertNoIncompatibleAnnotationsWithIOSClass:(IOSClass *)annotation withJavaLangReflectField:(JavaLangReflectField *)field withIOSClassArray:(IOSObjectArray *)undesiredAnnotations; @end J2OBJC_EMPTY_STATIC_INIT(OrgMockitoInternalConfigurationSpyAnnotationEngine) FOUNDATION_EXPORT void OrgMockitoInternalConfigurationSpyAnnotationEngine_init(OrgMockitoInternalConfigurationSpyAnnotationEngine *self); FOUNDATION_EXPORT OrgMockitoInternalConfigurationSpyAnnotationEngine *new_OrgMockitoInternalConfigurationSpyAnnotationEngine_init() NS_RETURNS_RETAINED; J2OBJC_TYPE_LITERAL_HEADER(OrgMockitoInternalConfigurationSpyAnnotationEngine) #endif // _OrgMockitoInternalConfigurationSpyAnnotationEngine_H_
38.673913
156
0.821248
00004e3694668535dc8e8d861e790d2feaf89e59
1,981
h
C
BlackVision/Tools/LibProjectManager/Source/LoadSceneResult.h
black-vision-engine/bv-engine
85089d41bb22afeaa9de070646e12aa1777ecedf
[ "MIT" ]
1
2022-01-28T11:43:47.000Z
2022-01-28T11:43:47.000Z
BlackVision/Tools/LibProjectManager/Source/LoadSceneResult.h
black-vision-engine/bv-engine
85089d41bb22afeaa9de070646e12aa1777ecedf
[ "MIT" ]
null
null
null
BlackVision/Tools/LibProjectManager/Source/LoadSceneResult.h
black-vision-engine/bv-engine
85089d41bb22afeaa9de070646e12aa1777ecedf
[ "MIT" ]
null
null
null
#pragma once #include "Engine/Models/SceneModel.h" #include "Exception.h" #include "Expected.h" namespace bv { class SceneWithWarnings { model::SceneModelPtr m_scene; Exceptions m_warnings; public: SceneWithWarnings( model::SceneModelPtr scene ) : m_scene( scene ) {} SceneWithWarnings( model::SceneModelPtr scene, Exceptions warnings ) : m_scene( scene ) , m_warnings( warnings ) {} model::SceneModelPtr GetScene() const { return m_scene; } Exceptions GetWarnings() const { return m_warnings; } }; class LoadSceneResult : public Expected< SceneWithWarnings > { public: LoadSceneResult( model::SceneModelPtr scene ) : Expected( scene ) {} LoadSceneResult( model::SceneModelPtr scene, Exceptions warnings ) : Expected( SceneWithWarnings( scene, warnings ) ) {} LoadSceneResult( const std::string & reason ) : Expected( reason ) {} LoadSceneResult( const Expected< SceneWithWarnings > & base ) : Expected< SceneWithWarnings >( base ) {} operator const model::SceneModelPtr () { return GetVal().GetScene(); } }; } // bv
38.096154
109
0.386169
182385f921ec12572b857421e0fd1056645df4ba
586
h
C
cgo.h
moonfruit/golua
d72f47b299db504630d1736b5bda4e0908b018fd
[ "MIT" ]
null
null
null
cgo.h
moonfruit/golua
d72f47b299db504630d1736b5bda4e0908b018fd
[ "MIT" ]
null
null
null
cgo.h
moonfruit/golua
d72f47b299db504630d1736b5bda4e0908b018fd
[ "MIT" ]
null
null
null
#ifndef _cgo_h #define _cgo_h #include <lua.h> #define META_GO_VALUE "golua.GoValue" #define META_GO_FUNCTION "golua.GoFunction" // c helper functions void luaGo_openBasicLibs(lua_State *L); void luaGo_preload(lua_State *L, const char *modname, lua_CFunction f); lua_State *luaGo_main(lua_State *L); int luaGo_call(lua_State *L, lua_CFunction f); int luaGo_load(lua_State *L, void *data, const char *chunkname, const char *mode); void luaGo_pushGoValue(lua_State *L, uintptr_t ud); int luaGo_callGoFunction(lua_State *L); int luaGo_getGoFunction(lua_State *L, int idx); #endif
23.44
82
0.776451
29f059517b28a2c86db1b2567e5358225ab8f2ae
1,257
h
C
include/Page/Udetail.h
Vivswan/CPP-98-Project
60bc67af212548406b4496ad9f0e3f9883093916
[ "MIT" ]
null
null
null
include/Page/Udetail.h
Vivswan/CPP-98-Project
60bc67af212548406b4496ad9f0e3f9883093916
[ "MIT" ]
null
null
null
include/Page/Udetail.h
Vivswan/CPP-98-Project
60bc67af212548406b4496ad9f0e3f9883093916
[ "MIT" ]
1
2019-11-22T21:29:30.000Z
2019-11-22T21:29:30.000Z
#ifndef USER_DETAIL_PAGES_H_ #define USER_DETAIL_PAGES_H_ class ChangeUsername: private EditPage { public: void start(){ this->intial(); userID uid; user.userFile.seekg(0,ios::beg); while(user.getNext(uid)){ if(strcmp(uid.username,currentUsername) == 0){ break; } } this->display("Leave the username blank for exit."); char * u = this->get("Enter New Username:"); if(u[0] == '\0'){ level = 5; return; } while(user.isUser(u)){ this->display("Username is already in use."); char * u = this->get("Please Re-Enter New Username:"); if(u[0] == '\0'){ level = 5; return; } } user.removeUser(currentUsername); user.insert(u,uid.password); strcpy(currentUsername,u); fflush(stdout); level = 5; } }; class ChangePassword: private EditPage { public: void start(){ this->intial(); userID uid; user.userFile.seekg(0,ios::beg); while(user.getNext(uid)){ if(strcmp(uid.username,currentUsername) == 0){ break; } } user.removeUser(uid.username); user.insert(uid.username,this->getDefault("Enter Password",uid.password)); if(strcmp(uid.username,"admin")==0) level = 3; else level = 5; fflush(stdout); } }; #endif
20.274194
77
0.614956
4b4dee3c70adebf56b091dc363e77f745c302d8b
9,819
h
C
src/Core/Matlab/matfile.h
benjaminlarson/SCIRunGUIPrototype
ed34ee11cda114e3761bd222a71a9f397517914d
[ "Unlicense" ]
null
null
null
src/Core/Matlab/matfile.h
benjaminlarson/SCIRunGUIPrototype
ed34ee11cda114e3761bd222a71a9f397517914d
[ "Unlicense" ]
null
null
null
src/Core/Matlab/matfile.h
benjaminlarson/SCIRunGUIPrototype
ed34ee11cda114e3761bd222a71a9f397517914d
[ "Unlicense" ]
null
null
null
/* For more information, please see: http://software.sci.utah.edu The MIT License Copyright (c) 2009 Scientific Computing and Imaging Institute, University of Utah. 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. */ // NOTE: This MatlabIO file is used in different projects as well. Please, do not // make it depend on other Scirun code. This way it is easier to maintain matlabIO // code among different projects. Thank you. /* * FILE: matfile.h * AUTH: Jeroen G Stinstra * DATE: 5 JAN 2004 */ #ifndef CORE_MATLABIO_MATFILE_H #define CORE_MATLABIO_MATFILE_H 1 /* * The matfile class is the basic interface for reading and * writing .mat files (Matlab files). This class currently * only supports the so called Matlab version 5 file format * which is used from version 5.0 to version 6.5, currently * the latest version of Matlab available. Matlab V4 files * should be converted using Matlab into the newer file format. * * This class handles the following aspects: * - opening and closing .mat files * - handling byte swapping * - reading/writing the file header * - reading/writing the tags in the .mat file * */ /* * CLASS DESCRIPTION * This class is an interface to a matfile and handles the raw file format * it deals with headers, byte swapping and reading and writing tags and the * associated data * * MEMORY MODEL * The class maintains its own copies of the data. Each vector, string and other * data unit is copied. * Large quantities of data are shipped in and out in matfiledata objects. These * objects are handles to memory blocks and maintain their own data integrity. * When copying a matfiledata object only pointers are copied, however all information * for freeing the object is stored inside and no memory losses should occur. * * ERROR HANDLING * All errors are reported as exceptions described in the matfilebase class. * Errors of external c library functions are caught and forwarded as exceptions. * * COPYING/ASSIGNMENT * Do not copy the object, this will lead to errors * * RESOURCE ALLOCATION * Files are closed by calling close() or by destroying the object * */ #include <cstdint> #include <stack> #include <Core/Matlab/matfiledata.h> #include <Core/Matlab/share.h> namespace SCIRun { namespace MatlabIO { class SCISHARE matfile : public matfilebase { private: // typedef of a struct to use for indexing where we are in // a file. struct matfileptr { int hdrptr; // location of tag header int datptr; // location of data segment int startptr; // location of the first tag header (to go one level up) int endptr; // location of the end of the data segment (end+1) int size; // length of data segment mitype type; }; // This next struct is used for buffering sections of the compressed // data chuncks in V7 of Matlab. // The basic idea is to decompress compressed pieces of the files and maintain a // list of the pieces that have been compresse // Using the offset in the file these pieces can be unique identified and cataloged struct compressbuffer { matfiledata mbuffer; // Buffer with reference counting // char *buffer; // buffer with uncompressed data int buffersize; // size of the buffer; int bufferoffset; // file offset of the buffer }; struct mxfile { int ref_; // Reference counter // The file can be read in two modes // 1) directly out of the file using the fptr_ // 2) out of a decompressed buffer // // If fcmpbuffer_ is not equal to zero the reading is // supposed to happen in the uncompressed buffer // The three remaining counters log where in the // file data has to be read // fcmpsize_ makes sure that no data is read going beyong the chunck of // unpressed data // fcmpoffset_ marks at which file offset the data went from uncompressed // raw data into a compressed data chunck, so seek can find the proper position // fcmpcount_ counts the number of bytes read for the mfread and mfwrite calls char *fcmpbuffer_; // Compression buffer matfiledata fcmpmbuffer_; // Same buffer but wrapped with my memory management system int fcmpsize_; // Size of the buffer int fcmpoffset_; // Offset of the buffer int fcmpcount_; // Counter to check where next to read data int fcmpalignoffset_; // Correction for alignment problem in filess FILE *fptr_; // File pointer std::string fname_; // Filename std::string fmode_; // File access mode: "r" or "w" int flength_; // File length char headertext_[118]; // The text in the header of the matfile int32_t subsysdata_[2]; // NEW IN VERSION 7 short version_; // Version of the matfile. short byteswap_; // =1 if bytes need to be swapped bool compressmode_; // whether we are in compressed mode std::stack<matfileptr> ptrstack_; // Stack containing information on where we are // currently reading and writing, the stack contains // all te pointers to locations in the file, for // the parent levels of the current one // A matfile is like a directory (tree structure) matfileptr curptr_; // current pointer // The next list contains the compressed buffers that were allocated // Hence compressed variables have to be decompressed only once, which // should boost the performance, but will cost memory std::deque<compressbuffer> cmplist_; // maintain a list of segments that have already been decompressed }; mxfile *m_; // private functions; // When reading data this function swaps the bytes // To further optimize the performance, loops should be // unrolled in this function. // currently it only supports certain element sizes void mfswapbytes(void *buffer,int elsize,int size); // test byte swapping bool byteswap(); bool byteswapmachine(); // Reading the Matlab-file header // This header contains text (126 bytes) explaining the origin of the data // Can be an arbritrary text void mfreadheader(); void mfwriteheader(); // two versions of reading and writing algorithms that deal with the byte swapping // issue. Actually only the reader does byte swapping, but this way there is a // consistent interface. // The offset version start reading at an certain location (includes a fseek at the start) void mfread(void *buffer,int elsize,int size); // read data and do byte swapping void mfread(void *buffer,int elsize,int size,int offset); void mfwrite(void *buffer,int elsize,int size); void mfwrite(void *buffer,int elsize,int size,int offset); public: // constructors matfile(const std::string& filename, const std::string& mode); matfile(); // destructors virtual ~matfile(); matfile(const matfile &m); // copy constructor matfile& operator= (const matfile &m); // assignment // open and close file virtual void open(const std::string& filename, const std::string& mode); virtual void close(); // matfile header void setheadertext(const std::string& text); std::string getheadertext(); // read/write data to file void readtag(matfiledata& mfd); void readdat(matfiledata& mfd); void writetag(matfiledata& mfd); void writedat(matfiledata& mfd); // openchild: // opens the current datablock as a substructure // it creates a new pointer and limits access to the file to // that datablock. All functions read now in the substructure // closechild: // return from substructure and restore all file pointers bool openchild(); void closechild(); // open and close a compressed section of data // Compression is only used for reading Matlab V7 files // Data is exported as non compressed data to be compatible with // version 5 and 6. bool opencompression(); void closecompression(); // navigation through file: // firsttag: // go back to the first data block // nexttag: // go to the next data block // gototag: // goto a previous marked block // firsttag and nexttag return a number indicating // where the datablock is in the file (offset in file) // if they return 0, there is no datablock. // rewind: // Go to the first tag at the top level int firsttag(); int nexttag(); int gototag(int tag); void rewind(); // A quick test to see what kind of access to the // file is used. Some functions only work for reading and // others for writing, these function allows for checking // the proper access bool isreadaccess(); bool iswriteaccess(); }; }} #endif
34.573944
106
0.703432
af4c4175f0f2e69439b09cc5d045b178c8f08230
112
h
C
cpp/cpp_primer/chapter06/chapter6.h
KaiserLancelot/Cpp-Primer
a4791a6765f0b6c864e8881e6a5328e2a3d68974
[ "MIT" ]
2
2019-12-21T00:53:47.000Z
2020-01-01T10:36:30.000Z
cpp/cpp_primer/chapter06/chapter6.h
KaiserLancelot/Cpp-Primer
a4791a6765f0b6c864e8881e6a5328e2a3d68974
[ "MIT" ]
null
null
null
cpp/cpp_primer/chapter06/chapter6.h
KaiserLancelot/Cpp-Primer
a4791a6765f0b6c864e8881e6a5328e2a3d68974
[ "MIT" ]
null
null
null
// // Created by kaiser on 18-11-28. // #pragma once #include <cstdint> std::int32_t fact(std::int32_t val);
11.2
36
0.660714
15dc7a4b15ef5f09cfbc35fb05715c6ee361f7a3
3,386
h
C
src/Pololu3piPlus32U4OLED.h
pololu/pololu-3pi-plus-32u4-arduino-library
a4d876bb1af1cd938cb6bb1c306b47ea2d804608
[ "MIT" ]
5
2021-02-15T21:13:46.000Z
2022-01-25T03:24:43.000Z
src/Pololu3piPlus32U4OLED.h
pololu/pololu-3pi-plus-32u4-arduino-library
a4d876bb1af1cd938cb6bb1c306b47ea2d804608
[ "MIT" ]
null
null
null
src/Pololu3piPlus32U4OLED.h
pololu/pololu-3pi-plus-32u4-arduino-library
a4d876bb1af1cd938cb6bb1c306b47ea2d804608
[ "MIT" ]
2
2021-12-13T15:06:25.000Z
2022-01-05T03:18:44.000Z
// Copyright (C) Pololu Corporation. See www.pololu.com for details. #pragma once #include <Arduino.h> #include <FastGPIO.h> #include <USBPause.h> #include <PololuSH1106Main.h> #include <util/delay.h> // This asm inside the macro below is an optimized version of // FastGPIO::Pin<mosPin>::setOutputValue(d >> b & 1); // It prevents the compiler from using slow branches to implement the // conditional logic, and also ensures that the writing speed doesn't depend // on the data. #define _P3PP_OLED_SEND_BIT(b) \ FastGPIO::Pin<clkPin>::setOutputValueLow(); \ asm volatile( \ "sbrc %2, %3\n" "sbi %0, %1\n" \ "sbrs %2, %3\n" "cbi %0, %1\n" \ : : \ "I" (FastGPIO::pinStructs[mosPin].portAddr - __SFR_OFFSET), \ "I" (FastGPIO::pinStructs[mosPin].bit), \ "r" (d), \ "I" (b)); \ FastGPIO::Pin<clkPin>::setOutputValueHigh(); namespace Pololu3piPlus32U4 { /// @brief Low-level functions for writing data to the SH1106 OLED on the /// Pololu 3pi+ 32U4 OLED robot. class OLEDCore { // Pin assignments static const uint8_t clkPin = 1, mosPin = IO_D5, resPin = 0, dcPin = 17; public: void initPins() { FastGPIO::Pin<clkPin>::setOutputLow(); } void reset() { FastGPIO::Pin<resPin>::setOutputLow(); _delay_us(10); FastGPIO::Pin<resPin>::setOutputHigh(); _delay_us(10); } void sh1106TransferStart() { // From https://github.com/pololu/usb-pause-arduino/blob/master/USBPause.h: // Disables USB interrupts because the Arduino USB interrupts use some of // the OLED pins. savedUDIEN = UDIEN; UDIEN = 0; savedUENUM = UENUM; UENUM = 0; savedUEIENX0 = UEIENX; UEIENX = 0; savedStateMosi = FastGPIO::Pin<mosPin>::getState(); savedStateDc = FastGPIO::Pin<dcPin>::getState(); FastGPIO::Pin<mosPin>::setOutputLow(); } void sh1106TransferEnd() { FastGPIO::Pin<mosPin>::setState(savedStateMosi); FastGPIO::Pin<dcPin>::setState(savedStateDc); // From https://github.com/pololu/usb-pause-arduino/blob/master/USBPause.h UENUM = 0; UEIENX = savedUEIENX0; UENUM = savedUENUM; UDIEN = savedUDIEN; } void sh1106CommandMode() { FastGPIO::Pin<dcPin>::setOutputLow(); } void sh1106DataMode() { FastGPIO::Pin<dcPin>::setOutputHigh(); } void sh1106Write(uint8_t d) { _P3PP_OLED_SEND_BIT(7); _P3PP_OLED_SEND_BIT(6); _P3PP_OLED_SEND_BIT(5); _P3PP_OLED_SEND_BIT(4); _P3PP_OLED_SEND_BIT(3); _P3PP_OLED_SEND_BIT(2); _P3PP_OLED_SEND_BIT(1); _P3PP_OLED_SEND_BIT(0); } private: uint8_t savedStateMosi, savedStateDc; uint8_t savedUDIEN, savedUENUM, savedUEIENX0; }; /// @brief Makes it easy to show text and graphics on the SH1106 OLED of /// the Pololu 3pi+ 32U4 OLED robot. /// /// This class inherits from the PololuSH1106Main class in the PololuOLED /// library, which provides almost all of its functionality. See the /// [PololuOLED library documentation](https://pololu.github.io/pololu-oled-arduino/) /// for more information about how to use this class. /// /// This class also inherits from the Arduino Print class /// (via PololuSH1106Main), so you can call the `print()` function on it with a /// variety of arguments. See the /// [Arduino print() documentation](http://arduino.cc/en/Serial/Print) for /// more information. class OLED : public PololuSH1106Main<OLEDCore> { }; }
26.661417
85
0.680744
e43449f9dbb9c93d42fd7f9aca9a12eb70d9d0e6
44,361
c
C
usr/src/cmd/mdb/sun4u/modules/unix/unix.c
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/cmd/mdb/sun4u/modules/unix/unix.c
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/cmd/mdb/sun4u/modules/unix/unix.c
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
1
2020-12-30T00:04:16.000Z
2020-12-30T00:04:16.000Z
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include <sys/types.h> #ifndef DEBUG #define DEBUG #define _SYS_DEBUG_H #include <sys/xc_impl.h> #undef DEBUG #else #define _SYS_DEBUG_H #include <sys/xc_impl.h> #endif #include <sys/traptrace.h> #include <sys/machparam.h> #include <sys/intreg.h> #include <sys/ivintr.h> #include <sys/mutex_impl.h> #include <mdb/mdb_modapi.h> #include <mdb/mdb_ctf.h> #include <mdb/mdb_whatis.h> #include "sfmmu.h" #ifndef SYSTRAP_TT #define SYSTRAP_TT 0x1300 #endif typedef struct trap_trace_fullrec { struct trap_trace_record ttf_rec; int ttf_cpu; } trap_trace_fullrec_t; #ifdef sun4v typedef struct htrap_trace_fullrec { struct htrap_trace_record ttf_rec; int ttf_cpu; } htrap_trace_fullrec_t; #endif /* * These strings and accompanying macros allow our string table to look * just like the real table in trap_table.s. */ static const char NOT[] = "reserved"; /* common reserved string */ static const char BAD[] = "unused"; /* common unused string */ #define NOT4 NOT, NOT, NOT, NOT #define BAD4 BAD, BAD, BAD, BAD static const char *const ttdescr[] = { NOT, /* 000 reserved */ "power-on", /* 001 power on reset */ "watchdog", /* 002 watchdog reset */ "xir", /* 003 externally initiated reset */ "sir", /* 004 software initiated reset */ "red", /* 005 red mode exception */ NOT, NOT, /* 006 - 007 reserved */ "immu-xcp", /* 008 instruction access exception */ "immu-miss", /* 009 instruction access MMU miss */ "immu-err", /* 00A instruction access error */ NOT, NOT4, /* 00B - 00F reserved */ "ill-inst", /* 010 illegal instruction */ "priv-inst", /* 011 privileged opcode */ "unimp-ldd", /* 012 unimplemented LDD */ "unimp-std", /* 013 unimplemented STD */ NOT4, NOT4, NOT4, /* 014 - 01F reserved */ "fp-disable", /* 020 fp disabled */ "fp-ieee754", /* 021 fp exception ieee 754 */ "fp-xcp-other", /* 022 fp exception other */ "tag-oflow", /* 023 tag overflow */ "cleanwin", /* 024 clean window */ "cleanwin", /* 025 clean window */ "cleanwin", /* 026 clean window */ "cleanwin", /* 027 clean window */ "div-zero", /* 028 division by zero */ "internal-err", /* 029 internal processor error */ NOT, NOT, NOT4, /* 02A - 02F reserved */ "dmmu-xcp", /* 030 data access exception */ "dmmu-miss", /* 031 data access MMU miss */ "dmmu-err", /* 032 data access error */ "dmmu-prot", /* 033 data access protection */ "unalign", /* 034 mem address not aligned */ "lddf-unalign", /* 035 LDDF mem address not aligned */ "stdf-unalign", /* 036 STDF mem address not aligned */ "priv-act", /* 037 privileged action */ "ldqf-unalign", /* 038 LDQF mem address not aligned */ "stqf-unalign", /* 039 STQF mem address not aligned */ NOT, NOT, NOT4, /* 03A - 03F reserved */ "async-d-err", /* 040 async data error */ "level-1", /* 041 interrupt level 1 */ "level-2", /* 042 interrupt level 2 */ "level-3", /* 043 interrupt level 3 */ "level-4", /* 044 interrupt level 4 */ "level-5", /* 045 interrupt level 5 */ "level-6", /* 046 interrupt level 6 */ "level-7", /* 047 interrupt level 7 */ "level-8", /* 048 interrupt level 8 */ "level-9", /* 049 interrupt level 9 */ "level-10", /* 04A interrupt level 10 */ "level-11", /* 04B interrupt level 11 */ "level-12", /* 04C interrupt level 12 */ "level-13", /* 04D interrupt level 13 */ "level-14", /* 04E interrupt level 14 */ "level-15", /* 04F interrupt level 15 */ NOT4, NOT4, NOT4, NOT4, /* 050 - 05F reserved */ "int-vec", /* 060 interrupt vector */ "pa-watch", /* 061 PA watchpoint */ "va-watch", /* 062 VA watchpoint */ "ecc-err", /* 063 corrected ECC error */ "itlb-miss", /* 064 instruction access MMU miss */ "itlb-miss", /* 065 instruction access MMU miss */ "itlb-miss", /* 066 instruction access MMU miss */ "itlb-miss", /* 067 instruction access MMU miss */ "dtlb-miss", /* 068 data access MMU miss */ "dtlb-miss", /* 069 data access MMU miss */ "dtlb-miss", /* 06A data access MMU miss */ "dtlb-miss", /* 06B data access MMU miss */ "dtlb-prot", /* 06C data access protection */ "dtlb-prot", /* 06D data access protection */ "dtlb-prot", /* 06E data access protection */ "dtlb-prot", /* 06F data access protection */ "fast-ecc-err", /* 070 fast ecache ECC error */ "dp-err", /* 071 data cache parity error */ "ip-err", /* 072 instr cache parity error */ NOT, NOT4, NOT4, /* 073 - 07B reserved */ #ifdef sun4v "cpu-mondo", /* 07C CPU mondo */ "dev-mondo", /* 07D device mondo */ "res.-err", /* 07E resumable error */ "non-res.-err", /* 07F non-resumable error */ #else NOT4, /* 07C - 07F reserved */ #endif "spill-0-norm", /* 080 spill 0 normal */ "spill-0-norm", /* 081 spill 0 normal */ "spill-0-norm", /* 082 spill 0 normal */ "spill-0-norm", /* 083 spill 0 normal */ "spill-1-norm", /* 084 spill 1 normal */ "spill-1-norm", /* 085 spill 1 normal */ "spill-1-norm", /* 086 spill 1 normal */ "spill-1-norm", /* 087 spill 1 normal */ "spill-2-norm", /* 088 spill 2 normal */ "spill-2-norm", /* 089 spill 2 normal */ "spill-2-norm", /* 08A spill 2 normal */ "spill-2-norm", /* 08B spill 2 normal */ "spill-3-norm", /* 08C spill 3 normal */ "spill-3-norm", /* 08D spill 3 normal */ "spill-3-norm", /* 08E spill 3 normal */ "spill-3-norm", /* 08F spill 3 normal */ "spill-4-norm", /* 090 spill 4 normal */ "spill-4-norm", /* 091 spill 4 normal */ "spill-4-norm", /* 092 spill 4 normal */ "spill-4-norm", /* 093 spill 4 normal */ "spill-5-norm", /* 094 spill 5 normal */ "spill-5-norm", /* 095 spill 5 normal */ "spill-5-norm", /* 096 spill 5 normal */ "spill-5-norm", /* 097 spill 5 normal */ "spill-6-norm", /* 098 spill 6 normal */ "spill-6-norm", /* 099 spill 6 normal */ "spill-6-norm", /* 09A spill 6 normal */ "spill-6-norm", /* 09B spill 6 normal */ "spill-7-norm", /* 09C spill 7 normal */ "spill-7-norm", /* 09D spill 7 normal */ "spill-7-norm", /* 09E spill 7 normal */ "spill-7-norm", /* 09F spill 7 normal */ "spill-0-oth", /* 0A0 spill 0 other */ "spill-0-oth", /* 0A1 spill 0 other */ "spill-0-oth", /* 0A2 spill 0 other */ "spill-0-oth", /* 0A3 spill 0 other */ "spill-1-oth", /* 0A4 spill 1 other */ "spill-1-oth", /* 0A5 spill 1 other */ "spill-1-oth", /* 0A6 spill 1 other */ "spill-1-oth", /* 0A7 spill 1 other */ "spill-2-oth", /* 0A8 spill 2 other */ "spill-2-oth", /* 0A9 spill 2 other */ "spill-2-oth", /* 0AA spill 2 other */ "spill-2-oth", /* 0AB spill 2 other */ "spill-3-oth", /* 0AC spill 3 other */ "spill-3-oth", /* 0AD spill 3 other */ "spill-3-oth", /* 0AE spill 3 other */ "spill-3-oth", /* 0AF spill 3 other */ "spill-4-oth", /* 0B0 spill 4 other */ "spill-4-oth", /* 0B1 spill 4 other */ "spill-4-oth", /* 0B2 spill 4 other */ "spill-4-oth", /* 0B3 spill 4 other */ "spill-5-oth", /* 0B4 spill 5 other */ "spill-5-oth", /* 0B5 spill 5 other */ "spill-5-oth", /* 0B6 spill 5 other */ "spill-5-oth", /* 0B7 spill 5 other */ "spill-6-oth", /* 0B8 spill 6 other */ "spill-6-oth", /* 0B9 spill 6 other */ "spill-6-oth", /* 0BA spill 6 other */ "spill-6-oth", /* 0BB spill 6 other */ "spill-7-oth", /* 0BC spill 7 other */ "spill-7-oth", /* 0BD spill 7 other */ "spill-7-oth", /* 0BE spill 7 other */ "spill-7-oth", /* 0BF spill 7 other */ "fill-0-norm", /* 0C0 fill 0 normal */ "fill-0-norm", /* 0C1 fill 0 normal */ "fill-0-norm", /* 0C2 fill 0 normal */ "fill-0-norm", /* 0C3 fill 0 normal */ "fill-1-norm", /* 0C4 fill 1 normal */ "fill-1-norm", /* 0C5 fill 1 normal */ "fill-1-norm", /* 0C6 fill 1 normal */ "fill-1-norm", /* 0C7 fill 1 normal */ "fill-2-norm", /* 0C8 fill 2 normal */ "fill-2-norm", /* 0C9 fill 2 normal */ "fill-2-norm", /* 0CA fill 2 normal */ "fill-2-norm", /* 0CB fill 2 normal */ "fill-3-norm", /* 0CC fill 3 normal */ "fill-3-norm", /* 0CD fill 3 normal */ "fill-3-norm", /* 0CE fill 3 normal */ "fill-3-norm", /* 0CF fill 3 normal */ "fill-4-norm", /* 0D0 fill 4 normal */ "fill-4-norm", /* 0D1 fill 4 normal */ "fill-4-norm", /* 0D2 fill 4 normal */ "fill-4-norm", /* 0D3 fill 4 normal */ "fill-5-norm", /* 0D4 fill 5 normal */ "fill-5-norm", /* 0D5 fill 5 normal */ "fill-5-norm", /* 0D6 fill 5 normal */ "fill-5-norm", /* 0D7 fill 5 normal */ "fill-6-norm", /* 0D8 fill 6 normal */ "fill-6-norm", /* 0D9 fill 6 normal */ "fill-6-norm", /* 0DA fill 6 normal */ "fill-6-norm", /* 0DB fill 6 normal */ "fill-7-norm", /* 0DC fill 7 normal */ "fill-7-norm", /* 0DD fill 7 normal */ "fill-7-norm", /* 0DE fill 7 normal */ "fill-7-norm", /* 0DF fill 7 normal */ "fill-0-oth", /* 0E0 fill 0 other */ "fill-0-oth", /* 0E1 fill 0 other */ "fill-0-oth", /* 0E2 fill 0 other */ "fill-0-oth", /* 0E3 fill 0 other */ "fill-1-oth", /* 0E4 fill 1 other */ "fill-1-oth", /* 0E5 fill 1 other */ "fill-1-oth", /* 0E6 fill 1 other */ "fill-1-oth", /* 0E7 fill 1 other */ "fill-2-oth", /* 0E8 fill 2 other */ "fill-2-oth", /* 0E9 fill 2 other */ "fill-2-oth", /* 0EA fill 2 other */ "fill-2-oth", /* 0EB fill 2 other */ "fill-3-oth", /* 0EC fill 3 other */ "fill-3-oth", /* 0ED fill 3 other */ "fill-3-oth", /* 0EE fill 3 other */ "fill-3-oth", /* 0EF fill 3 other */ "fill-4-oth", /* 0F0 fill 4 other */ "fill-4-oth", /* 0F1 fill 4 other */ "fill-4-oth", /* 0F2 fill 4 other */ "fill-4-oth", /* 0F3 fill 4 other */ "fill-5-oth", /* 0F4 fill 5 other */ "fill-5-oth", /* 0F5 fill 5 other */ "fill-5-oth", /* 0F6 fill 5 other */ "fill-5-oth", /* 0F7 fill 5 other */ "fill-6-oth", /* 0F8 fill 6 other */ "fill-6-oth", /* 0F9 fill 6 other */ "fill-6-oth", /* 0FA fill 6 other */ "fill-6-oth", /* 0FB fill 6 other */ "fill-7-oth", /* 0FC fill 7 other */ "fill-7-oth", /* 0FD fill 7 other */ "fill-7-oth", /* 0FE fill 7 other */ "fill-7-oth", /* 0FF fill 7 other */ "syscall-4x", /* 100 old system call */ "usr-brkpt", /* 101 user breakpoint */ "usr-div-zero", /* 102 user divide by zero */ "flush-wins", /* 103 flush windows */ "clean-wins", /* 104 clean windows */ "range-chk", /* 105 range check ?? */ "fix-align", /* 106 do unaligned references */ BAD, /* 107 unused */ "syscall-32", /* 108 ILP32 system call on LP64 */ "set-t0-addr", /* 109 set trap0 address */ BAD, BAD, BAD4, /* 10A - 10F unused */ BAD4, BAD4, BAD4, BAD4, /* 110 - 11F unused (V9 user traps?) */ "get-cc", /* 120 get condition codes */ "set-cc", /* 121 set condition codes */ "get-psr", /* 122 get psr */ "set-psr", /* 123 set psr (some fields) */ "getts", /* 124 get timestamp */ "gethrvtime", /* 125 get lwp virtual time */ "self-xcall", /* 126 self xcall */ "gethrtime", /* 127 get hrestime */ BAD, /* 128 unused (ST_SETV9STACK) */ "getlgrp", /* 129 get lgrpid */ BAD, BAD, BAD4, /* 12A - 12F unused */ BAD4, BAD4, /* 130 - 137 unused */ "dtrace-pid", /* 138 DTrace pid provider */ BAD, /* 139 unused */ "dtrace-return", /* 13A DTrace pid provider */ BAD, BAD4, /* 13B - 13F unused */ "syscall-64", /* 140 LP64 system call */ BAD, /* 141 unused */ "tt-freeze", /* 142 freeze traptrace */ "tt-unfreeze", /* 143 unfreeze traptrace */ BAD4, BAD4, BAD4, /* 144 - 14F unused */ BAD4, BAD4, BAD4, BAD4, /* 150 - 15F unused */ BAD4, BAD4, BAD4, BAD4, /* 160 - 16F unused */ BAD4, BAD4, BAD4, /* 170 - 17B unused */ "ptl1-panic", /* 17C test ptl1_panic */ "kmdb-enter", /* 17D kmdb enter (L1-A) */ "kmdb-brkpt", /* 17E kmdb breakpoint */ "obp-brkpt", /* 17F obp breakpoint */ #ifdef sun4v "fast_trap", /* 180 hypervisor fast trap */ "cpu_tick_npt", /* 181 cpu_tick_npt() hcall */ "cpu_stick_npt", /* 182 cpu_stick_npt() hcall */ "mmu_map_addr", /* 183 mmu_map_addr() hcall */ "mmu_unmap_addr", /* 184 mmu_unmap_addr() hcall */ "ttrace_addentry", /* 185 ttrace_addentry() hcall */ NOT, NOT, NOT4, NOT4, /* 186 - 18F reserved */ #else NOT4, NOT4, NOT4, NOT4, /* 180 - 18F reserved */ #endif NOT4, NOT4, NOT4, NOT4, /* 190 - 19F reserved */ NOT4, NOT4, NOT4, NOT4, /* 1A0 - 1AF reserved */ NOT4, NOT4, NOT4, NOT4, /* 1B0 - 1BF reserved */ NOT4, NOT4, NOT4, NOT4, /* 1C0 - 1CF reserved */ NOT4, NOT4, NOT4, NOT4, /* 1D0 - 1DF reserved */ NOT4, NOT4, NOT4, NOT4, /* 1E0 - 1EF reserved */ NOT4, NOT4, NOT4, NOT4 /* 1F0 - 1FF reserved */ }; static const size_t ttndescr = sizeof (ttdescr) / sizeof (ttdescr[0]); static GElf_Sym iv_sym; /* * Persistent data (shouldn't change). */ static int ncpu; /* _ncpu */ static ssize_t mbox_size; /* size of xc_mbox */ static ulong_t mbox_stoff; /* offset of xc_mbox.xc_state */ static mdb_ctf_id_t mbox_states; /* xc_state enumeration */ static int fetch_ncpu(void) { if (ncpu == 0) if (mdb_readsym(&ncpu, sizeof (ncpu), "_ncpu") == -1) { mdb_warn("symbol '_ncpu' not found"); return (1); } return (0); } static int fetch_mbox(void) { if (mbox_size <= 0) { mdb_ctf_id_t id; if (mdb_ctf_lookup_by_name("struct xc_mbox", &id) == -1) { mdb_warn("couldn't find type 'struct xc_mbox'"); return (1); } /* * These two could be combined into a single call to * mdb_ctf_member_info if xc_state was actually of type * enum xc_states. */ if (mdb_ctf_lookup_by_name("enum xc_states", &mbox_states) == -1) { mdb_warn("couldn't find type 'enum xc_states'"); return (1); } if (mdb_ctf_offsetof(id, "xc_state", &mbox_stoff) == -1) { mdb_warn("couldn't find 'xc_mbox.xc_state'"); return (1); } mbox_stoff /= NBBY; if ((mbox_size = mdb_ctf_type_size(id)) == -1) { mdb_warn("couldn't size 'struct xc_mbox'"); return (1); } } return (0); } static int print_range(int start, int end, int separator) { int count; char tmp; char *format; if (start == end) { /* Unfortunately, mdb_printf returns void */ format = separator ? ", %d" : "%d"; mdb_printf(format, start); count = mdb_snprintf(&tmp, 1, format, start); } else { format = separator ? ", %d-%d" : "%d-%d"; mdb_printf(format, start, end); count = mdb_snprintf(&tmp, 1, format, start, end); } return (count); } static void print_cpuset_range(ulong_t *cs, int words, int width) { int i, j; ulong_t m; int in = 0; int start; int end; int count = 0; int sep = 0; for (i = 0; i < words; i++) for (j = 0, m = 1; j < BT_NBIPUL; j++, m <<= 1) if (cs[i] & m) { if (in == 0) { start = i * BT_NBIPUL + j; in = 1; } } else { if (in == 1) { end = i * BT_NBIPUL + j - 1; count += print_range(start, end, sep); sep = 1; in = 0; } } if (in == 1) { end = i * BT_NBIPUL - 1; count += print_range(start, end, sep); } while (count++ < width) mdb_printf(" "); } /*ARGSUSED*/ static int cmd_cpuset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { uint_t rflag = 0, lflag = 0; int words; ulong_t *setp, set = 0; if (mdb_getopts(argc, argv, 'l', MDB_OPT_SETBITS, TRUE, &lflag, 'r', MDB_OPT_SETBITS, TRUE, &rflag, NULL) != argc) return (DCMD_USAGE); if (lflag && rflag) return (DCMD_USAGE); if (fetch_ncpu()) return (DCMD_ERR); if ((words = BT_BITOUL(ncpu)) == 1) { setp = &set; mdb_vread(setp, sizeof (ulong_t), addr); } else { setp = mdb_alloc(words * sizeof (ulong_t), UM_SLEEP | UM_GC); mdb_vread(setp, words * sizeof (ulong_t), addr); } if (lflag) { int i, j; ulong_t m; for (i = 0; i < words; i++) for (j = 0, m = 1; j < BT_NBIPUL; j++, m <<= 1) if (setp[i] & m) mdb_printf("%r\n", i * BT_NBIPUL + j); } else if (rflag) { int i; int sep = 0; for (i = 0; i < words; i++) { mdb_printf(sep ? " %?0lx" : "%?0lx", setp[i]); sep = 1; } } else { print_cpuset_range(setp, words, 0); } return (DCMD_OK); } /*ARGSUSED*/ int ttctl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { TRAP_TRACE_CTL *ctls, *ctl; int i, traptrace_buf_inuse = 0; if (argc != 0) return (DCMD_USAGE); if (fetch_ncpu()) return (DCMD_ERR); ctls = mdb_alloc(sizeof (TRAP_TRACE_CTL) * ncpu, UM_SLEEP | UM_GC); if (mdb_readsym(ctls, sizeof (TRAP_TRACE_CTL) * ncpu, "trap_trace_ctl") == -1) { mdb_warn("symbol 'trap_trace_ctl' not found"); return (DCMD_ERR); } for (ctl = &ctls[0], i = 0; i < ncpu; i++, ctl++) { if (ctl->d.vaddr_base == 0) continue; traptrace_buf_inuse = 1; mdb_printf("trap_trace_ctl[%d] = {\n", i); mdb_printf(" vaddr_base = 0x%lx\n", (long)ctl->d.vaddr_base); mdb_printf(" last_offset = 0x%x\n", ctl->d.last_offset); mdb_printf(" offset = 0x%x\n", ctl->d.offset); mdb_printf(" limit = 0x%x\n", ctl->d.limit); mdb_printf(" paddr_base = 0x%llx\n", ctl->d.paddr_base); mdb_printf(" asi = 0x%02x\n}\n", ctl->d.asi); } if (!traptrace_buf_inuse) { mdb_warn("traptrace not configured"); return (DCMD_ERR); } return (DCMD_OK); } /*ARGSUSED*/ static int ttprint_short(uintptr_t addr, const trap_trace_fullrec_t *full, int *cpu) { const char *ttstr; const struct trap_trace_record *ttp = &full->ttf_rec; if (*cpu == -1) mdb_printf("%3d ", full->ttf_cpu); else if (*cpu != full->ttf_cpu) return (0); /* * Decoding the traptype field is a bit messy. First we check for * several well-defined 16-bit values defined in <sys/traptrace.h>. */ switch (ttp->tt_tt) { case TT_SC_ENTR: ttstr = "sys-enter"; break; case TT_SC_RET: ttstr = "sys-exit"; break; case TT_SYS_RTT_PROM: ttstr = "prom_rtt"; break; case TT_SYS_RTT_PRIV: ttstr = "priv_rtt"; break; case TT_SYS_RTT_USER: ttstr = "user_rtt"; break; case TT_INTR_EXIT: ttstr = "int-thr-exit"; break; default: /* * Next we consider several prefixes (which are * typically OR'd with other information such as the * %pil or %tt value at the time of the trace). */ switch (ttp->tt_tt & 0xff00) { case TT_SERVE_INTR: ttstr = "serve-intr"; break; case TT_XCALL: ttstr = "xcall"; break; case TT_XCALL_CONT: ttstr = "xcall-cont"; break; case SYSTRAP_TT: ttstr = "sys_trap"; break; default: /* * Otherwise we try to convert the * tt value to a string using our * giant lookup table. */ ttstr = ttp->tt_tt < ttndescr ? ttdescr[ttp->tt_tt] : "?"; } } #ifdef sun4v mdb_printf("%016llx %04hx %-12s %02x %02x %0?p %A\n", ttp->tt_tick, ttp->tt_tt, ttstr, ttp->tt_tl, ttp->tt_gl, ttp->tt_tpc, ttp->tt_tpc); #else mdb_printf("%016llx %04hx %-12s %04hx %0?p %A\n", ttp->tt_tick, ttp->tt_tt, ttstr, ttp->tt_tl, ttp->tt_tpc, ttp->tt_tpc); #endif return (WALK_NEXT); } /*ARGSUSED*/ static int ttprint_long(uintptr_t addr, const trap_trace_fullrec_t *full, int *cpu) { const struct trap_trace_record *ttp = &full->ttf_rec; if (*cpu == -1) mdb_printf("%3d ", full->ttf_cpu); else if (*cpu != full->ttf_cpu) return (WALK_NEXT); #ifdef sun4v mdb_printf("%016llx %016llx %04hx %02x %02x %0?p %0?p %0?p " "[%p,%p,%p,%p]\n", ttp->tt_tick, ttp->tt_tstate, ttp->tt_tt, ttp->tt_tl, ttp->tt_gl, ttp->tt_tpc, ttp->tt_sp, ttp->tt_tr, ttp->tt_f1, ttp->tt_f2, ttp->tt_f3, ttp->tt_f4); #else mdb_printf("%016llx %016llx %04hx %04hx %0?p %0?p %0?p [%p,%p,%p,%p]\n", ttp->tt_tick, ttp->tt_tstate, ttp->tt_tt, ttp->tt_tl, ttp->tt_tpc, ttp->tt_sp, ttp->tt_tr, ttp->tt_f1, ttp->tt_f2, ttp->tt_f3, ttp->tt_f4); #endif return (WALK_NEXT); } typedef struct ttrace_cpu_data { struct trap_trace_record *tc_buf; struct trap_trace_record *tc_rec; struct trap_trace_record *tc_stop; size_t tc_bufsiz; uintptr_t tc_base; } ttrace_cpu_data_t; typedef struct ttrace_walk_data { int tw_ncpu; ttrace_cpu_data_t *tw_cpus; } ttrace_walk_data_t; int ttrace_walk_init(mdb_walk_state_t *wsp) { TRAP_TRACE_CTL *ctls, *ctl; int i, traptrace_buf_inuse = 0; ttrace_walk_data_t *tw; ttrace_cpu_data_t *tc; struct trap_trace_record *buf; if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("ttrace only supports global walks\n"); return (WALK_ERR); } if (fetch_ncpu()) return (WALK_ERR); ctls = mdb_alloc(sizeof (TRAP_TRACE_CTL) * ncpu, UM_SLEEP); if (mdb_readsym(ctls, sizeof (TRAP_TRACE_CTL) * ncpu, "trap_trace_ctl") == -1) { mdb_warn("symbol 'trap_trace_ctl' not found"); mdb_free(ctls, sizeof (TRAP_TRACE_CTL) * ncpu); return (WALK_ERR); } tw = mdb_zalloc(sizeof (ttrace_walk_data_t), UM_SLEEP); tw->tw_ncpu = ncpu; tw->tw_cpus = mdb_zalloc(sizeof (ttrace_cpu_data_t) * ncpu, UM_SLEEP); for (i = 0; i < ncpu; i++) { ctl = &ctls[i]; if (ctl->d.vaddr_base == 0) continue; traptrace_buf_inuse = 1; tc = &(tw->tw_cpus[i]); tc->tc_bufsiz = ctl->d.limit - sizeof (struct trap_trace_record); tc->tc_buf = buf = mdb_alloc(tc->tc_bufsiz, UM_SLEEP); tc->tc_base = (uintptr_t)ctl->d.vaddr_base; if (mdb_vread(buf, tc->tc_bufsiz, tc->tc_base) == -1) { mdb_warn("failed to read trap trace buffer at %p", ctl->d.vaddr_base); mdb_free(buf, tc->tc_bufsiz); tc->tc_buf = NULL; } else { tc->tc_rec = (struct trap_trace_record *) ((uintptr_t)buf + (uintptr_t)ctl->d.last_offset); tc->tc_stop = (struct trap_trace_record *) ((uintptr_t)buf + (uintptr_t)ctl->d.offset); } } if (!traptrace_buf_inuse) { mdb_warn("traptrace not configured"); mdb_free(ctls, sizeof (TRAP_TRACE_CTL) * ncpu); return (DCMD_ERR); } mdb_free(ctls, sizeof (TRAP_TRACE_CTL) * ncpu); wsp->walk_data = tw; return (WALK_NEXT); } int ttrace_walk_step(mdb_walk_state_t *wsp) { ttrace_walk_data_t *tw = wsp->walk_data; ttrace_cpu_data_t *tc; struct trap_trace_record *rec; int oldest, i, status; uint64_t oldest_tick = 0; int done = 1; trap_trace_fullrec_t fullrec; for (i = 0; i < tw->tw_ncpu; i++) { tc = &(tw->tw_cpus[i]); if (tc->tc_rec == NULL) continue; done = 0; if (tc->tc_rec->tt_tick == 0) mdb_warn("Warning: tt_tick == 0\n"); if (tc->tc_rec->tt_tick > oldest_tick) { oldest_tick = tc->tc_rec->tt_tick; oldest = i; } } if (done) return (-1); tc = &(tw->tw_cpus[oldest]); rec = tc->tc_rec; fullrec.ttf_rec = *rec; fullrec.ttf_cpu = oldest; if (oldest_tick != 0) status = wsp->walk_callback((uintptr_t)rec - (uintptr_t)tc->tc_buf + tc->tc_base, &fullrec, wsp->walk_cbdata); tc->tc_rec--; if (tc->tc_rec < tc->tc_buf) tc->tc_rec = (struct trap_trace_record *)((uintptr_t) tc->tc_buf + (uintptr_t)tc->tc_bufsiz - sizeof (struct trap_trace_record)); if (tc->tc_rec == tc->tc_stop) { tc->tc_rec = NULL; mdb_free(tc->tc_buf, tc->tc_bufsiz); } return (status); } void ttrace_walk_fini(mdb_walk_state_t *wsp) { ttrace_walk_data_t *tw = wsp->walk_data; mdb_free(tw->tw_cpus, sizeof (ttrace_cpu_data_t) * tw->tw_ncpu); mdb_free(tw, sizeof (ttrace_walk_data_t)); } int ttrace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { uint_t opt_x = FALSE; int cpu = -1; mdb_walk_cb_t ttprint; if (mdb_getopts(argc, argv, 'x', MDB_OPT_SETBITS, TRUE, &opt_x, NULL) != argc) return (DCMD_USAGE); if (flags & DCMD_ADDRSPEC) { if (fetch_ncpu()) return (DCMD_ERR); if (addr >= ncpu) { mdb_warn("expected cpu between 0 and %d\n", ncpu - 1); return (DCMD_ERR); } cpu = (int)addr; } if (cpu == -1) mdb_printf("CPU "); if (opt_x) { #ifdef sun4v mdb_printf("%-16s %-16s %-4s %-3s %-3s %-?s %-?s %-?s " "F1-4\n", "%tick", "%tstate", "%tt", "%tl", "%gl", "%tpc", "%sp", "TR"); #else mdb_printf("%-16s %-16s %-4s %-4s %-?s %-?s %-?s " "F1-4\n", "%tick", "%tstate", "%tt", "%tl", "%tpc", "%sp", "TR"); #endif ttprint = (mdb_walk_cb_t)ttprint_long; } else { #ifdef sun4v mdb_printf("%-16s %-4s %-12s %-3s %-3s %s\n", "%tick", "%tt", "", "%tl", "%gl", "%tpc"); #else mdb_printf("%-16s %-4s %-12s %-4s %s\n", "%tick", "%tt", "", "%tl", "%tpc"); #endif ttprint = (mdb_walk_cb_t)ttprint_short; } if (mdb_walk("ttrace", ttprint, &cpu) == -1) { mdb_warn("couldn't walk ttrace"); return (DCMD_ERR); } return (DCMD_OK); } #ifdef sun4v /*ARGSUSED*/ int httctl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { TRAP_TRACE_CTL *ctls, *ctl; int i, htraptrace_buf_inuse = 0; htrap_trace_hdr_t hdr; if (argc != 0) return (DCMD_USAGE); if (fetch_ncpu()) return (DCMD_ERR); ctls = mdb_alloc(sizeof (TRAP_TRACE_CTL) * ncpu, UM_SLEEP | UM_GC); if (mdb_readsym(ctls, sizeof (TRAP_TRACE_CTL) * ncpu, "trap_trace_ctl") == -1) { mdb_warn("symbol 'trap_trace_ctl' not found"); return (DCMD_ERR); } for (ctl = &ctls[0], i = 0; i < ncpu; i++, ctl++) { if (ctl->d.hvaddr_base == 0) continue; htraptrace_buf_inuse = 1; mdb_vread(&hdr, sizeof (htrap_trace_hdr_t), (uintptr_t)ctl->d.hvaddr_base); mdb_printf("htrap_trace_ctl[%d] = {\n", i); mdb_printf(" vaddr_base = 0x%lx\n", (long)ctl->d.hvaddr_base); mdb_printf(" last_offset = 0x%lx\n", hdr.last_offset); mdb_printf(" offset = 0x%lx\n", hdr.offset); mdb_printf(" limit = 0x%x\n", ctl->d.hlimit); mdb_printf(" paddr_base = 0x%llx\n}\n", ctl->d.hpaddr_base); } if (!htraptrace_buf_inuse) { mdb_warn("hv traptrace not configured"); return (DCMD_ERR); } return (DCMD_OK); } /*ARGSUSED*/ static int httprint_short(uintptr_t addr, const htrap_trace_fullrec_t *full, int *cpu) { const char *ttstr; const struct htrap_trace_record *ttp = &full->ttf_rec; if (*cpu == -1) mdb_printf("%3d ", full->ttf_cpu); else if (*cpu != full->ttf_cpu) return (0); /* * Convert the tt value to a string using our gaint lookuo table */ ttstr = ttp->tt_tt < ttndescr ? ttdescr[ttp->tt_tt] : "?"; mdb_printf("%016llx %02x %04hx %04hx %-16s %02x %02x %0?p %A\n", ttp->tt_tick, ttp->tt_ty, ttp->tt_tag, ttp->tt_tt, ttstr, ttp->tt_tl, ttp->tt_gl, ttp->tt_tpc, ttp->tt_tpc); return (WALK_NEXT); } /*ARGSUSED*/ static int httprint_long(uintptr_t addr, const htrap_trace_fullrec_t *full, int *cpu) { const struct htrap_trace_record *ttp = &full->ttf_rec; if (*cpu == -1) mdb_printf("%3d ", full->ttf_cpu); else if (*cpu != full->ttf_cpu) return (WALK_NEXT); mdb_printf("%016llx %016llx %02x %02x %04hx %04hx %02x %02x %0?p " "[%p,%p,%p,%p]\n", ttp->tt_tick, ttp->tt_tstate, ttp->tt_hpstate, ttp->tt_ty, ttp->tt_tag, ttp->tt_tt, ttp->tt_tl, ttp->tt_gl, ttp->tt_tpc, ttp->tt_f1, ttp->tt_f2, ttp->tt_f3, ttp->tt_f4); return (WALK_NEXT); } typedef struct httrace_cpu_data { struct htrap_trace_record *tc_buf; struct htrap_trace_record *tc_rec; struct htrap_trace_record *tc_stop; size_t tc_bufsiz; uintptr_t tc_base; } httrace_cpu_data_t; typedef struct httrace_walk_data { int tw_ncpu; httrace_cpu_data_t *tw_cpus; } httrace_walk_data_t; int httrace_walk_init(mdb_walk_state_t *wsp) { TRAP_TRACE_CTL *ctls, *ctl; int i, htraptrace_buf_inuse = 0; httrace_walk_data_t *tw; httrace_cpu_data_t *tc; struct htrap_trace_record *buf; htrap_trace_hdr_t *hdr; if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("httrace only supports global walks\n"); return (WALK_ERR); } if (fetch_ncpu()) return (WALK_ERR); ctls = mdb_alloc(sizeof (TRAP_TRACE_CTL) * ncpu, UM_SLEEP); if (mdb_readsym(ctls, sizeof (TRAP_TRACE_CTL) * ncpu, "trap_trace_ctl") == -1) { mdb_warn("symbol 'trap_trace_ctl' not found"); mdb_free(ctls, sizeof (TRAP_TRACE_CTL) * ncpu); return (WALK_ERR); } tw = mdb_zalloc(sizeof (httrace_walk_data_t), UM_SLEEP); tw->tw_ncpu = ncpu; tw->tw_cpus = mdb_zalloc(sizeof (httrace_cpu_data_t) * ncpu, UM_SLEEP); for (i = 0; i < ncpu; i++) { ctl = &ctls[i]; if (ctl->d.hvaddr_base == 0) continue; htraptrace_buf_inuse = 1; tc = &(tw->tw_cpus[i]); tc->tc_bufsiz = ctl->d.hlimit; tc->tc_buf = buf = mdb_alloc(tc->tc_bufsiz, UM_SLEEP); tc->tc_base = (uintptr_t)ctl->d.hvaddr_base; if (mdb_vread(buf, tc->tc_bufsiz, tc->tc_base) == -1) { mdb_warn("failed to read hv trap trace buffer at %p", ctl->d.hvaddr_base); mdb_free(buf, tc->tc_bufsiz); tc->tc_buf = NULL; } else { hdr = (htrap_trace_hdr_t *)buf; tc->tc_rec = (struct htrap_trace_record *) ((uintptr_t)buf + (uintptr_t)hdr->last_offset); tc->tc_stop = (struct htrap_trace_record *) ((uintptr_t)buf + (uintptr_t)hdr->offset); } } if (!htraptrace_buf_inuse) { mdb_warn("hv traptrace not configured"); mdb_free(ctls, sizeof (TRAP_TRACE_CTL) * ncpu); return (DCMD_ERR); } mdb_free(ctls, sizeof (TRAP_TRACE_CTL) * ncpu); wsp->walk_data = tw; return (WALK_NEXT); } int httrace_walk_step(mdb_walk_state_t *wsp) { httrace_walk_data_t *tw = wsp->walk_data; httrace_cpu_data_t *tc; struct htrap_trace_record *rec; int oldest, i, status; uint64_t oldest_tick = 0; int done = 1; htrap_trace_fullrec_t fullrec; for (i = 0; i < tw->tw_ncpu; i++) { tc = &(tw->tw_cpus[i]); if (tc->tc_rec == NULL) continue; done = 0; if (tc->tc_rec->tt_tick == 0) mdb_warn("Warning: tt_tick == 0\n"); if (tc->tc_rec->tt_tick >= oldest_tick) { oldest_tick = tc->tc_rec->tt_tick; oldest = i; } } if (done) return (-1); tc = &(tw->tw_cpus[oldest]); rec = tc->tc_rec; fullrec.ttf_rec = *rec; fullrec.ttf_cpu = oldest; if (oldest_tick != 0) status = wsp->walk_callback((uintptr_t)rec - (uintptr_t)tc->tc_buf + tc->tc_base, &fullrec, wsp->walk_cbdata); tc->tc_rec--; /* first record of the trap trace buffer is trap trace header */ if (tc->tc_rec == tc->tc_buf) tc->tc_rec = (struct htrap_trace_record *)((uintptr_t) tc->tc_buf + (uintptr_t)tc->tc_bufsiz - sizeof (struct htrap_trace_record)); if (tc->tc_rec == tc->tc_stop) { tc->tc_rec = NULL; mdb_free(tc->tc_buf, tc->tc_bufsiz); } return (status); } void httrace_walk_fini(mdb_walk_state_t *wsp) { httrace_walk_data_t *tw = wsp->walk_data; mdb_free(tw->tw_cpus, sizeof (httrace_cpu_data_t) * tw->tw_ncpu); mdb_free(tw, sizeof (httrace_walk_data_t)); } int httrace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { uint_t opt_x = FALSE; int cpu = -1; mdb_walk_cb_t ttprint; if (mdb_getopts(argc, argv, 'x', MDB_OPT_SETBITS, TRUE, &opt_x, NULL) != argc) return (DCMD_USAGE); if (flags & DCMD_ADDRSPEC) { if (fetch_ncpu()) return (DCMD_ERR); if (addr >= ncpu) { mdb_warn("expected cpu between 0 and %d\n", ncpu - 1); return (DCMD_ERR); } cpu = (int)addr; } if (cpu == -1) mdb_printf("CPU "); if (opt_x) { mdb_printf("%-16s %-16s %-3s %-3s %-4s %-4s %-3s %-3s %-?s " "F1-4\n", "%tick", "%tstate", "%hp", "%ty", "%tag", "%tt", "%tl", "%gl", "%tpc"); ttprint = (mdb_walk_cb_t)httprint_long; } else { mdb_printf("%-16s %-3s %-4s %-4s %-16s %-3s %-3s %s\n", "%tick", "%ty", "%tag", "%tt", "", "%tl", "%gl", "%tpc"); ttprint = (mdb_walk_cb_t)httprint_short; } if (mdb_walk("httrace", ttprint, &cpu) == -1) { mdb_warn("couldn't walk httrace"); return (DCMD_ERR); } return (DCMD_OK); } #endif struct { int xc_type; const char *xc_str; } xc_data[] = { { XT_ONE_SELF, "xt-one-self" }, { XT_ONE_OTHER, "xt-one-other" }, { XT_SOME_SELF, "xt-some-self" }, { XT_SOME_OTHER, "xt-some-other" }, { XT_ALL_SELF, "xt-all-self" }, { XT_ALL_OTHER, "xt-all-other" }, { XC_ONE_SELF, "xc-one-self" }, { XC_ONE_OTHER, "xc-one-other" }, { XC_ONE_OTHER_H, "xc-one-other-h" }, { XC_SOME_SELF, "xc-some-self" }, { XC_SOME_OTHER, "xc-some-other" }, { XC_SOME_OTHER_H, "xc-some-other-h" }, { XC_ALL_SELF, "xc-all-self" }, { XC_ALL_OTHER, "xc-all-other" }, { XC_ALL_OTHER_H, "xc-all-other-h" }, { XC_ATTENTION, "xc-attention" }, { XC_DISMISSED, "xc-dismissed" }, { XC_LOOP_ENTER, "xc-loop-enter" }, { XC_LOOP_DOIT, "xc-loop-doit" }, { XC_LOOP_EXIT, "xc-loop-exit" }, { 0, NULL } }; /*ARGSUSED*/ int xctrace_walk(uintptr_t addr, const trap_trace_fullrec_t *full, int *cpu) { const struct trap_trace_record *ttp = &full->ttf_rec; int i, type = ttp->tt_tt & 0xff; const char *str = "???"; if ((ttp->tt_tt & 0xff00) == TT_XCALL) { for (i = 0; xc_data[i].xc_str != NULL; i++) { if (xc_data[i].xc_type == type) { str = xc_data[i].xc_str; break; } } } else if ((ttp->tt_tt & 0xff00) == TT_XCALL_CONT) { str = "xcall-cont"; mdb_printf("%3d %016llx %-16s %08x %08x %08x %08x\n", full->ttf_cpu, ttp->tt_tick, str, ttp->tt_f1, ttp->tt_f2, ttp->tt_f3, ttp->tt_f4); return (WALK_NEXT); } else if (ttp->tt_tt == 0x60) { str = "int-vec"; } else { return (WALK_NEXT); } mdb_printf("%3d %016llx %-16s %08x %a\n", full->ttf_cpu, ttp->tt_tick, str, ttp->tt_sp, ttp->tt_tr); return (WALK_NEXT); } /*ARGSUSED*/ int xctrace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { if ((flags & DCMD_ADDRSPEC) || argc != 0) return (DCMD_USAGE); if (mdb_walk("ttrace", (mdb_walk_cb_t)xctrace_walk, NULL) == -1) { mdb_warn("couldn't walk ttrace"); return (DCMD_ERR); } return (DCMD_OK); } /* * Grrr... xc_mbox isn't in an _impl header file; we define it here. */ typedef struct xc_mbox { xcfunc_t *xc_func; uint64_t xc_arg1; uint64_t xc_arg2; cpuset_t xc_cpuset; volatile uint_t xc_state; } xc_mbox_t; typedef struct xc_mbox_walk { int xw_ndx; uintptr_t xw_addr; xc_mbox_t *xw_mbox; } xc_mbox_walk_t; static int xc_mbox_walk_init(mdb_walk_state_t *wsp) { GElf_Sym sym; xc_mbox_walk_t *xw; if (mdb_lookup_by_name("xc_mbox", &sym) == -1) { mdb_warn("couldn't find 'xc_mbox'"); return (WALK_ERR); } if (fetch_ncpu() || fetch_mbox()) return (WALK_ERR); xw = mdb_zalloc(sizeof (xc_mbox_walk_t), UM_SLEEP); xw->xw_mbox = mdb_zalloc(mbox_size * ncpu, UM_SLEEP); if (mdb_readsym(xw->xw_mbox, mbox_size * ncpu, "xc_mbox") == -1) { mdb_warn("couldn't read 'xc_mbox'"); mdb_free(xw->xw_mbox, mbox_size * ncpu); mdb_free(xw, sizeof (xc_mbox_walk_t)); return (WALK_ERR); } xw->xw_addr = sym.st_value; wsp->walk_data = xw; return (WALK_NEXT); } static int xc_mbox_walk_step(mdb_walk_state_t *wsp) { xc_mbox_walk_t *xw = wsp->walk_data; int status; if (xw->xw_ndx == ncpu) return (WALK_DONE); status = wsp->walk_callback(xw->xw_addr, &xw->xw_mbox[xw->xw_ndx++], wsp->walk_cbdata); xw->xw_addr += mbox_size; return (status); } static void xc_mbox_walk_fini(mdb_walk_state_t *wsp) { xc_mbox_walk_t *xw = wsp->walk_data; mdb_free(xw->xw_mbox, mbox_size * ncpu); mdb_free(xw, sizeof (xc_mbox_walk_t)); } static int xc_mbox(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { xc_mbox_t *mbox; GElf_Sym sym; const char *state; if (argc != 0) return (DCMD_USAGE); if (!(flags & DCMD_ADDRSPEC)) { if (mdb_walk_dcmd("xc_mbox", "xc_mbox", argc, argv) == -1) { mdb_warn("can't walk 'xc_mbox'"); return (DCMD_ERR); } return (DCMD_OK); } if (fetch_ncpu() || fetch_mbox()) return (DCMD_ERR); if (DCMD_HDRSPEC(flags)) { mdb_printf("%3s %-8s %-8s %-9s %-16s %-16s %s\n", "CPU", "ADDR", "STATE", "CPUSET", "ARG1", "ARG2", "HNDLR"); } mbox = mdb_alloc(mbox_size, UM_SLEEP | UM_GC); if (mdb_vread(mbox, mbox_size, addr) == -1) { mdb_warn("couldn't read xc_mbox at %p", addr); return (DCMD_ERR); } if (mbox->xc_func == NULL) return (DCMD_OK); if (mdb_lookup_by_name("xc_mbox", &sym) == -1) { mdb_warn("couldn't read 'xc_mbox'"); return (DCMD_ERR); } state = mdb_ctf_enum_name(mbox_states, /* LINTED - alignment */ *(int *)((char *)mbox + mbox_stoff)); mdb_printf("%3d %08x %-8s [ ", (int)((addr - sym.st_value) / mbox_size), addr, state ? state : "XC_???"); print_cpuset_range((ulong_t *)&mbox->xc_cpuset, BT_BITOUL(ncpu), 5); mdb_printf(" ] %-16a %-16a %a\n", mbox->xc_arg1, mbox->xc_arg2, mbox->xc_func); return (DCMD_OK); } typedef struct vecint_walk_data { intr_vec_t **vec_table; uintptr_t vec_base; size_t vec_idx; size_t vec_size; } vecint_walk_data_t; int vecint_walk_init(mdb_walk_state_t *wsp) { vecint_walk_data_t *vecint; if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("vecint walk only supports global walks\n"); return (WALK_ERR); } vecint = mdb_zalloc(sizeof (vecint_walk_data_t), UM_SLEEP); vecint->vec_size = MAXIVNUM * sizeof (intr_vec_t *); vecint->vec_base = (uintptr_t)iv_sym.st_value; vecint->vec_table = mdb_zalloc(vecint->vec_size, UM_SLEEP); if (mdb_vread(vecint->vec_table, vecint->vec_size, vecint->vec_base) == -1) { mdb_warn("couldn't read intr_vec_table"); mdb_free(vecint->vec_table, vecint->vec_size); mdb_free(vecint, sizeof (vecint_walk_data_t)); return (WALK_ERR); } wsp->walk_data = vecint; return (WALK_NEXT); } int vecint_walk_step(mdb_walk_state_t *wsp) { vecint_walk_data_t *vecint = (vecint_walk_data_t *)wsp->walk_data; size_t max = vecint->vec_size / sizeof (intr_vec_t *); intr_vec_t iv; int status; if (wsp->walk_addr == (uintptr_t)NULL) { while ((vecint->vec_idx < max) && ((wsp->walk_addr = (uintptr_t)vecint->vec_table[vecint->vec_idx++]) == (uintptr_t)NULL)) continue; } if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, wsp->walk_cbdata); if (mdb_vread(&iv, sizeof (intr_vec_t), (uintptr_t)wsp->walk_addr) == -1) { mdb_warn("failed to read iv_p %p\n", wsp->walk_addr); return (WALK_ERR); } wsp->walk_addr = (uintptr_t)iv.iv_vec_next; return (status); } void vecint_walk_fini(mdb_walk_state_t *wsp) { vecint_walk_data_t *vecint = wsp->walk_data; mdb_free(vecint->vec_table, vecint->vec_size); mdb_free(vecint, sizeof (vecint_walk_data_t)); } int vecint_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { intr_vec_t iv; if (!(flags & DCMD_ADDRSPEC)) { if (mdb_walk_dcmd("vecint", "vecint", argc, argv) == -1) { mdb_warn("can't walk vecint"); return (DCMD_ERR); } return (DCMD_OK); } if (DCMD_HDRSPEC(flags)) { mdb_printf("%4s %?s %4s %?s %?s %s\n", "INUM", "ADDR", "PIL", "ARG1", "ARG2", "HANDLER"); } if (mdb_vread(&iv, sizeof (iv), addr) == -1) { mdb_warn("couldn't read intr_vec_table at %p", addr); return (DCMD_ERR); } mdb_printf("%4x %?p %4d %?p %?p %a\n", iv.iv_inum, addr, iv.iv_pil, iv.iv_arg1, iv.iv_arg2, iv.iv_handler); return (DCMD_OK); } int softint_walk_init(mdb_walk_state_t *wsp) { intr_vec_t *list; if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("softint walk only supports global walks\n"); return (WALK_ERR); } /* Read global softint linked list pointer */ if (mdb_readvar(&list, "softint_list") == -1) { mdb_warn("failed to read the global softint_list pointer\n"); return (WALK_ERR); } wsp->walk_addr = (uintptr_t)list; return (WALK_NEXT); } /*ARGSUSED*/ void softint_walk_fini(mdb_walk_state_t *wsp) { /* Nothing to do here */ } int softint_walk_step(mdb_walk_state_t *wsp) { intr_vec_t iv; int status; if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, wsp->walk_cbdata); if (mdb_vread(&iv, sizeof (intr_vec_t), (uintptr_t)wsp->walk_addr) == -1) { mdb_warn("failed to read iv_p %p\n", wsp->walk_addr); return (WALK_ERR); } wsp->walk_addr = (uintptr_t)iv.iv_vec_next; return (status); } int softint_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { intr_vec_t iv; if (!(flags & DCMD_ADDRSPEC)) { if (mdb_walk_dcmd("softint", "softint", argc, argv) == -1) { mdb_warn("can't walk softint"); return (DCMD_ERR); } return (DCMD_OK); } if (DCMD_HDRSPEC(flags)) { mdb_printf("%?s %4s %4s %4s %?s %?s %s\n", "ADDR", "TYPE", "PEND", "PIL", "ARG1", "ARG2", "HANDLER"); } if (mdb_vread(&iv, sizeof (iv), addr) == -1) { mdb_warn("couldn't read softint at %p", addr); return (DCMD_ERR); } mdb_printf("%?p %4s %4d %4d %?p %?p %a\n", addr, (iv.iv_flags & IV_SOFTINT_MT) ? "M" : "S", iv.iv_flags & IV_SOFTINT_PEND, iv.iv_pil, iv.iv_arg1, iv.iv_arg2, iv.iv_handler); return (DCMD_OK); } static int whatis_walk_tt(uintptr_t taddr, const trap_trace_fullrec_t *ttf, mdb_whatis_t *w) { uintptr_t cur = 0; while (mdb_whatis_match(w, taddr, sizeof (struct trap_trace_record), &cur)) mdb_whatis_report_object(w, cur, taddr, "trap trace record for cpu %d\n", ttf->ttf_cpu); return (WHATIS_WALKRET(w)); } /*ARGSUSED*/ static int whatis_run_traptrace(mdb_whatis_t *w, void *ignored) { GElf_Sym sym; if (mdb_lookup_by_name("trap_trace_ctl", &sym) == -1) return (0); if (mdb_walk("ttrace", (mdb_walk_cb_t)whatis_walk_tt, w) == -1) mdb_warn("failed to walk 'ttrace'"); return (0); } /*ARGSUSED*/ int mutex_owner_init(mdb_walk_state_t *wsp) { return (WALK_NEXT); } int mutex_owner_step(mdb_walk_state_t *wsp) { uintptr_t addr = wsp->walk_addr; mutex_impl_t mtx; uintptr_t owner; kthread_t thr; if (mdb_vread(&mtx, sizeof (mtx), addr) == -1) return (WALK_ERR); if (!MUTEX_TYPE_ADAPTIVE(&mtx)) return (WALK_DONE); if ((owner = (uintptr_t)MUTEX_OWNER(&mtx)) == (uintptr_t)NULL) return (WALK_DONE); if (mdb_vread(&thr, sizeof (thr), owner) != -1) (void) wsp->walk_callback(owner, &thr, wsp->walk_cbdata); return (WALK_DONE); } static const mdb_dcmd_t dcmds[] = { { "cpuset", ":[-l|-r]", "dump a cpuset_t", cmd_cpuset }, { "ttctl", NULL, "dump trap trace ctl records", ttctl }, { "ttrace", "[-x]", "dump trap trace buffer for a cpu", ttrace }, #ifdef sun4v { "httctl", NULL, "dump hv trap trace ctl records", httctl }, { "httrace", "[-x]", "dump hv trap trace buffer for a cpu", httrace }, #endif { "xc_mbox", "?", "dump xcall mboxes", xc_mbox }, { "xctrace", NULL, "dump xcall trace buffer", xctrace }, { "vecint", NULL, "display a registered hardware interrupt", vecint_dcmd }, { "softint", NULL, "display a registered software interrupt", softint_dcmd }, { "sfmmu_vtop", ":[[-v] -a as]", "print virtual to physical mapping", sfmmu_vtop }, { "memseg_list", ":", "show memseg list", memseg_list }, { "tsbinfo", ":[-l [-a]]", "show tsbinfo", tsbinfo_list, tsbinfo_help }, { NULL } }; static const mdb_walker_t walkers[] = { { "mutex_owner", "walks the owner of a mutex", mutex_owner_init, mutex_owner_step }, { "ttrace", "walks the trap trace buffer for a CPU", ttrace_walk_init, ttrace_walk_step, ttrace_walk_fini }, #ifdef sun4v { "httrace", "walks the hv trap trace buffer for a CPU", httrace_walk_init, httrace_walk_step, httrace_walk_fini }, #endif { "xc_mbox", "walks the cross call mail boxes", xc_mbox_walk_init, xc_mbox_walk_step, xc_mbox_walk_fini }, { "vecint", "walk the list of registered hardware interrupts", vecint_walk_init, vecint_walk_step, vecint_walk_fini }, { "softint", "walk the list of registered software interrupts", softint_walk_init, softint_walk_step, softint_walk_fini }, { "memseg", "walk the memseg structures", memseg_walk_init, memseg_walk_step, memseg_walk_fini }, { NULL } }; static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers }; const mdb_modinfo_t * _mdb_init(void) { if (mdb_lookup_by_name("intr_vec_table", &iv_sym) == -1) { mdb_warn("couldn't find intr_vec_table"); return (NULL); } mdb_whatis_register("traptrace", whatis_run_traptrace, NULL, WHATIS_PRIO_EARLY, WHATIS_REG_NO_ID); return (&modinfo); }
27.082418
75
0.630847
6fec7d63911c829d68cbefdc1487c8a595554f72
633
h
C
IoTHub-TempSensor/config.h
niswitze/Hot-Warm-Cold-On-Azure-IoT
8c77b7749301098c3d576a292f0f7b10b06e1c08
[ "MIT" ]
null
null
null
IoTHub-TempSensor/config.h
niswitze/Hot-Warm-Cold-On-Azure-IoT
8c77b7749301098c3d576a292f0f7b10b06e1c08
[ "MIT" ]
null
null
null
IoTHub-TempSensor/config.h
niswitze/Hot-Warm-Cold-On-Azure-IoT
8c77b7749301098c3d576a292f0f7b10b06e1c08
[ "MIT" ]
null
null
null
// Physical device information for board and sensor #define DEVICE_ID "ESP8226-TS1" #define DHTTYPE DHT11 // Pin layout configuration #define LED_PIN 16 #define TEMP_PIN 14 // Interval time(ms) for sending messages int WAIT_INTERVAL = 5000; // Telemetry type this device will send #define TELEMETRY_TYPE "temperature" //Default data rate to use for Serial #define DATA_RATE 115200 // EEPROM address configuration #define EEPROM_SIZE 512 // SSID and SSID password's length should < 32 bytes // http://serverfault.com/a/45509 #define SSID_LEN 32 #define PASS_LEN 32 #define CONNECTION_STRING_LEN 256 #define MESSAGE_MAX_LEN 256
22.607143
52
0.78515
a5cf1d4808b6bd650d0ffa878c6ace19bd029e38
8,454
h
C
thrift/lib/cpp2/async/ServerStreamMultiPublisher.h
killight98/fbthrift
c28d5036f96f7eab67c30abadc5ddbe627a11ee3
[ "Apache-2.0" ]
2,112
2015-01-02T11:34:27.000Z
2022-03-31T16:30:42.000Z
thrift/lib/cpp2/async/ServerStreamMultiPublisher.h
killight98/fbthrift
c28d5036f96f7eab67c30abadc5ddbe627a11ee3
[ "Apache-2.0" ]
372
2015-01-05T10:40:09.000Z
2022-03-31T20:45:11.000Z
thrift/lib/cpp2/async/ServerStreamMultiPublisher.h
killight98/fbthrift
c28d5036f96f7eab67c30abadc5ddbe627a11ee3
[ "Apache-2.0" ]
582
2015-01-03T01:51:56.000Z
2022-03-31T02:01:09.000Z
/* * Copyright (c) Facebook, Inc. and its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <folly/Synchronized.h> #include <folly/Try.h> #include <thrift/lib/cpp2/async/ServerPublisherStream.h> #include <thrift/lib/cpp2/async/ServerStream.h> #include <thrift/lib/cpp2/async/ServerStreamDetail.h> #include <thrift/lib/cpp2/async/StreamCallbacks.h> namespace apache { namespace thrift { template <typename T, bool WithHeader = false> class ServerStreamMultiPublisher { using ConditionalPayload = typename ServerStreamPublisher<T, WithHeader>::ConditionalPayload; using StreamPtr = typename detail::ServerPublisherStream<T, WithHeader>::Ptr; using StreamPtrMap = folly::F14FastMap<size_t, StreamPtr>; using EncodeToStreams = folly::Synchronized< folly::F14FastMap<detail::StreamElementEncoder<T>*, StreamPtrMap>>; static auto constexpr kPendingStreamsKey = nullptr; public: ServerStreamMultiPublisher() : encodeToStreams_(std::make_shared<EncodeToStreams>()) {} void next(ConditionalPayload payload) { encodeToStreams_->withRLock([=, payload = std::move(payload)]( const auto& map) { auto remaining = map.size(); for (auto& [encode, streams] : map) { bool canMove = --remaining == 0; ConditionalPayload copy = canMove ? std::move(payload) : payload; if (!encode) { publishAll(folly::Try<ConditionalPayload>(std::move(copy)), streams); continue; } if constexpr (WithHeader) { if (!copy.payload) { StreamPayloadMetadata md; md.otherMetadata_ref() = std::move(copy.metadata); auto sp = folly::Try<StreamPayload>( folly::in_place, nullptr, std::move(md)); publishAll(std::move(sp), streams); } else { folly::Try<StreamPayload> sp = (*encode)(std::move(*copy.payload)); sp->payload->coalesce(); sp->metadata.otherMetadata_ref() = std::move(copy.metadata); publishAll(std::move(sp), streams); } } else { auto encoded = (*encode)(std::move(copy)); encoded->payload->coalesce(); publishAll(std::move(encoded), streams); } } }); } void complete(folly::exception_wrapper ew) && { auto encodeToStreams = std::move(*std::exchange(encodeToStreams_, nullptr)->wlock()); auto remaining = encodeToStreams.size(); for (auto& [encode, streams] : encodeToStreams) { bool canMove = --remaining == 0; auto copy = canMove ? std::move(ew) : ew; if (!encode) { publishAll(folly::Try<ConditionalPayload>(std::move(copy)), streams); } else { publishAll((*encode)(std::move(copy)), streams); } } } void complete() && { auto encodeToStreams = std::move(*std::exchange(encodeToStreams_, nullptr)->wlock()); for (auto& [encode, streams] : encodeToStreams) { if (!encode) { publishAll(folly::Try<ConditionalPayload>{}, streams); } else { publishAll(folly::Try<StreamPayload>{}, streams); } } } ServerStream<T> addStream() { return addStream([] {}); } // Completion callback is optional // It must not call complete() on the publisher object inline ServerStream<T> addStream(folly::Function<void()> onStreamCompleteOrCancel) { auto streamIndex = createStreamIndex(); auto cb = [streamIndex, userCb = std::move(onStreamCompleteOrCancel), encodeToStreamsWeak = std::weak_ptr(encodeToStreams_)]() mutable { removeStream(std::move(encodeToStreamsWeak), streamIndex); userCb(); }; auto stream = new detail::ServerPublisherStream<T, WithHeader>(std::move(cb)); addStreamToMap(streamIndex, stream->copy()); return ServerStream<T>( [streamIndex, encodeToStreamsWeak = std::weak_ptr(encodeToStreams_), stream = std::unique_ptr< detail::ServerPublisherStream<T, WithHeader>, typename detail::ServerPublisherStream<T, WithHeader>:: CancelDeleter>(stream)]( folly::Executor::KeepAlive<> serverExecutor, detail::StreamElementEncoder<T>* encode) mutable { auto serverStreamFactory = detail::ServerPublisherStream<T, WithHeader>::establishStream( std::move(stream), std::move(serverExecutor), encode); provideEncodeFn(std::move(encodeToStreamsWeak), streamIndex, encode); return serverStreamFactory; }); } ServerStreamMultiPublisher(ServerStreamMultiPublisher&&) = default; ServerStreamMultiPublisher& operator=(ServerStreamMultiPublisher&& other) { if (&other != this) { CHECK(!encodeToStreams_ || allStreamsCompletedOrCancelled()) << "StreamMultiPublisher must be completed or all streams must be cancelled."; } encodeToStreams_ = std::move(other.encodeToStreams_); return *this; } ~ServerStreamMultiPublisher() { CHECK(!encodeToStreams_ || allStreamsCompletedOrCancelled()) << "StreamMultiPublisher must be completed or all streams must be cancelled."; } private: template <typename Payload> void publishAll(folly::Try<Payload>&& payload, const StreamPtrMap& streams) { auto remaining = streams.size(); for (auto& [_, stream] : streams) { if (--remaining == 0) { stream->publish(std::move(payload)); } else if (payload.hasException()) { folly::exception_wrapper copy; payload.exception().handle( [&](const detail::EncodedStreamError& err) { copy = folly::make_exception_wrapper<detail::EncodedStreamError>( err); }, [&](...) { copy = payload.exception(); }); stream->publish(folly::Try<Payload>(std::move(copy))); } else { stream->publish(folly::copy(payload)); } } } void addStreamToMap(size_t streamIndex, StreamPtr stream) { encodeToStreams_->withWLock([&](auto& map) mutable { map[kPendingStreamsKey][streamIndex] = std::move(stream); }); } static void removeStream( std::weak_ptr<EncodeToStreams> encodeToStreamsWeak, size_t streamIndex) { if (auto encodeToStreams = encodeToStreamsWeak.lock()) { encodeToStreams->withWLock([=](auto& map) { for (auto it = map.begin(); it != map.end();) { auto& streams = it->second; if (streams.erase(streamIndex)) { if (streams.empty()) { map.erase(it); } break; } } }); } } static void provideEncodeFn( std::weak_ptr<EncodeToStreams> encodeToStreamsWeak, size_t streamIndex, detail::StreamElementEncoder<T>* encodeFn) { if (auto encodeToStreams = encodeToStreamsWeak.lock()) { encodeToStreams->withWLock([=](auto& map) { auto& streamsMap = map[encodeFn]; map[kPendingStreamsKey].eraseInto( streamIndex, [&](size_t, StreamPtr&& stream) { streamsMap.emplace(streamIndex, std::move(stream)); }); if (map[kPendingStreamsKey].empty()) { map.erase(kPendingStreamsKey); } }); } } FOLLY_EXPORT size_t createStreamIndex() { static std::atomic<size_t> counter{0}; return counter.fetch_add(1, std::memory_order_relaxed); } bool allStreamsCompletedOrCancelled() { bool ret = true; encodeToStreams_->withRLock([&](const auto& map) { for (auto& [_, streams] : map) { for (auto& [_, stream] : streams) { if (!stream->wasCancelled()) { ret = false; return; } } } }); return ret; } std::shared_ptr<EncodeToStreams> encodeToStreams_; }; } // namespace thrift } // namespace apache
34.647541
88
0.626449
a5cf9f82e5e0d90c6ae7d10ea016d1d402235c7a
3,145
h
C
Userland/Applications/FontEditor/NewFontDialog.h
g-w1/serenity
42abda2a192677c8c1b0012129f36d4bd7970325
[ "BSD-2-Clause" ]
1
2021-06-11T14:38:19.000Z
2021-06-11T14:38:19.000Z
Userland/Applications/FontEditor/NewFontDialog.h
g-w1/serenity
42abda2a192677c8c1b0012129f36d4bd7970325
[ "BSD-2-Clause" ]
null
null
null
Userland/Applications/FontEditor/NewFontDialog.h
g-w1/serenity
42abda2a192677c8c1b0012129f36d4bd7970325
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (c) 2021, the SerenityOS developers * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include <LibGUI/Window.h> #include <LibGUI/Wizards/WizardDialog.h> #include <LibGUI/Wizards/WizardPage.h> #include <LibGfx/BitmapFont.h> class NewFontDialog final : public GUI::WizardDialog { C_OBJECT(NewFontDialog); public: auto new_font_metadata() { save_metadata(); return m_new_font_metadata; } private: NewFontDialog(GUI::Window* parent_window); void save_metadata(); RefPtr<Gfx::BitmapFont> m_font_clone; struct NewFontMetadata { u8 glyph_width; u8 glyph_height; u8 glyph_spacing; u8 baseline; u8 mean_line; u8 presentation_size; u16 weight; String name; String family; Gfx::FontTypes type; bool is_fixed_width; } m_new_font_metadata; RefPtr<GUI::WizardPage> m_font_selection_page; RefPtr<GUI::ComboBox> m_select_font_combobox; RefPtr<GUI::Button> m_browse_button; RefPtr<GUI::WizardPage> m_font_properties_page; RefPtr<GUI::TextBox> m_name_textbox; RefPtr<GUI::TextBox> m_family_textbox; RefPtr<GUI::ComboBox> m_type_combobox; RefPtr<GUI::Label> m_type_info_label; RefPtr<GUI::ComboBox> m_weight_combobox; RefPtr<GUI::SpinBox> m_presentation_spinbox; RefPtr<GUI::WizardPage> m_glyph_properties_page; RefPtr<GUI::Widget> m_glyph_editor_container; RefPtr<GUI::SpinBox> m_glyph_height_spinbox; RefPtr<GUI::SpinBox> m_glyph_width_spinbox; RefPtr<GUI::SpinBox> m_baseline_spinbox; RefPtr<GUI::SpinBox> m_mean_line_spinbox; RefPtr<GUI::SpinBox> m_spacing_spinbox; RefPtr<GUI::CheckBox> m_fixed_width_checkbox; Vector<String> m_font_list; Vector<String> m_font_type_list; Vector<String> m_font_weight_list; };
34.944444
81
0.736407
9d5102a28be0c55473e3df2ed51cb3420934b65a
518
h
C
tests/FFSprite.h
zxzAndyMAC/FFmpegPlayer
a20a5c03381096bcbb050176e584d933f57468c1
[ "MIT" ]
1
2022-02-15T01:24:44.000Z
2022-02-15T01:24:44.000Z
tests/FFSprite.h
zxzAndyMAC/FFmpegPlayer
a20a5c03381096bcbb050176e584d933f57468c1
[ "MIT" ]
null
null
null
tests/FFSprite.h
zxzAndyMAC/FFmpegPlayer
a20a5c03381096bcbb050176e584d933f57468c1
[ "MIT" ]
null
null
null
#ifndef _FF_SPRITE_H_ #define _FF_SPRITE_H_ #include "cocos2d.h" #include <IFFmpeg.h> USING_NS_CC; class FFSprite : public Sprite { public: static FFSprite* create(); FFSprite(); ~FFSprite(); virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override final; void play(); void pause(); void replay(); void seek(double time); private: bool start = false; bool first = true; unsigned int refreshcount = 0; size_t readsize; char* buffer; FFMPEG::FFHandle id_1; }; #endif
14.388889
93
0.716216
77e254af3bf2c8eaa6f07e88d9911a81d7650473
1,667
c
C
virtualization/process_api/q8.c
yaiba/ostep-qa
999654741016ed290d7736433ce9724b485adce6
[ "MIT" ]
null
null
null
virtualization/process_api/q8.c
yaiba/ostep-qa
999654741016ed290d7736433ce9724b485adce6
[ "MIT" ]
null
null
null
virtualization/process_api/q8.c
yaiba/ostep-qa
999654741016ed290d7736433ce9724b485adce6
[ "MIT" ]
null
null
null
/* Write a program that creates two children, and connects the standard output of one to the standard input of the other, using the pipe() system call. pipe 是单向的数据流,有两个端(int fd[2] 就是两个文件描述符, 支持一般的文件描述操作),一端接受输入(write),一端提供输出(read) 单独一个进程建立pipe一般没什么用处,一般都会再fork一个子进程(子进程会继承/拷贝父进程的变量,文件描述符就在子进程也就能使用了),两个进程来通信(IPC) 当前进程把不使用的文件描述符close掉 fd[0] for reading, fd[1] for writing. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> char* cmd1[] = {"echo", "left?right", NULL}; char* cmd2[] = {"tr", "a-z", "A-Z", NULL}; void setup_src(int* pfd){ int rc = fork(); if (rc == -1){ fprintf(stderr, "fork failed\n"); exit(1); } else if (rc == 0) { printf("hello, i'm the src process (pid: %d)\n", getpid()); // duplicate stdout with pfd[1] dup2(pfd[1], STDOUT_FILENO); close(pfd[0]); execvp(cmd1[0], cmd1); } else { return; } } void setup_dst(int* pfd){ int rc = fork(); if (rc == -1){ fprintf(stderr, "fork failed\n"); exit(1); } else if (rc == 0) { printf("hello, i'm the dst process (pid: %d)\n", getpid()); dup2(pfd[0], STDIN_FILENO); close(pfd[1]); execvp(cmd2[0], cmd2); printf("dsf process done....\n"); } else { return; } } int main(int argc, char* argv[]){ printf("hello, i'm the entry process (pid: %d)\n", getpid()); int fd[2]; int pid, status; pipe(fd); setup_dst(fd); setup_src(fd); close(fd[0]); close(fd[1]); while ((pid = wait(&status)) != -1) fprintf(stderr, "process %d exits with %d\n", pid, WEXITSTATUS(status)); exit(0); }
24.880597
81
0.570486
992faef2056a1e0b30245f44f86476351f1d066e
632
h
C
myV2/Main/Controller/TabsViewController.h
Lneayce/v2ex-station
41cd4e432307c09e80c9b90feaa65fcfe0961301
[ "MIT" ]
1
2016-11-18T12:15:30.000Z
2016-11-18T12:15:30.000Z
myV2/Main/Controller/TabsViewController.h
Lneayce/v2ex-station
41cd4e432307c09e80c9b90feaa65fcfe0961301
[ "MIT" ]
null
null
null
myV2/Main/Controller/TabsViewController.h
Lneayce/v2ex-station
41cd4e432307c09e80c9b90feaa65fcfe0961301
[ "MIT" ]
null
null
null
// // TabsViewController.h // myV2 // // Created by Mac on 16/9/5. // Copyright © 2016年 Lneayce. All rights reserved. // #import <UIKit/UIKit.h> /** * 通知 */ #define TabViewDidSelectTabNotifacation @"TabViewDidSelectTabNotifacation" #define TabViewSelectedTabTypeUserinfoKey @"TabViewSelectedTabTypeUserinfoKey" //#define TabViewDidSelectInfoBtnNotification @"TabViewDidSelectInfoBtnNotification" //#define TabViewSelectedInfoBtnUserInfoKey @"TabViewSelectedInfoBtnUserInfoKey" @class MMDrawerController; @interface TabsViewController : UITableViewController @property (nonatomic, weak) MMDrawerController *drawer; @end
30.095238
84
0.799051
9938e56983fa30498a044d83ad8b2076021a7c90
978
h
C
Engine/Plugins/Compositing/Composure/Source/Composure/Private/ComposurePlayerCompositingCameraModifier.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Plugins/Compositing/Composure/Source/Composure/Private/ComposurePlayerCompositingCameraModifier.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Plugins/Compositing/Composure/Source/Composure/Private/ComposurePlayerCompositingCameraModifier.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "UObject/Object.h" #include "Classes/Camera/CameraModifier.h" #include "ComposurePlayerCompositingCameraModifier.generated.h" /** * Private camera manager for UComposurePlayerCompositingTarget. */ UCLASS(NotBlueprintType) class UComposurePlayerCompositingCameraModifier : public UCameraModifier , public IBlendableInterface { GENERATED_UCLASS_BODY() public: // Begins UCameraModifier bool ModifyCamera(float DeltaTime, FMinimalViewInfo& InOutPOV) override; // Ends UCameraModifier // Begins IBlendableInterface void OverrideBlendableSettings(class FSceneView& View, float Weight) const override; // Ends IBlendableInterface private: // Current player camera manager the target is bind on. UPROPERTY(Transient) class UComposurePlayerCompositingTarget* Target; friend class UComposurePlayerCompositingTarget; };
25.076923
85
0.807771
3fbfb35fa4fef74d308bc7948c4a2eb2f6bd92e6
14,100
c
C
SampleCode/StdDriver/I2S_WAVPLAYER/main.c
OpenNuvoton/NUC472_442BSP
92e487e8e53b807b27708d5022129dfa13b38249
[ "Apache-2.0" ]
8
2017-01-24T06:47:13.000Z
2021-11-10T09:05:38.000Z
SampleCode/StdDriver/I2S_WAVPLAYER/main.c
OpenNuvoton/NUC472_442BSP
92e487e8e53b807b27708d5022129dfa13b38249
[ "Apache-2.0" ]
7
2018-12-10T13:06:54.000Z
2019-11-29T17:12:59.000Z
SampleCode/StdDriver/I2S_WAVPLAYER/main.c
OpenNuvoton/NUC472_442BSP
92e487e8e53b807b27708d5022129dfa13b38249
[ "Apache-2.0" ]
3
2017-10-17T15:30:48.000Z
2018-12-21T07:04:00.000Z
/**************************************************************************//** * @file main.c * @version V1.00 * $Revision: 12 $ * $Date: 15/12/08 9:47a $ * @brief This is a WAV file player which plays back WAV file stored in * USB pen drive. * * @note * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ #include <stdio.h> #include <string.h> #include "NUC472_442.h" #include "config.h" #include "diskio.h" #include "ff.h" #include "usbh_core.h" #include "usbh_umas.h" #define NAU8822_ADDR 0x1A /* NAU8822 Device ID */ #define PLLCON_SETTING 0x4228 #define PLL_CLOCK 84000000 DMA_DESC_T DMA_DESC[2]; uint32_t PllClock = PLL_CLOCK; //uint32_t PcmBuff[BUFF_LEN] = {0}; uint32_t volatile u32BuffPos = 0; FATFS FatFs[_VOLUMES]; /* File system object for logical drive */ #ifdef __ICCARM__ #pragma data_alignment=32 BYTE Buff[1024] ; /* Working buffer */ DMA_DESC_T DMA_DESC[2]; #else BYTE Buff[1024] __attribute__((aligned(32))); /* Working buffer */ DMA_DESC_T DMA_DESC[2] __attribute__((aligned(32))); #endif uint8_t bAudioPlaying = 0; extern signed int aPCMBuffer[2][PCM_BUFFER_SIZE]; /*---------------------------------------------------------*/ /* User Provided RTC Function for FatFs module */ /*---------------------------------------------------------*/ /* This is a real time clock service to be called from */ /* FatFs module. Any valid time must be returned even if */ /* the system does not support an RTC. */ /* This function is not required in read-only cfg. */ unsigned long get_fattime (void) { unsigned long tmr; tmr=0x00000; return tmr; } void Delay(int count) { volatile uint32_t i; for (i = 0; i < count ; i++); } /*---------------------------------------------------------------------------------------------------------*/ /* Write 9-bit data to 7-bit address register of WAU8822 with I2C0 */ /*---------------------------------------------------------------------------------------------------------*/ void I2C_WriteWAU8822(uint8_t u8addr, uint16_t u16data) { I2C_START(I2C3); I2C_WAIT_READY(I2C3); I2C_SET_DATA(I2C3, NAU8822_ADDR<<1); I2C_SET_CONTROL_REG(I2C3, I2C_SI); I2C_WAIT_READY(I2C3); I2C_SET_DATA(I2C3, (uint8_t)((u8addr << 1) | (u16data >> 8))); I2C_SET_CONTROL_REG(I2C3, I2C_SI); I2C_WAIT_READY(I2C3); I2C_SET_DATA(I2C3, (uint8_t)(u16data & 0x00FF)); I2C_SET_CONTROL_REG(I2C3, I2C_SI); I2C_WAIT_READY(I2C3); I2C_STOP(I2C3); } void WAU8822_ConfigSampleRate(uint32_t u32SampleRate) { if((u32SampleRate % 8) == 0) { I2C_WriteWAU8822(36, 0x008); //12.288Mhz I2C_WriteWAU8822(37, 0x00C); I2C_WriteWAU8822(38, 0x093); I2C_WriteWAU8822(39, 0x0E9); } else { I2C_WriteWAU8822(36, 0x007); //11.2896Mhz I2C_WriteWAU8822(37, 0x021); I2C_WriteWAU8822(38, 0x131); I2C_WriteWAU8822(39, 0x026); } switch (u32SampleRate) { case 16000: I2C_WriteWAU8822(6, 0x1AD); /* Divide by 6, 16K */ I2C_WriteWAU8822(7, 0x006); /* 16K for internal filter coefficients */ break; case 32000: I2C_WriteWAU8822(6, 0x16D); /* Divide by 3, 32K */ I2C_WriteWAU8822(7, 0x002); /* 32K for internal filter coefficients */ break; case 44100: case 48000: I2C_WriteWAU8822(6, 0x14D); /* Divide by 1, 48K */ I2C_WriteWAU8822(7, 0x000); /* 48K for internal filter coefficients */ break; } } /*---------------------------------------------------------------------------------------------------------*/ /* WAU8822 Settings with I2C interface */ /*---------------------------------------------------------------------------------------------------------*/ void WAU8822_Setup() { printf("\nConfigure WAU8822 ..."); I2C_WriteWAU8822(0, 0x000); /* Reset all registers */ Delay(0x200); I2C_WriteWAU8822(1, 0x02F); I2C_WriteWAU8822(2, 0x1B3); /* Enable L/R Headphone, ADC Mix/Boost, ADC */ I2C_WriteWAU8822(3, 0x07F); /* Enable L/R main mixer, DAC */ // offset: 0x4 => default, 24bit, I2S format, Stereo I2C_WriteWAU8822(4, 0x010); /* 16-bit word length, I2S format, Stereo */ I2C_WriteWAU8822(5, 0x000); /* Companding control and loop back mode (all disable) */ I2C_WriteWAU8822(6, 0x1AD); /* Divide by 6, 16K */ I2C_WriteWAU8822(7, 0x006); /* 16K for internal filter coefficients */ I2C_WriteWAU8822(10, 0x008); /* DAC soft mute is disabled, DAC oversampling rate is 128x */ I2C_WriteWAU8822(14, 0x108); /* ADC HP filter is disabled, ADC oversampling rate is 128x */ I2C_WriteWAU8822(15, 0x1EF); /* ADC left digital volume control */ I2C_WriteWAU8822(16, 0x1EF); /* ADC right digital volume control */ I2C_WriteWAU8822(44, 0x000); /* LLIN/RLIN is not connected to PGA */ I2C_WriteWAU8822(47, 0x050); /* LLIN connected, and its Gain value */ I2C_WriteWAU8822(48, 0x050); /* RLIN connected, and its Gain value */ I2C_WriteWAU8822(50, 0x001); /* Left DAC connected to LMIX */ I2C_WriteWAU8822(51, 0x001); /* Right DAC connected to RMIX */ printf("[OK]\n"); } void SYS_Init(void) { /*---------------------------------------------------------------------------------------------------------*/ /* Init System Clock */ /*---------------------------------------------------------------------------------------------------------*/ /* Unlock protected registers */ SYS_UnlockReg(); /* Enable External XTAL (4~24 MHz) */ CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk); /* Waiting for 12MHz clock ready */ CLK_WaitClockReady( CLK_STATUS_HXTSTB_Msk); /* Switch HCLK clock source to HXT */ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HXT,CLK_CLKDIV0_HCLK(1)); /* Set PLL to power down mode and PLL_STB bit in CLKSTATUS register will be cleared by hardware.*/ CLK->PLLCTL |= CLK_PLLCTL_PD_Msk; /* Set PLL frequency */ CLK->PLLCTL = PLLCON_SETTING; /* Waiting for clock ready */ CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk); /* Switch HCLK clock source to PLL */ CLK->CLKSEL0 = CLK_CLKSEL0_HCLKSEL_PLL; /* Enable IP clock */ CLK_EnableModuleClock(UART0_MODULE); CLK_EnableModuleClock(TMR0_MODULE); CLK_EnableModuleClock(I2C3_MODULE); CLK_EnableModuleClock(I2S1_MODULE); CLK_EnableModuleClock(PDMA_MODULE); /* Select IP clock source */ CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UARTSEL_HXT, CLK_CLKDIV0_UART(1)); CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0SEL_HXT, 0); /* Update System Core Clock */ /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */ SystemCoreClockUpdate(); PllClock = PLL_CLOCK; // PLL SystemCoreClock = PLL_CLOCK / 1; // HCLK CyclesPerUs = PLL_CLOCK / 1000000; // For SYS_SysTickDelay() /*---------------------------------------------------------------------------------------------------------*/ /* Init USB Host clock */ /*---------------------------------------------------------------------------------------------------------*/ SYS->USBPHY |= SYS_USBPHY_LDO33EN_Msk; // Configure OTG function as OTG SYS->USBPHY |= 0x3; // Enable OTG CLK->APBCLK0 |= CLK_APBCLK0_OTGCKEN_Msk; OTG->PHYCTL = (OTG->PHYCTL | OTG_PHYCTL_OTGPHYEN_Msk) & ~OTG_PHYCTL_IDDETEN_Msk; OTG->CTL |= OTG_CTL_OTGEN_Msk | OTG_CTL_BUSREQ_Msk; // Multi-function PB.0 OTG_5V status, PB.1 OTG_5V enable SYS->GPB_MFPL = (SYS->GPB_MFPL & ~(SYS_GPB_MFPL_PB0MFP_USB0_OTG5V_ST | SYS_GPB_MFPL_PB1MFP_USB0_OTG5V_EN)) | 0x11; // Multi-function (PB.2,PB.3) for USB port 2 (D-,D+) SYS->GPB_MFPL = (SYS->GPB_MFPL & ~(SYS_GPB_MFPL_PB2MFP_USB1_D_N | SYS_GPB_MFPL_PB3MFP_USB1_D_P)) | 0x3300; // Set PB.4 output high to enable USB power SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB4MFP_Msk; PB->MODE = (PB->MODE & ~GPIO_MODE_MODE4_Msk) | (0x1 << GPIO_MODE_MODE4_Pos); PB->DOUT |= 0x10; // Enable PLL2, 480 MHz / 2 / (1+4) => 48 MHz output CLK->PLL2CTL = (4 << CLK_PLL2CTL_PLL2DIV_Pos); // wait PLL2 stable... while (!(CLK->STATUS & CLK_STATUS_PLL2STB_Msk)); // USB clock divided by 1 CLK->CLKDIV0 = (CLK->CLKDIV0 & ~CLK_CLKDIV0_USBHDIV_Msk) | (0 << CLK_CLKDIV0_USBHDIV_Pos); // Select USB Host clock source from PLL2 CLK->CLKSEL0 &= ~CLK_CLKSEL0_USBHSEL_Msk; // Enable USB Host CLK->AHBCLK |= CLK_AHBCLK_USBHCKEN_Msk; /*---------------------------------------------------------------------------------------------------------*/ /* Init I/O Multi-function */ /*---------------------------------------------------------------------------------------------------------*/ /* Set GPG multi-function pins for UART0 RXD and TXD */ SYS->GPG_MFPL |= SYS_GPG_MFPL_PG1MFP_UART0_RXD | SYS_GPG_MFPL_PG2MFP_UART0_TXD ; /* Set GPH3,GPH4 multi-function pins for I2C3 */ SYS->GPH_MFPL |= SYS_GPH_MFPL_PH3MFP_I2C3_SCL | SYS_GPH_MFPL_PH4MFP_I2C3_SDA ; /* Set multi function pin for I2S1 */ /* GPG7, GPG8, GPG9, GPI11, GPI12 */ SYS->GPG_MFPL = (SYS->GPG_MFPL & ~SYS_GPG_MFPL_PG7MFP_Msk) | SYS_GPG_MFPL_PG7MFP_I2S1_MCLK; SYS->GPG_MFPH = (SYS->GPG_MFPH & ~(SYS_GPG_MFPH_PG8MFP_Msk | SYS_GPG_MFPH_PG9MFP_Msk)) | (SYS_GPG_MFPH_PG8MFP_I2S1_DO | SYS_GPG_MFPH_PG9MFP_I2S1_DI); SYS->GPI_MFPH = (SYS->GPI_MFPH & ~(SYS_GPI_MFPH_PI11MFP_Msk | SYS_GPI_MFPH_PI12MFP_Msk)) | (SYS_GPI_MFPH_PI11MFP_I2S1_BCLK | SYS_GPI_MFPH_PI12MFP_I2S1_LRCK); /* Lock protected registers */ SYS_LockReg(); } void I2C3_Init(void) { /* Open I2C3 and set clock to 100k */ I2C_Open(I2C3, 100000); /* Get I2C3 Bus Clock */ printf("I2C clock %d Hz\n", I2C_GetBusClockFreq(I2C3)); /* Set I2C3 4 Slave Addresses */ I2C_SetSlaveAddr(I2C3, 0, 0x15, I2C_GCMODE_DISABLE); /* Slave Address : 0x15 */ I2C_SetSlaveAddr(I2C3, 1, 0x35, I2C_GCMODE_DISABLE); /* Slave Address : 0x35 */ I2C_SetSlaveAddr(I2C3, 2, 0x55, I2C_GCMODE_DISABLE); /* Slave Address : 0x55 */ I2C_SetSlaveAddr(I2C3, 3, 0x75, I2C_GCMODE_DISABLE); /* Slave Address : 0x75 */ } void PDMA_Init(void) { DMA_DESC[0].ctl = ((PCM_BUFFER_SIZE-1)<<PDMA_DSCT_CTL_TXCNT_Pos)|PDMA_WIDTH_32|PDMA_SAR_INC|PDMA_DAR_FIX|PDMA_REQ_SINGLE|PDMA_OP_SCATTER; DMA_DESC[0].endsrc = (uint32_t)&aPCMBuffer[0][0] + PCM_BUFFER_SIZE * 4; DMA_DESC[0].enddest = (uint32_t)&I2S1->TX; DMA_DESC[0].offset = (uint32_t)&DMA_DESC[1] - (PDMA->SCATBA); DMA_DESC[1].ctl = ((PCM_BUFFER_SIZE-1)<<PDMA_DSCT_CTL_TXCNT_Pos)|PDMA_WIDTH_32|PDMA_SAR_INC|PDMA_DAR_FIX|PDMA_REQ_SINGLE|PDMA_OP_SCATTER; DMA_DESC[1].endsrc = (uint32_t)&aPCMBuffer[1][0] + PCM_BUFFER_SIZE * 4; DMA_DESC[1].enddest = (uint32_t)&I2S1->TX; DMA_DESC[1].offset = (uint32_t)&DMA_DESC[0] - (PDMA->SCATBA); PDMA_Open(1 << 2); PDMA_SetTransferMode(2, PDMA_I2S1_TX, 1, (uint32_t)&DMA_DESC[0]); PDMA_EnableInt(2, 0); NVIC_EnableIRQ(PDMA_IRQn); } void PDMA_Reset_SCTable(uint8_t id) { DMA_DESC[id].ctl |= PDMA_OP_SCATTER; DMA_DESC[id].ctl |= ((PCM_BUFFER_SIZE-1)<<PDMA_DSCT_CTL_TXCNT_Pos); } /*---------------------------------------------------------------------------------------------------------*/ /* Main Function */ /*---------------------------------------------------------------------------------------------------------*/ int32_t main (void) { /* Init System, IP clock and multi-function I/O */ SYS_Init(); /* Init UART to 115200-8n1 for print message */ UART_Open(UART0, 115200); printf("+------------------------------------------------------------------------+\n"); printf("| I2S Driver Sample Code with WAU8822 |\n"); printf("+------------------------------------------------------------------------+\n"); printf(" NOTE: This sample code needs to work with WAU8822.\n"); /* Configure USB Host */ USBH_Open(); // Configure OTG function as Dual Role SYS_UnlockReg(); SYS->USBPHY = 0x102; USBH_MassInit(); Delay(0x500000); USBH_ProcessHubEvents(); /* Configure FATFS */ printf("rc=%d\n", (WORD)disk_initialize(0)); disk_read(0, Buff, 2, 1); f_mount(&FatFs[0], 0, 1); /* Init I2C3 to access WAU8822 */ I2C3_Init(); /* Configure as I2S slave */ I2S_Open(I2S1, I2S_MODE_SLAVE, 16000, I2S_DATABIT_16, I2S_STEREO, I2S_FORMAT_I2S, I2S_I2S); NVIC_EnableIRQ(I2S0_IRQn); // select source from HXT(12MHz) CLK_SetModuleClock(I2S1_MODULE, CLK_CLKSEL3_I2S1SEL_HXT, 0); /* Initialize WAU8822 codec */ WAU8822_Setup(); /* Set MCLK and enable MCLK */ I2S_EnableMCLK(I2S1, 12000000); /* Configure PDMA and use Scatter-Gather mode */ PDMA_Init(); // Plug-In DET, enable sound output (I3) SYS->GPI_MFPL = (SYS->GPI_MFPL & ~(SYS_GPI_MFPL_PI3MFP_Msk)); GPIO_SetMode(GPI, BIT3, GPIO_MODE_OUTPUT); PI3 = 0; WAVPlayer(); while(1); } /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
37.700535
162
0.540709
8bcd9423e0b91069a2082d61a8f025d9b02f9fed
336
h
C
src/lua-exports/ExportBox2d.h
SundeepK/Clone
7386f8d6f9ebb49babdcc08c3bd5dda701e89e9b
[ "MIT" ]
null
null
null
src/lua-exports/ExportBox2d.h
SundeepK/Clone
7386f8d6f9ebb49babdcc08c3bd5dda701e89e9b
[ "MIT" ]
null
null
null
src/lua-exports/ExportBox2d.h
SundeepK/Clone
7386f8d6f9ebb49babdcc08c3bd5dda701e89e9b
[ "MIT" ]
null
null
null
#ifndef EXPORTBOX2D_H_ #define EXPORTBOX2D_H_ #include "ExportableToLua.h" #include <memory.h> class ExportBox2d : public ExportableToLua{ public: ExportBox2d(); ~ExportBox2d(); void exportToLua(lua_State *myLuaState); private: class ExportBox2dImpl; std::unique_ptr<ExportBox2dImpl> m_impl; }; #endif /* EXPORTBOX2D_H_ */
14.608696
43
0.761905
6bc70facfb24d09967886e3da5fad10137604ab2
5,192
c
C
components/mqtt_middle_ware/mqtt_ctrl_subscription.c
glenn-edgar/esp32_gateway
5dc4a65eeb2226b6a6529c91a5491df7080b853f
[ "MIT" ]
2
2019-01-21T09:03:51.000Z
2019-02-04T06:51:34.000Z
components/mqtt_middle_ware/mqtt_ctrl_subscription.c
glenn-edgar/esp32_lua
e71ed4e48b78b7e67b6a35eb7ad1e35a81f639da
[ "MIT" ]
null
null
null
components/mqtt_middle_ware/mqtt_ctrl_subscription.c
glenn-edgar/esp32_lua
e71ed4e48b78b7e67b6a35eb7ad1e35a81f639da
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdint.h> #include <stddef.h> #include <string.h> #include "esp_wifi.h" #include "esp_system.h" #include "nvs_flash.h" #include "esp_event_loop.h" #include "lwip/sockets.h" #include "lwip/dns.h" #include "lwip/netdb.h" #include "esp_log.h" #include "mqtt_client.h" #include "mqtt_ctrl_load_setup_data.h" #include "wifi_station_setup.h" #include "mqtt_ctrl.h" #include "mqtt_heartbeat.h" #include "message_processor.h" #include "mqtt_ctrl_subscription.h" #define SUBSCRIPTION_MAX 32 typedef struct { SUBSCRITION_FUNCTION sub_function; char *topic; // variable will be malloced }SUBSCRIPTION_TABLE; static uint32_t subscription_number; static SUBSCRIPTION_TABLE subscription_table[SUBSCRIPTION_MAX]; static char *base_topic; static bool check_for_duplicates_sub_table(char *topic ); static void process_builtin_commands (esp_mqtt_client_handle_t mqtt_client, uint32_t topic_len, char *topic, uint32_t data_len, char *data ); void mqtt_initialize_subscriptions(char *base_top) { base_topic = base_top; subscription_number = 0; memset(subscription_table,0,sizeof(subscription_table)); mqtt_ctrl_register_subscription("BUILT_IN_CMD", process_builtin_commands); initialize_mqtt_heart_beat(); } void mqtt_ctrl_register_subscription(char *topic, SUBSCRITION_FUNCTION topic_function ) { uint32_t size; char *ref_topic; if( subscription_number >= SUBSCRIPTION_MAX ) { abort(); // ran out of table space } if( check_for_duplicates_sub_table(topic) == true) { abort(); // all ready in table } size = strlen(base_topic)+strlen(topic)+1; ref_topic = malloc(size); strcpy(ref_topic,base_topic); strcat(ref_topic,topic); subscription_table[subscription_number].sub_function = topic_function; subscription_table[subscription_number].topic = ref_topic; mqtt_clt_subscribe(ref_topic); subscription_number +=1; } void mqtt_ctl_restore_subscriptions(esp_mqtt_client_handle_t mqtt_client) { printf("restore subscriptions %d \n",subscription_number); for(int i = 0;i<subscription_number;i++ ) { printf("topic is %i %s \n",i,subscription_table[i].topic); mqtt_clt_subscribe(subscription_table[i].topic); } } void mqtt_ctl_handle_data(esp_mqtt_client_handle_t mqtt_client, uint32_t topic_len, char *topic, uint32_t data_len, char *data ) { for(int i=0;i<subscription_number;i++) { //printf("%.*s %s \n",topic_len,topic,subscription_table[i].topic); if(strlen(subscription_table[i].topic)!= topic_len) { continue; } if( strncmp(subscription_table[i].topic,topic,topic_len) == 0) { //printf("topic match \n"); subscription_table[i].sub_function(mqtt_client, topic_len, topic,data_len,data); return; } } printf("no match \n"); //abort(); // topic function not detected } /* Static Data */ static bool check_for_duplicates_sub_table(char *topic ) { int topic_len; topic_len = strlen(topic); for(int i=0;i<subscription_number;i++) { if(strlen(subscription_table[i].topic)!= topic_len) { break; } if( strncmp(subscription_table[i].topic,topic,topic_len) == 0) { return true; } } return false; } static void process_builtin_commands (esp_mqtt_client_handle_t mqtt_client, uint32_t topic_len, char *topic, uint32_t data_len, char *data ) { int msg_pack_number; MSG_PACK_ELEMENT *msg_pack_buffer; char *pack_buffer; int pack_buffer_size; if( message_processor(&msg_pack_number,&msg_pack_buffer, data,data_len) == true) { pack_buffer = msg_dict_stream( &pack_buffer_size,msg_pack_number,msg_pack_buffer); mqtt_clt_publish("BUILT_IN_CMD_REPLY", pack_buffer,pack_buffer_size); free(pack_buffer); } else { ;// printf("no message processor match\n"); } if( msg_pack_number > 0) { free(msg_pack_buffer); } }
24.72381
95
0.54584
6bd1aed41979d6841113df445d607414ad72c272
2,270
h
C
data/frameProcessor/include/PercivalProcess3Plugin.h
percival-detector/percival-detector
54e490b2f5aacfbae1955f7f29fd8c2fc2446d22
[ "Apache-2.0" ]
null
null
null
data/frameProcessor/include/PercivalProcess3Plugin.h
percival-detector/percival-detector
54e490b2f5aacfbae1955f7f29fd8c2fc2446d22
[ "Apache-2.0" ]
14
2017-06-22T10:47:15.000Z
2020-11-11T09:11:37.000Z
data/frameProcessor/include/PercivalProcess3Plugin.h
percival-detector/percival-detector
54e490b2f5aacfbae1955f7f29fd8c2fc2446d22
[ "Apache-2.0" ]
2
2019-11-12T16:54:46.000Z
2020-03-10T10:31:19.000Z
#ifndef TOOLS_FILEWRITER_PERCIVALPROCESS3PLUGIN_H_ #define TOOLS_FILEWRITER_PERCIVALPROCESS3PLUGIN_H_ #include <log4cxx/logger.h> #include <log4cxx/basicconfigurator.h> #include <log4cxx/propertyconfigurator.h> #include <log4cxx/helpers/exception.h> using namespace log4cxx; using namespace log4cxx::helpers; #include "FrameProcessorPlugin.h" #include "PercivalTransport.h" #include "ClassLoader.h" namespace FrameProcessor { /** Processing of Percival Frame objects. * * The PercivalProcess3Plugin class is responsible for receiving a raw data * Frame object and parsing the header information, splitting the raw data into * the two "data" and "reset" Frame objects. * This one does minimal processing, and is designed for use with the * descramber-board which does all the work. It needs to be elaborated to get * the improvements in Plugin0. */ class PercivalProcess3Plugin : public FrameProcessorPlugin { public: PercivalProcess3Plugin(); virtual ~PercivalProcess3Plugin(); void configure(OdinData::IpcMessage &config, OdinData::IpcMessage &reply); void configureProcess(OdinData::IpcMessage &config, OdinData::IpcMessage &reply); bool reset_statistics(); int get_version_major(); int get_version_minor(); int get_version_patch(); std::string get_version_short(); std::string get_version_long(); private: /** Configuration constant for process related items */ static const std::string CONFIG_PROCESS; /** Configuration constant for number of processes */ static const std::string CONFIG_PROCESS_NUMBER; /** Configuration constant for this process rank */ static const std::string CONFIG_PROCESS_RANK; void process_frame(boost::shared_ptr<Frame> frame); /** Pointer to logger */ LoggerPtr logger_; size_t concurrent_processes_; size_t concurrent_rank_; /* Frame counter */ uint32_t frame_counter_; }; /** * Registration of this plugin through the ClassLoader. This macro * registers the class without needing to worry about name mangling */ REGISTER(FrameProcessorPlugin, PercivalProcess3Plugin, "PercivalProcess3Plugin"); } /* namespace FrameProcessor */ #endif /* TOOLS_FILEWRITER_PERCIVALPROCESSPLUGIN_H_ */
31.971831
85
0.750661
df5bf8108709bb8520f43d92d5009d59eff2954e
4,232
h
C
nntrainer/dataset/data_producer.h
SIJUN0725/nntrainer
d22eeaa6591bedeff2480fc7853ebca60ebaa80c
[ "Apache-2.0" ]
91
2020-03-24T06:52:34.000Z
2022-03-27T18:56:32.000Z
nntrainer/dataset/data_producer.h
SIJUN0725/nntrainer
d22eeaa6591bedeff2480fc7853ebca60ebaa80c
[ "Apache-2.0" ]
1,815
2020-03-24T08:15:43.000Z
2022-03-31T09:14:47.000Z
nntrainer/dataset/data_producer.h
SIJUN0725/nntrainer
d22eeaa6591bedeff2480fc7853ebca60ebaa80c
[ "Apache-2.0" ]
45
2020-03-24T06:17:05.000Z
2022-03-28T23:47:12.000Z
// SPDX-License-Identifier: Apache-2.0 /** * Copyright (C) 2021 Jihoon Lee <jhoon.it.lee@samsung.com> * * @file data_producer.h * @date 09 July 2021 * @brief This file contains data producer interface * @see https://github.com/nnstreamer/nntrainer * @author Jihoon Lee <jhoon.it.lee@samsung.com> * @bug No known bugs except for NYI items * */ #ifndef __DATA_PRODUCER_H__ #define __DATA_PRODUCER_H__ #include <functional> #include <limits> #include <string> #include <tuple> #include <vector> #include <tensor.h> #include <tensor_dim.h> namespace nntrainer { class Exporter; enum class ExportMethods; /** * @brief DataProducer interface used to abstract data provider * */ class DataProducer { public: /** * @brief generator callable type which will fill a sample * @param[in] index current index with range of [0, size() - 1]. If * size() == SIZE_UNDEFINED, this parameter can be ignored * @param[out] inputs allocate tensor before expected to be filled by this * function * @param[out] labels allocate tensor before expected to be filled by this * function function. * @return bool true if this is the last sample, samples will NOT be ignored * and should be used, or passed at will of caller * */ using Generator = std::function<bool(unsigned int, /** index */ std::vector<Tensor> & /** inputs */, std::vector<Tensor> & /** labels */)>; constexpr inline static unsigned int SIZE_UNDEFINED = std::numeric_limits<unsigned int>::max(); /** * @brief Destroy the Data Loader object * */ virtual ~DataProducer() {} /** * @brief Get the producer type * @return const std::string type representation */ virtual const std::string getType() const = 0; /** * @brief Set the Property object * * @param properties properties to set */ virtual void setProperty(const std::vector<std::string> &properties) { if (!properties.empty()) { throw std::invalid_argument("There are unparsed properties"); } } /** * @brief finalize the class to return an immutable Generator. * @remark this function must assume that the batch dimension of each tensor * dimension is one. If actual dimension is not one, this function must ignore * the batch dimension and assume it to be one. * @param input_dims input dimensions. * @param label_dims label dimensions. * @param user_data user data to be used when finalize. * @return Generator generator is a function that generates a sample upon * call. */ virtual Generator finalize(const std::vector<TensorDim> &input_dims, const std::vector<TensorDim> &label_dims, void *user_data = nullptr) { return Generator(); } /** * @brief get the number of samples inside the dataset, if size * cannot be determined, this function must return. * DataProducer::SIZE_UNDEFINED. * @remark this function must assume that the batch dimension of each tensor * dimension is one. If actual dimension is not one, this function must ignore * the batch dimension and assume it to be one * @param input_dims input dimensions * @param label_dims label dimensions * * @return size calculated size */ virtual unsigned int size(const std::vector<TensorDim> &input_dims, const std::vector<TensorDim> &label_dims) const { return SIZE_UNDEFINED; } /** * @brief this function helps exporting the dataproducer in a predefined * format, while workarounding issue caused by templated function type eraser * * @param exporter exporter that conatins exporting logic * @param method enum value to identify how it should be exported to */ virtual void exportTo(Exporter &exporter, const ExportMethods &method) const { } /** * @brief denote if given producer is thread safe and can be parallelized. * @note if size() == SIZE_UNDEFIEND, thread safe shall be false * * @return bool true if thread safe. */ virtual bool isMultiThreadSafe() const { return false; } }; } // namespace nntrainer #endif // __DATA_PRODUCER_H__
32.305344
80
0.672495
d4fe54ca608a45d7381102237089252ebdf01405
385
c
C
A08/print.c
trinitykleckner/assignments
1f1b1d361b391e55701a45fa1b5fd58a6056c276
[ "MIT" ]
null
null
null
A08/print.c
trinitykleckner/assignments
1f1b1d361b391e55701a45fa1b5fd58a6056c276
[ "MIT" ]
null
null
null
A08/print.c
trinitykleckner/assignments
1f1b1d361b391e55701a45fa1b5fd58a6056c276
[ "MIT" ]
null
null
null
//#include <stdlib.h> #include <stdio.h> #include <unistd.h> //#include <time.h> int main (int argc, char* argv[]) { void* initial = sbrk(0); printf("The initial top of the heap is %p\n",initial); void* current = sbrk(0); printf("The current top of the heap is %p\n",current); printf("Increased by %ld (%#lx) bytes\n", current - initial, current - initial); return 0; }
24.0625
82
0.641558
1db8af21645f6164be8fc3839c262146c5d7f31a
1,324
h
C
lib/include/encrypt_api.h
developer-kikikaikai/EncryptedEditor
138494aef72f154bfc64b01f530b2c8729895b29
[ "MIT" ]
null
null
null
lib/include/encrypt_api.h
developer-kikikaikai/EncryptedEditor
138494aef72f154bfc64b01f530b2c8729895b29
[ "MIT" ]
4
2019-03-06T16:41:11.000Z
2019-03-23T02:28:44.000Z
lib/include/encrypt_api.h
developer-kikikaikai/EncryptedEditor
138494aef72f154bfc64b01f530b2c8729895b29
[ "MIT" ]
null
null
null
/** * * @file encrypt_api.h * * @brief This is API to encrypt/decrypt datas * **/ #ifndef ENCDYPT_API_H_ #define ENCDYPT_API_H_ #ifdef __cplusplus extern "C" { #endif /*! __cplusplus */ typedef enum { ENC_API_ENCRYPT_TYPE_AES256_CBC, ENC_API_ENCRYPT_TYPE_ARIA128_CBC, ENC_API_ENCRYPT_TYPE_CAMELLIA256_CBC, ENC_API_ENCRYPT_TYPE_CHACHA20, ENC_API_ENCRYPT_TYPE_CHACHA20_POLY1305, } enc_api_encrypt_type_e; /** * @brief encrypt * @param[in] type encryption type * @param[in] src_buf source buffer * @param[in] src_len source length * @param[out] result_buf encrypted data buffer * @return encrypted data length. error if return negative value * @note please release result_buf by using free */ int enc_api_encrypt(enc_api_encrypt_type_e type, const unsigned char *src_buf, int src_len, unsigned char ** result_buf); /** * @brief decrypt * @param[in] type encryption type * @param[in] src_buf source buffer * @param[in] src_len source length * @param[out] result_buf encrypted data buffer * @return encrypted data length. error if return negative value * @note please release result_buf by using free */ int enc_api_decrypt(enc_api_encrypt_type_e type, const unsigned char *src_buf, int src_len, unsigned char ** result_buf); #ifdef __cplusplus } #endif /*! __cplusplus */ #endif/*ENCDYPT_API_H_*/
32.292683
121
0.76284
3d98f2da0775faaf4c77ed408feb905c5aa37d87
1,399
c
C
src/timer/timer.c
ifzz/Love
e35b0805e08b02f7d04503e3d21efd32d64a86db
[ "MIT" ]
8
2016-11-03T04:11:17.000Z
2021-11-14T20:26:32.000Z
src/timer/timer.c
ifzz/Love
e35b0805e08b02f7d04503e3d21efd32d64a86db
[ "MIT" ]
null
null
null
src/timer/timer.c
ifzz/Love
e35b0805e08b02f7d04503e3d21efd32d64a86db
[ "MIT" ]
2
2019-10-08T04:31:25.000Z
2020-02-01T19:06:15.000Z
#ifdef EMSCRIPTEN # include <emscripten.h> #else # include <SDL.h> #endif #include "timer.h" static float const FpsUpdateTimeout = 1.0f; static struct { float averageDeltaTime; float lastFpsUpdate; float currentTime; float deltaTime; float fps; int frames; } moduleData; float timer_getTime(void) { #ifdef EMSCRIPTEN return emscripten_get_now() / 1000.0f; #else return SDL_GetTicks() / 1000.0f; #endif } void timer_step(void) { ++moduleData.frames; float last = moduleData.currentTime; moduleData.currentTime = timer_getTime(); moduleData.deltaTime = moduleData.currentTime - last; float timeSinceLastUpdate = moduleData.currentTime - moduleData.lastFpsUpdate; if(timeSinceLastUpdate > FpsUpdateTimeout) { moduleData.averageDeltaTime = timeSinceLastUpdate / moduleData.frames; moduleData.fps = moduleData.frames / timeSinceLastUpdate; moduleData.lastFpsUpdate = moduleData.currentTime; moduleData.frames = 0; } } float timer_getFPS(void) { return moduleData.fps; } float timer_getDelta(void) { return moduleData.deltaTime; } float timer_getAverageDelta(void) { return moduleData.averageDeltaTime; } void timer_init() { float now = timer_getTime(); moduleData.averageDeltaTime = 0.0; moduleData.lastFpsUpdate = now; moduleData.currentTime = now; moduleData.deltaTime = 0.0f; moduleData.fps = 0.0f; moduleData.frames = 0; }
21.523077
80
0.746247
4bfda92416d5d8357e1e80f65e3347769ab04388
1,105
h
C
SubtitlesWidgets_struct.h
NotDiscordOfficial/Fortnite_SDK
58f8da148256f99cb35518003306fffee33c4a21
[ "MIT" ]
null
null
null
SubtitlesWidgets_struct.h
NotDiscordOfficial/Fortnite_SDK
58f8da148256f99cb35518003306fffee33c4a21
[ "MIT" ]
null
null
null
SubtitlesWidgets_struct.h
NotDiscordOfficial/Fortnite_SDK
58f8da148256f99cb35518003306fffee33c4a21
[ "MIT" ]
1
2021-07-22T00:31:44.000Z
2021-07-22T00:31:44.000Z
// Enum SubtitlesWidgets.ESubtitleDisplayBackgroundOpacity enum class ESubtitleDisplayBackgroundOpacity : uint8 { Clear, Low, Medium, High, Solid, ESubtitleDisplayBackgroundOpacity_MAX, }; // Enum SubtitlesWidgets.ESubtitleDisplayTextBorder enum class ESubtitleDisplayTextBorder : uint8 { None, Outline, DropShadow, ESubtitleDisplayTextBorder_MAX, }; // Enum SubtitlesWidgets.ESubtitleDisplayTextColor enum class ESubtitleDisplayTextColor : uint8 { White, Yellow, ESubtitleDisplayTextColor_MAX, }; // Enum SubtitlesWidgets.ESubtitleDisplayTextSize enum class ESubtitleDisplayTextSize : uint8 { ExtraSmall, Small, Medium, Large, ExtraLarge, ESubtitleDisplayTextSize_MAX, }; // ScriptStruct SubtitlesWidgets.SubtitleFormat // Size: 0x04 (Inherited: 0x00) struct FSubtitleFormat { enum class ESubtitleDisplayTextSize SubtitleTextSize; // 0x00(0x01) enum class ESubtitleDisplayTextColor SubtitleTextColor; // 0x01(0x01) enum class ESubtitleDisplayTextBorder SubtitleTextBorder; // 0x02(0x01) enum class ESubtitleDisplayBackgroundOpacity SubtitleBackgroundOpacity; // 0x03(0x01) };
24.555556
86
0.817195
ef8836a9dfb06686175dd63bf5f681a600e35c5b
2,076
h
C
Pyt/qpy/QtCore/qpycore_pyqtproperty.h
sonerkcardak/python-detailed-assistant
161b82289c5ae7149fe638ba6a5192b6aa6833d8
[ "Apache-2.0" ]
null
null
null
Pyt/qpy/QtCore/qpycore_pyqtproperty.h
sonerkcardak/python-detailed-assistant
161b82289c5ae7149fe638ba6a5192b6aa6833d8
[ "Apache-2.0" ]
null
null
null
Pyt/qpy/QtCore/qpycore_pyqtproperty.h
sonerkcardak/python-detailed-assistant
161b82289c5ae7149fe638ba6a5192b6aa6833d8
[ "Apache-2.0" ]
null
null
null
// This contains the definitions for the implementation of pyqtProperty. // // Copyright (c) 2020 Riverbank Computing Limited <info@riverbankcomputing.com> // // This file is part of PyQt5. // // This file may be used under the terms of the GNU General Public License // version 3.0 as published by the Free Software Foundation and appearing in // the file LICENSE included in the packaging of this file. Please review the // following information to ensure the GNU General Public License version 3.0 // requirements will be met: http://www.gnu.org/copyleft/gpl.html. // // If you do not wish to use this file under the terms of the GPL version 3.0 // then you may purchase a commercial license. For more information contact // info@riverbankcomputing.com. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #ifndef _QPYCORE_PYQTPROPERTY_H #define _QPYCORE_PYQTPROPERTY_H #include <Python.h> class Chimera; extern "C" { // This defines the structure of a PyQt property. typedef struct { PyObject_HEAD // The fget/getter/read callable. PyObject *pyqtprop_get; // The fset/setter/write callable. PyObject *pyqtprop_set; // The fdel/deleter callable. PyObject *pyqtprop_del; // The docstring. PyObject *pyqtprop_doc; // The freset/reset callable. PyObject *pyqtprop_reset; // The notify signal. PyObject *pyqtprop_notify; // The property type. PyObject *pyqtprop_type; // The parsed type information. const Chimera *pyqtprop_parsed_type; // The DESIGNABLE, SCRIPTABLE, STORED, USER, CONSTANT and FINAL flags. unsigned pyqtprop_flags; // The REVISION. int pyqtprop_revision; // The property's sequence number that determines the position of the // property in the QMetaObject. uint pyqtprop_sequence; } qpycore_pyqtProperty; } // The type object. extern PyTypeObject *qpycore_pyqtProperty_TypeObject; bool qpycore_pyqtProperty_init_type(); #endif
25.012048
79
0.733141
c71012e874c0df0bbd3abb5838fd0b732f92b6f9
1,179
h
C
src/Parsers/ParserRolesOrUsersSet.h
lizhichao/ClickHouse
3f5dc37095ccca18de490fab162d6e3cb99756aa
[ "Apache-2.0" ]
18
2021-05-29T01:12:33.000Z
2021-11-18T12:34:48.000Z
src/Parsers/ParserRolesOrUsersSet.h
lizhichao/ClickHouse
3f5dc37095ccca18de490fab162d6e3cb99756aa
[ "Apache-2.0" ]
16
2021-06-07T21:32:30.000Z
2022-03-31T21:08:29.000Z
src/Parsers/ParserRolesOrUsersSet.h
lizhichao/ClickHouse
3f5dc37095ccca18de490fab162d6e3cb99756aa
[ "Apache-2.0" ]
2
2021-07-13T06:42:45.000Z
2021-07-21T13:47:22.000Z
#pragma once #include <Parsers/IParserBase.h> namespace DB { /** Parses a string like this: * {role|CURRENT_USER} [,...] | NONE | ALL | ALL EXCEPT {role|CURRENT_USER} [,...] */ class ParserRolesOrUsersSet : public IParserBase { public: ParserRolesOrUsersSet & allowAll(bool allow_all_ = true) { allow_all = allow_all_; return *this; } ParserRolesOrUsersSet & allowUserNames(bool allow_user_names_ = true) { allow_user_names = allow_user_names_; return *this; } ParserRolesOrUsersSet & allowRoleNames(bool allow_role_names_ = true) { allow_role_names = allow_role_names_; return *this; } ParserRolesOrUsersSet & allowCurrentUser(bool allow_current_user_ = true) { allow_current_user = allow_current_user_; return *this; } ParserRolesOrUsersSet & useIDMode(bool id_mode_ = true) { id_mode = id_mode_; return *this; } protected: const char * getName() const override { return "RolesOrUsersSet"; } bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; private: bool allow_all = false; bool allow_user_names = false; bool allow_role_names = false; bool allow_current_user = false; bool id_mode = false; }; }
35.727273
137
0.728584
6079a9b4f4968e008287d6861cd92903177293d9
3,422
h
C
include/SDL/SDL_syswm.h
bazelregistry/sdl12-compat
f1a2e795230d9d3c68d60afbee772e8fa707e0e9
[ "Zlib" ]
null
null
null
include/SDL/SDL_syswm.h
bazelregistry/sdl12-compat
f1a2e795230d9d3c68d60afbee772e8fa707e0e9
[ "Zlib" ]
null
null
null
include/SDL/SDL_syswm.h
bazelregistry/sdl12-compat
f1a2e795230d9d3c68d60afbee772e8fa707e0e9
[ "Zlib" ]
null
null
null
/* Simple DirectMedia Layer Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* These headers are from sdl12-compat, and are intended to give just enough functionality to let you build an SDL-1.2-based project without having the real SDL-1.2 available to you. */ #ifndef _SDL_syswm_h #define _SDL_syswm_h #include "SDL_stdinc.h" #include "SDL_error.h" #include "SDL_version.h" #ifndef SDL_PROTOTYPES_ONLY # if defined(__WIN32__) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include <windows.h> # include "begin_code.h" typedef struct SDL_SysWMmsg { SDL_version version; HWND hwnd; UINT msg; WPARAM wParam; LPARAM lParam; } SDL_SysWMmsg; typedef struct SDL_SysWMinfo { SDL_version version; HWND window; HGLRC hglrc; } SDL_SysWMinfo; # include "close_code.h" # elif defined(unix) /* shrug */ # ifdef __APPLE__ # define Cursor X11Cursor # endif # include <X11/Xlib.h> # include <X11/Xatom.h> # ifdef __APPLE__ # undef Cursor # endif # include "begin_code.h" typedef enum SDL_SYSWM_TYPE { SDL_SYSWM_X11 } SDL_SYSWM_TYPE; typedef struct SDL_SysWMmsg { SDL_version version; SDL_SYSWM_TYPE subsystem; union { XEvent xevent; } event; } SDL_SysWMmsg; typedef struct SDL_SysWMinfo { SDL_version version; SDL_SYSWM_TYPE subsystem; union { struct { Display *display; Window window; void (*lock_func)(void); void (*unlock_func)(void); Window fswindow; Window wmwindow; Display *gfxdisplay; } x11; } info; } SDL_SysWMinfo; # include "close_code.h" # else # include "begin_code.h" typedef struct SDL_SysWMmsg { SDL_version version; int data; } SDL_SysWMmsg; typedef struct SDL_SysWMinfo { SDL_version version; int data; } SDL_SysWMinfo; # include "close_code.h" # endif #endif #include "begin_code.h" extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); #include "close_code.h" #endif
25.348148
76
0.601403
902b6aa6e1f90950f61d601c3eb268ab7f590363
576
h
C
Library/Models/MARMenuItem.h
rsumner31/Marvin
135ff6b1b67229d4216d0520c201301b5c9dc942
[ "MIT" ]
null
null
null
Library/Models/MARMenuItem.h
rsumner31/Marvin
135ff6b1b67229d4216d0520c201301b5c9dc942
[ "MIT" ]
1
2015-12-30T10:03:29.000Z
2015-12-30T10:03:29.000Z
Library/Models/MARMenuItem.h
zenangst/Marvin
68388c4f46d84f9560db1cc64a7fa7f19550a2e8
[ "MIT" ]
null
null
null
// // MARMenuItem.h // Marvin // // Created by Christoffer Winterkvist on 14/07/14. // // #import <Foundation/Foundation.h> #import "MarvinManager.h" @interface MARMenuItem : NSObject @property (nonatomic, strong) NSString *title; @property (nonatomic, strong) NSString *submenu; @property (nonatomic, strong) NSString *keyEquivalent; @property (nonatomic, copy) void (^command)(); - (instancetype)initWithTitle:(NSString *)title submenu:(NSString *)submenu keyEquivalent:(NSString *)binding command:(void (^)(MarvinManager *manager))command; + (NSArray *)items; @end
25.043478
160
0.734375
b0d28d1c3e461ce2a2b9cc7d7b8318260fb021a0
524
c
C
FromSlides/C/13_sync_with_flush.c
WarwickRSE/OpenMPExamples
bc0c1fbfbe26932102da518feeb52aea5def57c4
[ "BSD-3-Clause" ]
1
2021-09-16T16:37:17.000Z
2021-09-16T16:37:17.000Z
FromSlides/C/13_sync_with_flush.c
WarwickRSE/OpenMPExamples
bc0c1fbfbe26932102da518feeb52aea5def57c4
[ "BSD-3-Clause" ]
null
null
null
FromSlides/C/13_sync_with_flush.c
WarwickRSE/OpenMPExamples
bc0c1fbfbe26932102da518feeb52aea5def57c4
[ "BSD-3-Clause" ]
null
null
null
/*NOTE THIS CODE DOESN'T WORK*/ #include <stdio.h> #include <omp.h> int main(){ int data; int flag; flag = 0; data = 0; #pragma omp parallel if(omp_get_thread_num() == 0) { //Thread 0 sets the payload and sets the flag data = 42; flag = 1; #pragma omp flush(data, flag) } else { //On all other threads wait until the flag is set while (!flag){ #pragma omp flush(flag) } #pragma omp flush(data) printf("Thread %i got payload %i\n", omp_get_thread_num(), data); } }
18.714286
69
0.604962
8e366c1a8748c7e92269393743c00dba3caa2595
177
h
C
include/il2cpp/Dpr/Battle/Logic/Section_ViewEffect/Result.h
martmists-gh/BDSP
d6326c5d3ad9697ea65269ed47aa0b63abac2a0a
[ "MIT" ]
1
2022-01-15T20:20:27.000Z
2022-01-15T20:20:27.000Z
include/il2cpp/Dpr/Battle/Logic/Section_ViewEffect/Result.h
martmists-gh/BDSP
d6326c5d3ad9697ea65269ed47aa0b63abac2a0a
[ "MIT" ]
null
null
null
include/il2cpp/Dpr/Battle/Logic/Section_ViewEffect/Result.h
martmists-gh/BDSP
d6326c5d3ad9697ea65269ed47aa0b63abac2a0a
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp.h" void Dpr_Battle_Logic_Section_ViewEffect_Result___ctor (Dpr_Battle_Logic_Section_ViewEffect_Result_o* __this, const MethodInfo* method_info);
29.5
141
0.864407
b802d88ee26fd2e85526a6bc9e50fee36eecf6f5
717
h
C
src/p3d/renderer/d3d11/d3d11_ConstConvert.h
AlexandrSachkov/Prototype3D
1cf705973a8d9137014935686b7fcb034ab95123
[ "MIT" ]
null
null
null
src/p3d/renderer/d3d11/d3d11_ConstConvert.h
AlexandrSachkov/Prototype3D
1cf705973a8d9137014935686b7fcb034ab95123
[ "MIT" ]
null
null
null
src/p3d/renderer/d3d11/d3d11_ConstConvert.h
AlexandrSachkov/Prototype3D
1cf705973a8d9137014935686b7fcb034ab95123
[ "MIT" ]
null
null
null
#pragma once #include "../../Constants.h" #include <d3d11.h> namespace p3d { namespace d3d11 { bool convertBindFlag(P3D_BIND_FLAG flag, D3D11_BIND_FLAG& d3d11Flag); struct UsageDesc { D3D11_USAGE usage; D3D11_CPU_ACCESS_FLAG cpuAccessFlag; }; bool convertUsageFlag(P3D_USAGE flag, UsageDesc& usageDesc); bool convertFillMode(P3D_FILL_MODE fill, D3D11_FILL_MODE& d3d11Fill); bool convertCullMode(P3D_CULL_MODE cull, D3D11_CULL_MODE& d3d11Cull); bool convertTextureMapMode(P3D_TEX_MAP_MODE mode, D3D11_TEXTURE_ADDRESS_MODE& d3d11MapMode); D3D11_PRIMITIVE_TOPOLOGY convertPrimitiveTopology(P3D_PRIMITIVE_TOPOLOGY tp); } }
35.85
100
0.72106
5224886a09f9ed19df69f0954afebdee2f45ee3c
1,874
h
C
src/vgmtrans-qt/QtVGMRoot.h
sykhro/vgmtrans-qt
6d0780bdaaac29ffe118b9be2e2ad87401b426fe
[ "Zlib" ]
18
2018-01-04T17:42:15.000Z
2021-05-26T02:52:22.000Z
src/vgmtrans-qt/QtVGMRoot.h
sykhro/vgmtrans-qt
6d0780bdaaac29ffe118b9be2e2ad87401b426fe
[ "Zlib" ]
6
2017-10-19T16:47:19.000Z
2021-09-10T15:26:24.000Z
src/vgmtrans-qt/QtVGMRoot.h
sykhro/vgmtrans-qt
6d0780bdaaac29ffe118b9be2e2ad87401b426fe
[ "Zlib" ]
1
2017-10-19T16:40:12.000Z
2017-10-19T16:40:12.000Z
/* * VGMTrans (c) 2002-2019 * Licensed under the zlib license, * refer to the included LICENSE.txt file */ #pragma once #include <QObject> #include "Root.h" class QtVGMRoot : public QObject, public VGMRoot { Q_OBJECT public: virtual void UI_SetRootPtr(VGMRoot **theRoot); virtual void UI_PreExit(); virtual void UI_Exit(); virtual void UI_AddRawFile(RawFile *newFile); virtual void UI_CloseRawFile(RawFile *targFile); virtual void UI_OnBeginScan(); virtual void UI_SetScanInfo(); virtual void UI_OnEndScan(); virtual void UI_AddVGMFile(VGMFile *theFile); virtual void UI_AddVGMSeq(VGMSeq *theSeq); virtual void UI_AddVGMInstrSet(VGMInstrSet *theInstrSet); virtual void UI_AddVGMSampColl(VGMSampColl *theSampColl); virtual void UI_AddVGMMisc(VGMMiscFile *theMiscFile); virtual void UI_AddVGMColl(VGMColl *theColl); virtual void UI_RemoveVGMColl(VGMColl *targColl); virtual void UI_BeginRemoveVGMFiles(); virtual void UI_EndRemoveVGMFiles(); virtual void UI_AddItemSet(VGMFile *file, std::vector<ItemSet> *itemset); virtual std::string UI_GetOpenFilePath(const std::string &suggestedFilename = "", const std::string &extension = ""); virtual std::string UI_GetSaveFilePath(const std::string &suggestedFilename, const std::string &extension = ""); virtual std::string UI_GetSaveDirPath(const std::string &suggestedDir = ""); signals: void UI_AddedRawFile(); void UI_RemovedRawFile(); void UI_AddedVGMFile(); void UI_RemovedVGMFile(); void UI_AddedVGMColl(); void UI_RemovedVGMColl(); void UI_RemoveVGMFile(VGMFile *targFile); void UI_AddItem(VGMItem *item, VGMItem *parent, const std::string &itemName, void *UI_specific); }; extern QtVGMRoot qtVGMRoot;
35.358491
100
0.700107
26f0d365b12a87ebaecff7b3271048b0bdeedfcb
3,106
c
C
drivers/disk/sdmmc_subsys.c
ldalek/zephyr
fa2054f93e4e80b079a4a6a9e84d642e51912042
[ "Apache-2.0" ]
1
2022-02-23T09:03:56.000Z
2022-02-23T09:03:56.000Z
drivers/disk/sdmmc_subsys.c
ldalek/zephyr
fa2054f93e4e80b079a4a6a9e84d642e51912042
[ "Apache-2.0" ]
3
2021-10-14T04:32:03.000Z
2021-11-12T09:02:16.000Z
drivers/disk/sdmmc_subsys.c
ldalek/zephyr
fa2054f93e4e80b079a4a6a9e84d642e51912042
[ "Apache-2.0" ]
1
2018-07-07T11:14:38.000Z
2018-07-07T11:14:38.000Z
/* * Copyright 2022 NXP * * SPDX-License-Identifier: Apache-2.0 */ /* * SDMMC disk driver using zephyr SD subsystem */ #define DT_DRV_COMPAT zephyr_sdmmc_disk #include <zephyr/sd/sdmmc.h> #include <zephyr/drivers/disk.h> enum sd_status { SD_UNINIT, SD_ERROR, SD_OK, }; struct sdmmc_config { const struct device *host_controller; }; struct sdmmc_data { struct sd_card card; enum sd_status status; char *name; }; static int disk_sdmmc_access_init(struct disk_info *disk) { const struct device *dev = disk->dev; const struct sdmmc_config *cfg = dev->config; struct sdmmc_data *data = dev->data; int ret; if (data->status == SD_OK) { /* Called twice, don't reinit */ return 0; } if (!sd_is_card_present(cfg->host_controller)) { return DISK_STATUS_NOMEDIA; } ret = sd_init(cfg->host_controller, &data->card); if (ret) { data->status = SD_ERROR; return ret; } data->status = SD_OK; return 0; } static int disk_sdmmc_access_status(struct disk_info *disk) { const struct device *dev = disk->dev; const struct sdmmc_config *cfg = dev->config; struct sdmmc_data *data = dev->data; if (!sd_is_card_present(cfg->host_controller)) { return DISK_STATUS_NOMEDIA; } if (data->status == SD_OK) { return DISK_STATUS_OK; } else { return DISK_STATUS_UNINIT; } } static int disk_sdmmc_access_read(struct disk_info *disk, uint8_t *buf, uint32_t sector, uint32_t count) { const struct device *dev = disk->dev; struct sdmmc_data *data = dev->data; return sdmmc_read_blocks(&data->card, buf, sector, count); } static int disk_sdmmc_access_write(struct disk_info *disk, const uint8_t *buf, uint32_t sector, uint32_t count) { const struct device *dev = disk->dev; struct sdmmc_data *data = dev->data; return sdmmc_write_blocks(&data->card, buf, sector, count); } static int disk_sdmmc_access_ioctl(struct disk_info *disk, uint8_t cmd, void *buf) { const struct device *dev = disk->dev; struct sdmmc_data *data = dev->data; return sdmmc_ioctl(&data->card, cmd, buf); } static const struct disk_operations sdmmc_disk_ops = { .init = disk_sdmmc_access_init, .status = disk_sdmmc_access_status, .read = disk_sdmmc_access_read, .write = disk_sdmmc_access_write, .ioctl = disk_sdmmc_access_ioctl, }; static struct disk_info sdmmc_disk = { .ops = &sdmmc_disk_ops, }; static int disk_sdmmc_init(const struct device *dev) { struct sdmmc_data *data = dev->data; data->status = SD_UNINIT; sdmmc_disk.dev = dev; sdmmc_disk.name = data->name; return disk_access_register(&sdmmc_disk); } #define DISK_ACCESS_SDMMC_INIT(n) \ static const struct sdmmc_config sdmmc_config_##n = { \ .host_controller = DEVICE_DT_GET(DT_INST_PARENT(n)), \ }; \ \ static struct sdmmc_data sdmmc_data_##n = { \ .name = CONFIG_SDMMC_VOLUME_NAME, \ }; \ \ DEVICE_DT_INST_DEFINE(n, \ &disk_sdmmc_init, \ NULL, \ &sdmmc_data_##n, \ &sdmmc_config_##n, \ POST_KERNEL, \ CONFIG_SDMMC_INIT_PRIORITY, \ NULL); DT_INST_FOREACH_STATUS_OKAY(DISK_ACCESS_SDMMC_INIT)
21.873239
82
0.702833
f8646f50e5354543da1a854684817e3bf58d1070
291
c
C
Chapter14/23_Typedef_B/main.c
jmhong-simulation/tbc-workbook
e342856573537e89472a12f1d3fc373c8a227949
[ "Unlicense" ]
35
2020-05-17T04:26:19.000Z
2022-03-01T03:05:10.000Z
Chapter14/23_Typedef_B/main.c
learner-nosilv/TBC-workbook
77365b2ed482a7695a64283c846e67b88dd66f64
[ "Unlicense" ]
null
null
null
Chapter14/23_Typedef_B/main.c
learner-nosilv/TBC-workbook
77365b2ed482a7695a64283c846e67b88dd66f64
[ "Unlicense" ]
16
2020-05-27T10:29:10.000Z
2022-03-01T03:05:19.000Z
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> /* "One good way to synthesize declarations is in small steps with typedef, ..." - K&R book Chapter 5.12 */ /* Complicated Function Declarations */ /* Use typedef to make declarations simpler */ int main() { return 0; }
10.034483
46
0.676976
f8e1199645baeb60b17fdcbf1b7456bb5cc1b4c4
1,628
h
C
PrivateFrameworks/FileProvider/FPXEnumerator.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/FileProvider/FPXEnumerator.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/FileProvider/FPXEnumerator.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" #import "FPXEnumerator.h" @class FPItemID, FPXDomainContext, NSString; @interface FPXEnumerator : NSObject <FPXEnumerator> { FPXDomainContext *_domainContext; id <NSFileProviderEnumerator> _vendorEnumerator; FPItemID *_observedItemID; BOOL _invalidated; BOOL _forceFileURLs; id <FPXEnumeratorObserver> _observer; } @property(readonly) id <FPXEnumeratorObserver> observer; // @synthesize observer=_observer; - (void).cxx_destruct; - (void)enumeratorBecameFrontmost:(BOOL)arg1 inWindow:(id)arg2 completionHandler:(CDUnknownBlockType)arg3; - (void)keepAliveConnectionForRegisteredObserver:(CDUnknownBlockType)arg1; - (void)alternateContentsWereUpdatedAtURL:(id)arg1 forItem:(id)arg2; @property(readonly) FPItemID *observedItemID; - (void)enumerateChangesFromToken:(id)arg1 reply:(CDUnknownBlockType)arg2; - (void)enumerateItemsFromPage:(id)arg1 reply:(CDUnknownBlockType)arg2; - (void)currentSyncAnchorWithCompletion:(CDUnknownBlockType)arg1; - (void)forceAddFileURLsForItems:(id)arg1; - (void)forceItemUpdate:(id)arg1; - (void)invalidateVendorEnumeration; - (void)invalidate; - (void)dealloc; @property(readonly, copy) NSString *description; - (id)initWithObservedItemID:(id)arg1 domainContext:(id)arg2 vendorEnumerator:(id)arg3 observer:(id)arg4 forceFileURLs:(BOOL)arg5; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
34.638298
130
0.781941
0a37eabd5754e2c1405a738dc0359c14ad7bcd67
3,965
c
C
tests/tst-string-append.c
ikerexxe/libeconf
1513a26f9636deea15a962644463bdd8b5e64598
[ "MIT" ]
46
2019-08-19T13:00:56.000Z
2022-02-24T05:17:46.000Z
tests/tst-string-append.c
ikerexxe/libeconf
1513a26f9636deea15a962644463bdd8b5e64598
[ "MIT" ]
49
2019-08-20T07:00:34.000Z
2022-03-11T10:51:14.000Z
tests/tst-string-append.c
ikerexxe/libeconf
1513a26f9636deea15a962644463bdd8b5e64598
[ "MIT" ]
21
2019-08-19T11:35:45.000Z
2021-12-24T05:00:25.000Z
#ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stdio.h> #include <string.h> #include "libeconf_ext.h" /* Test case: * An string array has been defined mutitple times in a file with the * same ID. If the environment ECONF_JOIN_SAME_ENTRIES is set, these * multiple entries are packed into an single one. */ static int print_error_get (const char *getgroup, const char *key, econf_err error) { fprintf (stderr, "ERROR: tried to get '%s' from '%s': %s\n", key, getgroup, econf_errString(error)); return 1; } static bool check_StringArray (econf_file *key_file, const char *group, const char *key, const char *const *values, const size_t value_lines, const char *comment_before_key, const char *comment_after_value) { econf_err error; econf_ext_value *ext_val; if ((error = econf_getExtValue(key_file, group, key, &ext_val))) { print_error_get (group, key, error); return false; } size_t i=0; while (ext_val->values[i] != 0) { if ((ext_val->values[i] == NULL && values[i] != NULL) || (ext_val->values[i] != NULL && values[i] == NULL) || strcmp(ext_val->values[i], values[i])) { fprintf (stderr, "ERROR: %s:Expected String:\n'%s'\n, Got:\n'%s'\n", key, values[i], ext_val->values[i]); econf_freeExtValue(ext_val); return false; } i++; } if (i != value_lines) { fprintf (stderr, "ERROR: String array does not have expected length: %d exp.: %d\n", (int) i, (int) value_lines); econf_freeExtValue(ext_val); return false; } if ((ext_val->comment_before_key != NULL && comment_before_key == NULL) || (ext_val->comment_before_key == NULL && comment_before_key != NULL) || (ext_val->comment_before_key != NULL && comment_before_key != NULL && strcmp(ext_val->comment_before_key, comment_before_key) != 0)) { fprintf (stderr, "comment_before_key ERROR: %s\nExpected String:\n'%s'\nGot:\n'%s'\n", key, comment_before_key, ext_val->comment_before_key); econf_freeExtValue(ext_val); return false; } if ((ext_val->comment_after_value != NULL && comment_after_value == NULL) || (ext_val->comment_after_value == NULL && comment_after_value != NULL) || (ext_val->comment_after_value != NULL && comment_after_value != NULL && strcmp(ext_val->comment_after_value, comment_after_value) != 0)) { fprintf (stderr, "comment_after_value ERROR: %s\nExpected String:\n'%s'\nGot:\n'%s'\n", key, comment_after_value, ext_val->comment_after_value); econf_freeExtValue(ext_val); return false; } econf_freeExtValue(ext_val); return true; } int main(void) { econf_file *key_file = NULL; econf_err error; int retval = 0; static const struct { const char *const key; const char *const val[5]; const size_t lines; const char *const comment_before_key; const char *const comment_after_value; } tests[] = { { "append_option", {"one", "two", "three", "four"}, 4, " header of first entry\n header of second entry", "\n one\n two\nthree\nfour"}, { "reset_option", {""}, 1, " header of init reset option\n header of reset option", NULL}, { "reinit_option", {"three", "four"}, 2, " header of reinit option\n header of last reinit option", "three\nfour"} }; /* double entries will be joined together */ setenv("ECONF_JOIN_SAME_ENTRIES", "1", 1); error = econf_readFile (&key_file, TESTSDIR"tst-append-string/input.conf", "=", "#"); if (error) { fprintf (stderr, "ERROR: couldn't read configuration file: %s\n", econf_errString(error)); return 1; } for (size_t i = 0; i < sizeof(tests)/sizeof(*tests); i++) { if (!check_StringArray(key_file, "main", tests[i].key, tests[i].val, tests[i].lines, tests[i].comment_before_key ,tests[i].comment_after_value)) retval = 1; } econf_free(key_file); return retval; }
29.154412
94
0.646658
f786aee2746fcae1c9da331203199752c33c69eb
625
h
C
Shared/emuquery.h
devzendo/transputer-emulator
0609b100c480f661aada4fc0d75d63d9038e6b56
[ "Apache-2.0" ]
5
2020-02-22T19:05:48.000Z
2020-09-02T17:14:11.000Z
Shared/emuquery.h
devzendo/transputer-emulator
0609b100c480f661aada4fc0d75d63d9038e6b56
[ "Apache-2.0" ]
null
null
null
Shared/emuquery.h
devzendo/transputer-emulator
0609b100c480f661aada4fc0d75d63d9038e6b56
[ "Apache-2.0" ]
1
2022-02-16T05:40:06.000Z
2022-02-16T05:40:06.000Z
//------------------------------------------------------------------------------ // // File : emuquery.h // Description : Opcodes loaded into Areg for emuquery hook instruction // License : Apache License v2.0 - see LICENSE.txt for more details // Created : 14/11/2005 // // (C) 2005-2020 Matt J. Gumbley // matt.gumbley@devzendo.org // http://devzendo.github.io/parachute // //------------------------------------------------------------------------------ #ifndef _EMUQUERY_H #define _EMUQUERY_H // All are loaded into Areg; all result in Areg being changed. #define EQA_MEMTOP 0x00 #endif // _EMUQUERY_H
28.409091
80
0.52
fb18ebf5b9859827697b7b122649aaf24da055ea
698
h
C
code/engine.vc2008/xrGame/script_world_property.h
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
7
2018-03-27T12:36:07.000Z
2020-06-26T11:31:52.000Z
code/engine.vc2008/xrGame/script_world_property.h
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
2
2018-05-26T23:17:14.000Z
2019-04-14T18:33:27.000Z
code/engine.vc2008/xrGame/script_world_property.h
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
5
2020-10-18T11:55:26.000Z
2022-03-28T07:21:35.000Z
//////////////////////////////////////////////////////////////////////////// // Module : script_world_property.h // Created : 19.03.2004 // Modified : 19.03.2004 // Author : Dmitriy Iassenev // Description : Script world property //////////////////////////////////////////////////////////////////////////// #pragma once #include "graph_engine_space.h" #include "../xrScripts/export/script_export_space.h" using CScriptWorldProperty = GraphEngineSpace::CWorldProperty; class CScriptWorldPropertyWrapper { public: DECLARE_SCRIPT_REGISTER_FUNCTION }; add_to_type_list(CScriptWorldPropertyWrapper) #undef script_type_list #define script_type_list save_type_list(CScriptWorldPropertyWrapper)
30.347826
76
0.630372
daaae15840084d8cd370e52df3ce3c29716e2d34
2,868
c
C
src/codec_utils/F1AP/Served-EUTRA-Cells-Information.c
tanmayg14/o-du-l2
60d14257f866aab93574d57cceecad4859670f82
[ "Apache-2.0", "CC-BY-4.0" ]
9
2020-10-13T06:37:10.000Z
2022-03-05T17:57:52.000Z
src/codec_utils/F1AP/Served-EUTRA-Cells-Information.c
wineslab/colosseum-scope-e2
f0457b39e03cadb2a93523bc73ccc2d056f2188b
[ "Apache-2.0", "CC-BY-4.0" ]
null
null
null
src/codec_utils/F1AP/Served-EUTRA-Cells-Information.c
wineslab/colosseum-scope-e2
f0457b39e03cadb2a93523bc73ccc2d056f2188b
[ "Apache-2.0", "CC-BY-4.0" ]
7
2020-09-29T09:56:01.000Z
2022-03-24T10:50:32.000Z
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "F1AP-IEs" * found in "F1.asn1" * `asn1c -D ./out -fcompound-names -fno-include-deps -findirect-choice -gen-PER -no-gen-example` */ #include "Served-EUTRA-Cells-Information.h" #include "ProtocolExtensionContainer.h" asn_TYPE_member_t asn_MBR_Served_EUTRA_Cells_Information_1[] = { { ATF_NOFLAGS, 0, offsetof(struct Served_EUTRA_Cells_Information, eUTRA_Mode_Info), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_EUTRA_Mode_Info, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "eUTRA-Mode-Info" }, { ATF_NOFLAGS, 0, offsetof(struct Served_EUTRA_Cells_Information, protectedEUTRAResourceIndication), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ProtectedEUTRAResourceIndication, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "protectedEUTRAResourceIndication" }, { ATF_POINTER, 1, offsetof(struct Served_EUTRA_Cells_Information, iE_Extensions), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ProtocolExtensionContainer_4624P91, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "iE-Extensions" }, }; static const int asn_MAP_Served_EUTRA_Cells_Information_oms_1[] = { 2 }; static const ber_tlv_tag_t asn_DEF_Served_EUTRA_Cells_Information_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_Served_EUTRA_Cells_Information_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* eUTRA-Mode-Info */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* protectedEUTRAResourceIndication */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* iE-Extensions */ }; asn_SEQUENCE_specifics_t asn_SPC_Served_EUTRA_Cells_Information_specs_1 = { sizeof(struct Served_EUTRA_Cells_Information), offsetof(struct Served_EUTRA_Cells_Information, _asn_ctx), asn_MAP_Served_EUTRA_Cells_Information_tag2el_1, 3, /* Count of tags in the map */ asn_MAP_Served_EUTRA_Cells_Information_oms_1, /* Optional members */ 1, 0, /* Root/Additions */ 3, /* First extension addition */ }; asn_TYPE_descriptor_t asn_DEF_Served_EUTRA_Cells_Information = { "Served-EUTRA-Cells-Information", "Served-EUTRA-Cells-Information", &asn_OP_SEQUENCE, asn_DEF_Served_EUTRA_Cells_Information_tags_1, sizeof(asn_DEF_Served_EUTRA_Cells_Information_tags_1) /sizeof(asn_DEF_Served_EUTRA_Cells_Information_tags_1[0]), /* 1 */ asn_DEF_Served_EUTRA_Cells_Information_tags_1, /* Same as above */ sizeof(asn_DEF_Served_EUTRA_Cells_Information_tags_1) /sizeof(asn_DEF_Served_EUTRA_Cells_Information_tags_1[0]), /* 1 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_Served_EUTRA_Cells_Information_1, 3, /* Elements count */ &asn_SPC_Served_EUTRA_Cells_Information_specs_1 /* Additional specs */ };
38.756757
101
0.744421
1f422f5e03b31b5239a1e11dfeb14bdfeabb4447
1,849
h
C
iOS/Classes/Native/UnityEngine_UnityEngine_SocialPlatforms_GameCenter2181296590MethodDeclarations.h
mopsicus/unity-share-plugin-ios-android
3ee99aef36034a1e4d7b156172953f9b4dfa696f
[ "MIT" ]
11
2016-07-22T19:58:09.000Z
2021-09-21T12:51:40.000Z
iOS/Classes/Native/UnityEngine_UnityEngine_SocialPlatforms_GameCenter2181296590MethodDeclarations.h
mopsicus/unity-share-plugin-ios-android
3ee99aef36034a1e4d7b156172953f9b4dfa696f
[ "MIT" ]
1
2018-05-07T14:32:13.000Z
2018-05-08T09:15:30.000Z
iOS/Classes/Native/UnityEngine_UnityEngine_SocialPlatforms_GameCenter2181296590MethodDeclarations.h
mopsicus/unity-share-plugin-ios-android
3ee99aef36034a1e4d7b156172953f9b4dfa696f
[ "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> // UnityEngine.SocialPlatforms.Impl.Score struct Score_t3396031228; // UnityEngine.SocialPlatforms.GameCenter.GcScoreData struct GcScoreData_t2181296590; struct GcScoreData_t2181296590_marshaled_pinvoke; struct GcScoreData_t2181296590_marshaled_com; #include "codegen/il2cpp-codegen.h" #include "UnityEngine_UnityEngine_SocialPlatforms_GameCenter2181296590.h" // UnityEngine.SocialPlatforms.Impl.Score UnityEngine.SocialPlatforms.GameCenter.GcScoreData::ToScore() extern "C" Score_t3396031228 * GcScoreData_ToScore_m2728389301 (GcScoreData_t2181296590 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // Methods for marshaling struct GcScoreData_t2181296590; struct GcScoreData_t2181296590_marshaled_pinvoke; extern "C" void GcScoreData_t2181296590_marshal_pinvoke(const GcScoreData_t2181296590& unmarshaled, GcScoreData_t2181296590_marshaled_pinvoke& marshaled); extern "C" void GcScoreData_t2181296590_marshal_pinvoke_back(const GcScoreData_t2181296590_marshaled_pinvoke& marshaled, GcScoreData_t2181296590& unmarshaled); extern "C" void GcScoreData_t2181296590_marshal_pinvoke_cleanup(GcScoreData_t2181296590_marshaled_pinvoke& marshaled); // Methods for marshaling struct GcScoreData_t2181296590; struct GcScoreData_t2181296590_marshaled_com; extern "C" void GcScoreData_t2181296590_marshal_com(const GcScoreData_t2181296590& unmarshaled, GcScoreData_t2181296590_marshaled_com& marshaled); extern "C" void GcScoreData_t2181296590_marshal_com_back(const GcScoreData_t2181296590_marshaled_com& marshaled, GcScoreData_t2181296590& unmarshaled); extern "C" void GcScoreData_t2181296590_marshal_com_cleanup(GcScoreData_t2181296590_marshaled_com& marshaled);
43
159
0.866955
f7a1e51cbd9ae0a7f2323068cff27e7198e0bc31
1,831
h
C
BlackVision/LibBlackVision/Source/Engine/Editors/ModelSceneEditor.h
black-vision-engine/bv-engine
85089d41bb22afeaa9de070646e12aa1777ecedf
[ "MIT" ]
1
2022-01-28T11:43:47.000Z
2022-01-28T11:43:47.000Z
BlackVision/LibBlackVision/Source/Engine/Editors/ModelSceneEditor.h
black-vision-engine/bv-engine
85089d41bb22afeaa9de070646e12aa1777ecedf
[ "MIT" ]
null
null
null
BlackVision/LibBlackVision/Source/Engine/Editors/ModelSceneEditor.h
black-vision-engine/bv-engine
85089d41bb22afeaa9de070646e12aa1777ecedf
[ "MIT" ]
null
null
null
#pragma once #include "Engine/Models/SceneModel.h" #include "Engine/Models/BasicNode.h" namespace bv { namespace model { class ModelSceneEditor { private: BasicNodePtr & m_rootNode; BasicNodePtr m_detachedNode; private: ModelSceneEditor ( const ModelSceneEditor & other ); ModelSceneEditor & operator = ( const ModelSceneEditor & other ); public: ModelSceneEditor ( BasicNodePtr & rootNode ); void SetRootNode ( BasicNodePtr mainRootNode, BasicNodePtr sceneRootNode ); bool DeleteRootNode ( BasicNodePtr mainRootNode ); void AddChildNode ( BasicNodePtr parentNode, BasicNodePtr childNode ); bool DeleteChildNode ( BasicNodePtr parentNode, BasicNodePtr childNode ); void AddGizmoNode ( BasicNodePtr gizmoOwner, BasicNodePtr gizmoRoot ); void DeleteGizmoNode ( BasicNodePtr gizmoOwner, BasicNodePtr gizmoRoot ); void AttachRootNode (); bool DetachRootNode (); bool AttachChildNode ( BasicNodePtr parent ); bool AttachChildNode ( BasicNodePtr parent, UInt32 destIdx ); bool DetachChildNode ( BasicNodePtr parent, BasicNodePtr nodeToDetach ); BasicNodePtr GetDetachedNode () const; void DeleteDetachedNode (); BasicNodePtr GetRootNode () const; IModelNodePtr GetNode ( const std::string & path, const std::string & separator = "/" ) const; }; } // model } //bv
35.211538
121
0.545057
1c27323c5440644bf9b433b77d167a05fea0d37b
58
h
C
c/header.h
lavima/itf21215_examples
5aec0a1ffbee43be23ad13b831f6e19a70c48c4f
[ "MIT" ]
null
null
null
c/header.h
lavima/itf21215_examples
5aec0a1ffbee43be23ad13b831f6e19a70c48c4f
[ "MIT" ]
null
null
null
c/header.h
lavima/itf21215_examples
5aec0a1ffbee43be23ad13b831f6e19a70c48c4f
[ "MIT" ]
6
2019-08-30T08:26:01.000Z
2019-12-08T14:15:28.000Z
#define HELLO_STRING "Hello World!\n" void printHello();
14.5
37
0.741379
20234bcd459dd06b534af8b1714fea8e63abd733
303
h
C
src/framework/model_loaders/ModelFactory.h
ferzerkerx/viking-engine
c87d688d5fb21259fe1efe6b42a0a1f7024fa750
[ "MIT" ]
1
2018-05-01T21:50:17.000Z
2018-05-01T21:50:17.000Z
src/framework/model_loaders/ModelFactory.h
ferzerkerx/viking-engine
c87d688d5fb21259fe1efe6b42a0a1f7024fa750
[ "MIT" ]
null
null
null
src/framework/model_loaders/ModelFactory.h
ferzerkerx/viking-engine
c87d688d5fb21259fe1efe6b42a0a1f7024fa750
[ "MIT" ]
null
null
null
// // Created by fernando on 01.05.18. // #ifndef VIKING_ENGINE_MODELFACTORY_H #define VIKING_ENGINE_MODELFACTORY_H #include "Md2Model.h" class ModelFactory { public: static Md2Model *LoadMD2(const char *md2_file_name, const char *texture_file_name); }; #endif //VIKING_ENGINE_MODELFACTORY_H
15.947368
87
0.772277
5440e46359896c081348aa61de0c6f8b70dd5aac
2,366
c
C
src/arch-pic32/cxa_pic32_usart.c
dalleysa/common-c
bde075f125fac7846d61deb11f09fd27d1052c80
[ "MIT" ]
8
2019-08-30T15:18:40.000Z
2021-12-06T23:01:16.000Z
src/arch-pic32/cxa_pic32_usart.c
dalleysa/common-c
bde075f125fac7846d61deb11f09fd27d1052c80
[ "MIT" ]
8
2015-07-02T00:51:53.000Z
2019-07-12T12:38:13.000Z
src/arch-pic32/cxa_pic32_usart.c
dalleysa/common-c
bde075f125fac7846d61deb11f09fd27d1052c80
[ "MIT" ]
3
2017-01-13T18:04:51.000Z
2019-08-14T20:58:20.000Z
/* * This file is subject to the terms and conditions defined in * file 'LICENSE', which is part of this source code package. * * @author Christopher Armenio */ #include "cxa_pic32_usart.h" // ******** includes ******** #include <stdbool.h> #include <cxa_assert.h> #include <cxa_delay.h> // ******** local macro definitions ******** // ******** local type definitions ******** // ******** local function prototypes ******** static cxa_ioStream_readStatus_t ioStream_cb_readByte(uint8_t *const byteOut, void *const userVarIn); static bool ioStream_cb_writeBytes(void* buffIn, size_t bufferSize_bytesIn, void *const userVarIn); // ******** local variable declarations ********* // ******** global function implementations ******** void cxa_pic32_usart_init(cxa_pic32_usart_t *const usartIn, int uartHarmonyInstanceIn) { cxa_assert(usartIn); // setup our UART hardware usartIn->usartHandle = DRV_USART_Open(uartHarmonyInstanceIn, DRV_IO_INTENT_READWRITE|DRV_IO_INTENT_NONBLOCKING); // setup our ioStream (last once everything is setup) cxa_ioStream_init(&usartIn->super.ioStream); cxa_ioStream_bind(&usartIn->super.ioStream, ioStream_cb_readByte, ioStream_cb_writeBytes, (void*)usartIn); } // ******** local function implementations ******** static cxa_ioStream_readStatus_t ioStream_cb_readByte(uint8_t *const byteOut, void *const userVarIn) { cxa_pic32_usart_t* usartIn = (cxa_pic32_usart_t*)userVarIn; cxa_assert(usartIn); // make sure we don't have an error on the UART if( DRV_USART_ErrorGet(usartIn->usartHandle) != DRV_USART_ERROR_NONE ) return CXA_IOSTREAM_READSTAT_ERROR; //Check to see if we have a byte to receive per DRV_USART.h _ReadByte function if(DRV_USART_ReceiverBufferIsEmpty(usartIn->usartHandle)) return CXA_IOSTREAM_READSTAT_NODATA; uint8_t tmpBuff = DRV_USART_ReadByte(usartIn->usartHandle); if( byteOut != NULL ) *byteOut = tmpBuff; return CXA_IOSTREAM_READSTAT_GOTDATA; } static bool ioStream_cb_writeBytes(void* buffIn, size_t bufferSize_bytesIn, void *const userVarIn) { cxa_pic32_usart_t* usartIn = (cxa_pic32_usart_t*)userVarIn; cxa_assert(usartIn); for(size_t i=0; i < bufferSize_bytesIn; i++) { while(DRV_USART_TransmitBufferIsFull(usartIn->usartHandle)); DRV_USART_WriteByte(usartIn->usartHandle, ((uint8_t*)buffIn)[i]); } return true; }
30.333333
116
0.733305
bff7ec1472647c05a713f6dbc79a0be6ae8fd0d5
985
h
C
utils/Timer.h
LBJ-Wade/cosmograph
dbd0cb1014666ad47fbbb48831989a1b79923eb0
[ "MIT" ]
5
2019-02-04T18:06:37.000Z
2020-10-23T12:06:07.000Z
utils/Timer.h
LBJ-Wade/cosmograph
dbd0cb1014666ad47fbbb48831989a1b79923eb0
[ "MIT" ]
null
null
null
utils/Timer.h
LBJ-Wade/cosmograph
dbd0cb1014666ad47fbbb48831989a1b79923eb0
[ "MIT" ]
2
2019-10-21T20:29:02.000Z
2022-02-28T06:57:11.000Z
#ifndef COSMO_UTILS_TIMER_H #define COSMO_UTILS_TIMER_H #include <ctime> #include <iostream> #include <map> namespace cosmo { /** * @brief Individual timer classes used by the TimerManager class. */ class Timer { public: Timer() : m_secs(0) {} inline double time() const { return m_secs; } inline void start() { clock_gettime(CLOCK_MONOTONIC, &m_starttime); } void stop(); void reset(); Timer operator+(const Timer &t2); Timer operator-(const Timer &t2); private: double m_secs; struct timespec m_starttime; struct timespec m_stoptime; }; /** * @brief TimerManager class containing multiple timers; * access individual timers via, eg, TM["my_timer"].start() */ class TimerManager { public: TimerManager() {}; std::string getStateString(); inline Timer& operator[](std::string key) { return m_timers[key]; } friend std::ostream& operator<<(std::ostream &ostr, TimerManager T); private: std::map<std::string, Timer> m_timers; }; } #endif
17.589286
71
0.699492
8725a0c80c647cfe0719d36388ee9cb53f41642f
436
h
C
X1Player/TestViewController.h
diamondfive/X1Player
47fe0028a5cc5207df2cad40e2af6d9a2187065f
[ "MIT" ]
24
2018-11-01T08:54:40.000Z
2022-03-14T04:40:04.000Z
X1Player/TestViewController.h
Costword/X1Player
88315dcb2b6ccbfb090aede24bbc2b2c3663f6a1
[ "MIT" ]
3
2019-05-16T12:48:55.000Z
2020-05-27T07:27:52.000Z
X1Player/TestViewController.h
Costword/X1Player
88315dcb2b6ccbfb090aede24bbc2b2c3663f6a1
[ "MIT" ]
5
2018-11-27T22:45:37.000Z
2022-02-16T09:45:53.000Z
// // TestViewController.h // X1PlayerSDK // // Created by 彦彰 on 2017/10/20. // Copyright © 2017年 channelsoft. All rights reserved. // #import <UIKit/UIKit.h> @interface TestViewController : UIViewController @property (nonatomic, assign) float type;// 1 直播 2 录播 3 距离开始XX @property (nonatomic, assign) NSInteger startTime; @property (nonatomic, strong) NSString *imageUrl; @property (nonatomic, strong) UIImage *image; @end
19.818182
64
0.724771
f66acf2e02374829e88d09b7a5b22a5fe60540be
1,512
c
C
NGSpice/ngspice-30/src/spicelib/devices/jfet2/jfet2mask.c
Surya-98/Snapcuit
9789a779485d8af2426a2d4e6403a06f44acadcb
[ "MIT" ]
null
null
null
NGSpice/ngspice-30/src/spicelib/devices/jfet2/jfet2mask.c
Surya-98/Snapcuit
9789a779485d8af2426a2d4e6403a06f44acadcb
[ "MIT" ]
null
null
null
NGSpice/ngspice-30/src/spicelib/devices/jfet2/jfet2mask.c
Surya-98/Snapcuit
9789a779485d8af2426a2d4e6403a06f44acadcb
[ "MIT" ]
null
null
null
/********** Based on jfetmask.c Copyright 1990 Regents of the University of California. All rights reserved. Author: 1987 Mathew Lew and Thomas L. Quarles Modified to add PS model and new parameter definitions ( Anthony E. Parker ) Copyright 1994 Macquarie University, Sydney Australia. 10 Feb 1994: Added call to jfetparm.h **********/ /* */ #include "ngspice/ngspice.h" #include "ngspice/const.h" #include "ngspice/ifsim.h" #include "ngspice/cktdefs.h" #include "ngspice/devdefs.h" #include "jfet2defs.h" #include "ngspice/sperror.h" #include "ngspice/suffix.h" /*ARGSUSED*/ int JFET2mAsk(CKTcircuit *ckt, GENmodel *inModel, int which, IFvalue *value) { JFET2model *model = (JFET2model*)inModel; NG_IGNORE(ckt); switch(which) { case JFET2_MOD_TNOM: value->rValue = model->JFET2tnom-CONSTCtoK; return(OK); #define PARAM(code,id,flag,ref,default,descrip) case id: \ value->rValue = model->ref; return(OK); #include "jfet2parm.h" case JFET2_MOD_DRAINCONDUCT: value->rValue = model->JFET2drainConduct; return(OK); case JFET2_MOD_SOURCECONDUCT: value->rValue = model->JFET2sourceConduct; return(OK); case JFET2_MOD_TYPE: if (model->JFET2type == NJF) value->sValue = "njf"; else value->sValue = "pjf"; return(OK); default: return(E_BADPARM); } /* NOTREACHED */ }
26.068966
77
0.617725
c6e0ecbe42ce1fd773cd331b52f6bc73d450b682
11,443
c
C
user/manchestrate.c
yo8aiv/espthernet
d9dc2898bb4be32bdd7fd5f93b4de7fee5d5e5f5
[ "BSD-2-Clause-FreeBSD" ]
241
2016-04-01T14:13:09.000Z
2022-02-15T17:53:32.000Z
user/manchestrate.c
yo8aiv/espthernet
d9dc2898bb4be32bdd7fd5f93b4de7fee5d5e5f5
[ "BSD-2-Clause-FreeBSD" ]
6
2016-05-23T14:05:44.000Z
2020-01-29T17:48:45.000Z
user/manchestrate.c
yo8aiv/espthernet
d9dc2898bb4be32bdd7fd5f93b4de7fee5d5e5f5
[ "BSD-2-Clause-FreeBSD" ]
44
2016-04-02T08:28:53.000Z
2022-03-04T03:16:59.000Z
//Copyright 2015-2016 <>< Charles Lohr, see LICENSE file. This file is licensed under the 2-Clause BSD License. #include "manchestrate.h" #include <mystuff.h> #include "i2sduplex.h" #include "c_types.h" //The code up here is for decoding manchester encoded packets. #include "demanchestrate_table.h" uint16_t gl_state1; uint8_t gl_in_preamble; uint32_t gl_dataoutword; uint8_t gl_dataoutplace; int16_t current_packet_rec_place; uint8_t * current_packet; uint8_t rx_cur; //uint8_t rx_pack_data[RXBUFS*MAX_FRAMELEN]; uint16_t rx_pack_lens[RXBUFS]; uint8_t rx_pack_flags[RXBUFS]; int8_t PacketStoreInSitu = 0; #ifdef ALLOW_FRAME_DEBUGGING //For storing packets when they come in, so they can be processed in the main loop. uint32_t PacketStore[STOPKTSIZE]; uint16_t PacketStoreLength; int8_t KeepNextPacket = 0; #endif extern uint32_t g_process_paktime; //This is called before manchester coded data is shifted into DecodePacket. int ResetPacketInternal() { int i; if( rx_pack_flags[rx_cur] != 2 ) { rx_pack_flags[rx_cur] = 0; } for( i = 0; i < RXBUFS; i++ ) { if( rx_pack_flags[i] == 0 ) break; } if( i == RXBUFS ) return -1; rx_pack_flags[i] = 1; current_packet = &ETbuffer[PTR_TO_RX_BUF(i)]; rx_cur = i; gl_state1 = 0; gl_in_preamble = 2; current_packet_rec_place = 0; gl_dataoutword = 0; gl_dataoutplace = 0; return i; } //Returns 0 if packet was exhausted before finding an end-of-packet marker. //Returns n if packet contained invalid codes (like an end of packet) within this function. int32_t DecodePacket( uint32_t * dat, uint16_t len ) { //XXX TRICKY: GCC does an extra operation to downconvert to bits when operating with this value. It is safe to leave as a 32-bit value. //This applies to "nibble" and "dataoutplace" uint16_t state1 = gl_state1; uint8_t in_preamble = gl_in_preamble; int32_t nibble = 28; uint32_t v; uint32_t k = 0; uint32_t dataoutword = gl_dataoutword; uint32_t dataoutplace = gl_dataoutplace; if( in_preamble == 2 ) { v = dat[0]; //Deal with the pre-preamble uint8_t b0 = v&1; //Most recent bit. //Not actually nibble, re-pruposed. for( nibble = 1; nibble < 32; nibble++ ) { if( ((v>>nibble)&1) != b0 ) break; } if( nibble > 6 ) { //Faulty data. gl_state1 = state1; gl_in_preamble = in_preamble; rx_pack_flags[rx_cur] = 0; return 0; } state1 = (1<<9) | ((v&1)<<8) | ( (nibble-1) << 5 ); in_preamble = 1; nibble = 28; k = 1; } if( in_preamble == 1 ) { for( ; k < len; k++ ) { v = dat[k]; //Wait for preamble to complete. for( ; nibble >= 0; nibble-=4 ) { state1 |= (v>>nibble)&0x0f; state1 = ManchesterTable1[state1]; if( (state1 & 0x400) ) //Break in the preamble! { in_preamble = 0; nibble-=4; break; } state1 &= 0x3f0; } if( !in_preamble ) { //When we get here, we expect to have gotten two shorts... but, it could be three TOTAL. //If it's two, all is well.. if it's 3... we have to be a little more careful. //We can see if it was 3 by seeing if intonation in was set. If it was, then we know //We're on the 3rd. if( ( state1 & 0x800 ) ) //Indicates two bits were just outputted in the last nibble. { dataoutplace = 1; dataoutword = 0; state1 &=~(1<<9); } else { //Only had 2 values sent, always set polarity to high. //Set 'polarity' state1 |= 0x200; } state1 &= 0x3f0; break; } nibble = 28; } //Didn't leave preamble, but no more data left. if( k == len ) { gl_in_preamble = in_preamble; gl_state1 = state1; return 0; } #define nibblet( x )\ state1 |= (v>>x)&0x0f;\ state1 = ManchesterTable1[state1];\ dataoutword |= (state1&3)<<dataoutplace;\ dataoutplace += (state1>>2)&3;\ state1 &= 0x3f0;\ //Since we hit the end of the preamble, we have to finish out the //32-bit word... We do that here. //Neat trick: By dividing by 4 then switching based off that, saves 107 bytes of code space! nibble>>=2; switch( nibble ) { case 7:nibblet(28); case 6:nibblet(24); case 5:nibblet(20); case 4:nibblet(16); case 3:nibblet(12); case 2:nibblet(8); case 1:nibblet(4); case 0:nibblet(0); } k++; } gl_in_preamble = in_preamble; //Not in premable, this does actual packet decoding. { //uint16_t lcl_current_packet_rec_place = current_packet_rec_place; uint8_t * cpr = &((uint8_t*)current_packet)[current_packet_rec_place]; uint8_t * cprm = &((uint8_t*)current_packet)[MAX_FRAMELEN]; for( ; k < len; k++ ) { v = dat[k]; nibblet(28); nibblet(24); nibblet(20); nibblet(16); nibblet(12); nibblet(8); nibblet(4); nibblet(0); //It is possible that we might be a byte behind at some point. That is okay. We'll do another check before being done. if( dataoutplace >= 8 ) { if( cpr >= cprm ) { rx_pack_flags[rx_cur] = 0; return k+1; } *cpr++ = dataoutword; dataoutword >>= 8; dataoutplace -= 8; } //End of data (may be good or bad) if( (state1 & 0xE0) == 0xE0 ) { gl_dataoutword = dataoutword; gl_dataoutplace = dataoutplace; current_packet_rec_place = cpr - (uint8_t*)current_packet; gl_state1 = state1; //If we're a byte behind, take it out here. //Does this need to be a while???? while( dataoutplace >= 8 ) { if( cpr >= cprm ) { rx_pack_flags[rx_cur] = 0; return k+1; } *cpr++ = dataoutword; dataoutword >>= 8; dataoutplace -= 8; } rx_pack_lens[rx_cur] = current_packet_rec_place; //I've tried wording this different ways, always produces more GCC code. if( current_packet_rec_place > 9 ) { //Probs a good packet? rx_pack_flags[rx_cur] = 2; } else { //Super runt packet (def bad) rx_pack_flags[rx_cur] = 0; } return k+1; } } //More data is to come. gl_dataoutword = dataoutword; gl_dataoutplace = dataoutplace; current_packet_rec_place = cpr - (uint8_t*)current_packet; gl_state1 = state1; return 0; } } //Process a bundle from the i2s engine. // //This is called from within the i2s interrupt. void GotNewI2SData( uint32_t * dat, int datlen ) { int i = 0; int r; static int stripe = 0; gotdma=1; keep_going: //Search for until data is ffffffff or 00000000. //This would be if we think we hit the end of a packet or a bad packet. //Just speed along till the bad dream is over. if( PacketStoreInSitu < 0 ) { for( ; i < datlen; i++ ) { uint32_t d = dat[i]; //Look for a set of 3 non null packets. if( d != 0xffffffff && d != 0x00000000 ) { PacketStoreInSitu = 0; gotlink = 1; stripe = 1; break; } } //Still searching? If so come back in here next time. if( PacketStoreInSitu ) return; } //Otherwise we're looking for several non-zero packets in a row. //This would indicate a start of a packet. if( PacketStoreInSitu == 0 ) { //Quescent state. for( ; i < datlen; i+=2 ) { uint32_t d = dat[i]; //Look for a set of 3 non null packets. if( d != 0xffffffff && d != 0x00000000 ) { gotlink = 1; stripe++; if( stripe == 3 ) { PacketStoreInSitu = 1; break; } } else { stripe = 0; } } //Nothing interesting happened all packet. Return back to the host. if( !PacketStoreInSitu ) return; stripe = 0; //Something happened... r = ResetPacketInternal(1); //Make sure we can get a free packet. if( r < 0 ) { //Otherwise, we have to dump this on-wire packet. PacketStoreInSitu = -1; goto keep_going; } //Good to go and start processing data. #ifdef ALLOW_FRAME_DEBUGGING if( KeepNextPacket > 0 && KeepNextPacket < 3 ) { PacketStoreLength = 0; g_process_paktime = 0; } #endif //We can safely skip a free word since preambles are so long. //Do this for performance reasons. i ++; } #ifdef ALLOW_FRAME_DEBUGGING if( KeepNextPacket > 0 && KeepNextPacket < 3 ) { int start; if( i != 0 ) { //Starting a packet. start = i-(4); if( start < 0 ) start = 0; } else { //Middle of packet start = i; } int k; for( k = start; k < datlen && PacketStoreLength < STOPKTSIZE; k++ ) { PacketStore[PacketStoreLength++] = dat[k]; } g_process_paktime -= system_get_time(); } #endif //Start processing a packet. if( i < datlen ) { r = DecodePacket( &dat[i], datlen - i ); } i += r; #ifdef ALLOW_FRAME_DEBUGGING if( KeepNextPacket > 0 && KeepNextPacket < 3 ) { g_process_paktime += system_get_time(); } #endif //Done with this segment, next one to come. if( r == 0 ) { gotlink = 1; return; } //Packet is complete, or error in packet. No matter what, we have to finish off the packet next time. PacketStoreInSitu = -1; #ifdef ALLOW_FRAME_DEBUGGING if( KeepNextPacket > 0 && KeepNextPacket < 3 ) { int trim = (datlen-i); trim--; if( trim < 0 ) trim = 0; if( trim > PacketStoreLength - 10 ) trim = (PacketStoreLength-10); PacketStoreLength -= trim; //Only release if packet not waiting for clear. if( KeepNextPacket == 1 ) KeepNextPacket = 4; //Packet knowingly faulted and we were waiting for packet? if( KeepNextPacket == 2 && rx_pack_flags[rx_cur] == 0 ) KeepNextPacket = 4; } #endif goto keep_going; } /////////////////////////////////////////////////////////////////////////////// //// Sending (Manchestration) Portion /////////////////////////////////////////////////////////////////////////////// //The code down here is for sending, Manchester Encoding data. extern volatile uint8_t i2stxdone; uint32_t sendDMAbuffer[MAX_FRAMELEN+8+6+6] __attribute__ ((aligned (16))); uint32_t * sDMA; static const uint16_t ManchesterTable[16] __attribute__ ((aligned (16))) = { 0b1100110011001100, 0b0011110011001100, 0b1100001111001100, 0b0011001111001100, 0b1100110000111100, 0b0011110000111100, 0b1100001100111100, 0b0011001100111100, 0b1100110011000011, 0b0011110011000011, 0b1100001111000011, 0b0011001111000011, 0b1100110000110011, 0b0011110000110011, 0b1100001100110011, 0b0011001100110011, }; //#define PushManch( k ) { *(sDMA++) = (ManchesterTable[(k)>>4])|(ManchesterTable[(k)&0x0f]<<16); } void PushManch( unsigned char k ) { *(sDMA++) = (ManchesterTable[(k)>>4])|(ManchesterTable[(k)&0x0f]<<16); } void ICACHE_FLASH_ATTR SendPacketData( const unsigned char * c, uint16_t len ) { if( len > MAX_FRAMELEN ) { printf( "Sending packet too big.\n" ); return; } sDMA = &sendDMAbuffer[0]; len*=4; //For some reason the ESP's DMA engine trashes something in the beginning here, Don't send the preamble until after the first 128 bits. *(sDMA++) = 0x00; *(sDMA++) = 0x00; *(sDMA++) = 0x00; *(sDMA++) = 0x00; PushManch( 0x55 ); PushManch( 0x55 ); PushManch( 0x55 ); PushManch( 0x55 ); PushManch( 0x55 ); PushManch( 0x55 ); PushManch( 0x55 ); PushManch( 0xD5 ); while(!i2stxdone); const unsigned char * endc = c + len; while( c != endc ) { char g = *(c++); PushManch( g ); } //Ok, this last part seems super tricky. //If we're hooked up to magnetics through a line driver, it should be 0x00000000 //If we're hooked up directly, should be 0xffffffff //This appeared to be a good compromise. *(sDMA++) = 0xfff00000; *(sDMA++) = 0x00; *(sDMA++) = 0x00; *(sDMA++) = 0x00; SendI2SPacket( sendDMAbuffer, sDMA - sendDMAbuffer ); }
22.133462
137
0.638032
67249a1942b98ffa915b4ca77b7b79ea1c1a4486
16,924
c
C
slrs/libgphoto2/gphoto2-abilities-list.c
milinddeore/360D-Sampler
a17df51aa3f1252274337c2421b90e4bd1c6b40e
[ "MIT" ]
null
null
null
slrs/libgphoto2/gphoto2-abilities-list.c
milinddeore/360D-Sampler
a17df51aa3f1252274337c2421b90e4bd1c6b40e
[ "MIT" ]
null
null
null
slrs/libgphoto2/gphoto2-abilities-list.c
milinddeore/360D-Sampler
a17df51aa3f1252274337c2421b90e4bd1c6b40e
[ "MIT" ]
null
null
null
/** \file gphoto2-abilities-list.c * \brief List of supported camera models including their abilities. * * \author Copyright 2000 Scott Fritzinger * * \par * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * \par * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * \par * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #include "config.h" #include <gphoto2/gphoto2-abilities-list.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ltdl.h> #include <gphoto2/gphoto2-result.h> #include <gphoto2/gphoto2-port-log.h> #include <gphoto2/gphoto2-library.h> #ifdef ENABLE_NLS # include <libintl.h> # undef _ # define _(String) dgettext (GETTEXT_PACKAGE, String) # ifdef gettext_noop # define N_(String) gettext_noop (String) # else # define N_(String) (String) # endif #else # define textdomain(String) (String) # define gettext(String) (String) # define dgettext(Domain,Message) (Message) # define dcgettext(Domain,Message,Type) (Message) # define bindtextdomain(Domain,Directory) (Domain) # define bind_textdomain_codeset(Domain,Charset) (Domain) # define _(String) (String) # define N_(String) (String) #endif /** \internal */ #define CHECK_RESULT(result) {int r = (result); if (r < 0) return (r);} /** \internal */ struct _CameraAbilitiesList { int count; int maxcount; CameraAbilities *abilities; }; /** \internal */ static int gp_abilities_list_lookup_id (CameraAbilitiesList *, const char *); /** \internal */ static int gp_abilities_list_sort (CameraAbilitiesList *); /** * \brief Set the current character codeset libgphoto2 is operating in. * * Set the codeset for all messages returned by libgphoto2. * \param codeset New codeset for the messages. For instance "utf-8". * \return old codeset as returned from bind_textdomain_codeset(). * * You would then call gp_abilities_list_load() in order to * populate it. */ const char* gp_message_codeset (const char *codeset) { gp_port_message_codeset (codeset); return bind_textdomain_codeset (GETTEXT_PACKAGE, codeset); } /** * \brief Allocate the memory for a new abilities list. * * Function to allocate the memory for a new abilities list. * \param list CameraAbilitiesList object to initialize * \return gphoto2 error code * * You would then call gp_abilities_list_load() in order to * populate it. */ int gp_abilities_list_new (CameraAbilitiesList **list) { C_PARAMS (list); /* * We do this here because everybody needs to call this function * first before accessing a camera. Pretty ugly, but I don't know * an other way without introducing a global initialization * function... */ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); C_MEM (*list = calloc (1, sizeof (CameraAbilitiesList))); return (GP_OK); } /** * \brief Free the given CameraAbilitiesList object. * * \param list a CameraAbilitiesList * \return a gphoto2 error code */ int gp_abilities_list_free (CameraAbilitiesList *list) { C_PARAMS (list); CHECK_RESULT (gp_abilities_list_reset (list)); free (list); return (GP_OK); } typedef struct { CameraList *list; int result; } foreach_data_t; static int foreach_func (const char *filename, lt_ptr data) { foreach_data_t *fd = data; CameraList *list = fd->list; GP_LOG_D ("Found '%s'.", filename); fd->result = gp_list_append (list, filename, NULL); return ((fd->result == GP_OK)?0:1); } int gp_abilities_list_load_dir (CameraAbilitiesList *list, const char *dir, GPContext *context) { CameraLibraryIdFunc id; CameraLibraryAbilitiesFunc ab; CameraText text; int ret, x, old_count, new_count; int i, p; const char *filename; CameraList *flist; int count; lt_dlhandle lh; C_PARAMS (list && dir); GP_LOG_D ("Using ltdl to load camera libraries from '%s'...", dir); CHECK_RESULT (gp_list_new (&flist)); ret = gp_list_reset (flist); if (ret < GP_OK) { gp_list_free (flist); return ret; } if (1) { /* a new block in which we can define a temporary variable */ foreach_data_t foreach_data = { NULL, GP_OK }; foreach_data.list = flist; lt_dlinit (); lt_dladdsearchdir (dir); ret = lt_dlforeachfile (dir, foreach_func, &foreach_data); lt_dlexit (); if (ret != 0) { gp_list_free (flist); GP_LOG_E ("Internal error looking for camlibs (%d)", ret); gp_context_error (context, _("Internal error looking for camlibs. " "(path names too long?)")); return (foreach_data.result!=GP_OK)?foreach_data.result:GP_ERROR; } } count = gp_list_count (flist); if (count < GP_OK) { gp_list_free (flist); return ret; } GP_LOG_D ("Found %i camera drivers.", count); lt_dlinit (); p = gp_context_progress_start (context, count, _("Loading camera drivers from '%s'..."), dir); for (i = 0; i < count; i++) { ret = gp_list_get_name (flist, i, &filename); if (ret < GP_OK) { gp_list_free (flist); return ret; } lh = lt_dlopenext (filename); if (!lh) { GP_LOG_D ("Failed to load '%s': %s.", filename, lt_dlerror ()); continue; } /* camera_id */ id = lt_dlsym (lh, "camera_id"); if (!id) { GP_LOG_D ("Library '%s' does not seem to " "contain a camera_id function: %s", filename, lt_dlerror ()); lt_dlclose (lh); continue; } /* * Make sure the camera driver hasn't been * loaded yet. */ if (id (&text) != GP_OK) { lt_dlclose (lh); continue; } if (gp_abilities_list_lookup_id (list, text.text) >= 0) { lt_dlclose (lh); continue; } /* camera_abilities */ ab = lt_dlsym (lh, "camera_abilities"); if (!ab) { GP_LOG_D ("Library '%s' does not seem to " "contain a camera_abilities function: " "%s", filename, lt_dlerror ()); lt_dlclose (lh); continue; } old_count = gp_abilities_list_count (list); if (old_count < 0) { lt_dlclose (lh); continue; } if (ab (list) != GP_OK) { lt_dlclose (lh); continue; } /* do not free the library in valgrind mode */ #if !defined(VALGRIND) lt_dlclose (lh); #endif new_count = gp_abilities_list_count (list); if (new_count < 0) continue; /* Copy in the core-specific information */ for (x = old_count; x < new_count; x++) { strcpy (list->abilities[x].id, text.text); strcpy (list->abilities[x].library, filename); } gp_context_progress_update (context, p, i); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { lt_dlexit (); gp_list_free (flist); return (GP_ERROR_CANCEL); } } gp_context_progress_stop (context, p); lt_dlexit (); gp_list_free (flist); return (GP_OK); } /** * \brief Scans the system for camera drivers. * * \param list a CameraAbilitiesList * \param context a GPContext * \return a gphoto2 error code * * All supported camera models will then be added to the list. * */ int gp_abilities_list_load (CameraAbilitiesList *list, GPContext *context) { const char *camlib_env = getenv(CAMLIBDIR_ENV); const char *camlibs = (camlib_env != NULL)?camlib_env:CAMLIBS; C_PARAMS (list); CHECK_RESULT (gp_abilities_list_load_dir (list, camlibs, context)); CHECK_RESULT (gp_abilities_list_sort (list)); return (GP_OK); } static int gp_abilities_list_detect_usb (CameraAbilitiesList *list, int *ability, GPPort *port) { int i, count, res = GP_ERROR_IO_USB_FIND; CHECK_RESULT (count = gp_abilities_list_count (list)); /* Detect USB cameras */ GP_LOG_D ("Auto-detecting USB cameras..."); *ability = -1; for (i = 0; i < count; i++) { int v, p, c, s; if (!(list->abilities[i].port & port->type)) continue; v = list->abilities[i].usb_vendor; p = list->abilities[i].usb_product; if (v) { res = gp_port_usb_find_device(port, v, p); if (res == GP_OK) { GP_LOG_D ("Found '%s' (0x%x,0x%x)", list->abilities[i].model, v, p); *ability = i; } else if (res < 0 && res != GP_ERROR_IO_USB_FIND) { /* another error occurred. * perhaps we should better * report this to the calling * method? */ GP_LOG_D ( "gp_port_usb_find_device(vendor=0x%x, " "product=0x%x) returned %i, clearing " "error message on port", v, p, res); } if (res != GP_ERROR_IO_USB_FIND) return res; } c = list->abilities[i].usb_class; s = list->abilities[i].usb_subclass; p = list->abilities[i].usb_protocol; if (c) { res = gp_port_usb_find_device_by_class(port, c, s, p); if (res == GP_OK) { GP_LOG_D ("Found '%s' (0x%x,0x%x,0x%x)", list->abilities[i].model, c, s, p); *ability = i; } else if (res < 0 && res != GP_ERROR_IO_USB_FIND) { /* another error occurred. * perhaps we should better * report this to the calling * method? */ GP_LOG_D ( "gp_port_usb_find_device_by_class(" "class=0x%x, subclass=0x%x, " "protocol=0x%x) returned %i, " "clearing error message on port", c, s, p, res); } if (res != GP_ERROR_IO_USB_FIND) return res; } } return res; } /** * \param list a CameraAbilitiesList * \param info_list the GPPortInfoList of ports to use for detection * \param l a #CameraList that contains the autodetected cameras after the call * \param context a #GPContext * * Tries to detect any camera connected to the computer using the supplied * list of supported cameras and the supplied info_list of ports. * * \return a gphoto2 error code */ int gp_abilities_list_detect (CameraAbilitiesList *list, GPPortInfoList *info_list, CameraList *l, GPContext *context) { GPPortInfo info; GPPort *port; int i, info_count; C_PARAMS (list && info_list && l); gp_list_reset (l); CHECK_RESULT (info_count = gp_port_info_list_count (info_list)); CHECK_RESULT (gp_port_new (&port)); for (i = 0; i < info_count; i++) { int res; char *xpath; GPPortType type; CHECK_RESULT (gp_port_info_list_get_info (info_list, i, &info)); CHECK_RESULT (gp_port_set_info (port, info)); gp_port_info_get_type (info, &type); res = gp_port_info_get_path (info, &xpath); if (res <GP_OK) continue; switch (type) { case GP_PORT_USB: case GP_PORT_USB_SCSI: case GP_PORT_USB_DISK_DIRECT: { int ability; res = gp_abilities_list_detect_usb (list, &ability, port); if (res == GP_OK) { gp_list_append(l, list->abilities[ability].model, xpath); } else if (res < 0) gp_port_set_error (port, NULL); break; } case GP_PORT_DISK: { char *s, path[1024]; struct stat stbuf; s = strchr (xpath, ':'); if (!s) break; s++; snprintf (path, sizeof(path), "%s/DCIM", s); if (-1 == stat(path, &stbuf)) { snprintf (path, sizeof(path), "%s/dcim", s); if (-1 == stat(path, &stbuf)) continue; } gp_list_append (l, "Mass Storage Camera", xpath); break; } case GP_PORT_PTPIP: { char *s; s = strchr (xpath, ':'); if (!s) break; s++; if (!strlen(s)) break; gp_list_append (l, "PTP/IP Camera", xpath); break; } default: /* * We currently cannot detect any cameras on this * port */ break; } } gp_port_free (port); return (GP_OK); } /** * \brief Remove first colon from string, if any. Replace it by a space. * \param str a char * string */ static void remove_colon_from_string (char *str) { char *ch; ch = strchr(str, ':'); if (ch) { *ch = ' '; } } /** * \brief Append the abilities to the list. * \param list CameraAbilitiesList * \param abilities CameraAbilities * \return a gphoto2 error code * * This function is called by a camera library on camera_abilities() * in order to inform libgphoto2 about a supported camera model. * */ int gp_abilities_list_append (CameraAbilitiesList *list, CameraAbilities abilities) { C_PARAMS (list); if (list->count == list->maxcount) { C_MEM (list->abilities = realloc (list->abilities, sizeof (CameraAbilities) * (list->maxcount + 100))); list->maxcount += 100; } memcpy (&(list->abilities [list->count]), &abilities, sizeof (CameraAbilities)); /* FIXME: We replace the colon by a space in the model string * This keeps backward compatibility until we have * thought of and implemented something better. */ remove_colon_from_string(list->abilities[list->count].model); list->count++; return (GP_OK); } /** * \brief Reset the list. * \param list a CameraAbilitiesList * \return a gphoto2 error code */ int gp_abilities_list_reset (CameraAbilitiesList *list) { C_PARAMS (list); free (list->abilities); list->abilities = NULL; list->count = 0; list->maxcount = 0; return (GP_OK); } /** * \brief Count the entries in the supplied list. * \param list a #CameraAbilitiesList * \returns The number of entries or a gphoto2 error code */ int gp_abilities_list_count (CameraAbilitiesList *list) { C_PARAMS (list); return (list->count); } static int cmp_abilities (const void *a, const void *b) { const CameraAbilities *ca = a; const CameraAbilities *cb = b; return strcasecmp (ca->model, cb->model); } static int gp_abilities_list_sort (CameraAbilitiesList *list) { C_PARAMS (list); qsort (list->abilities, list->count, sizeof(CameraAbilities), cmp_abilities); return (GP_OK); } static int gp_abilities_list_lookup_id (CameraAbilitiesList *list, const char *id) { int x; C_PARAMS (list && id); for (x = 0; x < list->count; x++) if (!strcmp (list->abilities[x].id, id)) return (x); return (GP_ERROR); } /** * \brief Search the list for an entry of given model name * \param list a #CameraAbilitiesList * \param model a camera model name * \return Index of entry or gphoto2 error code */ int gp_abilities_list_lookup_model (CameraAbilitiesList *list, const char *model) { int x; C_PARAMS (list && model); for (x = 0; x < list->count; x++) { if (!strcasecmp (list->abilities[x].model, model)) return (x); } GP_LOG_E ("Could not find any driver for '%s'", model); return (GP_ERROR_MODEL_NOT_FOUND); } /** * \brief Retrieve the camera abilities of entry with supplied index number. * * \param list a CameraAbilitiesList * \param index index * \param abilities pointer to CameraAbilities for returned data. * \return a gphoto2 error code * * Retrieves the camera abilities of entry with supplied * index number. Typically, you would call gp_camera_set_abilities() * afterwards in order to prepare the initialization of a camera. */ int gp_abilities_list_get_abilities (CameraAbilitiesList *list, int index, CameraAbilities *abilities) { C_PARAMS (list && abilities); C_PARAMS (0 <= index && index < list->count); memcpy (abilities, &list->abilities[index], sizeof (CameraAbilities)); return (GP_OK); } #ifdef _GPHOTO2_INTERNAL_CODE /* enum CameraOperation */ const StringFlagItem gpi_camera_operation_map[] = { { "none", GP_OPERATION_NONE }, { "capture_image", GP_OPERATION_CAPTURE_IMAGE }, { "capture_video", GP_OPERATION_CAPTURE_VIDEO }, { "capture_audio", GP_OPERATION_CAPTURE_AUDIO }, { "capture_preview", GP_OPERATION_CAPTURE_PREVIEW }, { "config", GP_OPERATION_CONFIG }, { NULL, 0 }, }; /* enum CameraFileOperation */ const StringFlagItem gpi_file_operation_map[] = { { "none", GP_FILE_OPERATION_NONE }, { "delete", GP_FILE_OPERATION_DELETE }, { "preview", GP_FILE_OPERATION_PREVIEW }, { "raw", GP_FILE_OPERATION_RAW }, { "audio", GP_FILE_OPERATION_AUDIO }, { "exif", GP_FILE_OPERATION_EXIF }, { NULL, 0 }, }; /* enum CameraFolderOperation */ const StringFlagItem gpi_folder_operation_map[] = { { "none", GP_FOLDER_OPERATION_NONE }, { "delete_all", GP_FOLDER_OPERATION_DELETE_ALL }, { "put_file", GP_FOLDER_OPERATION_PUT_FILE }, { "make_dir", GP_FOLDER_OPERATION_MAKE_DIR }, { "remove_dir", GP_FOLDER_OPERATION_REMOVE_DIR }, { NULL, 0 }, }; /* enum GphotoDeviceType */ const StringFlagItem gpi_gphoto_device_type_map[] = { { "still_camera", GP_DEVICE_STILL_CAMERA }, { "audio_player", GP_DEVICE_AUDIO_PLAYER }, { NULL, 0 }, }; /* enum CameraDriverStatus */ const StringFlagItem gpi_camera_driver_status_map[] = { { "production", GP_DRIVER_STATUS_PRODUCTION }, { "testing", GP_DRIVER_STATUS_TESTING }, { "experimental", GP_DRIVER_STATUS_EXPERIMENTAL }, { "deprecated", GP_DRIVER_STATUS_DEPRECATED }, { NULL, 0 }, }; #endif /* _GPHOTO2_INTERNAL_CODE */ /* * Local Variables: * c-file-style:"linux" * indent-tabs-mode:t * End: */
23.937765
79
0.679863
56a84b460302787bdedfa18682c633e62111faa1
1,122
h
C
centauri/camera.h
MBakels/Centauri_Framework
eaca476af5ef8c7679e9026605868e8db2af014f
[ "MIT" ]
null
null
null
centauri/camera.h
MBakels/Centauri_Framework
eaca476af5ef8c7679e9026605868e8db2af014f
[ "MIT" ]
null
null
null
centauri/camera.h
MBakels/Centauri_Framework
eaca476af5ef8c7679e9026605868e8db2af014f
[ "MIT" ]
null
null
null
#ifndef CAMERA_H #define CAMERA_H #include <GLFW/glfw3.h> #include <glm/glm.hpp> #include <glm/ext.hpp> #include <glm/gtc/matrix_transform.hpp> #include "vectorx.h" class Camera { public: Camera(); virtual ~Camera(); void UpdateCamera(); glm::mat4 ViewMatrix() { return _viewMatrix; }; glm::mat4 ProjectionMatrix() { return _projectionMatrix; }; void Camera::Orthogonal(); std::string PostProcessingVertexshader() { return _postProcessingVertexshader; }; std::string PostProcessingFragmentshader() { return _postProcessingFragmentshader; }; void PostProcessingVertexshader(std::string vertexshader) { _postProcessingVertexshader = vertexshader; }; void PostProcessingFragmentshader(std::string fragmentshader) { _postProcessingFragmentshader = fragmentshader; }; Point3 position; Point3 rotation; private: glm::mat4 _viewMatrix; glm::mat4 _projectionMatrix; Point3 _offset; glm::vec3 _up; glm::vec3 _right; glm::vec3 _direction; std::string _postProcessingVertexshader; // Post processing vertexshader std::string _postProcessingFragmentshader; // Post processing fragmentshader }; #endif
24.391304
115
0.772727
481ca14ffeec08cdf832d800eff3166fdabe9e54
18,710
c
C
third-party/libfabric/libfabric-src/prov/mrail/src/mrail_cq.c
nldias/chapel
3a63044cd50b639dca8e851d4a505546b57bc299
[ "ECL-2.0", "Apache-2.0" ]
3
2015-02-15T16:49:11.000Z
2017-06-23T13:15:50.000Z
third-party/libfabric/libfabric-src/prov/mrail/src/mrail_cq.c
nldias/chapel
3a63044cd50b639dca8e851d4a505546b57bc299
[ "ECL-2.0", "Apache-2.0" ]
30
2017-01-20T21:37:45.000Z
2017-03-28T21:11:56.000Z
third-party/libfabric/libfabric-src/prov/mrail/src/mrail_cq.c
nldias/chapel
3a63044cd50b639dca8e851d4a505546b57bc299
[ "ECL-2.0", "Apache-2.0" ]
2
2020-02-27T21:06:13.000Z
2020-04-21T11:19:31.000Z
/* * Copyright (c) 2018-2019 Intel Corporation, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE 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 <ofi_iov.h> #include "mrail.h" static int mrail_cq_write_send_comp(struct util_cq *cq, struct mrail_tx_buf *tx_buf) { int ret = 0; ofi_ep_tx_cntr_inc(&tx_buf->ep->util_ep); if (tx_buf->flags & FI_COMPLETION) { ret = ofi_cq_write(cq, tx_buf->context, (tx_buf->flags & (FI_TAGGED | FI_MSG)) | FI_SEND, 0, NULL, 0, 0); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to write to util cq\n"); } } if (tx_buf->hdr.protocol == MRAIL_PROTO_RNDV && tx_buf->hdr.protocol_cmd == MRAIL_RNDV_REQ) { free(tx_buf->rndv_req); fi_close(tx_buf->rndv_mr_fid); } ofi_ep_lock_acquire(&tx_buf->ep->util_ep); ofi_buf_free(tx_buf); ofi_ep_lock_release(&tx_buf->ep->util_ep); return ret; } int mrail_cq_write_recv_comp(struct mrail_ep *mrail_ep, struct mrail_hdr *hdr, struct fi_cq_tagged_entry *comp, struct mrail_recv *recv) { FI_DBG(&mrail_prov, FI_LOG_CQ, "finish recv: length: %zu " "tag: 0x%" PRIx64 "\n", comp->len - sizeof(struct mrail_pkt), hdr->tag); ofi_ep_rx_cntr_inc(&mrail_ep->util_ep); if (!(recv->flags & FI_COMPLETION)) return 0; return ofi_cq_write(mrail_ep->util_ep.rx_cq, recv->context, recv->comp_flags | (comp->flags & FI_REMOTE_CQ_DATA), comp->len - sizeof(struct mrail_pkt), NULL, comp->data, hdr->tag); } static int mrail_cq_write_rndv_recv_comp(struct mrail_ep *mrail_ep, struct mrail_recv *recv) { FI_DBG(&mrail_prov, FI_LOG_CQ, "finish rndv recv: length: %zu " "tag: 0x%" PRIx64 "\n", recv->rndv.len, recv->rndv.tag); ofi_ep_rx_cntr_inc(&mrail_ep->util_ep); if (!(recv->flags & FI_COMPLETION)) return 0; return ofi_cq_write(mrail_ep->util_ep.rx_cq, recv->context, recv->comp_flags | recv->rndv.flags, recv->rndv.len, NULL, recv->rndv.data, recv->rndv.tag); } static void mrail_finish_rndv_recv(struct util_cq *cq, struct mrail_req *req, struct fi_cq_tagged_entry *comp) { struct mrail_cq *mrail_cq = container_of(cq, struct mrail_cq, util_cq); struct mrail_recv *recv = req->comp.op_context; int ret; ret = mrail_cq_write_rndv_recv_comp(req->mrail_ep, recv); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Cannot write to recv cq\n"); assert(0); } ret = mrail_send_rndv_ack_blocking(req->mrail_ep, mrail_cq, recv->addr, (void *)recv->rndv.context); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Cannot send rndv ack: %s\n", fi_strerror(-ret)); assert(0); } mrail_free_req(req->mrail_ep, req); mrail_push_recv(recv); } static int mrail_cq_process_rndv_req(struct fi_cq_tagged_entry *comp, struct mrail_recv *recv) { struct fi_recv_context *recv_ctx = comp->op_context; struct fi_msg msg = { .context = recv_ctx, }; struct mrail_ep *mrail_ep; struct mrail_pkt *mrail_pkt; struct mrail_rndv_hdr *rndv_hdr; struct mrail_rndv_req *rndv_req; struct fi_msg_rma rma_msg; uint64_t *base_addrs; size_t key_size; size_t offset; int ret, retv = 0; int i; mrail_ep = recv_ctx->ep->fid.context; mrail_pkt = (struct mrail_pkt *)comp->buf; rndv_hdr = (struct mrail_rndv_hdr *)&mrail_pkt[1]; rndv_req = (struct mrail_rndv_req *)&rndv_hdr[1]; recv->rndv.context = (void *)rndv_hdr->context; recv->rndv.flags = comp->flags & FI_REMOTE_CQ_DATA; recv->rndv.len = rndv_req->len; recv->rndv.tag = mrail_pkt->hdr.tag; recv->rndv.data = comp->data; base_addrs = (uint64_t *)(rndv_req->rawkey + rndv_req->rawkey_size); for (offset = 0, i = 0; i < rndv_req->count; i++) { if (i < rndv_req->mr_count) { key_size = rndv_req->rma_iov[i].key; ret = fi_mr_map_raw(&mrail_ep->util_ep.domain->domain_fid, base_addrs[i], rndv_req->rawkey + offset, key_size, &rndv_req->rma_iov[i].key, 0); assert(!ret); offset += key_size; } else { rndv_req->rma_iov[i].key = rndv_req->rma_iov[0].key; } } rma_msg.msg_iov = recv->iov + 1; rma_msg.desc = recv->desc + 1; rma_msg.iov_count = recv->count - 1; rma_msg.addr = recv->addr; rma_msg.rma_iov = rndv_req->rma_iov; rma_msg.rma_iov_count = rndv_req->count; rma_msg.context = recv; ret = fi_readmsg(&mrail_ep->util_ep.ep_fid, &rma_msg, MRAIL_RNDV_FLAG | FI_COMPLETION); if (ret) retv = ret; ret = fi_recvmsg(recv_ctx->ep, &msg, FI_DISCARD); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to discard buffered recv\n"); retv = retv ? retv : ret; } return retv; } static int mrail_cq_process_rndv_ack(struct fi_cq_tagged_entry *comp) { struct fi_recv_context *recv_ctx = comp->op_context; struct fi_msg msg = { .context = recv_ctx, }; struct mrail_pkt *mrail_pkt; struct mrail_rndv_hdr *rndv_hdr; struct mrail_tx_buf *tx_buf; int ret, retv = 0; mrail_pkt = (struct mrail_pkt *)comp->buf; rndv_hdr = (struct mrail_rndv_hdr *)&mrail_pkt[1]; tx_buf = (struct mrail_tx_buf *)rndv_hdr->context; ret = mrail_cq_write_send_comp(tx_buf->ep->util_ep.tx_cq, tx_buf); if (ret) retv = ret; ret = fi_recvmsg(recv_ctx->ep, &msg, FI_DISCARD); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to discard buffered recv\n"); retv = retv ? retv : ret; } return retv; } int mrail_cq_process_buf_recv(struct fi_cq_tagged_entry *comp, struct mrail_recv *recv) { struct fi_recv_context *recv_ctx = comp->op_context; struct fi_msg msg = { .context = recv_ctx, }; struct mrail_ep *mrail_ep; struct mrail_pkt *mrail_pkt; size_t size, len; int ret, retv = 0; if (comp->flags & FI_MORE) { msg.msg_iov = recv->iov; msg.iov_count = recv->count; msg.addr = recv->addr; recv_ctx->context = recv; ret = fi_recvmsg(recv_ctx->ep, &msg, FI_CLAIM); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to claim buffered recv\n"); assert(0); // TODO write cq error entry } return ret; } mrail_ep = recv_ctx->ep->fid.context; mrail_pkt = (struct mrail_pkt *)comp->buf; if (mrail_pkt->hdr.protocol == MRAIL_PROTO_RNDV) return mrail_cq_process_rndv_req(comp, recv); len = comp->len - sizeof(*mrail_pkt); size = ofi_copy_to_iov(&recv->iov[1], recv->count - 1, 0, mrail_pkt->data, len); if (size < len) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Message truncated recv buf " "size: %zu message length: %zu\n", size, len); ret = ofi_cq_write_error_trunc( mrail_ep->util_ep.rx_cq, recv->context, recv->comp_flags | (comp->flags & FI_REMOTE_CQ_DATA), 0, NULL, comp->data, mrail_pkt->hdr.tag, comp->len - size); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to write truncation error to util cq\n"); retv = ret; } mrail_cntr_incerr(mrail_ep->util_ep.rx_cntr); goto out; } ret = mrail_cq_write_recv_comp(mrail_ep, &mrail_pkt->hdr, comp, recv); if (ret) retv = ret; out: ret = fi_recvmsg(recv_ctx->ep, &msg, FI_DISCARD); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to discard buffered recv\n"); retv = retv ? retv : ret; } mrail_push_recv(recv); return retv; } /* Should only be called while holding the EP's lock */ static struct mrail_recv *mrail_match_recv(struct mrail_ep *mrail_ep, struct fi_cq_tagged_entry *comp, int src_addr) { struct mrail_hdr *hdr = comp->buf; struct mrail_recv *recv; if (hdr->op == ofi_op_msg) { FI_DBG(&mrail_prov, FI_LOG_CQ, "Got MSG op\n"); recv = mrail_match_recv_handle_unexp(&mrail_ep->recv_queue, 0, src_addr, (char *)comp, sizeof(*comp), NULL); } else { assert(hdr->op == ofi_op_tagged); FI_DBG(&mrail_prov, FI_LOG_CQ, "Got TAGGED op with tag: 0x%" PRIx64 "\n", hdr->tag); recv = mrail_match_recv_handle_unexp(&mrail_ep->trecv_queue, hdr->tag, src_addr, (char *)comp, sizeof(*comp), NULL); } return recv; } static struct mrail_ooo_recv *mrail_get_next_recv(struct mrail_peer_info *peer_info) { struct slist *queue = &peer_info->ooo_recv_queue; struct mrail_ooo_recv *ooo_recv; if (!slist_empty(queue)) { ooo_recv = container_of(queue->head, struct mrail_ooo_recv, entry); if (ooo_recv->seq_no == peer_info->expected_seq_no) { slist_remove_head(queue); peer_info->expected_seq_no++; return ooo_recv; } } return NULL; } static int mrail_process_ooo_recvs(struct mrail_ep *mrail_ep, struct mrail_peer_info *peer_info) { struct mrail_ooo_recv *ooo_recv; struct mrail_recv *recv; int ret; ofi_ep_lock_acquire(&mrail_ep->util_ep); ooo_recv = mrail_get_next_recv(peer_info); while (ooo_recv) { FI_DBG(&mrail_prov, FI_LOG_CQ, "found ooo_recv seq=%d\n", ooo_recv->seq_no); /* Requesting FI_AV_TABLE from the underlying provider allows * us to use peer_info->addr as an int here. */ recv = mrail_match_recv(mrail_ep, &ooo_recv->comp, (int) peer_info->addr); ofi_ep_lock_release(&mrail_ep->util_ep); if (recv) { ret = mrail_cq_process_buf_recv(&ooo_recv->comp, recv); if (ret) return ret; } ofi_ep_lock_acquire(&mrail_ep->util_ep); ofi_buf_free(ooo_recv); ooo_recv = mrail_get_next_recv(peer_info); } ofi_ep_lock_release(&mrail_ep->util_ep); return 0; } static int mrail_ooo_recv_before(struct slist_entry *item, const void *arg) { struct mrail_ooo_recv *ooo_recv; struct mrail_ooo_recv *new_recv; ooo_recv = container_of(item, struct mrail_ooo_recv, entry); new_recv = container_of(arg, struct mrail_ooo_recv, entry); return (new_recv->seq_no < ooo_recv->seq_no); } /* Should only be called while holding the EP's lock */ static void mrail_save_ooo_recv(struct mrail_ep *mrail_ep, struct mrail_peer_info *peer_info, uint32_t seq_no, struct fi_cq_tagged_entry *comp) { struct slist *queue = &peer_info->ooo_recv_queue; struct mrail_ooo_recv *ooo_recv; ooo_recv = ofi_buf_alloc(mrail_ep->ooo_recv_pool); if (!ooo_recv) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Cannot allocate ooo_recv\n"); assert(0); } ooo_recv->entry.next = NULL; ooo_recv->seq_no = seq_no; memcpy(&ooo_recv->comp, comp, sizeof(*comp)); slist_insert_before_first_match(queue, mrail_ooo_recv_before, &ooo_recv->entry); FI_DBG(&mrail_prov, FI_LOG_CQ, "saved ooo_recv seq=%d\n", seq_no); } static int mrail_handle_recv_completion(struct fi_cq_tagged_entry *comp, fi_addr_t src_addr) { struct fi_recv_context *recv_ctx; struct mrail_peer_info *peer_info; struct mrail_ep *mrail_ep; struct mrail_recv *recv; struct mrail_hdr *hdr; uint32_t seq_no; int ret; if (comp->flags & FI_CLAIM) { /* This message has already been processed and claimed. * See mrail_cq_process_buf_recv(). */ recv = comp->op_context; assert(recv->hdr.version == MRAIL_HDR_VERSION); ret = mrail_cq_write_recv_comp(recv->ep, &recv->hdr, comp, recv); mrail_push_recv(recv); goto exit; } recv_ctx = comp->op_context; mrail_ep = recv_ctx->ep->fid.context; hdr = comp->buf; // TODO make rxm send buffered recv amount of data for large message assert(hdr->version == MRAIL_HDR_VERSION); if (hdr->protocol == MRAIL_PROTO_RNDV && hdr->protocol_cmd == MRAIL_RNDV_ACK) return mrail_cq_process_rndv_ack(comp); seq_no = ntohl(hdr->seq); peer_info = ofi_av_get_addr(mrail_ep->util_ep.av, (int) src_addr); FI_DBG(&mrail_prov, FI_LOG_CQ, "ep=%p peer=%d received seq=%d, expected=%d\n", mrail_ep, (int)peer_info->addr, seq_no, peer_info->expected_seq_no); ofi_ep_lock_acquire(&mrail_ep->util_ep); if (seq_no == peer_info->expected_seq_no) { /* This message was received in order */ peer_info->expected_seq_no++; /* Requesting FI_AV_TABLE from the underlying provider allows * us to use src_addr as an int here. */ recv = mrail_match_recv(mrail_ep, comp, (int) src_addr); ofi_ep_lock_release(&mrail_ep->util_ep); if (recv) { ret = mrail_cq_process_buf_recv(comp, recv); if (ret) goto exit; } /* Process any next-in-order message that had already arrived */ ret = mrail_process_ooo_recvs(mrail_ep, peer_info); } else { /* This message was received early. * Save it into the out-of-order recv queue. */ mrail_save_ooo_recv(mrail_ep, peer_info, seq_no, comp); ofi_ep_lock_release(&mrail_ep->util_ep); ret = 0; } exit: return ret; } static int mrail_cq_close(fid_t fid) { struct mrail_cq *mrail_cq = container_of(fid, struct mrail_cq, util_cq.cq_fid.fid); int ret, retv = 0; ret = mrail_close_fids((struct fid **)mrail_cq->cqs, mrail_cq->num_cqs); if (ret) retv = ret; free(mrail_cq->cqs); ret = ofi_cq_cleanup(&mrail_cq->util_cq); if (ret) retv = retv ? retv : ret; free(mrail_cq); return retv; } static struct fi_ops mrail_cq_fi_ops = { .size = sizeof(struct fi_ops), .close = mrail_cq_close, .bind = fi_no_bind, .control = fi_no_control, .ops_open = fi_no_ops_open, }; static struct fi_ops_cq mrail_cq_ops = { .size = sizeof(struct fi_ops_cq), .read = ofi_cq_read, .readfrom = ofi_cq_readfrom, .readerr = ofi_cq_readerr, .sread = ofi_cq_sread, .sreadfrom = ofi_cq_sreadfrom, .signal = ofi_cq_signal, // TODO define cq strerror, may need to pass rail index // in err_data .strerror = fi_no_cq_strerror, }; static void mrail_handle_rma_completion(struct util_cq *cq, struct fi_cq_tagged_entry *comp) { int ret; struct mrail_req *req; struct mrail_subreq *subreq; subreq = comp->op_context; req = subreq->parent; if (ofi_atomic_dec32(&req->expected_subcomps) == 0) { if (req->comp.flags & MRAIL_RNDV_FLAG) { mrail_finish_rndv_recv(cq, req, comp); return; } ret = ofi_cq_write(cq, req->comp.op_context, req->comp.flags, req->comp.len, req->comp.buf, req->comp.data, req->comp.tag); if (ret) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Cannot write to util cq\n"); /* This should not happen unless totally out of memory, * in which case there is nothing we can do. */ assert(0); } if (comp->flags & FI_WRITE) ofi_ep_wr_cntr_inc(&req->mrail_ep->util_ep); else ofi_ep_rd_cntr_inc(&req->mrail_ep->util_ep); mrail_free_req(req->mrail_ep, req); } } void mrail_poll_cq(struct util_cq *cq) { struct mrail_cq *mrail_cq; struct mrail_tx_buf *tx_buf; struct fi_cq_tagged_entry comp; fi_addr_t src_addr; size_t i, idx; int ret; static int last_succ_rail = 0; mrail_cq = container_of(cq, struct mrail_cq, util_cq); for (i = 0; i < mrail_cq->num_cqs;) { idx = (last_succ_rail + i) % mrail_cq->num_cqs; ret = fi_cq_readfrom(mrail_cq->cqs[idx], &comp, 1, &src_addr); if (ret == -FI_EAGAIN || !ret) { i++; continue; } if (ret < 0) { FI_WARN(&mrail_prov, FI_LOG_CQ, "Unable to read rail completion: %s\n", fi_strerror(-ret)); goto err; } // TODO handle variable length message if (comp.flags & FI_RECV) { ret = mrail_cq->process_comp(&comp, src_addr); if (ret) goto err; } else if (comp.flags & (FI_READ | FI_WRITE)) { mrail_handle_rma_completion(cq, &comp); } else if (comp.flags & FI_SEND) { tx_buf = comp.op_context; if (tx_buf->hdr.protocol == MRAIL_PROTO_RNDV) { if (tx_buf->hdr.protocol_cmd == MRAIL_RNDV_REQ) { /* buf will be freed when ACK comes */ } else if (tx_buf->hdr.protocol_cmd == MRAIL_RNDV_ACK) { ofi_ep_lock_acquire(&tx_buf->ep->util_ep); ofi_buf_free(tx_buf); ofi_ep_lock_release(&tx_buf->ep->util_ep); } } else { ret = mrail_cq_write_send_comp(cq, tx_buf); if (ret) goto err; } } else { /* We currently cannot support FI_REMOTE_READ and * FI_REMOTE_WRITE because RMA operations are split * across all rails. We would need to introduce some * sort of protocol to keep track of remotely-initiated * RMA operations. */ assert(comp.flags & (FI_REMOTE_READ | FI_REMOTE_WRITE)); FI_WARN(&mrail_prov, FI_LOG_CQ, "Unsupported completion flag\n"); } last_succ_rail = idx; if (mrail_config[0].policy == MRAIL_POLICY_FIXED) break; } return; err: // TODO write error to cq assert(0); } static void mrail_cq_progress(struct util_cq *cq) { mrail_poll_cq(cq); /* Progress the bound EPs */ ofi_cq_progress(cq); } int mrail_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr, struct fid_cq **cq_fid, void *context) { struct mrail_domain *mrail_domain; struct mrail_cq *mrail_cq; struct fi_cq_attr rail_cq_attr = { .wait_obj = FI_WAIT_NONE, .format = MRAIL_RAIL_CQ_FORMAT, .size = attr->size, }; size_t i; int ret; mrail_cq = calloc(1, sizeof(*mrail_cq)); if (!mrail_cq) return -FI_ENOMEM; ret = ofi_cq_init(&mrail_prov, domain, attr, &mrail_cq->util_cq, &mrail_cq_progress, context); if (ret) { free(mrail_cq); return ret; } mrail_domain = container_of(domain, struct mrail_domain, util_domain.domain_fid); mrail_cq->cqs = calloc(mrail_domain->num_domains, sizeof(*mrail_cq->cqs)); if (!mrail_cq->cqs) goto err; mrail_cq->num_cqs = mrail_domain->num_domains; for (i = 0; i < mrail_cq->num_cqs; i++) { ret = fi_cq_open(mrail_domain->domains[i], &rail_cq_attr, &mrail_cq->cqs[i], NULL); if (ret) { FI_WARN(&mrail_prov, FI_LOG_EP_CTRL, "Unable to open rail CQ\n"); goto err; } } // TODO add regular process comp when FI_BUFFERED_RECV not set mrail_cq->process_comp = mrail_handle_recv_completion; *cq_fid = &mrail_cq->util_cq.cq_fid; (*cq_fid)->fid.ops = &mrail_cq_fi_ops; (*cq_fid)->ops = &mrail_cq_ops; return 0; err: mrail_cq_close(&mrail_cq->util_cq.cq_fid.fid); return ret; }
27.514706
84
0.696259
21e92264da682f26877a649aa05c84c882196296
401
h
C
platform/ItronOSWrapper/private/ItronLock.h
katono/cppelib
bb2be96eaea2d0d742f65deafbe8cd33363f3003
[ "MIT" ]
8
2018-07-27T20:43:08.000Z
2021-08-14T05:10:41.000Z
platform/ItronOSWrapper/private/ItronLock.h
katono/cppelib
bb2be96eaea2d0d742f65deafbe8cd33363f3003
[ "MIT" ]
null
null
null
platform/ItronOSWrapper/private/ItronLock.h
katono/cppelib
bb2be96eaea2d0d742f65deafbe8cd33363f3003
[ "MIT" ]
null
null
null
#ifndef ITRON_LOCK_H_INCLUDED #define ITRON_LOCK_H_INCLUDED #include "kernel.h" namespace ItronOSWrapper { class Lock { private: ID m_mtxId; ER m_err; public: explicit Lock(ID mtxId) : m_mtxId(mtxId), m_err(E_OK) { if (m_mtxId > 0) { m_err = loc_mtx(m_mtxId); } } ~Lock() { if ((m_mtxId > 0) && (m_err == E_OK)) { unl_mtx(m_mtxId); } } }; } #endif // ITRON_LOCK_H_INCLUDED
12.935484
54
0.650873
ad4b90995c739a5919ecfbd6311eb757399a31bd
3,080
h
C
Source/Samples/83_Theora/TheoraPlayer.h
elix22/Urho3D-Theora
dde418017c46851884e0f873c5a3b07c7b5f9f71
[ "MIT" ]
11
2020-02-01T11:39:26.000Z
2021-10-19T03:36:49.000Z
Source/Samples/83_Theora/TheoraPlayer.h
elix22/Urho3D-Theora
dde418017c46851884e0f873c5a3b07c7b5f9f71
[ "MIT" ]
null
null
null
Source/Samples/83_Theora/TheoraPlayer.h
elix22/Urho3D-Theora
dde418017c46851884e0f873c5a3b07c7b5f9f71
[ "MIT" ]
4
2020-02-19T13:44:01.000Z
2021-10-19T03:36:52.000Z
// // Copyright (c) 2008-2020 the Urho3D project. // // 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 "Sample.h" #include "TheoraData.h" //============================================================================= //============================================================================= namespace Urho3D { class Node; class Scene; class StaticModel; class Material; class Texture2D; } class Theora; class TheoraAudio; //============================================================================= //============================================================================= class TheoraPlayer : public Sample { URHO3D_OBJECT(TheoraPlayer, Sample); public: /// Construct. TheoraPlayer(Context* context); virtual void Setup(); virtual void Start(); private: void CreateScene(); void InitializeTheora(); void AddElapsedTime(float timeStep); void ProcessAudioVideo(); void Play(); void Pause(); void Stop(); bool SetOutputModel(StaticModel *model); void ScaleModelAccordingVideoRatio(); void InitAudio(); bool InitTexture(); /// Construct an instruction text to the UI. void CreateInstructions(); /// Subscribe to application-wide logic update events. void SubscribeToEvents(); /// Handle the logic update event. void HandleUpdate(StringHash eventType, VariantMap& eventData); /// Read input and moves the camera. void MoveCamera(float timeStep); private: SharedPtr<Theora> theora_; Vector<SharedPtr<VideoData>> videoBufferContainer_; Vector<SharedPtr<AudioData>> audioBufferContainer_; SharedPtr<StaticModel> outputModel_; SharedPtr<Material> outputMaterial_; SharedArrayPtr<unsigned char> framePlanarDataRGBA_; SharedPtr<Texture2D> rgbaTexture_; SharedPtr<TheoraAudio> theoraAudio_; TheoraAVInfo theoraAVInfo_; WeakPtr<Node> tvNode_; bool rescaleNode_; float elapsedTime_; int64_t elapsedTime64_; bool stopped_; bool paused_; Timer inputTimer_; };
31.752577
80
0.659416
4299adf5b4393f6fd26c894da6ebf560543b33e6
787
c
C
src/sel4_strncmp.c
winksaville/libsel4string
6d64fb753e503110ac4c074ed02b97b1e79bbb18
[ "BSD-2-Clause" ]
null
null
null
src/sel4_strncmp.c
winksaville/libsel4string
6d64fb753e503110ac4c074ed02b97b1e79bbb18
[ "BSD-2-Clause" ]
null
null
null
src/sel4_strncmp.c
winksaville/libsel4string
6d64fb753e503110ac4c074ed02b97b1e79bbb18
[ "BSD-2-Clause" ]
null
null
null
/* * copyright 2015, Wink Saville * * this software may be distributed and modified according to the terms of * the bsd 2-clause license. note that no warranty is provided. * see "license_bsd2.txt" for details. */ #include <sel4/simple_types.h> #include <sel4/string.h> /** * Compare two strings, returns 0 if they are identical. * return < 0 if the first non-matching character of str1 * is < that of str2 or > 0 if str1 > str2. */ int seL4_StrNCmp(const char *str1, const char *str2, int num) { int diff = 0; if (num > 0) { for (int i = 0; i < num; i++) { char ch1 = str1[i]; char ch2 = str2[i]; diff = ch1 - ch2; if (diff != 0) { return diff; } } } return diff; }
24.59375
74
0.56925
8e0da4f129754d37bb54150dc44859de07030967
300
h
C
Example/JBInterfaceController/JBInterfaceController/AppDelegate.h
jacobvanorder/JBInterfaceController
4fb111d900d5ee9b9c42ec82b070936d05596232
[ "MIT" ]
52
2015-04-03T08:29:27.000Z
2021-07-09T15:17:33.000Z
Example/JBInterfaceController/JBInterfaceController/AppDelegate.h
jacobvanorder/JBInterfaceController
4fb111d900d5ee9b9c42ec82b070936d05596232
[ "MIT" ]
null
null
null
Example/JBInterfaceController/JBInterfaceController/AppDelegate.h
jacobvanorder/JBInterfaceController
4fb111d900d5ee9b9c42ec82b070936d05596232
[ "MIT" ]
5
2015-04-21T20:41:31.000Z
2015-09-07T05:25:06.000Z
// // AppDelegate.h // JBInterfaceController // // Created by Michael Swanson on 4/2/15. // Copyright (c) 2015 Michael Swanson. All rights reserved. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
16.666667
60
0.72
19ddeb5f51f48f5a9729334022752e7ff0d8e567
1,921
c
C
rtos/kernel/assert.c
n3rd-bugs/tiny-rtos
4014c58f8f15c95df6ab60f4ad2c5e456f97ad7f
[ "RSA-MD" ]
6
2017-07-24T08:32:09.000Z
2020-12-20T22:55:02.000Z
rtos/kernel/assert.c
n3rd-bugs/tiny-rtos
4014c58f8f15c95df6ab60f4ad2c5e456f97ad7f
[ "RSA-MD" ]
1
2020-02-05T03:10:42.000Z
2020-02-06T09:15:26.000Z
rtos/kernel/assert.c
n3rd-bugs/tiny-rtos
4014c58f8f15c95df6ab60f4ad2c5e456f97ad7f
[ "RSA-MD" ]
null
null
null
/* * assert.c * * Copyright (c) 2015 Usama Masood <mirzaon@gmail.com> All rights reserved. * * This file is part of a non-commercial software. For more details please * refer to the license agreement that comes with this software. * * If you have not received a license file please contact: * Usama Masood <mirzaon@gmail.com> * */ #include <kernel.h> #include <sys_info.h> #include <string.h> #include <stdlib.h> #ifdef IO_SERIAL #include <serial.h> #endif /* IO_SERIAL */ /* * system_assert * @code: This can be used to identify the issue. * @file: File from where this assert was raised. * @line: Line number from which this assert was raised. * @task: The task context from which this was called. * This function will halt the system and print the file/line and task * information if required. */ void system_assert(int32_t code, char *file, uint32_t line, TASK *task) { #ifdef IO_SERIAL #ifdef ASSERT_FILE_INFO uint8_t line_buf[12]; #endif /* ASSERT_FILE_INFO */ #endif /* Remove some compiler warnings. */ UNUSED_PARAM(code); UNUSED_PARAM(task); #if (!defined(ASSERT_FILE_INFO) || !defined(IO_SERIAL)) UNUSED_PARAM(file); UNUSED_PARAM(line); #endif /* Disable system interrupts. */ DISABLE_INTERRUPTS(); #ifdef IO_SERIAL #ifdef ASSERT_FILE_INFO /* Put filename. */ serial_assert_puts((uint8_t *)file, 0); /* Put colon. */ serial_assert_puts((uint8_t *)":", 0); /* Print line number. */ itoa((int)line, (char *)line_buf, 10); serial_assert_puts(line_buf, 0); /* Put line terminator. */ serial_assert_puts((uint8_t *)"\r\n", 0); #endif /* ASSERT_FILE_INFO */ #ifdef TASK_STATS /* Print current system information. */ util_print_sys_info_assert(); #endif /* TASK_STATS */ #endif /* IO_SERIAL */ /* For now there are no recovery mechanisms defined. */ while (1) { ; } } /* system_assert */
24.628205
75
0.67621
257f817371056a53e41777ebc196470261f89935
15,733
c
C
benchmarks/milc/milc_qcd-7.8.1/generic/field_utilities.c
mcopik/perf-taint
16613b83f504c114a77f7a22d587c29ce52d7a4b
[ "BSD-3-Clause" ]
2
2020-10-20T09:27:07.000Z
2021-03-22T05:10:24.000Z
benchmarks/milc/milc_qcd-7.8.1/generic/field_utilities.c
spcl/perf-taint
16613b83f504c114a77f7a22d587c29ce52d7a4b
[ "BSD-3-Clause" ]
11
2021-06-03T08:55:28.000Z
2022-01-20T19:38:29.000Z
benchmarks/milc/milc_qcd-7.8.1/generic/field_utilities.c
mcopik/perf-taint
16613b83f504c114a77f7a22d587c29ce52d7a4b
[ "BSD-3-Clause" ]
1
2020-12-05T09:53:50.000Z
2020-12-05T09:53:50.000Z
/************************ field_utilities.c *****************************/ /* MIMD version 7 */ /* A collection of utilities for creating and copying fields */ /* (Plus a timing utility) */ #include "generic_includes.h" /*--------------------------------------------------------------------*/ double start_timing(void){ double dtime; #ifdef PRTIME dtime = -dclock(); #else dtime = 0; #endif return dtime; } /*--------------------------------------------------------------------*/ void print_timing(double dtime, char *str){ #ifdef PRTIME dtime += dclock(); node0_printf("Time for %s %e\n",str, dtime); fflush(stdout); #endif } /*--------------------------------------------------------------------*/ #define make_clear_field(ABBREV, T) \ void clear_##ABBREV##_field(T *x){ \ memset(x,'\0',sites_on_node*sizeof(T)); \ } #define make_create_field(ABBREV, T) \ T* create_##ABBREV##_field(void){ \ T *x; \ x = (T *)malloc(sites_on_node*sizeof(T)); \ if(x == NULL){ \ printf("create_field: no room\n"); \ terminate(1); \ } \ clear_##ABBREV##_field(x); \ return x; \ } #define make_copy_field(ABBREV, T) \ void copy_##ABBREV##_field(T *dst, T *src){ \ memcpy(dst, src, sites_on_node*sizeof(T)); \ } #define make_destroy_field(ABBREV, T) \ void destroy_##ABBREV##_field(T *x){ \ if(x != NULL) free(x); \ } #define make_all_field(ABBREV, T) \ make_clear_field(ABBREV, T); \ make_create_field(ABBREV, T); \ make_copy_field(ABBREV, T); \ make_destroy_field(ABBREV, T); /*--------------------------------------------------------------------*/ /* Array versions of the above. Each site has n copies of the type */ #define make_clear_array_field(ABBREV, T) \ void clear_##ABBREV##_array_field(T *x, int n){ \ memset(x,'\0',sites_on_node*sizeof(T)*n); \ } #define make_create_array_field(ABBREV, T) \ T* create_##ABBREV##_array_field(int n){ \ T *x; \ x = (T *)malloc(sites_on_node*sizeof(T)*n); \ if(x == NULL){ \ printf("create_array_field: no room\n"); \ terminate(1); \ } \ clear_##ABBREV##_array_field(x,n); \ return x; \ } #define make_copy_array_field(ABBREV, T) \ void copy_##ABBREV##_array_field(T *dst, T *src, int n){ \ memcpy(dst, src, sites_on_node*sizeof(T)*n); \ } #define make_destroy_array_field(ABBREV, T) \ void destroy_##ABBREV##_array_field(T *x, int n){ \ if(x != NULL) free(x); \ } #define make_all_array_field(ABBREV, T) \ make_clear_array_field(ABBREV, T); \ make_create_array_field(ABBREV, T); \ make_copy_array_field(ABBREV, T); \ make_destroy_array_field(ABBREV, T); /*------------------------------------------------------------------*/ /* Create standard create, copy, clear, destroy for standard types */ make_all_field(r, Real) make_all_field(c, complex) make_all_field(v, su3_vector) make_all_field(m, su3_matrix) make_all_field(wv, wilson_vector) make_all_field(swv, spin_wilson_vector) /*------------------------------------------------------------------*/ /* Create standard create, copy, clear, destroy for standard types */ make_all_array_field(r, Real) make_all_array_field(c, complex) make_all_array_field(v, su3_vector) make_all_array_field(m, su3_matrix) make_all_array_field(wv, wilson_vector) make_all_array_field(swv, spin_wilson_vector) /*------------------------------------------------------------------*/ /* copy a gauge field in the site structure - an array of four su3_matrices */ void gauge_field_copy(field_offset src, field_offset dest){ register int i,dir,src2,dest2; register site *s; FORALLSITES(i,s){ src2=src; dest2=dest; for(dir=XUP;dir<=TUP; dir++){ su3mat_copy( (su3_matrix *)F_PT(s,src2), (su3_matrix *)F_PT(s,dest2) ); src2 += sizeof(su3_matrix); dest2 += sizeof(su3_matrix); } } } /*------------------------------------------------------------------*/ /* copy a gauge field from the site structure to a field - an array of four su3_matrices. We imitate the raw QOP format here, but use the MILC layout site order . */ su3_matrix **gauge_field_copy_site_to_field(field_offset src){ int i,dir; site *s; su3_matrix *tmp; su3_matrix **dest; dest = (su3_matrix **)malloc(4*sizeof(su3_matrix *)); FORALLUPDIR(dir){ dest[dir] = (su3_matrix *)malloc(sites_on_node*sizeof(su3_matrix)); if(dest[dir] == NULL){ printf("gauge_field_copy_site_to_field: No room\n"); return NULL; } } FORALLSITES(i,s){ tmp = (su3_matrix *)F_PT(s, src); \ FORALLUPDIR(dir){ su3mat_copy( tmp + dir, dest[dir] + i ); } } return dest; } /*------------------------------------------------------------------*/ /* copy a gauge field from a field to the site structure. The opposite of gauge_field_copy_site_to_field. */ void gauge_field_copy_field_to_site(su3_matrix **src, field_offset dest){ int i,dir; site *s; su3_matrix *tmp; FORALLSITES(i,s){ tmp = (su3_matrix *)F_PT(s, dest); \ FORALLUPDIR(dir){ su3mat_copy( src[dir] + i, tmp + dir ); } } } /*------------------------------------------------------------------*/ /* destroy a gauge field with the format used above */ void destroy_gauge_field(su3_matrix **f){ int dir; if(f != NULL){ FORALLUPDIR(dir){ if(f[dir] != NULL) free(f[dir]); } free(f); } } /*--------------------------------------------------------------------*/ su3_vector *create_v_field_from_site_member(field_offset sv){ su3_vector *v; int i; site *s; v = create_v_field(); FORALLSITES(i,s){ memcpy(v+i, F_PT(s,sv), sizeof(su3_vector)); } return v; } /*--------------------------------------------------------------------*/ void copy_site_member_from_v_field(field_offset sv, su3_vector *v){ int i; site *s; FORALLSITES(i,s){ memcpy(F_PT(s,sv), v+i, sizeof(su3_vector)); } } /*--------------------------------------------------------------------*/ void add_v_fields(su3_vector *vsum, su3_vector *v1, su3_vector *v2){ int i; site *s; FORALLSITES(i,s){ add_su3_vector(v1+i, v2+i, vsum+i); } } /*--------------------------------------------------------------------*/ void extract_c_from_v(complex *c, su3_vector *v, int color){ int i; site *s; FORALLSITES(i,s){ c[i] = v[i].c[color]; } } /*--------------------------------------------------------------------*/ /* Insert complex field into su3_vector field */ void insert_v_from_c(su3_vector *v, complex *c, int color){ int i; site *s; FORALLSITES(i,s){ v[i].c[color] = c[i]; } } /*--------------------------------------------------------------------*/ ks_prop_field *create_ksp_field(int nc){ ks_prop_field *ksp; int color; ksp = (ks_prop_field *)malloc(sizeof(ks_prop_field)); if(ksp == NULL){ printf("create_ksp_field(%d): No room for temporary\n",this_node); terminate(1); } ksp->nc = nc; ksp->v = (su3_vector **) malloc(nc*sizeof(su3_vector *)); if(ksp->v == NULL){ printf("create_ksp_field(%d): No room for temporary\n",this_node); terminate(1); } for(color= 0; color < nc; color++) ksp->v[color] = create_v_field(); return ksp; } /*--------------------------------------------------------------------*/ void clear_ksp_field(ks_prop_field *ksp){ int color; for(color= 0; color < ksp->nc; color++) clear_v_field(ksp->v[color]); } /*--------------------------------------------------------------------*/ void copy_ksp_field(ks_prop_field *kspcopy, ks_prop_field *ksp){ int color; kspcopy->nc = ksp->nc; for(color = 0; color < ksp->nc; color++){ copy_v_field(kspcopy->v[color], ksp->v[color]); } } /*--------------------------------------------------------------------*/ ks_prop_field *create_ksp_field_copy(ks_prop_field *k){ ks_prop_field *ksp; ksp = create_ksp_field(k->nc); copy_ksp_field(ksp, k); return ksp; } /*--------------------------------------------------------------------*/ void destroy_ksp_field(ks_prop_field *ksp){ int color; for(color = 0; color < ksp->nc; color++){ destroy_v_field(ksp->v[color]); } free(ksp->v); free(ksp); } /*--------------------------------------------------------------------*/ void copy_v_from_ksp(su3_vector *v, ks_prop_field *ksp, int color){ int i; site *s; FORALLSITES(i,s){ v[i] = ksp->v[color][i]; } } /*--------------------------------------------------------------------*/ void insert_ksp_from_v(ks_prop_field *ksp, su3_vector *v, int color){ int i; site *s; FORALLSITES(i,s){ ksp->v[color][i] = v[i]; } } /*--------------------------------------------------------------------*/ /* Copy complex field from wilson_vector field */ void extract_c_from_wv(complex *c, wilson_vector *wv, int spin, int color){ int i; site *s; FORALLSITES(i,s){ c[i] = wv[i].d[spin].c[color]; } } /*--------------------------------------------------------------------*/ /* Insert c field into wv field */ void insert_wv_from_c(wilson_vector *wv, complex *c, int spin, int color){ int i; site *s; FORALLSITES(i,s){ wv[i].d[spin].c[color] = c[i]; } } /*--------------------------------------------------------------------*/ /* Insert v field into wv field */ void insert_wv_from_v(wilson_vector *wv, su3_vector *v, int spin){ int i; site *s; int c; FORALLSITES(i,s){ for(c = 0; c < 3; c++) wv[i].d[spin].c[c] = v[i].c[c]; } } /*--------------------------------------------------------------------*/ /* Insert v field into wv field */ void extract_v_from_wv(su3_vector *v, wilson_vector *wv, int spin){ int i; site *s; int c; FORALLSITES(i,s){ for(c = 0; c < 3; c++) v[i].c[c] = wv[i].d[spin].c[c]; } } /*--------------------------------------------------------------------*/ spin_wilson_vector *extract_swv_from_wp(wilson_prop_field *wp, int color){ return wp->swv[color]; } /*--------------------------------------------------------------------*/ /* Reallocates space for the spin wilson vectors */ void rebuild_wp_field(wilson_prop_field *wp){ int color; if(wp->nc <= 0){ node0_printf("rebuild_wp_field: Illegal %d colors\n", wp->nc); terminate(1); } if(wp->swv == NULL){ printf("rebuild_wp_field(%d): Needs allocated swv\n",this_node); terminate(1); } for(color= 0; color < wp->nc; color++) wp->swv[color] = create_swv_field(); } /*--------------------------------------------------------------------*/ wilson_prop_field *create_wp_field(int nc){ wilson_prop_field *wp= NULL; if(nc <= 0){ node0_printf("create_wp_field: Illegal %d colors\n", nc); terminate(1); } wp = (wilson_prop_field *) malloc(sizeof(wilson_prop_field)); if(wp == NULL){ printf("create_wp_field(%d): No room\n",this_node); terminate(1); } wp->nc = nc; wp->swv = (spin_wilson_vector **) malloc(nc*sizeof(spin_wilson_vector *)); if(wp->swv == NULL){ printf("create_wp_field(%d): No room for %d colors in field\n",this_node, nc); terminate(1); } rebuild_wp_field(wp); return wp; } /*--------------------------------------------------------------------*/ void clear_wp_field(wilson_prop_field *wp){ int color; for(color= 0; color < wp->nc; color++) clear_swv_field(wp->swv[color]); } /*--------------------------------------------------------------------*/ void copy_wp_field(wilson_prop_field *wpcopy, wilson_prop_field *wp){ int color, i; site *s; wpcopy->nc = wp->nc; for(color = 0; color < wp->nc; color++){ FORALLSITES(i,s){ wpcopy->swv[color][i] = wp->swv[color][i]; } } } /*--------------------------------------------------------------------*/ void scalar_mult_add_ksprop_field(ks_prop_field *a, ks_prop_field *b, Real s, ks_prop_field *c){ int i,c1; for(c1 = 0; c1 < c->nc; c1++) FORALLFIELDSITES(i){ scalar_mult_add_su3_vector(&a->v[c1][i], &b->v[c1][i], s, &c->v[c1][i]); } } /*--------------------------------------------------------------------*/ void scalar_mult_add_wprop_field(wilson_prop_field *a, wilson_prop_field *b, Real s, wilson_prop_field *c){ int i,s1,c1; for(c1 = 0; c1 < c->nc; c1++) FORALLFIELDSITES(i){ for(s1=0; s1<4; s1++) scalar_mult_add_wvec(&a->swv[c1][i].d[s1], &b->swv[c1][i].d[s1], s, &c->swv[c1][i].d[s1]); } } /*--------------------------------------------------------------------*/ wilson_prop_field *create_wp_field_copy(wilson_prop_field *w){ wilson_prop_field *wp; wp = create_wp_field(w->nc); copy_wp_field(wp, w); return wp; } /*--------------------------------------------------------------------*/ /* Transpose source and sink color and spin indices in place */ wilson_prop_field *transpose_wp_field(wilson_prop_field *wp){ int c1, c2, s1, s2, i; site *s; spin_wilson_vector swv[3]; spin_wilson_vector zero; wilson_prop_field *twp = create_wp_field(3); if(wp->nc < 3){ memset(&zero, '\0', sizeof(zero)); } else if(wp->nc > 3){ node0_printf("transpose_wp_field: Requires max three colors to do a transpose, but have %d\n",wp->nc); terminate(1); } FORALLSITES(i,s){ for(c2 = 0; c2 < 3; c2++){ if(c2 < wp->nc) swv[c2] = wp->swv[c2][i]; else swv[c2] = zero; } for(c2 = 0; c2 < 3; c2++) for(s2 = 0; s2 < 4; s2++) for(s1 = 0; s1 < 4; s1++) for(c1 = 0; c1 < 3; c1++) twp->swv[c1][i].d[s1].d[s2].c[c2] = swv[c2].d[s2].d[s1].c[c1]; } return twp; } /*--------------------------------------------------------------------*/ void copy_wv_from_v(wilson_vector *wv, su3_vector *v, int spin){ int i; FORALLFIELDSITES(i){ wv[i].d[spin] = v[i]; } } /*--------------------------------------------------------------------*/ void copy_wv_from_wp(wilson_vector *wv, wilson_prop_field *wp, int color, int spin){ int i; site *s; FORALLSITES(i,s){ wv[i] = wp->swv[color][i].d[spin]; } } /*--------------------------------------------------------------------*/ void copy_wv_from_wprop(wilson_vector *wv, wilson_propagator *wprop, int color, int spin){ int i; site *s; FORALLSITES(i,s){ wv[i] = wprop[i].c[color].d[spin]; } } /*--------------------------------------------------------------------*/ void copy_wv_from_swv(wilson_vector *wv, spin_wilson_vector *swv, int spin){ int i; site *s; FORALLSITES(i,s){ wv[i] = swv[i].d[spin]; } } /*--------------------------------------------------------------------*/ void copy_wp_from_wv(wilson_prop_field *wp, wilson_vector *wv, int color, int spin){ int i; site *s; FORALLSITES(i,s){ wp->swv[color][i].d[spin] = wv[i]; } } /*--------------------------------------------------------------------*/ /* Free major storage, but preserves nc and swv */ void free_wp_field(wilson_prop_field *wp){ int color; if(wp == NULL)return; for(color = 0; color < wp->nc; color++){ destroy_swv_field(wp->swv[color]); wp->swv[color] = NULL; } } /*--------------------------------------------------------------------*/ /* Free everything */ void destroy_wp_field(wilson_prop_field *wp){ if(wp == NULL)return; free_wp_field(wp); if(wp->swv != NULL) free(wp->swv); free(wp); } /*--------------------------------------------------------------------*/ wilson_vector *create_wv_from_swv(spin_wilson_vector *swv, int spin){ int i; site *s; wilson_vector *wv = create_wv_field(); FORALLSITES(i,s){ wv[i] = swv[i].d[spin]; } return wv; } /*--------------------------------------------------------------------*/ void insert_swv_from_wv(spin_wilson_vector *swv, int spin, wilson_vector *wv){ int i; site *s; FORALLSITES(i,s){ swv[i].d[spin] = wv[i]; } }
25.49919
108
0.50785
e81b30c2c39836bf9b0a605a1399b574f493e580
1,404
h
C
sdktools/trace/traceview/logsessioninformationdlg.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
sdktools/trace/traceview/logsessioninformationdlg.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
sdktools/trace/traceview/logsessioninformationdlg.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2002 Microsoft Corporation. All rights reserved. // Copyright (c) 2002 OSR Open Systems Resources, Inc. // // LogSessionInformationDlg.h : CLogSessionInformationDlg header ////////////////////////////////////////////////////////////////////////////// #pragma once #include "afxwin.h" // CLogSessionInformationDlg dialog class CLogSessionInformationDlg : public CPropertyPage { DECLARE_DYNAMIC(CLogSessionInformationDlg) public: CLogSessionInformationDlg(); virtual ~CLogSessionInformationDlg(); BOOL OnInitDialog(); BOOL OnSetActive(); BOOL OnKillActive(); // Dialog Data enum { IDD = IDD_LOG_SESSION_INFORMATION_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedLogfileBrowseButton(); afx_msg void OnBnClickedWriteLogfileCheck(); afx_msg void OnBnClickedAdvancedButton(); CEdit m_logSessionName; CEdit m_logFileName; CButton m_appendLogFile; CButton m_realTime; CLogSession *m_pLogSession; BOOL m_bAppend; BOOL m_bRealTime; BOOL m_bWriteLogFile; CString m_logFileNameString; CString m_displayNameString; };
28.08
79
0.610399
95c7a41bed52d02d525841d28c590fd95ff385a3
1,708
h
C
research_control/researchmainwindow.h
doublejinitials/soro
1f2e5be0b6a4c0296e927d65fd792afeb4819454
[ "Apache-2.0" ]
1
2018-09-16T20:16:56.000Z
2018-09-16T20:16:56.000Z
research_control/researchmainwindow.h
doublejinitials/soro
1f2e5be0b6a4c0296e927d65fd792afeb4819454
[ "Apache-2.0" ]
null
null
null
research_control/researchmainwindow.h
doublejinitials/soro
1f2e5be0b6a4c0296e927d65fd792afeb4819454
[ "Apache-2.0" ]
null
null
null
#ifndef SORO_MISSIONCONTROL_RESEARCHMAINWINDOW_H #define SORO_MISSIONCONTROL_RESEARCHMAINWINDOW_H #include <QMainWindow> #include <QCloseEvent> #include <QQuickItem> #include <QTimerEvent> #include <QMouseEvent> #include "libsoromc/stereocamerawidget.h" #include "libsoromc/gamepadmanager.h" #include "libsoromc/drivecontrolsystem.h" #include "hudlatencygraphimpl.h" namespace Ui { class ResearchMainWindow; } namespace Soro { namespace MissionControl { class ResearchMainWindow : public QMainWindow { Q_OBJECT public: explicit ResearchMainWindow(const GamepadManager *gamepad, const DriveControlSystem *driveSystem, QWidget *parent = 0); ~ResearchMainWindow(); StereoCameraWidget *getCameraWidget(); bool isHudVisible() const; int getHudParallax() const; int getHudLatency() const; signals: void closed(); public slots: void sensorUpdate(char tag, int value); void setHudParallax(int parallax); void setHudVisible(bool visible); void setHudLatency(int latency); void zeroHudOrientation(); protected: void closeEvent(QCloseEvent *event); void timerEvent(QTimerEvent *event); void resizeEvent(QResizeEvent *event); private slots: void adjustHud(); void adjustSizeAndPosition(); void gamepadPoll(); private: Ui::ResearchMainWindow *ui; const GamepadManager *_gamepad; const DriveControlSystem *_driveSystem; int _updateLatencyTimerId = TIMER_INACTIVE; int _resizeTimerId = TIMER_INACTIVE; int _hudParallax = 50; bool _hudVisible = true; int _hudLatency = 0; QPoint _mouseDownPos; }; } // namespace MissionControl } // namespace Soro #endif // SORO_MISSIONCONTROL_RESEARCHMAINWINDOW_H
24.056338
123
0.755269
95f666d5194e423a049b4ad6dc87ac3236ccd848
1,325
h
C
Frameworks/CNISDKCoreKit.framework/Headers/CNISDKDeliverableCategory.h
conichiGMBH/conichi-ios-sdk-wiki
d5e7ee9bcecfdd9ac476e47643f4966c68b7ce3d
[ "BSD-4-Clause" ]
null
null
null
Frameworks/CNISDKCoreKit.framework/Headers/CNISDKDeliverableCategory.h
conichiGMBH/conichi-ios-sdk-wiki
d5e7ee9bcecfdd9ac476e47643f4966c68b7ce3d
[ "BSD-4-Clause" ]
null
null
null
Frameworks/CNISDKCoreKit.framework/Headers/CNISDKDeliverableCategory.h
conichiGMBH/conichi-ios-sdk-wiki
d5e7ee9bcecfdd9ac476e47643f4966c68b7ce3d
[ "BSD-4-Clause" ]
null
null
null
// // CNISDKDeliverableCategory.h // conichiSDK // // Created by Anton Domashnev on 8/5/15. // Copyright © 2015 conichi. All rights reserved. // #import "CNISDKObject.h" @class CNISDKDeliverableItem; #import "CNISDKEnums.h" #import "CNISDKMacros.h" #define CNISDKDeliverableCategoryKeypath(NAME) CNISDKKeypath(CNISDKDeliverableCategory, NAME) NS_ASSUME_NONNULL_BEGIN /** * The `CNISDKDeliverableCategory` defines entity that represents hotel minibar item category (spirits, snacks, etc) */ @interface CNISDKDeliverableCategory : CNISDKObject /** * Categorie's name */ @property (nonatomic, copy, readonly) NSString *name; /** * Categorie's unique identifier */ @property (nonatomic, copy, readonly) NSString *code; /** * Display order to optionally sort in UI specified by the merchant */ @property (nonatomic, assign, readonly) NSInteger displayOrder; /** * Categorie's use case */ @property (nonatomic, assign, readonly) CNISDKDeliverableCategoryUseCase useCase; /** * Array of subcategories - `CNISDKDeliverableCategory` objects */ @property (nonatomic, strong, readonly) NSArray<CNISDKDeliverableCategory *> *categories; /** * Deliverable items that category contains */ @property (nonatomic, strong, readonly) NSArray<CNISDKDeliverableItem *> *items; @end NS_ASSUME_NONNULL_END
21.721311
117
0.751698
bf004b7d270ad307b96034c624f4ff67b567d6e1
464
h
C
apps/FbxStream/fbxloader.h
mocap-ca/Open3DStream
e376b359d349e18030aec287c3e8eb68928e24ff
[ "MIT" ]
13
2020-07-26T15:19:18.000Z
2021-11-13T05:05:24.000Z
apps/FbxStream/fbxloader.h
pdkyll/Open3DStream
e376b359d349e18030aec287c3e8eb68928e24ff
[ "MIT" ]
null
null
null
apps/FbxStream/fbxloader.h
pdkyll/Open3DStream
e376b359d349e18030aec287c3e8eb68928e24ff
[ "MIT" ]
4
2020-07-28T21:26:24.000Z
2022-01-25T18:58:37.000Z
#ifndef FBXLOADER_H #define FBXLOADER_H #include "o3ds/model.h" #include <fbxsdk.h> #include <string> namespace O3DS { struct TimeInfo { FbxTime Start; FbxTime End; FbxTime Inc; }; class MobuUpdater : public O3DS::Updater { public: MobuUpdater(FbxNode *node); void update(O3DS::Transform *t); std::string info(); FbxNode *mNode; FbxTime mTime; }; int Load(const char *path, O3DS::SubjectList& subjects, TimeInfo &time_info); } #endif
14.5
78
0.698276
bf7adfbf4435af64e7806a200343f933964f563d
2,797
h
C
src/ICPing.h
MajenkoLibraries/ICPing
1ac1c2f11c853b21187a2b0ef04198d90bc39c85
[ "BSD-3-Clause" ]
null
null
null
src/ICPing.h
MajenkoLibraries/ICPing
1ac1c2f11c853b21187a2b0ef04198d90bc39c85
[ "BSD-3-Clause" ]
null
null
null
src/ICPing.h
MajenkoLibraries/ICPing
1ac1c2f11c853b21187a2b0ef04198d90bc39c85
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2015, Majenko Technologies * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of Majenko Technologies nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _ICPING_H #define _ICPING_H #if (ARDUINO >= 100) # include <Arduino.h> #else # include <WProgram.h> #endif class ICPing { private: static bool _timerConfigured; static uint8_t _timerPrescale; volatile static double _usPerTick; static ICPing *_handlers[9]; // Could do with this being smaller? uint8_t _trig_pin; uint8_t _echo_pin; volatile p32_ic *_reg; volatile uint32_t _mm; p32_ioport *_trig_port; uint32_t _trig_mask; uint32_t _irq; uint32_t _vector; volatile bool _ready; volatile bool _first; volatile uint16_t _start; volatile uint16_t _end; volatile bool _freeRun; p32_ioport *getPortInformation(uint8_t pin, uint32_t *mask); public: ICPing(uint8_t trig, uint8_t echo) : _trig_pin(trig), _echo_pin(echo) {} void begin(); void handleFreeRun(); void handleInterrupt(); void startPing(); uint32_t getDistance(); bool isReady(); void enableFreeRunMode(); static void __USER_ISR interruptHandler(); static void __USER_ISR freeRunHandler(); }; #endif
35.405063
83
0.706471
452002c033ac06a094ed99e1c9f9f629df729e58
5,953
h
C
src/GeneratedFiles/ui_dialogStereoSettings.h
USArmyResearchLab/Fusion3D
98b79ccfcbfd444a924f65c321482b540382758d
[ "Apache-2.0" ]
4
2021-09-08T02:07:22.000Z
2022-03-30T02:48:56.000Z
src/GeneratedFiles/ui_dialogStereoSettings.h
USArmyResearchLab/Fusion3D
98b79ccfcbfd444a924f65c321482b540382758d
[ "Apache-2.0" ]
null
null
null
src/GeneratedFiles/ui_dialogStereoSettings.h
USArmyResearchLab/Fusion3D
98b79ccfcbfd444a924f65c321482b540382758d
[ "Apache-2.0" ]
1
2021-10-11T02:53:53.000Z
2021-10-11T02:53:53.000Z
/******************************************************************************** ** Form generated from reading UI file 'dialogStereoSettings.ui' ** ** Created by: Qt User Interface Compiler version 5.12.6 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_DIALOGSTEREOSETTINGS_H #define UI_DIALOGSTEREOSETTINGS_H #include <QtCore/QVariant> #include <QtWidgets/QApplication> #include <QtWidgets/QCheckBox> #include <QtWidgets/QDialog> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> #include <QtWidgets/QPushButton> #include <QtWidgets/QRadioButton> #include <QtWidgets/QSlider> QT_BEGIN_NAMESPACE class Ui_dialogStereoSettings { public: QLabel *label; QLabel *label_2; QRadioButton *offButton; QRadioButton *rawButton; QRadioButton *anaglyphButton; QCheckBox *swapBox; QSlider *offsetSlider; QLabel *label_3; QLabel *label_4; QLabel *label_5; QPushButton *cancelButton; QLineEdit *offEdit; void setupUi(QDialog *dialogStereoSettings) { if (dialogStereoSettings->objectName().isEmpty()) dialogStereoSettings->setObjectName(QString::fromUtf8("dialogStereoSettings")); dialogStereoSettings->resize(373, 210); label = new QLabel(dialogStereoSettings); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(20, 10, 361, 21)); label_2 = new QLabel(dialogStereoSettings); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setGeometry(QRect(130, 30, 191, 16)); offButton = new QRadioButton(dialogStereoSettings); offButton->setObjectName(QString::fromUtf8("offButton")); offButton->setGeometry(QRect(30, 50, 161, 17)); rawButton = new QRadioButton(dialogStereoSettings); rawButton->setObjectName(QString::fromUtf8("rawButton")); rawButton->setGeometry(QRect(30, 70, 321, 17)); anaglyphButton = new QRadioButton(dialogStereoSettings); anaglyphButton->setObjectName(QString::fromUtf8("anaglyphButton")); anaglyphButton->setGeometry(QRect(30, 90, 231, 17)); swapBox = new QCheckBox(dialogStereoSettings); swapBox->setObjectName(QString::fromUtf8("swapBox")); swapBox->setGeometry(QRect(30, 160, 211, 17)); offsetSlider = new QSlider(dialogStereoSettings); offsetSlider->setObjectName(QString::fromUtf8("offsetSlider")); offsetSlider->setGeometry(QRect(120, 130, 181, 19)); offsetSlider->setOrientation(Qt::Horizontal); label_3 = new QLabel(dialogStereoSettings); label_3->setObjectName(QString::fromUtf8("label_3")); label_3->setGeometry(QRect(30, 130, 91, 16)); label_4 = new QLabel(dialogStereoSettings); label_4->setObjectName(QString::fromUtf8("label_4")); label_4->setGeometry(QRect(120, 110, 21, 16)); label_5 = new QLabel(dialogStereoSettings); label_5->setObjectName(QString::fromUtf8("label_5")); label_5->setGeometry(QRect(300, 110, 21, 16)); cancelButton = new QPushButton(dialogStereoSettings); cancelButton->setObjectName(QString::fromUtf8("cancelButton")); cancelButton->setGeometry(QRect(290, 180, 75, 23)); offEdit = new QLineEdit(dialogStereoSettings); offEdit->setObjectName(QString::fromUtf8("offEdit")); offEdit->setGeometry(QRect(310, 130, 41, 20)); retranslateUi(dialogStereoSettings); QObject::connect(offButton, SIGNAL(clicked()), dialogStereoSettings, SLOT(doOff())); QObject::connect(rawButton, SIGNAL(clicked()), dialogStereoSettings, SLOT(doRaw())); QObject::connect(anaglyphButton, SIGNAL(clicked()), dialogStereoSettings, SLOT(doAnaglyph())); QObject::connect(offsetSlider, SIGNAL(sliderReleased()), dialogStereoSettings, SLOT(doOffset())); QObject::connect(swapBox, SIGNAL(toggled(bool)), dialogStereoSettings, SLOT(doSwap(bool))); QObject::connect(cancelButton, SIGNAL(clicked()), dialogStereoSettings, SLOT(doCancel())); QObject::connect(offEdit, SIGNAL(editingFinished()), dialogStereoSettings, SLOT(doOffsetEdit())); QMetaObject::connectSlotsByName(dialogStereoSettings); } // setupUi void retranslateUi(QDialog *dialogStereoSettings) { dialogStereoSettings->setWindowTitle(QApplication::translate("dialogStereoSettings", "dialogStereoSettings", nullptr)); label->setText(QApplication::translate("dialogStereoSettings", "Coin3D library cant toggle between raw stereo and other stereo settings", nullptr)); label_2->setText(QApplication::translate("dialogStereoSettings", "Use Defaults menu to do this", nullptr)); offButton->setText(QApplication::translate("dialogStereoSettings", "Stereo off", nullptr)); rawButton->setText(QApplication::translate("dialogStereoSettings", "Raw stereo (OpenGL Quadbuffered)", nullptr)); anaglyphButton->setText(QApplication::translate("dialogStereoSettings", "Anaglyph (red-blue)", nullptr)); swapBox->setText(QApplication::translate("dialogStereoSettings", "Swap Eyes -- if stereo effect 'inside out'", nullptr)); label_3->setText(QApplication::translate("dialogStereoSettings", "Camera offset", nullptr)); label_4->setText(QApplication::translate("dialogStereoSettings", "0", nullptr)); label_5->setText(QApplication::translate("dialogStereoSettings", "4", nullptr)); cancelButton->setText(QApplication::translate("dialogStereoSettings", "Cancel", nullptr)); } // retranslateUi }; namespace Ui { class dialogStereoSettings: public Ui_dialogStereoSettings {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_DIALOGSTEREOSETTINGS_H
50.02521
157
0.678817
b5c5b907ce033520a1ada5be1899fec63f3ca372
5,442
h
C
Twitter-Dumped/7.60.6/TFNTwitterDeviceFeatureSwitches.h
ichitaso/TwitterListEnabler
d4d9ba973e59ff7f0d97ae74fc473bdd0aea54df
[ "MIT" ]
1
2019-10-15T09:26:49.000Z
2019-10-15T09:26:49.000Z
Twitter-Dumped/7.60.6/TFNTwitterDeviceFeatureSwitches.h
ichitaso/TwitterListEnabler
d4d9ba973e59ff7f0d97ae74fc473bdd0aea54df
[ "MIT" ]
null
null
null
Twitter-Dumped/7.60.6/TFNTwitterDeviceFeatureSwitches.h
ichitaso/TwitterListEnabler
d4d9ba973e59ff7f0d97ae74fc473bdd0aea54df
[ "MIT" ]
1
2019-11-17T06:06:49.000Z
2019-11-17T06:06:49.000Z
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <objc/NSObject.h> @interface TFNTwitterDeviceFeatureSwitches : NSObject { } + (_Bool)isNewsCameraStatusesUploadEndpointEnabled; + (id)blacklistedPeriscopeURLDestinations; + (_Bool)isHighlightedLabelRequestParameterEnabled; + (double)stratoHashflagsRefreshInterval; + (_Bool)limitBufferingAggressivelyOnPausedItems; + (_Bool)limitBufferingOnAllPlayerItems; + (id)preWarmConnectionHostNames; + (unsigned long long)maxNumberDiscountedURLs; + (_Bool)isDisplayTextModelEnabled; + (id)_featureSwitches; + (long long)tpmIdSyncClickIntervalInSeconds; + (long long)tpmIdSyncFetchIntervalInSeconds; + (_Bool)isDeferingAccountAndUserUpdateNotificationEnabled; + (long long)backgroundTaskExpirationReportingThreshold; + (_Bool)isGraphQLStatusesShowDarkReadEnabled; + (_Bool)isGraphQLStatusesShowEnabled; + (_Bool)isGraphQLAccountVerifyCredentialsEnabled; + (_Bool)isGraphQLUsersShowEnabled; + (_Bool)coreServices2UserBuilderEnabled; + (id)coreServices2TNLBackgroundIdleTimeout; + (id)coreServices2TNLForegroundIdleTimeout; + (unsigned long long)maximumFullNameLength; + (long long)scribeAPIErrorSampleSize; + (long long)scribeAPISampleSize; + (id)httpHostMapArray; + (_Bool)isOAuthScopeBackendEnabled; + (_Bool)isTeamsAccountUIEnabled; + (_Bool)isTeamsAccountEnabled; + (id)optionalSetForKey:(id)arg1; + (id)requiredSetForKey:(id)arg1; + (void)setIsFeatureSwitchSetCachingEnabled:(_Bool)arg1; + (_Bool)isFeatureSwitchSetCachingEnabled; + (id)shouldUseSetCachingQueue; + (void)accessFeatureSwitchValueOnce:(long long *)arg1 valueAccessBlock:(CDUnknownBlockType)arg2; + (long long)appSplitNewsCameraSwipeAngle; + (_Bool)isDashOpenOnLongPressBackEnabled; + (_Bool)isDashContentSFSVCEnabled; + (_Bool)isBetaBugButtonEmailFlowEnabled; + (_Bool)isTNLForPeriscopePluginEnabled; + (id)nonFatalSecurityBlacklist; + (id)dataSensitiveCountries; + (id)dataInsensitiveCountries; + (id)foundMediaDomains; + (id)CDNFileExtensionList; + (id)CDNHostRootList; + (long long)CDNSampleSize; + (_Bool)isOnboardingFormsBasedSettingsListSubtaskEnabled; + (_Bool)isOnboardingPreferredLanguageSelectorEnabled; + (_Bool)isOnboardingNotificationsBackstopPromptEnabled; + (_Bool)isOnboardingLocationBackstopPromptEnabled; + (id)appEventTrackingShortenedTrackingParameters; + (double)appEventTrackingNonReferredOpenInterval; + (_Bool)isExternalURLProtectionEnabled; + (id)bouncerWhitelistAll; + (id)bouncerWhitelistEntrances; + (_Bool)isPublicInterestInterstitialEnabled; + (_Bool)isMultiAccountIdentityEnabled; + (_Bool)isMultiAccountIncentiveEnabled; + (_Bool)isLoginJSInstrumentationEnabled; + (id)phoneSignupCountriesNotificationsWhitelist; + (id)phoneSignupCountriesBlacklist; + (id)phoneSignupCountriesGraylist; + (_Bool)usePushPayloadsForComponentBadgeCounts; + (_Bool)isAggregateBadgingInPushEnabled; + (double)ambientNotificationCooldownPeriod; + (long long)maxQueuedAmbientNotifications; + (long long)rightToLeftMode; + (_Bool)isFeatureSwitchesCrashlyticsLoggingEnabled; + (long long)appStoreReviewPromptDaysAfterCrashMin; + (long long)appStoreReviewPromptDaysBetweenAttemptsMin; + (long long)appStoreReviewPromptConsecutiveDaysMin; + (_Bool)isAppStoreReviewShowPromptAfterFavoriteEnabled; + (_Bool)isAppStoreReviewShowPromptAfterTweetEnabled; + (_Bool)isAppStoreReviewShowPromptOnStartupEnabled; + (id)private_redactionListForKey:(id)arg1 defaultList:(id)arg2; + (id)protectedStatusKeysRedactionList; + (id)protectedUserKeysRedactionList; + (id)HTTPHeaderFieldRedactionList; + (id)userDefaultsKeysRedactionList; + (_Bool)isSpotlightBackgroundFetchEnabled; + (double)homeTimelineBackgroundFetchSinceBackgroundThreshold; + (double)homeTimelineBackgroundFetchLongRefreshThreshold; + (double)homeTimelineBackgroundFetchLaunchThreshold; + (double)homeTimelineBackgroundFetchUILaunchDelay; + (double)homeTimelineBackgroundFetchUpdateTime; + (_Bool)isHomeTimelineBackgroundFetchEnabled; + (_Bool)isModalSheetsSlideoverEnabledForTweetDrafts; + (_Bool)isModalSheetsComposerUnificationSlideoverEnabled; + (double)_CGFloatForKey:(id)arg1 minValue:(double)arg2 maxValue:(double)arg3; + (long long)_integerForKey:(id)arg1 minValue:(long long)arg2 maxValue:(long long)arg3; + (id)nonUsernamePaths; + (long long)mediaURLLength; + (long long)shortenedURLLengthSecure; + (id)blackListedWebViewDomains; + (id)blackListedEmailDomains; + (double)scribeStatusLingerMaxThresholdInSeconds; + (double)scribeStatusLingerMinThresholdInSeconds; + (long long)typeaheadMaxUserMatches; + (long long)typeaheadMaxRecentSearchesHorizontallyScrolling; + (long long)typeaheadMaxRecentSearches; + (long long)typeaheadMaxQueryMatches; + (long long)typeaheadUserPrefetchSize; + (double)typeaheadUserPrefetchRateInSeconds; + (long long)antispamQueryFrequency; + (long long)antispamConnectUserCount; + (long long)antispamConnectTweetCount; + (_Bool)disableInlinePhotosInstagram; + (_Bool)disableWatchdogDetection; + (_Bool)shouldScribeCrash; + (_Bool)shouldScribeError; + (_Bool)isKeyboardCellSelectionEnabled; + (_Bool)isSmartInvertColorsEnabled; + (_Bool)isNestedActionButtonEnabled; + (_Bool)isLargeScreenLayoutExtendedContentEnabled; + (_Bool)isLargeScreenLayoutSpecializationEnabled; + (_Bool)isContextMenuPreviewingEnabled; + (_Bool)is3DTouchPreviewingEnabled; + (_Bool)isUNUserNotificationCenterEnabled; @end
40.61194
97
0.839581
80fe25317da25868bb3cc071d9792158041e52a6
2,395
h
C
src/drivers/rstcan/stm32_can_drv.h
Dapingguo001/px4-1.7.3
0a2507df311cf2a0f0422e49a5187fd2d0f6d4c7
[ "BSD-3-Clause" ]
null
null
null
src/drivers/rstcan/stm32_can_drv.h
Dapingguo001/px4-1.7.3
0a2507df311cf2a0f0422e49a5187fd2d0f6d4c7
[ "BSD-3-Clause" ]
null
null
null
src/drivers/rstcan/stm32_can_drv.h
Dapingguo001/px4-1.7.3
0a2507df311cf2a0f0422e49a5187fd2d0f6d4c7
[ "BSD-3-Clause" ]
null
null
null
#ifndef __STM32_CAN_DRV__ #define __STM32_CAN_DRV__ #include "rstcan_master.h" #if defined(CONFIG_ARCH_BOARD_PHENIX_GH) #define RSTCAN_PORT_NUM (1) #elif defined(CONFIG_ARCH_BOARD_PX4FMU_ROB) #define RSTCAN_PORT_NUM (2) #else //#error Missing definition: RSTCAN_PORT_NUM must be defined in stm32_can_drv.h #define RSTCAN_PORT_NUM (1) #endif #define CAN_DRV_PORT_BUF_SIZE (64) # define readreg32(a) (*(volatile uint32_t *)(a)) # define writereg32(a,v) (*(volatile uint32_t *)(a) = (v)) struct can_describe{ uint8_t port; /* CAN port number (1 or 2) */ uint8_t rx0_irq; /* CAN RX FIFO 0 IRQ number */ uint8_t tx_irq; /* CAN TX IRQ number */ uint32_t base_addr; /* Base address of the CAN registers */ uint8_t filter; /* Filter number */ uint32_t baudrate; /* Configured baud */ sem_t tx_sem; /* Counting semaphore */ uint8_t tx_waiter; /* Counting semaphore */ uint16_t tx_buf_size; volatile uint16_t tx_buf_head; /* Index to the head [IN] in the circular buffer */ volatile uint16_t tx_buf_tail; /* Index to the tail [OUT] in the circular buffer */ struct rstcan_frame tx_buf[CAN_DRV_PORT_BUF_SIZE]; /* Circular buffer of CAN messages */ }; /**********************************ring buffer********************************************/ #define BUF_AVAILABLE(buf) ((buf##_head > (_tail=buf##_tail))? (buf##_size - buf##_head) + _tail: _tail - buf##_head) #define BUF_SPACE(buf) (((_head=buf##_head) > buf##_tail)?(_head - buf##_tail) - 1:((buf##_size - buf##_tail) + _head) - 1) #define BUF_EMPTY(buf) (buf##_head == buf##_tail) #define BUF_ADVANCETAIL(buf, n) buf##_tail = (buf##_tail + n) % buf##_size #define BUF_ADVANCEHEAD(buf, n) buf##_head = (buf##_head + n) % buf##_size #ifdef __cplusplus extern "C"{ #endif inline uint32_t _readreg(struct can_describe *desc, int offset) { return readreg32(desc->base_addr+offset); } inline void _writereg(struct can_describe *desc, int offset, uint32_t value) { writereg32(desc->base_addr+offset, value); } void *can_drv_init(uint8_t port); int32_t can_drv_get_send_space(void *fd); int32_t can_drv_send_frame(void *fd, struct rstcan_frame *frame); #ifdef __cplusplus } #endif #endif
36.287879
123
0.63215
6862098328f79603cec3b724ab92b777c4c85064
259
c
C
src/libc/c/libintl.c
Mithilesh1609/mako
ea6a3b869b7ca79e06b50c42c091b76cd8b0b880
[ "MIT" ]
58
2019-08-13T14:58:30.000Z
2022-03-31T16:41:20.000Z
src/libc/c/libintl.c
Mithilesh1609/mako
ea6a3b869b7ca79e06b50c42c091b76cd8b0b880
[ "MIT" ]
1
2020-11-05T16:49:08.000Z
2022-02-04T20:53:54.000Z
src/libc/c/libintl.c
Mithilesh1609/mako
ea6a3b869b7ca79e06b50c42c091b76cd8b0b880
[ "MIT" ]
7
2019-09-17T15:51:55.000Z
2022-03-12T03:26:33.000Z
// libintl.c // // Internationalization. // // Author: Ajay Tatachar <ajaymt2@illinois.edu> #include <libintl.h> char *gettext(const char *msgid) { return (char *)msgid; } char *dgettext(const char *domainname, const char *msgid) { return (char *)msgid; }
18.5
57
0.69112
9c72a93d3e746f6e011bca8a5470db6e8f4bb5a2
24,038
h
C
pyeda-0.19.3/extension/espresso/src/espresso.h
lthurlow/Boolean-Constrained-Routing
d60a648d17d5dadaa0fb5ef9961fcea9d9784dfe
[ "MIT" ]
196
2015-01-12T08:06:28.000Z
2022-03-26T17:18:06.000Z
pyeda-0.19.3/extension/espresso/src/espresso.h
lthurlow/Boolean-Constrained-Routing
d60a648d17d5dadaa0fb5ef9961fcea9d9784dfe
[ "MIT" ]
66
2015-02-23T17:29:52.000Z
2022-01-16T16:04:01.000Z
pyeda-0.19.3/extension/espresso/src/espresso.h
lthurlow/Boolean-Constrained-Routing
d60a648d17d5dadaa0fb5ef9961fcea9d9784dfe
[ "MIT" ]
40
2015-04-09T22:11:23.000Z
2021-12-23T15:53:50.000Z
// Filename: espresso.h #ifndef ESPRESSO_H #define ESPRESSO_H #include <stdio.h> #include "utility.h" #include "sparse.h" /*-----THIS USED TO BE set.h----- */ // // set.h -- definitions for packed arrays of bits // // This header file describes the data structures which comprise a // facility for efficiently implementing packed arrays of bits // (otherwise known as sets, cf. Pascal). // // A set is a vector of bits and is implemented here as an array of // unsigned integers. The low order bits of set[0] give the index of // the last word of set data. The higher order bits of set[0] are // used to store data associated with the set. The set data is // contained in elements set[1] ... set[LOOP(set)] as a packed bit // array. // // A family of sets is a two-dimensional matrix of bits and is // implemented with the data type "set_family". // // bits per integer #define BPI 32 #define LOGBPI 5 /* Define the set type */ typedef unsigned int set; /* Define the set family type -- an array of sets */ typedef struct set_family { int wsize; /* Size of each set in 'ints' */ int sf_size; /* User declared set size */ int capacity; /* Number of sets allocated */ int count; /* The number of sets in the family */ int active_count; /* Number of "active" sets */ set *data; /* Pointer to the set data */ struct set_family *next; /* For garbage collection */ } set_family_t; /* Macros to set and test single elements */ #define WHICH_WORD(element) (((element) >> LOGBPI) + 1) #define WHICH_BIT(element) ((element) & (BPI-1)) /* # of ints needed to allocate a set with "size" elements */ #define SET_SIZE(size) ((size) <= BPI ? 2 : (WHICH_WORD((size)-1) + 1)) /* * Three fields are maintained in the first word of the set * LOOP is the index of the last word used for set data * SIZE is available for general use (e.g., recording # elements in set) * NELEM retrieves the number of elements in the set */ #define LOOP(set) (set[0] & 0x03ff) #define PUTLOOP(set, i) (set[0] &= ~0x03ff, set[0] |= (i)) #define SIZE(set) (set[0] >> 16) #define PUTSIZE(set, size) (set[0] &= 0xffff, set[0] |= ((size) << 16)) #define NELEM(set) (BPI * LOOP(set)) #define LOOPINIT(size) ((size <= BPI) ? 1 : WHICH_WORD((size)-1)) // FLAGS store general information about the set #define SET(set, flag) (set[0] |= (flag)) #define RESET(set, flag) (set[0] &= ~ (flag)) #define TESTP(set, flag) (set[0] & (flag)) // Flag definitions #define PRIME 0x8000 // cube is prime #define NONESSEN 0x4000 // cube cannot be essential prime #define ACTIVE 0x2000 // cube is still active #define REDUND 0x1000 // cube is redundant(at this point) #define COVERED 0x0800 // cube has been covered #define RELESSEN 0x0400 // cube is relatively essential /* Most efficient way to look at all members of a set family */ #define foreach_set(R, last, p) \ for(p=R->data,last=p+R->count*R->wsize;p<last;p+=R->wsize) #define foreach_remaining_set(R, last, pfirst, p) \ for(p=pfirst+R->wsize,last=R->data+R->count*R->wsize;p<last;p+=R->wsize) #define foreach_active_set(R, last, p) \ foreach_set(R,last,p) if (TESTP(p, ACTIVE)) /* Another way that also keeps the index of the current set member in i */ #define foreachi_set(R, i, p) \ for(p=R->data,i=0;i<R->count;p+=R->wsize,i++) #define foreachi_active_set(R, i, p) \ foreachi_set(R,i,p) if (TESTP(p, ACTIVE)) /* Looping over all elements in a set: * foreach_set_element(set *p, int i, unsigned val, int base) { * ... * } */ #define foreach_set_element(p, i, val, base) \ for (i = LOOP(p); i > 0; ) \ for (val = p[i], base = --i << LOGBPI; val != 0; base++, val >>= 1) \ if (val & 1) // Return a pointer to a given member of a set family #define GETSET(family, index) ((family)->data + (family)->wsize * (index)) // Allocate and deallocate sets #define set_new(size) set_clear(ALLOC(unsigned int, SET_SIZE(size)), size) #define set_full(size) set_fill(ALLOC(unsigned int, SET_SIZE(size)), size) #define set_save(r) set_copy(ALLOC(unsigned int, SET_SIZE(NELEM(r))), r) #define set_free(r) FREE(r) // Check for set membership, remove set element and insert set element #define is_in_set(set, e) (set[WHICH_WORD(e)] & (1 << WHICH_BIT(e))) #define set_insert(set, e) (set[WHICH_WORD(e)] |= (1 << WHICH_BIT(e))) #define set_remove(set, e) (set[WHICH_WORD(e)] &= ~(1 << WHICH_BIT(e))) #define count_ones(v) \ ( bit_count[v & 255] \ + bit_count[(v >> 8) & 255] \ + bit_count[(v >> 16) & 255] \ + bit_count[(v >> 24) & 255] ) // Table for efficient bit counting extern int bit_count[256]; /*----- END OF set.h ----- */ // Define a boolean type #define bool int #define FALSE 0 #define TRUE 1 #define MAYBE 2 #define print_bool(x) ((x) == 0 ? "FALSE" : ((x) == 1 ? "TRUE" : "MAYBE")) // Map many cube/cover types/routines into equivalent set types/routines #define free_cubelist(T) FREE(T[0]); FREE(T); // cost_t describes the cost of a cover typedef struct cost_struct { int cubes; // number of cubes in the cover int in; // transistor count, binary-valued variables int out; // transistor count, output part int mv; // transistor count, multiple-valued vars int total; // total number of transistors int primes; // number of prime cubes } cost_t; // pair_t describes bit-paired variables typedef struct pair_struct { int cnt; int *var1; int *var2; } pair_t; // symbolic_list_t describes a single ".symbolic" line typedef struct symbolic_list_struct { int variable; int pos; struct symbolic_list_struct *next; } symbolic_list_t; // symbolic_list_t describes a single ".symbolic" line typedef struct symbolic_label_struct { char *label; struct symbolic_label_struct *next; } symbolic_label_t; // symbolic_t describes a linked list of ".symbolic" lines typedef struct symbolic_struct { symbolic_list_t *symbolic_list; // linked list of items int symbolic_list_length; // length of symbolic_list list symbolic_label_t *symbolic_label; // linked list of new names int symbolic_label_length; // length of symbolic_label list struct symbolic_struct *next; } symbolic_t; // PLA_t stores the logical representation of a PLA typedef struct { set_family_t *F, *D, *R; // on-set, off-set and dc-set char *filename; // filename int pla_type; // logical PLA format set *phase; // phase to split into on-set and off-set pair_t *pair; // how to pair variables char **label; // labels for the columns symbolic_t *symbolic; // allow binary->symbolic mapping symbolic_t *symbolic_output; // allow symbolic output mapping } PLA_t; #define equal(a,b) (strcmp(a,b) == 0) /* This is a hack which I wish I hadn't done, but too painful to change */ #define CUBELISTSIZE(T) (((set **) T[1] - T) - 3) /* The pla_type field describes the input and output format of the PLA */ #define F_type 1 #define D_type 2 #define R_type 4 #define PLEASURE_type 8 /* output format */ #define EQNTOTT_type 16 /* output format algebraic eqns */ #define KISS_type 128 /* output format kiss */ #define CONSTRAINTS_type 256 /* output the constraints (numeric) */ #define SYMBOLIC_CONSTRAINTS_type 512 /* output the constraints (symbolic) */ #define FD_type (F_type | D_type) #define FR_type (F_type | R_type) #define DR_type (D_type | R_type) #define FDR_type (F_type | D_type | R_type) /* Definitions for the debug variable */ #define COMPL 0x0001 #define ESSEN 0x0002 #define EXPAND 0x0004 #define EXPAND1 0x0008 #define GASP 0x0010 #define IRRED 0x0020 #define REDUCE 0x0040 #define REDUCE1 0x0080 #define SPARSE 0x0100 #define TAUT 0x0200 #define EXACT 0x0400 #define MINCOV 0x0800 #define MINCOV1 0x1000 #define SHARP 0x2000 #define IRRED1 0x4000 #define VERSION "UC Berkeley, Espresso Version #2.3, Release date 01/31/88" #define POSITIVE_PHASE(pos)\ (is_in_set(PLA->phase, CUBE.first_part[CUBE.output]+pos) != 0) #define INLABEL(var) PLA->label[CUBE.first_part[var] + 1] #define OUTLABEL(pos) PLA->label[CUBE.first_part[CUBE.output] + pos] #define GETINPUT(c, pos) \ ((c[WHICH_WORD(2*pos)] >> WHICH_BIT(2*pos)) & 3) #define GETOUTPUT(c, pos) \ (is_in_set(c, CUBE.first_part[CUBE.output] + pos) != 0) #define PUTINPUT(c, pos, value)\ c[WHICH_WORD(2*pos)] = (c[WHICH_WORD(2*pos)] & ~(3 << WHICH_BIT(2*pos))) \ | (value << WHICH_BIT(2*pos)) #define PUTOUTPUT(c, pos, value)\ c[WHICH_WORD(pos)] = (c[WHICH_WORD(pos)] & (1 << WHICH_BIT(pos))) \ | (value << WHICH_BIT(pos)) #define TWO 3 #define DASH 3 #define ONE 2 #define ZERO 1 // // Global Variable Declarations // extern unsigned int debug; /* debug parameter */ extern bool verbose_debug; /* -v: whether to print a lot */ extern bool echo_comments; /* turned off by -eat option */ extern bool echo_unknown_commands; /* always true ?? */ extern bool force_irredundant; /* -nirr command line option */ extern bool skip_make_sparse; extern bool kiss; /* -kiss command line option */ extern bool pos; /* -pos command line option */ extern bool print_solution; /* -x command line option */ extern bool recompute_onset; /* -onset command line option */ extern bool remove_essential; /* -ness command line option */ extern bool single_expand; /* -fast command line option */ extern bool unwrap_onset; /* -nunwrap command line option */ extern bool use_random_order; /* -random command line option */ extern bool use_super_gasp; /* -strong command line option */ extern char *filename; /* filename PLA was read from */ extern bool debug_exact_minimization; /* dumps info for -do exact */ /* * pla_types are the input and output types for reading/writing a PLA */ struct pla_types_struct { char *key; int value; }; /* * The cube structure is a global structure which contains information * on how a set maps into a cube -- i.e., number of parts per variable, * number of variables, etc. Also, many fields are pre-computed to * speed up various primitive operations. */ #define CUBE_TEMP 10 struct cube_struct { int size; /* set size of a cube */ int num_vars; /* number of variables in a cube */ int num_binary_vars; /* number of binary variables */ int *first_part; /* first element of each variable */ int *last_part; /* first element of each variable */ int *part_size; /* number of elements in each variable */ int *first_word; /* first word for each variable */ int *last_word; /* last word for each variable */ set *binary_mask; /* Mask to extract binary variables */ set *mv_mask; /* mask to get mv parts */ set **var_mask; /* mask to extract a variable */ set **temp; /* an array of temporary sets */ set *fullset; /* a full cube */ set *emptyset; /* an empty cube */ unsigned int inmask; /* mask to get odd word of binary part */ int inword; /* which word number for above */ int *sparse; /* should this variable be sparse? */ int num_mv_vars; /* number of multiple-valued variables */ int output; /* which variable is "output" (-1 if none) */ }; struct cdata_struct { int *part_zeros; /* count of zeros for each element */ int *var_zeros; /* count of zeros for each variable */ int *parts_active; /* number of "active" parts for each var */ bool *is_unate; /* indicates given var is unate */ int vars_active; /* number of "active" variables */ int vars_unate; /* number of unate variables */ int best; /* best "binate" variable */ }; extern struct pla_types_struct pla_types[]; extern struct cube_struct CUBE; extern struct cdata_struct CDATA; #define DISJOINT 0x55555555 // function declarations // cofactor.c int binate_split_select(set **T, set *cleft, set *cright, int debug_flag); set_family_t *cubeunlist(set **A1); set **cofactor(set **T, set *c); set **cube1list(set_family_t *A); set **cube2list(set_family_t *A, set_family_t *B); set **cube3list(set_family_t *A, set_family_t *B, set_family_t *C); set **scofactor(set **T, set *c, int var); void massive_count(set **T); // compl.c set_family_t *complement(set **T); set_family_t *simplify(set **T); void simp_comp(set **T, set_family_t **Tnew, set_family_t **Tbar); // contain.c int d1_rm_equal(set **A1, int (*compare)(set **, set**)); int rm2_contain(set **A1, set **B1); int rm2_equal(set **A1, set **B1, set **E1, int (*compare)(set **, set**)); int rm_contain(set **A1); int rm_equal(set **A1, int (*compare)(set **, set**)); int rm_rev_contain(set **A1); set **sf_list(set_family_t *A); set **sf_sort(set_family_t *A, int (*compare)(set **, set **)); set_family_t *d1merge(set_family_t *A, int var); set_family_t *dist_merge(set_family_t *A, set *mask); set_family_t *sf_contain(set_family_t *A); set_family_t *sf_dupl(set_family_t *A); set_family_t *sf_ind_contain(set_family_t *A, int *row_indices); set_family_t *sf_ind_unlist(set **A1, int totcnt, int size, int *row_indices, set *pfirst); set_family_t *sf_merge(set **A1, set **B1, set **E1, int totcnt, int size); set_family_t *sf_rev_contain(set_family_t *A); set_family_t *sf_union(set_family_t *A, set_family_t *B); set_family_t *sf_unlist(set **A1, int totcnt, int size); // cubestr.c void cube_setup(void); void cube_setdown(void); // cvrin.c void PLA_labels(PLA_t *PLA); char *get_word(FILE *fp, char *word); int label_index(PLA_t *PLA, char *word, int *varp, int *ip); int read_pla(FILE *fp, bool needs_dcset, bool needs_offset, int pla_type, PLA_t **PLA_return); int read_symbolic(FILE *fp, PLA_t *PLA, char *word, symbolic_t **retval); PLA_t *new_PLA(void); void PLA_summary(PLA_t *PLA); void free_PLA(PLA_t *PLA); void parse_pla(FILE *fp, PLA_t *PLA); void read_cube(FILE *fp, PLA_t *PLA); void skip_line(FILE *fpin, FILE *fpout, bool echo); // cvrm.c void foreach_output_function(PLA_t *PLA, int (*func)(PLA_t *, int), int (*func1)(PLA_t *, int)); int cubelist_partition(set **T, set ***A, set ***B, unsigned int comp_debug); int so_both_do_espresso(PLA_t *PLA, int i); int so_both_do_exact(PLA_t *PLA, int i); int so_both_save(PLA_t *PLA, int i); int so_do_espresso(PLA_t *PLA, int i); int so_do_exact(PLA_t *PLA, int i); int so_save(PLA_t *PLA, int i); set_family_t *cof_output(set_family_t *T, int i); set_family_t *lex_sort(set_family_t *T); set_family_t *mini_sort(set_family_t *F, int (*compare)(set **, set**)); set_family_t *random_order(set_family_t *F); set_family_t *size_sort(set_family_t *T); set_family_t *sort_reduce(set_family_t *T); set_family_t *uncof_output(set_family_t *T, int i); set_family_t *unravel(set_family_t *B, int start); set_family_t *unravel_range(set_family_t *B, int start, int end); void so_both_espresso(PLA_t *PLA, int strategy); void so_espresso(PLA_t *PLA, int strategy); // cvrmisc.c char *fmt_cost(cost_t *cost); char *print_cost(set_family_t *F); void copy_cost(cost_t *s, cost_t *d); void cover_cost(set_family_t *F, cost_t *cost); void fatal(char *s); // cvrout.c char *fmt_cube(set *c, char *out_map, char *s); char *pc1(set *c); char *pc2(set *c); void makeup_labels(PLA_t *PLA); void kiss_output(FILE *fp, PLA_t *PLA); void kiss_print_cube(FILE *fp, PLA_t *PLA, set *p, char *out_string); void output_symbolic_constraints(FILE *fp, PLA_t *PLA, int output_symbolic); void cprint(set_family_t *T); void debug1_print(set_family_t *T, char *name, int num); void debug_print(set **T, char *name, int level); void eqn_output(PLA_t *PLA); void fpr_header(FILE *fp, PLA_t *PLA, int output_type); void fprint_pla(FILE *fp, PLA_t *PLA, int output_type); void pls_group(PLA_t *PLA, FILE *fp); void pls_label(PLA_t *PLA, FILE *fp); void pls_output(PLA_t *PLA); void print_cube(FILE *fp, set *c, char *out_map); void print_expanded_cube(FILE *fp, set *c, set *phase); // espresso.c set_family_t *espresso(set_family_t *F, set_family_t *D1, set_family_t *R); // essen.c bool essen_cube(set_family_t *F, set_family_t *D, set *c); set_family_t *cb_consensus(set_family_t *T, set *c); set_family_t *cb_consensus_dist0(set_family_t *R, set *p, set *c); set_family_t *essential(set_family_t **Fp, set_family_t **Dp); // exact.c set_family_t *minimize_exact(set_family_t *F, set_family_t *D, set_family_t *R, int exact_cover); set_family_t *minimize_exact_literals(set_family_t *F, set_family_t *D, set_family_t *R, int exact_cover); // expand.c bool feasibly_covered(set_family_t *BB, set *c, set *RAISE, set *new_lower); int most_frequent(set_family_t *CC, set *FREESET); set_family_t *all_primes(set_family_t *F, set_family_t *R); set_family_t *expand(set_family_t *F, set_family_t *R, bool nonsparse); set_family_t *find_all_primes(set_family_t *BB, set *RAISE, set *FREESET); void elim_lowering(set_family_t *BB, set_family_t *CC, set *RAISE, set *FREESET); void essen_parts(set_family_t *BB, set_family_t *CC, set *RAISE, set *FREESET); void essen_raising(set_family_t *BB, set *RAISE, set *FREESET); void expand1(set_family_t *BB, set_family_t *CC, set *RAISE, set *FREESET, set *OVEREXPANDED_CUBE, set *SUPER_CUBE, set *INIT_LOWER, int *num_covered, set *c); void mincov(set_family_t *BB, set *RAISE, set *FREESET); void select_feasible(set_family_t *BB, set_family_t *CC, set *RAISE, set *FREESET, set *SUPER_CUBE, int *num_covered); void setup_BB_CC(set_family_t *BB, set_family_t *CC); // gasp.c set_family_t *expand_gasp(set_family_t *F, set_family_t *D, set_family_t *R, set_family_t *Foriginal); set_family_t *irred_gasp(set_family_t *F, set_family_t *D, set_family_t *G); set_family_t *last_gasp(set_family_t *F, set_family_t *D, set_family_t *R, cost_t *cost); set_family_t *super_gasp(set_family_t *F, set_family_t *D, set_family_t *R, cost_t *cost); void expand1_gasp(set_family_t *F, set_family_t *D, set_family_t *R, set_family_t *Foriginal, int c1index, set_family_t **G); // hack.c void find_inputs(set_family_t *A, PLA_t *PLA, symbolic_list_t *list, int base, int value, set_family_t **newF, set_family_t **newD); void form_bitvector(set *p, int base, int value, symbolic_list_t *list); void map_dcset(PLA_t *PLA); void map_output_symbolic(PLA_t *PLA); void map_symbolic(PLA_t *PLA); set_family_t *map_symbolic_cover(set_family_t *T, symbolic_list_t *list, int base); void symbolic_hack_labels(PLA_t *PLA, symbolic_t *list, set *compress, int new_size, int old_size, int size_added); // irred.c bool cube_is_covered(set **T, set *c); bool taut_special_cases(set **T); bool tautology(set **T); set_family_t *irredundant(set_family_t *F, set_family_t *D); void mark_irredundant(set_family_t *F, set_family_t *D); void irred_split_cover(set_family_t *F, set_family_t *D, set_family_t **E, set_family_t **Rt, set_family_t **Rp); sm_matrix *irred_derive_table(set_family_t *D, set_family_t *E, set_family_t *Rp); // mincov.c sm_row *sm_minimum_cover(sm_matrix *A, int *weight, int heuristic, int debug_level); // opo.c void output_phase_setup(PLA_t *PLA, int first_output); PLA_t *set_phase(PLA_t *PLA); set_family_t *opo(set *phase, set_family_t *T, set_family_t *D, set_family_t *R, int first_output); set *find_phase(PLA_t *PLA, int first_output, set *phase1); set_family_t *opo_leaf(set_family_t *T, set *select, int out1, int out2); set_family_t *opo_recur(set_family_t *T, set_family_t *D, set *select, int offset, int first, int last); void opoall(PLA_t *PLA, int first_output, int last_output, int opo_strategy); void phase_assignment(PLA_t *PLA, int opo_strategy); void repeated_phase_assignment(PLA_t *PLA); // pair.c void generate_all_pairs(pair_t *pair, int n, set *candidate, void (*action)(pair_t *)); int **find_pairing_cost(PLA_t *PLA, int strategy); void find_best_cost(pair_t *pair); int greedy_best_cost(int **cost_array_local, pair_t **pair_p); void minimize_pair(pair_t *pair); void pair_free(pair_t *pair); void pair_all(PLA_t *PLA, int pair_strategy); set_family_t *delvar(set_family_t *A, bool *paired); set_family_t *pairvar(set_family_t *A, pair_t *pair); pair_t *pair_best_cost(int **cost_array_local); pair_t *pair_new(int n); pair_t *pair_save(pair_t *pair, int n); void print_pair(pair_t *pair); void find_optimal_pairing(PLA_t *PLA, int strategy); void set_pair(PLA_t *PLA); void set_pair1(PLA_t *PLA, bool adjust_labels); // primes.c set_family_t *primes_consensus(set **T); // reduce.c bool sccc_special_cases(set **T, set **result); set_family_t *reduce(set_family_t *F, set_family_t *D); set *reduce_cube(set **FD, set *p); set *sccc(set **T); set *sccc_cube(set *result, set *p); set *sccc_merge(set *left, set *right, set *cl, set *cr); #include "set.h" // setc.c bool ccommon(set *a, set *b, set *cof); bool cdist0(set *a, set *b); bool full_row(set *p, set *cof); int ascend(set **a, set **b); int cactive(set *a); int cdist(set *a, set *b); int cdist01(set *a, set *b); int d1_order(set **a, set **b); int desc1(set *a, set *b); int descend(set **a, set **b); int lex_order(set **a, set **b); set *force_lower(set *xlower, set *a, set *b); void consensus(set *r, set *a, set *b); // sharp.c set_family_t *cb1_dsharp(set_family_t *T, set *c); set_family_t *cb_dsharp(set *c, set_family_t *T); set_family_t *cb_recur_sharp(set *c, set_family_t *T, int first, int last, int level); set_family_t *cb_sharp(set *c, set_family_t *T); set_family_t *cv_dsharp(set_family_t *A, set_family_t *B); set_family_t *cv_intersect(set_family_t *A, set_family_t *B); set_family_t *cv_sharp(set_family_t *A, set_family_t *B); set_family_t *dsharp(set *a, set *b); set_family_t *make_disjoint(set_family_t *A); set_family_t *sharp(set *a, set *b); // sminterf.c set *do_sm_minimum_cover(set_family_t *A); // sparse.c set_family_t *make_sparse(set_family_t *F, set_family_t *D, set_family_t *R); set_family_t *mv_reduce(set_family_t *F, set_family_t *D); // unate.c set_family_t *map_cover_to_unate(set **T); set_family_t *map_unate_to_cover(set_family_t *A); set_family_t *exact_minimum_cover(set_family_t *T); set_family_t *unate_compl(set_family_t *A); set_family_t *unate_complement(set_family_t *A); set_family_t *unate_intersect(set_family_t *A, set_family_t *B, bool largest_only); // verify.c void PLA_permute(PLA_t *PLA1, PLA_t *PLA2); bool PLA_verify(PLA_t *PLA1, PLA_t *PLA2); bool check_consistency(PLA_t *PLA); bool verify(set_family_t *F, set_family_t *Fold, set_family_t *Dold); #endif // ESPRESSO_H
41.302405
132
0.659248
ec060875b4f6ac181494de21c1adf987acc88f34
782
h
C
InstrumentRecognizer/include/ClassifierTesters.h
Lewerow/InstrumentRecognizer
ca6ad1c674854aa1cbd0dc006d25ace321f2213c
[ "MIT" ]
null
null
null
InstrumentRecognizer/include/ClassifierTesters.h
Lewerow/InstrumentRecognizer
ca6ad1c674854aa1cbd0dc006d25ace321f2213c
[ "MIT" ]
null
null
null
InstrumentRecognizer/include/ClassifierTesters.h
Lewerow/InstrumentRecognizer
ca6ad1c674854aa1cbd0dc006d25ace321f2213c
[ "MIT" ]
null
null
null
#pragma once #include "ClassifierObservers.h" class DescriptionDBManager; class ReportBuilder; class ClassifierTester : public ClassifierObserver { public: ClassifierTester(void); virtual ~ClassifierTester(void); }; class CorrectClassifierTester : public ClassifierTester { public: CorrectClassifierTester(std::shared_ptr<DescriptionDBManager>); virtual void notifyFinishedTraining(Classifier*); virtual void notifyStartedTraining(Classifier*); virtual void notifyIteration(Classifier*, unsigned int); private: std::shared_ptr<DescriptionDBManager> descriptionDBManager; CorrectClassifierTester(const CorrectClassifierTester&) : descriptionDBManager(descriptionDBManager) {}; CorrectClassifierTester& operator=(const CorrectClassifierTester&) {return *this;}; };
25.225806
105
0.820972
02cf42cbf92a768ed7f48d1aa0a744eddff88aff
3,429
c
C
src/ucvm2mesh/mesh_check.c
baagaard-usgs/UCVMC
53d3c136ea32bceaa02a89c351fee7e8155a5af5
[ "Apache-2.0", "BSD-3-Clause" ]
18
2017-01-27T09:26:15.000Z
2022-03-21T14:40:26.000Z
src/ucvm2mesh/mesh_check.c
baagaard-usgs/UCVMC
53d3c136ea32bceaa02a89c351fee7e8155a5af5
[ "Apache-2.0", "BSD-3-Clause" ]
85
2016-12-10T01:50:34.000Z
2022-01-05T20:46:36.000Z
src/ucvm2mesh/mesh_check.c
baagaard-usgs/UCVMC
53d3c136ea32bceaa02a89c351fee7e8155a5af5
[ "Apache-2.0", "BSD-3-Clause" ]
9
2017-10-19T16:57:34.000Z
2021-06-18T16:26:47.000Z
/** * mesh_strip_ijk.c - Strip fields from existing mesh * * Based on code written by Ricardo Taborda * <ricardotaborda@gmail.com> and Tiankai Tu * <tutk@cs.cmu.edu>. * * Modified by Gideon Juve <juve@usc.edu> * Modified by Patrick Small <patrices@usc.edu> */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <math.h> #include "um_mesh.h" #define MAX_NODES 10000 void usage(char *arg) { printf("Usage: %s input format\n\n",arg); printf("input: path to the input file\n"); printf("format: format of file, IJK-12, IJK-20, IJK-32\n\n"); printf("Version: %s\n\n", VERSION); } int nodeOK(char *n, int rec_size, size_t offset) { mesh_ijk12_t node; switch (rec_size) { case 12: case 20: memcpy(&node, n, 12); break; case 32: memcpy(&node, (n+12), 12); break; default: fprintf(stderr, "Invalid rec size\n"); return(1); } if (isnan(node.vp) || isnan(node.vs) || isnan(node.rho)) { fprintf(stderr, "NAN mat prop detected at %zd\n", offset); return(1); } if (isinf(node.vp) || isinf(node.vs) || isinf(node.rho)) { fprintf(stderr, "Inf mat prop detected at %zd\n", offset); return(1); } if (node.vp <= 0.0) { fprintf(stderr, "Neg Vp at %zd\n", offset); return(1); } if (node.vs <= 0.0) { fprintf(stderr, "Neg Vs at %zd\n", offset); return(1); } if (node.rho <= 0.0) { fprintf(stderr, "Neg Rho at %zd\n", offset); return(1); } return(0); } int dumpNode(char *n, int rec_size) { mesh_ijk12_t node; mesh_ijk20_t node_med; switch (rec_size) { case 12: memcpy(&node, n, 12); break; case 20: memcpy(&node, n, 12); memcpy(&node_med, n, 20); break; case 32: memcpy(&node, (n+12), 12); memcpy(&node_med, (n+12), 20); break; default: fprintf(stderr, "Invalid rec size\n"); return(1); } fprintf(stderr, "Node:\n"); fprintf(stderr, "\tVp, Vs, Rho: %f, %f, %f\n", node.vp, node.vs, node.rho); if (rec_size > 12) { fprintf(stderr, "\tQp, Qs: %f, %f\n", node_med.qp, node_med.qs); } return(0); } int main(int argc, char **argv) { int a; char input[256]; char format[256]; char *node_buf; int rec_size; FILE *is; size_t num_read; size_t file_read; // Parse args if(argc != 3) { usage(argv[0]); exit(1); } strcpy(input, argv[1]); strcpy(format, argv[2]); for (a = 0; a < MAX_MESH_FORMATS; a++) { if (strcmp(format, MESH_FORMAT_NAMES[a]) == 0) { rec_size = MESH_FORMAT_LENS[a]; break; } } if (a == MAX_MESH_FORMATS) { fprintf(stderr, "Invalid format specified\n"); return(1); } node_buf = (char *)malloc(MAX_NODES * rec_size); printf("Record size is %d bytes\n", rec_size); printf("Opening input file %s\n", input); is = fopen(input, "rb"); if (is == NULL) { perror("fopen"); exit(1); } file_read = 0; while (!feof(is)) { num_read = fread(node_buf, rec_size, MAX_NODES, is); if (num_read > 0) { for (a = 0; a < num_read; a++) { if (nodeOK((node_buf + (a * rec_size)), rec_size, file_read + (size_t)a) != 0) { dumpNode((node_buf + (a * rec_size)), rec_size); exit(1); } } } file_read += num_read; } free(node_buf); fclose(is); printf("Checked %zd vals total\n", file_read); return 0; }
19.706897
81
0.587927
b3d8d4f806bb2a53cbad73d7ee3c39ba222d0f27
436
h
C
FormTableDemo/FormTableDemo/app/views/form/FTFormTableViewCell.h
hmx101607/FormTable
fd987d5a1ca8de6a67f6ba391ff766ae14bc80dc
[ "MIT" ]
21
2018-08-13T10:26:55.000Z
2021-12-01T09:35:46.000Z
FormTableDemo/FormTableDemo/app/views/form/FTFormTableViewCell.h
hmx101607/FormTable
fd987d5a1ca8de6a67f6ba391ff766ae14bc80dc
[ "MIT" ]
null
null
null
FormTableDemo/FormTableDemo/app/views/form/FTFormTableViewCell.h
hmx101607/FormTable
fd987d5a1ca8de6a67f6ba391ff766ae14bc80dc
[ "MIT" ]
1
2019-03-06T08:23:10.000Z
2019-03-06T08:23:10.000Z
// // FTFormTableViewCell.h // FormTableDemo // // Created by mason on 2017/7/13. // // #import <UIKit/UIKit.h> #import "FTFormModel.h" #define kFormTitle @"kFormTitle" #define kFormIndex @"kFormIndex" #define kFormItemArray @"kFormItemArray" #define kClickFormItemNotification @"kClickFormItemNotification" @interface FTFormTableViewCell : UITableViewCell /** <##> */ @property (strong, nonatomic) FTFormModel*formModel; @end
18.166667
64
0.743119
b3b01d430d256e2681abca97d740d17b119d2554
4,785
c
C
drivers/misc/gcx/gccore/gcmem.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
drivers/misc/gcx/gccore/gcmem.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
drivers/misc/gcx/gccore/gcmem.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
/* * gcmain.c * * Copyright (C) 2010-2011 Vivante Corporation. * * This package is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include <linux/pagemap.h> #include <linux/dma-mapping.h> #include "gcmain.h" #define GCZONE_NONE 0 #define GCZONE_ALL (~0U) #define GCZONE_CACHED (1 << 0) #define GCZONE_NONCACHED (1 << 1) #define GCZONE_FLUSH (1 << 2) GCDBG_FILTERDEF(mem, GCZONE_NONE, "cached", "noncached", "flush") enum gcerror gc_alloc_noncached(struct gcpage *p, unsigned int size) { enum gcerror gcerror; GCENTERARG(GCZONE_NONCACHED, "p = 0x%08X\n", (unsigned int) p); p->pages = NULL; p->order = 0; p->size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); p->logical = NULL; p->physical = ~0UL; GCDBG(GCZONE_NONCACHED, "requested size=%d\n", size); GCDBG(GCZONE_NONCACHED, "aligned size=%d\n", p->size); p->logical = dma_alloc_coherent(NULL, p->size, &p->physical, GFP_KERNEL); if (!p->logical) { GCERR("failed to allocate memory\n"); gcerror = GCERR_OOPM; goto exit; } GCDBG(GCZONE_NONCACHED, "logical=0x%08X\n", (unsigned int) p->logical); GCDBG(GCZONE_NONCACHED, "physical=0x%08X\n", (unsigned int) p->physical); GCEXIT(GCZONE_NONCACHED); return GCERR_NONE; exit: gc_free_noncached(p); GCEXITARG(GCZONE_NONCACHED, "gcerror = 0x%08X\n", gcerror); return gcerror; } void gc_free_noncached(struct gcpage *p) { GCENTERARG(GCZONE_NONCACHED, "p = 0x%08X\n", (unsigned int) p); if (p->logical != NULL) { dma_free_coherent(NULL, p->size, p->logical, p->physical); p->logical = NULL; } p->physical = ~0UL; p->size = 0; GCEXIT(GCZONE_NONCACHED); } enum gcerror gc_alloc_cached(struct gcpage *p, unsigned int size) { enum gcerror gcerror; struct page *pages; int count; GCENTERARG(GCZONE_CACHED, "p = 0x%08X\n", (unsigned int) p); p->order = get_order(size); p->pages = NULL; p->size = (1 << p->order) * PAGE_SIZE; p->logical = NULL; p->physical = ~0UL; GCDBG(GCZONE_CACHED, "requested size=%d\n", size); GCDBG(GCZONE_CACHED, "aligned size=%d\n", p->size); p->pages = alloc_pages(GFP_KERNEL, p->order); if (p->pages == NULL) { GCERR("failed to allocate memory\n"); gcerror = GCERR_OOPM; goto exit; } p->physical = page_to_phys(p->pages); p->logical = (unsigned int *) page_address(p->pages); if (p->logical == NULL) { GCERR("failed to retrieve page virtual address\n"); gcerror = GCERR_PMMAP; goto exit; } /* Reserve pages. */ pages = p->pages; count = p->size / PAGE_SIZE; while (count--) SetPageReserved(pages++); GCDBG(GCZONE_CACHED, "page array=0x%08X\n", (unsigned int) p->pages); GCDBG(GCZONE_CACHED, "logical=0x%08X\n", (unsigned int) p->logical); GCDBG(GCZONE_CACHED, "physical=0x%08X\n", (unsigned int) p->physical); GCEXIT(GCZONE_CACHED); return GCERR_NONE; exit: gc_free_cached(p); GCEXITARG(GCZONE_CACHED, "gcerror = 0x%08X\n", gcerror); return gcerror; } void gc_free_cached(struct gcpage *p) { GCENTERARG(GCZONE_CACHED, "p = 0x%08X\n", (unsigned int) p); GCDBG(GCZONE_CACHED, "page array=0x%08X\n", (unsigned int) p->pages); GCDBG(GCZONE_CACHED, "logical=0x%08X\n", (unsigned int) p->logical); GCDBG(GCZONE_CACHED, "physical=0x%08X\n", (unsigned int) p->physical); GCDBG(GCZONE_CACHED, "size=%d\n", p->size); if (p->logical != NULL) { struct page *pages; int count; pages = p->pages; count = p->size / PAGE_SIZE; while (count--) ClearPageReserved(pages++); p->logical = NULL; } if (p->pages != NULL) { __free_pages(p->pages, p->order); p->pages = NULL; } p->physical = ~0UL; p->order = 0; p->size = 0; GCEXIT(GCZONE_CACHED); } void gc_flush_cached(struct gcpage *p) { GCENTERARG(GCZONE_FLUSH, "p = 0x%08X\n", (unsigned int) p); dmac_flush_range(p->logical, (unsigned char *) p->logical + p->size); outer_flush_range(p->physical, p->physical + p->size); GCEXIT(GCZONE_FLUSH); } void gc_flush_region(unsigned int physical, void *logical, unsigned int offset, unsigned int size) { unsigned char *startlog; unsigned int startphys; GCENTER(GCZONE_FLUSH); GCDBG(GCZONE_FLUSH, "logical=0x%08X\n", (unsigned int) logical); GCDBG(GCZONE_FLUSH, "physical=0x%08X\n", physical); GCDBG(GCZONE_FLUSH, "offset=%d\n", offset); GCDBG(GCZONE_FLUSH, "size=%d\n", size); startlog = (unsigned char *) logical + offset; startphys = physical + offset; dmac_flush_range(startlog, startlog + size); outer_flush_range(startphys, startphys + size); GCEXIT(GCZONE_FLUSH); }
23.688119
71
0.685684
beec5cc6e20c3e3e028e21f81862c47ee8dcd39b
123
h
C
src/dvc_evnt.h
marklauter/Interlane
4899b1327c8d34cec71ed66d1624cd345f69569c
[ "MIT" ]
null
null
null
src/dvc_evnt.h
marklauter/Interlane
4899b1327c8d34cec71ed66d1624cd345f69569c
[ "MIT" ]
null
null
null
src/dvc_evnt.h
marklauter/Interlane
4899b1327c8d34cec71ed66d1624cd345f69569c
[ "MIT" ]
null
null
null
#ifndef _device_event_edit_menu_h #define _device_event_edit_menu_h extern void Device_Event_Menu(int cat_index); #endif
17.571429
45
0.861789
474b694a77799a03eb3e402292f3b6b566dd4e12
16,300
c
C
cholesky.c
tranvansang/cholesky
0d040335112210096d975dbb5e0d7b6427d72b53
[ "MIT" ]
null
null
null
cholesky.c
tranvansang/cholesky
0d040335112210096d975dbb5e0d7b6427d72b53
[ "MIT" ]
null
null
null
cholesky.c
tranvansang/cholesky
0d040335112210096d975dbb5e0d7b6427d72b53
[ "MIT" ]
1
2021-05-30T18:45:08.000Z
2021-05-30T18:45:08.000Z
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <mpi.h> #include <string.h> #include <omp.h> //param /*#define RUN_SERIAL*/ #define RUN_PARALLEL #define N 100 #define WEAK_SCALING // if weak_scaling is defined, n = N * np * omp_get_num_threads() //debug /*#define DEBUG*/ /*#define VERBOSE*/ //printing precision #define PRECISION 2 //other constants #define ROOT_RANK 0 #define EPS 1e-10 #ifdef DEBUG #define MPI(x) mpi_result = x; \ if (mpi_result != MPI_SUCCESS) { \ print_error(mpi_result); \ } \ assert(mpi_result == MPI_SUCCESS); #else // DEBUG #define MPI(x) mpi_result = x; assert(mpi_result == MPI_SUCCESS); #endif // DEBUG //matrix element - row major #define ELM(a, r, c, ld) ((a) + (r) * (ld) + c) void print_error(int mpi_result){ int eclass, estr_len; char estring[MPI_MAX_ERROR_STRING]; MPI_Error_class(mpi_result, &eclass); MPI_Error_string(mpi_result, estring, &estr_len); printf("Error %d, class %d: %s\n", mpi_result, eclass, estring); fflush(stdout); } /* matrix-vector multiply : y = A * x, where A is symmetric and only lower half are stored */ void symMatVec(int n, double *a, double *x, double *y) { int i, j; for (i=0; i< n; i++) { double t = 0.0; for (j=0; j<= i; j++) t += *ELM(a, i, j, n) * x[j]; for (j= i+1; j< n; j++) t += *ELM(a, j, i, n) * x[j]; y[i] = t; } } void print_lower(double *a, int n, int ld){ int i, j; for(i = 0; i < n; i++){ for(j = 0; j <= i; j++) printf("%.*lf\t", PRECISION, *ELM(a, i, j, ld)); printf("\n"); } } void print_upper(double *a, int n, int ld){ int i, j; for(i = 0; i < n; i++){ for(j = 0; j < n; j++) if (j < i) printf("__________\t"); else printf("%.*lf\t", PRECISION, *ELM(a, i, j, ld)); printf("\n"); } } void print_full(double *a, int nrow, int ncol, int ld){ int i, j; for(i = 0; i < nrow; i++){ for(j = 0; j <ncol; j++) printf("%.*lf\t", PRECISION, *ELM(a, i, j, ld)); printf("\n"); } } /* solve Ax = b */ void solveSym_serial(int n, double *a, double *x, double *b) { int i, j, k; /* LDLT decomposition: A = L * D * L^t */ for (i=0; i< n; i++) { double invp = 1.0 / *ELM(a, i, i, n); for (j= i+1; j< n; j++) { double aji = *ELM(a, j, i, n); *ELM(a,j, i, n) *= invp; for (k= i+1; k<= j; k++) *ELM(a, j, k, n) -= aji * *ELM(a, k, i, n); } #ifdef VERBOSE printf("matrix after iteration %d\n", i); print_lower(a, n, n); printf("\n"); #endif // VERBOSE } #ifdef VERBOSE printf("array after serial ldlt: \n"); print_lower(a, n, n); printf("\n"); #endif // VERBOSE /* forward solve L y = b: but y is stored in x can be merged to the previous loop */ for (i=0; i< n; i++) { double t = b[i]; for (j=0; j< i; j++) t -= *ELM(a, i, j, n) * x[j]; x[i] = t; } /* backward solve D L^t x = y */ for (i= n-1; i>= 0; i--) { double t = x[i] / *ELM(a, i, i, n); for (j= i+1; j< n; j++) t -= *ELM(a, j, i, n) * x[j]; x[i] = t; } } //calculate number of rows for process with rank inline int get_nrows(int n, int np, int rank){ return (n + np - rank - 1) / np; } //get original row index (size) from local row inline int get_row(int np, int rank, int local_row){ return local_row * np + rank; } /* solve Ax = b */ void solveSym(int rank, int np, int n, double *a, double *x, double *b) { int i, j, k, tag, receiver, mpi_result, row, skipped_rows_count, sender; int nrows_local = get_nrows(n, np, rank); double *local_a = malloc(sizeof(double) * n * nrows_local); double *local_a_t = malloc(sizeof(double) * n * nrows_local); double *first_column = malloc(sizeof(double) * n); double *allgather_buf = malloc(sizeof(double) * n); assert(local_a != NULL); assert(local_a_t != NULL); assert(first_column != NULL); assert(allgather_buf != NULL); double tmp, aji; int nrequests; if (rank == 0) nrequests = n - nrows_local; else nrequests = nrows_local; MPI_Request *requests = malloc(sizeof(MPI_Request) * nrequests); MPI_Status *statuses = malloc(sizeof(MPI_Status) * nrequests); int *displs = malloc(sizeof(int) * np); int *recvcounts = malloc(sizeof(int) * np); assert(requests != NULL); assert(statuses != NULL); assert(displs != NULL); assert(recvcounts != NULL); //root process if (rank == ROOT_RANK){ j = 0; //deliver row data to each other processes from root process #pragma omp parallel for private(tag, receiver, k) for(i = 0; i < n; i++){ tag = i / np; receiver = i % np; if (receiver != 0){ #pragma omp critical k = j++; MPI(MPI_Isend(ELM(a, i, 0, n), i + 1, MPI_DOUBLE, receiver, tag, MPI_COMM_WORLD, requests + k)); } } //copy to my own //(n + np - 1) / np = nrows_local #pragma omp parallel for private(row) for(i = 0; i < nrows_local; i++){ row = get_row(np, rank, i); memcpy(ELM(local_a, i, 0, n), ELM(a, row, 0, n), sizeof(double) * (row + 1)); } }else { //child process #pragma omp parallel for private(row, tag) for(i = 0; i < nrows_local; i++){ row = get_row(np, rank, i); tag = i; MPI(MPI_Irecv(ELM(local_a, i, 0, n), row + 1, MPI_DOUBLE, ROOT_RANK, tag, MPI_COMM_WORLD, requests + i)); } MPI(MPI_Waitall(nrequests, requests, statuses)); /*for(i = 0; i < nrows_local; i++){*/ /*printf("rank %d status %d: %d\n", rank, i, statuses[i].MPI_ERROR);*/ /*if (statuses[i].MPI_ERROR != MPI_SUCCESS)*/ /*print_error(statuses[i].MPI_ERROR);*/ /*}*/ } //transpose to column major #pragma omp parallel for private(row) for(i = 0; i < nrows_local; i++){ //also take diagonal elms row = get_row(np, rank, i); #pragma omp parallel for for(j = 0; j <= row; j++){ *ELM(local_a_t, j, i, nrows_local) = *ELM(local_a, i, j, n); } } //wait all requests in root process if (rank == ROOT_RANK){ MPI(MPI_Waitall(nrequests, requests, statuses)); } /* LDLT decomposition: A = L * D * L^t */ for(i = 0; i < n; i++){ for(j = 0; j < np; j++){ recvcounts[j] = get_nrows(n, np, j) - get_nrows(i, np, j); displs[j] = j == 0 ? 0 : displs[j - 1] + recvcounts[j -1]; } //broadcast first column (i.e. first row of column-major) of current iteration skipped_rows_count = get_nrows(i, np, rank); MPI(MPI_Allgatherv(ELM(local_a_t, i, skipped_rows_count, nrows_local), recvcounts[rank], MPI_DOUBLE, allgather_buf, recvcounts, displs, MPI_DOUBLE, MPI_COMM_WORLD)); #ifdef VERBOSE if (i == 1) for(j = 0; j < np; j++){ MPI(MPI_Barrier(MPI_COMM_WORLD)); if (rank == j){ printf("allgather (rank = %d): ", j); for(k = 0; k < n; k++) printf("%.*lf\t", PRECISION, allgather_buf[k]); printf("\n"); } } #endif //put elms of collected buffer into correct order #pragma omp parallel for private(row) for(j = 0; j < np; j++){ row = recvcounts[j]; #pragma omp parallel for for(k = 0; k < row; k++) first_column[(k + get_nrows(i, np, j)) * np + j] = allgather_buf[displs[j] + k]; } #ifdef VERBOSE if (i == 1) for(j = 0; j < np; j++){ MPI(MPI_Barrier(MPI_COMM_WORLD)); if (rank == j){ printf("first column (rank = %d): ", j); for(k = i; k < n; k++) printf("%.*lf\t", PRECISION, first_column[k]); printf("\n"); } } #endif //pre devide first_column to speedup (reduce deviding operation) row = get_row(np, rank, nrows_local -1); #pragma omp parallel for for(j = i + 1; j <= row; j++) first_column[j] /= first_column[i]; //do LDLT calculation //for all rows skipped_rows_count = get_nrows(i + 1, np, rank); //get_nrows of i + 1 because we are going to skip the row i (do j-loop from i+ 1 to n) #pragma omp parallel for private(aji, row) for(j = skipped_rows_count; j < nrows_local; j++){ //backup aji aji = *ELM(local_a_t, i, j, nrows_local); row = get_row(np, rank, j); //first elm *ELM(local_a_t, i, j, nrows_local) = first_column[row]; //other elms #pragma omp parallel for for(k = i + 1; k <= row; k++) *ELM(local_a_t, k, j, nrows_local) -= aji * first_column[k]; } MPI(MPI_Barrier(MPI_COMM_WORLD)); #ifdef VERBOSE for(j = 0; j < np; j++){ if (rank == j){ printf("matrix(transposed) after iteration %d rank %d\n", i, j); print_full(local_a_t, get_row(np, rank, nrows_local - 1) + 1, nrows_local, nrows_local); printf("\n"); fflush(stdout); } MPI(MPI_Barrier(MPI_COMM_WORLD)); } if (rank == ROOT_RANK){ printf("first column: "); for(j = i; j < n; j++) printf("%.*lf\t", PRECISION, first_column[j]); printf("\n"); } #endif // VERBOSE } //transpose back to row-major #pragma omp parallel for private(row) for(i = 0; i < nrows_local; i++){ row = get_row(np, rank, i); //also take diagonal elms #pragma omp parallel for for(j = 0; j <= row; j++){ *ELM(local_a, i, j, n) = *ELM(local_a_t, j, i, nrows_local); } if (rank != ROOT_RANK){ //trasfer back to root process MPI( MPI_Isend( ELM(local_a, i, 0, n), row + 1, MPI_DOUBLE, ROOT_RANK, i, MPI_COMM_WORLD, requests + i )); } } if (rank == ROOT_RANK){ //receive calculated buffer from all processes j = 0; #pragma omp parallel for private(tag, sender, k) for(i = 0; i < n; i++){ tag = i / np; sender = i % np; if (sender != 0){ #pragma omp critical k = j++; MPI(MPI_Irecv(ELM(a, i, 0, n), i + 1, MPI_DOUBLE, sender, tag, MPI_COMM_WORLD, requests + k)); } } //copy from my own //(n + np - 1) / np = nrows_local #pragma omp parallel for private(row) for(i = 0; i < nrows_local; i++){ row = get_row(np, rank, i); memcpy(ELM(a, row, 0, n), ELM(local_a, i, 0, n), sizeof(double) * (row + 1)); } /*MPI(MPI_Waitall(nrequests, requests, statuses));*/ MPI(MPI_Waitall(nrequests, requests, statuses)); /*for(i = 0; i < nrows_local; i++){*/ /*if (statuses[i].MPI_ERROR != MPI_SUCCESS){*/ /*printf("rank %d status %d: %d\n", rank, i, statuses[i].MPI_ERROR);*/ /*print_error(statuses[i].MPI_ERROR);*/ /*}*/ /*}*/ #ifdef VERBOSE if (rank == ROOT_RANK){ printf("array after parallel computation: \n"); print_lower(a, n, n); printf("\n"); } #endif // VERBOSE /* forward solve L y = b: but y is stored in x can be merged to the previous loop */ for (i=0; i< n; i++) { double t = b[i]; #pragma omp parallel for reduction(-:t) for (j=0; j< i; j++) t -= *ELM(a, i, j, n) * x[j]; x[i] = t; } /* backward solve D L^t x = y */ for (i= n-1; i>= 0; i--) { double t = x[i] / *ELM(a, i, i, n); #pragma omp parallel for reduction(-:t) for (j= i+1; j< n; j++) t -= *ELM(a, j, i, n) * x[j]; x[i] = t; } } else { MPI(MPI_Waitall(nrequests, requests, statuses)); } free(statuses); free(local_a); free(requests); free(first_column); free(allgather_buf); free(displs); free(recvcounts); free(local_a_t); } double norm(double *x, double* y, int n){ /* check error norm */ double e = 0; int i; for (i=0; i< n; i++) e += (x[i] - y[i]) * (x[i] - y[i]); return sqrt(e); } //error handler void cholesky_mpi_error_handler( MPI_Comm *comm, int *err, ... ) { if (*err != MPI_ERR_OTHER) { printf( "Unexpected error code\n" );fflush(stdout); } else { printf("error caused in comm %d, error: %d", *comm, err ? *err : -1); fflush(stdout); } } typedef struct { double serial; double parallel; } bmtime_t; bmtime_t benchmark(int n, int np, int rank){ bmtime_t bmtime; int i, j, mpi_result; double *a, *xx, *b, *x, e, s, *a_copy, *b_copy; double time_start, time_stop; if (rank == ROOT_RANK){ /* matrix */ a = malloc(sizeof(double) * n * n); assert(a != NULL); /* fill lower triangular elements */ for (i=0; i< n; i++) for (j=0; j< i; j++) *ELM(a, i, j, n) = rand()/(RAND_MAX + 1.0); /* fill diagonal elements */ for (i=0; i< n; i++) { s = 0.0; for (j=0; j< i; j++) s += *ELM(a, i, j, n); for (j= i+1; j< n; j++) s += *ELM(a, j, i, n); /* upper triangular */ *ELM(a, i, i, n) = s + 1.0; /* diagonal dominant */ } #ifdef VERBOSE printf("original matrix: \n"); print_lower(a, n, n); printf("\n"); #endif // VERBOSE /* first make the solution */ xx = malloc(sizeof(double) * n); assert(xx != NULL); for (i=0; i< n; i++) xx[i] = 1.0; /* or anything you like */ /* make right hand side b = Ax */ b = malloc(sizeof(double) * n); assert(b != NULL); symMatVec(n, a, xx, b); /* solution vector, pretend to be unknown */ x = malloc(sizeof(double) * n); assert(x != NULL); #ifdef RUN_SERIAL //clone data a_copy = malloc(sizeof(double) * n * n); assert(a_copy != NULL); b_copy = malloc(sizeof(double) * n); assert(b_copy != NULL); memcpy(a_copy, a, sizeof(double) * n * n); memcpy(b_copy, b, sizeof(double) * n); //serial solver time_start = MPI_Wtime(); solveSym_serial(n, a_copy, x, b_copy); time_stop = MPI_Wtime(); bmtime.serial = time_stop - time_start; e = norm(x, xx, n); if (e >= EPS){ bmtime.serial = -1; fprintf(stderr, "expected error norm less than %e, but %e received while serial benchmark with size = %d\n", EPS, e, n); } //free data free(a_copy); free(b_copy); memset(x, 0, sizeof(double) * n); #else // RUN_SERIAL bmtime.serial = 0; #endif // RUN_SERIAL } #ifdef RUN_PARALLEL MPI(MPI_Barrier(MPI_COMM_WORLD)); //parallel version time_start = MPI_Wtime(); /* solve: the main computation */ solveSym(rank, np, n, a, x, b); MPI(MPI_Barrier(MPI_COMM_WORLD)); time_stop = MPI_Wtime(); bmtime.parallel = time_stop - time_start; if (rank == ROOT_RANK) { e = norm(x, xx, n); if (e >= EPS){ bmtime.parallel = -1; fprintf(stderr, "expected error norm less than %e, but %e received while parallel benchmark with size = %d\n", EPS, e, n); } } #else // RUN_PARALLEL bmtime.parallel = -1; #endif // RUN_PARALLEL if (rank == ROOT_RANK){ //free data free(a); free(xx); free(b); free(x); } return bmtime; } int main(int argc, char **argv) { int mpi_result, n; double time_start, time_stop; // Initialize the MPI environment int provided; MPI(MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided )); if (MPI_THREAD_MULTIPLE != provided){ fprintf(stderr, "Expected mpi thread support %d but %d returned\n", MPI_THREAD_MULTIPLE, provided); return 1; } MPI(MPI_Barrier(MPI_COMM_WORLD)); time_start = MPI_Wtime(); //set error handler MPI_Errhandler err_handler; /*MPI(MPI_Comm_create_errhandler(&cholesky_mpi_error_handler, &err_handler));*/ /*MPI(MPI_Comm_set_errhandler(MPI_COMM_WORLD, err_handler));*/ #ifdef DEBUG MPI(MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN)); #endif // DEBUG // Get the number of processes int np; MPI(MPI_Comm_size(MPI_COMM_WORLD, &np)); // Get the rank of the process int rank; MPI(MPI_Comm_rank(MPI_COMM_WORLD, &rank)); int nt; #pragma omp parallel #pragma omp master nt = omp_get_num_threads(); #ifdef WEAK_SCALING n = N * np * nt; #else // WEAK_SCALING n = N; #endif // WEAK_SCALING bmtime_t bmtime = benchmark(n, np, rank); if (rank == ROOT_RANK){ printf("%d\t%d\t%d\t%.10lf\t%.10lf\n", np, nt, n, bmtime.serial, bmtime.parallel); } MPI(MPI_Barrier(MPI_COMM_WORLD)); time_stop = MPI_Wtime(); /*if (rank == ROOT_RANK){*/ /*printf("Total job time / limit (10 min): %.2lf%%\n", (time_stop - time_start) / 60 / 10 * 100);*/ /*}*/ //free error handler /*MPI_Errhandler_free( &err_handler );*/ // Finalize the MPI environment. MPI_Finalize(); return 0; }
27.21202
169
0.569693
007001b6731d88713ad2e37a56727bf05dd8db57
1,085
h
C
PrintedDocumentLinkingSystem/src/ContentHashExtractionModule/RegexCHashExtractor.h
floschne/BachelorThesis
50f54e0ffbe9ec2a009f42f26e20403f1425a723
[ "Apache-2.0" ]
null
null
null
PrintedDocumentLinkingSystem/src/ContentHashExtractionModule/RegexCHashExtractor.h
floschne/BachelorThesis
50f54e0ffbe9ec2a009f42f26e20403f1425a723
[ "Apache-2.0" ]
null
null
null
PrintedDocumentLinkingSystem/src/ContentHashExtractionModule/RegexCHashExtractor.h
floschne/BachelorThesis
50f54e0ffbe9ec2a009f42f26e20403f1425a723
[ "Apache-2.0" ]
null
null
null
#ifndef PRINTEDDOCUMENTVERIFICATIONSYSTEM_REGEXCHASHEXTRACTOR_H #define PRINTEDDOCUMENTVERIFICATIONSYSTEM_REGEXCHASHEXTRACTOR_H #include <map> #include "IContentHashExtractor.h" #include "../Datatypes/ContentHash.h" #include "../Datatypes/Document.h" namespace PDLS { class RegexCHashExtractor : public IContentHashExtractor { std::map<ContentHashType, const std::string*> _contentHashMatcherMap {}; Content* extractDocumentContent(Document* pDocument); void generateContentHashMatcherMap(); public: RegexCHashExtractor(const ContentHashType& hT); virtual ContentHash* extractContentHash(Document* doc, const std::string& hashPrefix, const std::string& hashPostfix) override; inline const std::string* getContentHashMatcher(const ContentHashType& hT) { return _contentHashMatcherMap[hT]; } inline const std::string* getContentHashMatcher() { return _contentHashMatcherMap[_expectedHashType]; } }; } #endif //PRINTEDDOCUMENTVERIFICATIONSYSTEM_REGEXCHASHEXTRACTOR_H
29.324324
135
0.741014
009b2d00dc45ef8365efb9f7808b9135653b97cb
4,946
c
C
gpvdm_core/liblight/light_srcs.c
roderickmackenzie/gpvdm
914fd2ee93e7202339853acaec1d61d59b789987
[ "BSD-3-Clause" ]
12
2016-09-13T08:58:13.000Z
2022-01-17T07:04:52.000Z
gpvdm_core/liblight/light_srcs.c
roderickmackenzie/gpvdm
914fd2ee93e7202339853acaec1d61d59b789987
[ "BSD-3-Clause" ]
3
2017-11-11T12:33:02.000Z
2019-03-08T00:48:08.000Z
gpvdm_core/liblight/light_srcs.c
roderickmackenzie/gpvdm
914fd2ee93e7202339853acaec1d61d59b789987
[ "BSD-3-Clause" ]
6
2019-01-03T06:17:12.000Z
2022-01-01T15:59:00.000Z
// // General-purpose Photovoltaic Device Model gpvdm.com - a drift diffusion // base/Shockley-Read-Hall model for 1st, 2nd and 3rd generation solarcells. // The model can simulate OLEDs, Perovskite cells, and OFETs. // // Copyright 2008-2022 Roderick C. I. MacKenzie https://www.gpvdm.com // r.c.i.mackenzie at googlemail.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. // /** @file device_heat.c @brief Malloc for the device structure. */ #define _FILE_OFFSET_BITS 64 #define _LARGEFILE_SOURCE #include <stdio.h> #include <stdlib.h> #include <device.h> #include <string.h> #include <dump.h> #include <mesh.h> #include <ray_fun.h> #include <newton_tricks.h> #include <memory.h> #include <circuit.h> #include <shape.h> #include <lang.h> #include <util.h> #include <heat_fun.h> #include <gpvdm_const.h> #include <light_srcs.h> #include <light_fun.h> static int unused __attribute__((unused)); static char* unused_pchar __attribute__((unused)); void light_srcs_init(struct simulation *sim,struct light_sources *srcs) { srcs->nlight_sources=-1; srcs->light_sources=NULL; srcs->lstart=-1; srcs->lstop=-1; srcs->llen=-1; } void light_srcs_free(struct simulation *sim,struct light_sources *srcs) { int i; for (i=0;i<srcs->nlight_sources;i++) { light_src_free(sim, &(srcs->light_sources[i])); } free(srcs->light_sources); light_srcs_init(sim,srcs); } void light_srcs_dump(struct simulation *sim,char *path,struct light_sources *srcs) { int i; char out_dir[PATH_MAX]; join_path(2,out_dir,path,"optical_output"); gpvdm_mkdir(out_dir); for (i=0;i<srcs->nlight_sources;i++) { light_src_dump(sim,out_dir,&(srcs->light_sources[i])); } } void light_srcs_cpy(struct simulation *sim,struct light_sources *out,struct light_sources *in) { int i; if (in->nlight_sources>0) { out->light_sources=malloc(sizeof(struct light_src)*in->nlight_sources); out->nlight_sources=in->nlight_sources; for (i=0;i<in->nlight_sources;i++) { light_src_cpy(sim,&(out->light_sources[i]), &(in->light_sources[i])); } } out->lstart=in->lstart; out->lstop=in->lstop; out->llen=in->llen; } void light_srcs_load(struct simulation *sim,struct light_sources *srcs,struct json_obj *json_light_sources) { int i; char temp[200]; struct json_obj *json_lights; struct json_obj *json_config; struct json_obj *json_seg; struct json_obj *json_virtual_spectra; json_config=json_obj_find(json_light_sources, "config"); if (json_config==NULL) { ewe(sim,"Object lights not found\n"); } json_get_int(sim, json_config, &srcs->llen,"lpoints"); json_lights=json_obj_find(json_light_sources, "lights"); if (json_lights==NULL) { ewe(sim,"Object lights not found\n"); } json_get_int(sim, json_lights, &srcs->nlight_sources,"segments"); if (srcs->nlight_sources>0) { srcs->light_sources=malloc(sizeof(struct light_src)*srcs->nlight_sources); for (i=0;i<srcs->nlight_sources;i++) { sprintf(temp,"segment%d",i); json_seg=json_obj_find(json_lights, temp); json_virtual_spectra=json_obj_find(json_seg, "virtual_spectra"); if (json_virtual_spectra==NULL) { ewe(sim,"Object virtual_spectra not found\n"); } light_src_init(sim,&(srcs->light_sources[i])); light_src_load(sim,&(srcs->light_sources[i]), json_seg); } light_srcs_cal_lambda_min_max(sim,srcs); for (i=0;i<srcs->nlight_sources;i++) { light_src_build_spectra_tot(sim,&(srcs->light_sources[i]), srcs->lstart, srcs->lstop, srcs->llen); } } } void light_srcs_cal_lambda_min_max(struct simulation *sim,struct light_sources *srcs) { int i; srcs->lstop=-1.0; srcs->lstart=1e6; if (srcs->nlight_sources>0) { for (i=0;i<srcs->nlight_sources;i++) { if (srcs->light_sources[i].lstart<srcs->lstart) { srcs->lstart=srcs->light_sources[i].lstart; } if (srcs->light_sources[i].lstop>srcs->lstop) { srcs->lstop=srcs->light_sources[i].lstop; } } } }
25.895288
107
0.725637
2e294e87cd5b0de2f277052381a4a54b0225fe00
1,365
h
C
command.h
lavosprime/heropool
f217c134510e76d5b556bd81c0ddc2fd22f44a17
[ "MIT" ]
null
null
null
command.h
lavosprime/heropool
f217c134510e76d5b556bd81c0ddc2fd22f44a17
[ "MIT" ]
null
null
null
command.h
lavosprime/heropool
f217c134510e76d5b556bd81c0ddc2fd22f44a17
[ "MIT" ]
null
null
null
/******************************************************************************\ Copyright (c) 2014-2015 by Cooper Johnson <lavosprime@gmail.com> This program is free software provided under the terms of the MIT License. command.h: Wrapper around processing of user commmands. \******************************************************************************/ #ifndef COMMAND_H_ #define COMMAND_H_ #include <algorithm> #include <string> #include <vector> namespace heropool { class Database; // Handles a single user command based on the arguments provided by the user. class Command final { public: // Creates a Command that uses the given arguments for execution. explicit Command(std::vector<std::string> args) : args_(std::move(args)) {} // Performs the action specified by the command arguments. void Execute(const Database* db); // Returns whether the program should end after execution of this command. bool CausesExit(void); // Use compiler-provided move construction and move assignment. Command(Command&&) = default; Command& operator=(Command&&) = default; private: // Disable copy construction and copy assignment. Command(const Command&) = delete; Command& operator=(const Command&) = delete; // The arguments to the command. std::vector<std::string> args_; }; } // namespace heropool #endif // COMMAND_H_
31.022727
80
0.650549
6d2150629c0a7e01ad7f5fc11e38894b002f2951
513
h
C
Drawing.UWP/DrawingUWP/D2DShapeLayer.h
msrao83/Telerik
e0000ddacf48d4f9997562b34442f2617e86842c
[ "Apache-2.0" ]
1,338
2017-02-08T17:22:49.000Z
2022-03-30T10:29:08.000Z
Drawing.UWP/DrawingUWP/D2DShapeLayer.h
msrao83/Telerik
e0000ddacf48d4f9997562b34442f2617e86842c
[ "Apache-2.0" ]
197
2017-02-09T04:34:05.000Z
2022-03-30T11:17:33.000Z
Drawing.UWP/DrawingUWP/D2DShapeLayer.h
msrao83/Telerik
e0000ddacf48d4f9997562b34442f2617e86842c
[ "Apache-2.0" ]
308
2017-02-08T17:23:49.000Z
2022-03-19T08:52:38.000Z
#pragma once #include <D2DShape.h> #include <collection.h> namespace Telerik { namespace UI { namespace Drawing { ref class D2DShapeLayer { internal: D2DShapeLayer(void); void Render(D2DRenderContext^ context, Rect invalidRect, DoublePoint offset); // used to sort the layers by z-index bool operator < (D2DShapeLayer^ layer) { return this->parameters.ZIndex < layer->parameters.ZIndex; } ShapeLayerParameters parameters; std::vector<D2DShape^> shapes; }; } } }
17.689655
105
0.692008
7a14bfcdd20e75411cca409eb4892ecb7921c1d2
1,076
c
C
libft/srcs/ft_strcmp.c
dolovnyak/rt_indi
def722cd81a9163ba8b531fb4d651b316cfa1190
[ "Unlicense" ]
3
2019-12-11T16:26:30.000Z
2021-07-05T08:28:32.000Z
libft/srcs/ft_strcmp.c
dolovnyak/rt_indi
def722cd81a9163ba8b531fb4d651b316cfa1190
[ "Unlicense" ]
null
null
null
libft/srcs/ft_strcmp.c
dolovnyak/rt_indi
def722cd81a9163ba8b531fb4d651b316cfa1190
[ "Unlicense" ]
3
2019-10-12T14:56:50.000Z
2019-11-04T10:58:03.000Z
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: broggo <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/09/26 20:29:03 by broggo #+# #+# */ /* Updated: 2018/09/26 20:29:07 by broggo ### ########.fr */ /* */ /* ************************************************************************** */ int ft_strcmp(const char *s1, const char *s2) { while ((*s1) || (*s2)) { if (*s1 != *s2) return (*(unsigned char *)s1 - *(unsigned char *)s2); s1++; s2++; } return (0); }
44.833333
80
0.169145
a39c23bfa6c9f68b6e055c1f5bb9d0dfe4c0799e
927
h
C
Sources/ElkCraft/Include/ElkCraft/Gameplay/ItemInteraction.h
adriengivry/ElkCraft
7147b1aae7183eee692f2691cac24505a61515c1
[ "MIT" ]
10
2018-11-09T03:38:30.000Z
2022-01-31T11:46:10.000Z
Sources/ElkCraft/Include/ElkCraft/Gameplay/ItemInteraction.h
adriengivry/ElkCraft
7147b1aae7183eee692f2691cac24505a61515c1
[ "MIT" ]
null
null
null
Sources/ElkCraft/Include/ElkCraft/Gameplay/ItemInteraction.h
adriengivry/ElkCraft
7147b1aae7183eee692f2691cac24505a61515c1
[ "MIT" ]
10
2018-09-30T05:07:35.000Z
2021-12-22T04:41:38.000Z
#pragma once #include <ElkGameEngine/ElkGameEngine.h> #include <ElkTools/Utils/BlocksInfo.h> #include "ElkCraft/Gameplay/Inventory.h" #include "ElkCraft/Gameplay/HealthSystem.h" #include "ElkCraft/Gameplay/HungerSystem.h" #include "ElkCraft/Gameplay/PlayerController.h" #include "ElkCraft/Terrain/World.h" #include "ElkCraft/Utils/ItemsInfo.h" namespace ElkCraft::Gameplay { class ItemInteraction : public ElkGameEngine::Objects::Components::Behaviours::ABehaviour { public: ItemInteraction(); ~ItemInteraction() = default; void Update() override; void HandleInputs(); void UseItem(); private: ElkGameEngine::Managers::InputManager& m_inputManager; ElkTools::Managers::AudioManager& m_audioManager; std::shared_ptr<ElkCraft::Gameplay::Inventory> m_inventory; std::shared_ptr<ElkCraft::Gameplay::HealthSystem> m_healthSystem; std::shared_ptr<ElkCraft::Gameplay::HungerSystem> m_hungerSystem; }; }
27.264706
90
0.778857
d177952f16fe704d031dab9e1701257f13d81169
3,184
h
C
util.h
gavin-stewart/HPC_domain_decomp
4118bcf7076d88e3f65cd6890ece03242a7e66da
[ "MIT" ]
null
null
null
util.h
gavin-stewart/HPC_domain_decomp
4118bcf7076d88e3f65cd6890ece03242a7e66da
[ "MIT" ]
null
null
null
util.h
gavin-stewart/HPC_domain_decomp
4118bcf7076d88e3f65cd6890ece03242a7e66da
[ "MIT" ]
null
null
null
/* * Copyright (c) 2010 Andreas Kloeckner * * 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 UTIL_H #define UTIL_H #include <stdlib.h> #include <stdio.h> #ifdef __APPLE__ #include <sys/time.h> typedef struct timeval timestamp_type; static void get_timestamp(timestamp_type *t) { gettimeofday(t, NULL); } static double timestamp_diff_in_seconds(timestamp_type start, timestamp_type end) { /* Perform the carry for the later subtraction by updating start. */ if (end.tv_usec < start.tv_usec) { int nsec = (start.tv_usec - end.tv_usec) / 1000000 + 1; start.tv_usec -= 1000000 * nsec; start.tv_sec += nsec; } if (end.tv_usec - start.tv_usec > 1000000) { int nsec = (end.tv_usec - start.tv_usec) / 1000000; start.tv_usec += 1000000 * nsec; start.tv_sec -= nsec; } return end.tv_sec - start.tv_sec + (end.tv_usec - start.tv_usec)*1e-6; } #else #include <time.h> typedef struct timespec timestamp_type; static void get_timestamp(timestamp_type *t) { clock_gettime(CLOCK_REALTIME, t); } static double timestamp_diff_in_seconds(timestamp_type start, timestamp_type end) { struct timespec temp; if ((end.tv_nsec-start.tv_nsec)<0) { temp.tv_sec = end.tv_sec-start.tv_sec-1; temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; } else { temp.tv_sec = end.tv_sec-start.tv_sec; temp.tv_nsec = end.tv_nsec-start.tv_nsec; } return temp.tv_sec + 1e-9*temp.tv_nsec; } #endif #define MAX_LINE_LEN 1024 /* * Read a line from stdin. * From http://stackoverflow.com/a/314422/1148634 */ static char *read_a_line(void) { char * line = (char *) malloc(MAX_LINE_LEN), * linep = line; size_t lenmax = MAX_LINE_LEN, len = lenmax; int c; if(line == NULL) return NULL; for(;;) { c = fgetc(stdin); if(c == EOF) break; if(--len == 0) { char *linen = (char *) realloc(linep, lenmax *= 2); len = lenmax; if(linen == NULL) { free(linep); return NULL; } line = linen + (line - linep); linep = linen; } if((*line++ = c) == '\n') break; } *line = '\0'; return linep; } #endif
24.682171
81
0.683731
4d5b7bae0bd82e053e701c834651152ae910266b
2,559
h
C
src/normalization/LiteralValues.h
rigred/VC4C
6c900c0e2fae2cbdd22c5adb044f385ae005468a
[ "MIT" ]
111
2017-11-02T14:46:45.000Z
2022-03-15T21:32:59.000Z
src/normalization/LiteralValues.h
rigred/VC4C
6c900c0e2fae2cbdd22c5adb044f385ae005468a
[ "MIT" ]
139
2017-10-09T07:39:01.000Z
2021-11-20T15:31:27.000Z
src/normalization/LiteralValues.h
rigred/VC4C
6c900c0e2fae2cbdd22c5adb044f385ae005468a
[ "MIT" ]
33
2017-10-10T10:19:58.000Z
2022-02-27T15:59:50.000Z
/* * Author: doe300 * * See the file "LICENSE" for the full license governing this code. */ #ifndef LITERALVALUES_H #define LITERALVALUES_H #include "../Values.h" namespace vc4c { class Method; class Module; class InstructionWalker; struct Configuration; namespace normalization { /* * Handles the use of literal containers (e.g. literal constant vectors) by inserting the single elements at * their positions. * * Also optimizes some special cases, like rotation of literal vector or uniform vectors (all elements are the * same) */ InstructionWalker handleContainer( const Module& module, Method& method, InstructionWalker it, const Configuration& config); /* * Handles the use of literal operands by either converting them to SmallImmediates or loading them into * temporary locals as 32-bit literal values * * Example: * %3 = add 17, %2 * * is converted to: * %immediate = loadi 17 * %3 = add %immediate, %2 * * NOTE: This optimization-step is required for the further compilation to work correctly */ InstructionWalker handleImmediate( const Module& module, Method& method, InstructionWalker it, const Configuration& config); /* * Facilitates the register-mapping by rewriting operations, where one operand is a SmallImmediate and the other * is a local which is unlikely to be mapped to accumulators by introducing a temporary local which is then used * together with the SmallImmediate and should be mapped to an accumulator. * * Example: * %2 = add 1, %1 * * is converted to: * %use_with_literal = %1 * %2 = add 1, %use_with_literal * * NOTE: Skipping this step results in many (possibly long-living and often-used) locals being forced to * physical register-file A, since the physical file B is used for the SmallImmediate */ InstructionWalker handleUseWithImmediate( const Module& module, Method& method, InstructionWalker it, const Configuration& config); /** * Returns the small immediate representation of the given literal, if it can be represented as such */ Optional<SmallImmediate> toImmediate(Literal lit); } // namespace normalization } // namespace vc4c #endif /* LITERALVALUES_H */
36.042254
120
0.631887
4d5febbac43f99cfab873d9bbe27c1a7bf90408f
1,668
h
C
src/opengl/buffer_view.h
vknauss/LD48
9b8795f7d2ebf1e4d13d61dab4062eeaa166d4bf
[ "MIT" ]
null
null
null
src/opengl/buffer_view.h
vknauss/LD48
9b8795f7d2ebf1e4d13d61dab4062eeaa166d4bf
[ "MIT" ]
null
null
null
src/opengl/buffer_view.h
vknauss/LD48
9b8795f7d2ebf1e4d13d61dab4062eeaa166d4bf
[ "MIT" ]
null
null
null
#pragma once #include <cassert> #include <cstddef> #include "buffer.h" namespace OpenGL { // A view into a region of a Buffer // Allows data transfer via mapped writes class BufferView { private: const Buffer* pBuffer; size_t offset, length; public: // @param offset the index of the first byte in the BufferView // @param length the size in bytes of the range used for mapping BufferView(const Buffer* pBuffer, size_t offset, size_t length); // Write into the mapped buffer range using a custom callback object // with an effective function call signature of (void *) => void template<typename Fn> void writeData(Fn&& fn) const; inline const Buffer* getBuffer() const { return pBuffer; } inline const size_t getOffset() const { return offset; } inline const size_t getLength() const { return length; } }; template<typename Fn> void BufferView::writeData(Fn&& fn) const { void* pBufferData; glBindBuffer(GL_COPY_WRITE_BUFFER, pBuffer->getHandle()); // using GL_COPY_WRITE_BUFFER because why not GLbitfield flags = GL_MAP_WRITE_BIT; if (offset == 0 && length == pBuffer->getSize()) { flags |= GL_MAP_INVALIDATE_BUFFER_BIT; } else { flags |= GL_MAP_INVALIDATE_RANGE_BIT; } pBufferData = glMapBufferRange(GL_COPY_WRITE_BUFFER, offset, length, flags); assert(pBufferData); fn(pBufferData); glBindBuffer(GL_COPY_WRITE_BUFFER, pBuffer->getHandle()); // rebind the buffer in case the user did some shenanigans glUnmapBuffer(GL_COPY_WRITE_BUFFER); glBindBuffer(GL_COPY_WRITE_BUFFER, 0); } } // namespace OpenGL
26.47619
120
0.694245
0659df2553157b45779cb67a4adbb8f1ce33ad16
4,686
h
C
containers/strings.h
korrmet/yosh
573dbca6bbdc58376b2d9df2f56a98cb3c8ad54e
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
containers/strings.h
korrmet/yosh
573dbca6bbdc58376b2d9df2f56a98cb3c8ad54e
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
containers/strings.h
korrmet/yosh
573dbca6bbdc58376b2d9df2f56a98cb3c8ad54e
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
#ifndef STRINGS_H #define STRINGS_H #include <stddef.h> //TODO: decide about pack it in object and choose object packing model /** \page string_container String Container * * \section description Description * * This code provide cpp stl style of a string in common c program. It is very * flexible and can be used in any project i can imagine. * * \section usage Usage * * Basically usage is: * * create string * * manipulate it * * delete string */ #define CONT_STANDARD_STRING_EXT_VAL 10 /**< length in symbols of string extend increment */ typedef struct //yosh_string_t { char* s; ///< pointer to the string size_t len; ///< length of the string char* iter; ///< iterator which represent next symbol for reading } cont_string_t; /** \brief some stuff of standard library * \details needed to provide string container with multiple API's in one * project. this featue may be imposrtant for embedded systems which * may contain multiple components developed for baremetal systems and * each contains it's own implementation of malloc and requires you * to use it only. */ typedef struct //cont_string_calls_t { /** \brief allocate memory * \details signature is similar to standard malloc * \arg size size of memory you going to allocate * \return pointer to allocated memory or error sequence * \retval NULL error * \retval !NULL valid pointer */ void* (*malloc)(size_t size); /** \brief free memory * \details signature is similar to standard free * \arg ptr pointer to memory you going to free */ void (*free)(void* ptr); /** \brief copy memory * \details signature is similar to standard memcpy * \arg dst pointer to destination memory area * \arg src pointer to source memory area * \arg n size in bytes of memory which will be copied * \return pointer to copied data or error sequence * \note check it in original memcpy * \retval NULL error * \retval !NULL valid pointer to copied data */ void* (*memcpy)(void* dst, const void* src, size_t n); /** \brief fill memory by specific character * \details signature is similar to standard memset * \arg dst pointer to destination memory area * \arg val character to fill memosy * \arg n size in bytes of memory shich you going to fill * \return pointer to setted data or error sequence * \note check it in original memset * \retval NULL error * \retval !NULL valid pointer */ void* (*memset)(void* dst, int val, size_t n); /** \brief compare to strings * \details signature is similar to standard strcmp * \note TODO: maybe memcmp will be better? * \arg str1 pointer to first string to compare * \arg str2 pointer to second string to compare * \return result of comparsion or error sequence * \retval <0 error occured/can't compare * \retval 0 strings are equal * \retval >0 number of char where strings start to differ */ int (*strcmp)(const char* str1, const char* str2); } cont_string_calls_t; /** \brief part of string container. creates a new string * \details dynamically allocates memory * \arg c memory system calls descriptor * \arg n size of string * \return poi nter to created string or error sequence * \retval null error sequence * \retval !null valid pointer */ cont_string_t* cont_new_string(cont_string_calls_t* c, size_t n); /** \brief part of string container. deletes an existing string * \details dynamically free memory * \arg d yosh descriptor. need to take free function * \arg s pointer to a string container */ void cont_del_string(cont_string_calls_t* c, cont_string_t* s); /** \brief part of string container. extends string to larger size * \details allocates ne memory and free old * \arg c string calls descriptor * \arg s pointer to a string * \arg n number of bytes to increase string volume * \return pointer to extended string */ cont_string_t* cont_ext_string(cont_string_calls_t* c, cont_string_t* s, size_t n); /** \brief part of string container. adds character to the end of string * \details automatically extends string if neede * \arg c string calls descriptor * \arg s pointer to string container * \note TODO: why double pointer? * \arg ch character to be added to string */ void cont_string_add_char(cont_string_calls_t* c, cont_string_t** s, char ch); #endif//STRINGS_H
41.105263
80
0.671575