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
c82bca03355c8995693120eb2af4e5c6d2d8c5d1
456
h
C
TLColorFlowLayout/Classes/TLCollectionViewFlowLayout.h
huawtswork/TLColorFlowLayout
7b7ab5b0335a7eed93ed674dc64ed641efb2ff45
[ "MIT" ]
null
null
null
TLColorFlowLayout/Classes/TLCollectionViewFlowLayout.h
huawtswork/TLColorFlowLayout
7b7ab5b0335a7eed93ed674dc64ed641efb2ff45
[ "MIT" ]
null
null
null
TLColorFlowLayout/Classes/TLCollectionViewFlowLayout.h
huawtswork/TLColorFlowLayout
7b7ab5b0335a7eed93ed674dc64ed641efb2ff45
[ "MIT" ]
null
null
null
#import <UIKit/UIKit.h> @protocol TLCollectionViewDelegateFlowLayout <UICollectionViewDelegateFlowLayout> - (UIColor *)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout backgroundColorForSection:(NSInteger)section; @end @interface TLCollectionViewFlowLayout : UICollectionViewFlowLayout @property (nonatomic, strong) NSMutableArray<UICollectionViewLayoutAttributes *> *decorationViewAttrs; @end
30.4
162
0.850877
aed216b433af7c355b7198d0998da244827f5083
150
h
C
test/patterns/mediator/mediator_test.h
saadshams/puremvc-c-standard-framework
e629648d5299110d47b43241becc698298cf483e
[ "BSD-3-Clause" ]
null
null
null
test/patterns/mediator/mediator_test.h
saadshams/puremvc-c-standard-framework
e629648d5299110d47b43241becc698298cf483e
[ "BSD-3-Clause" ]
null
null
null
test/patterns/mediator/mediator_test.h
saadshams/puremvc-c-standard-framework
e629648d5299110d47b43241becc698298cf483e
[ "BSD-3-Clause" ]
null
null
null
#ifndef PUREMVC_MEDIATOR_TEST_H #define PUREMVC_MEDIATOR_TEST_H void testNameAccessor(); void testViewAccessor(); #endif //PUREMVC_MEDIATOR_TEST_H
16.666667
32
0.84
261201783eca61d3a8830d51b99c431036f47090
209
h
C
choice.h
jfcasley/go-fltk
f086de1087ed492859328319b7dbec7f3f6bc832
[ "MIT" ]
null
null
null
choice.h
jfcasley/go-fltk
f086de1087ed492859328319b7dbec7f3f6bc832
[ "MIT" ]
null
null
null
choice.h
jfcasley/go-fltk
f086de1087ed492859328319b7dbec7f3f6bc832
[ "MIT" ]
null
null
null
#pragma once #ifdef __cplusplus extern "C" { #endif typedef struct Fl_Choice Fl_Choice; extern Fl_Choice *go_fltk_new_Choice(int x, int y, int w, int h, const char *label); #ifdef __cplusplus } #endif
14.928571
86
0.732057
6470f1eb3500b88765d0bba75e71d24f2fe77142
1,062
h
C
src/xrGame/UI.h
clayne/xray-16
32ebf81a252c7179e2824b2874f911a91e822ad1
[ "OML", "Linux-OpenIB" ]
2
2015-02-23T10:43:02.000Z
2015-06-11T14:45:08.000Z
src/xrGame/UI.h
clayne/xray-16
32ebf81a252c7179e2824b2874f911a91e822ad1
[ "OML", "Linux-OpenIB" ]
17
2022-01-25T08:58:23.000Z
2022-03-28T17:18:28.000Z
src/xrGame/UI.h
clayne/xray-16
32ebf81a252c7179e2824b2874f911a91e822ad1
[ "OML", "Linux-OpenIB" ]
1
2015-06-05T20:04:00.000Z
2015-06-05T20:04:00.000Z
#pragma once #include "UICursor.h" #include "UIDialogHolder.h" // refs class CHUDManager; class CUIGameCustom; class CUIMainIngameWnd; class CUIMessagesWindow; struct SDrawStaticStruct; class CUI : public CDialogHolder { CUIGameCustom* pUIGame; bool m_bShowGameIndicators; public: CHUDManager* m_Parent; CUIMainIngameWnd* UIMainIngameWnd; CUIMessagesWindow* m_pMessagesWnd; public: CUI(CHUDManager* p); virtual ~CUI(); bool Render(); void UIOnFrame(); void Load(CUIGameCustom* pGameUI); void UnLoad(); bool IR_OnKeyboardHold(int dik); bool IR_OnKeyboardPress(int dik); bool IR_OnKeyboardRelease(int dik); bool IR_OnMouseMove(int, int); bool IR_OnMouseWheel(int direction); CUIGameCustom* UIGame() { return pUIGame; } void ShowGameIndicators(bool b); bool GameIndicatorsShown() { return m_bShowGameIndicators; } void ShowCrosshair(bool b); bool CrosshairShown(); SDrawStaticStruct* AddInfoMessage(LPCSTR message); void OnConnected(); void UpdatePda(); };
20.823529
64
0.719397
afed726482586337505e9bcb7139b40a79b6cc06
14,102
c
C
Verilog/P5/isim/tb.exe.sim/work/m_00000000003279699937_2175365797.c
JJLeo/BUAA-CO-2020
1d1a3797f7188530464a1dfbe8a017dd01bb817a
[ "MIT" ]
9
2021-03-04T07:22:24.000Z
2021-11-30T02:56:08.000Z
Verilog/P5/isim/tb.exe.sim/work/m_00000000003279699937_2175365797.c
johnnyamazing/BUAA-CO-2020
1d1a3797f7188530464a1dfbe8a017dd01bb817a
[ "MIT" ]
null
null
null
Verilog/P5/isim/tb.exe.sim/work/m_00000000003279699937_2175365797.c
johnnyamazing/BUAA-CO-2020
1d1a3797f7188530464a1dfbe8a017dd01bb817a
[ "MIT" ]
3
2021-09-28T07:41:35.000Z
2021-12-14T08:55:28.000Z
/**********************************************************************/ /* ____ ____ */ /* / /\/ / */ /* /___/ \ / */ /* \ \ \/ */ /* \ \ Copyright (c) 2003-2009 Xilinx, Inc. */ /* / / All Right Reserved. */ /* /---/ /\ */ /* \ \ / \ */ /* \___\/\___\ */ /***********************************************************************/ /* This file is designed for use with ISim build 0x7708f090 */ #define XSI_HIDE_SYMBOL_SPEC true #include "xsi.h" #include <memory.h> #ifdef __GNUC__ #include <stdlib.h> #else #include <malloc.h> #define alloca _alloca #endif static void Cont_47_0(char *t0) { char t5[8]; char *t1; char *t2; char *t3; char *t4; unsigned int t6; unsigned int t7; unsigned int t8; char *t9; char *t10; unsigned int t11; unsigned int t12; unsigned int t13; unsigned int t14; unsigned int t15; unsigned int t16; unsigned int t17; char *t18; char *t19; unsigned int t20; unsigned int t21; unsigned int t22; int t23; unsigned int t24; unsigned int t25; unsigned int t26; int t27; unsigned int t28; unsigned int t29; unsigned int t30; unsigned int t31; char *t32; char *t33; char *t34; char *t35; char *t36; unsigned int t37; unsigned int t38; char *t39; unsigned int t40; unsigned int t41; char *t42; unsigned int t43; unsigned int t44; char *t45; LAB0: t1 = (t0 + 4928U); t2 = *((char **)t1); if (t2 == 0) goto LAB2; LAB3: goto *t2; LAB2: t2 = (t0 + 3128U); t3 = *((char **)t2); t2 = (t0 + 3768U); t4 = *((char **)t2); t6 = *((unsigned int *)t3); t7 = *((unsigned int *)t4); t8 = (t6 | t7); *((unsigned int *)t5) = t8; t2 = (t3 + 4); t9 = (t4 + 4); t10 = (t5 + 4); t11 = *((unsigned int *)t2); t12 = *((unsigned int *)t9); t13 = (t11 | t12); *((unsigned int *)t10) = t13; t14 = *((unsigned int *)t10); t15 = (t14 != 0); if (t15 == 1) goto LAB4; LAB5: LAB6: t32 = (t0 + 6648); t33 = (t32 + 56U); t34 = *((char **)t33); t35 = (t34 + 56U); t36 = *((char **)t35); memset(t36, 0, 8); t37 = 1U; t38 = t37; t39 = (t5 + 4); t40 = *((unsigned int *)t5); t37 = (t37 & t40); t41 = *((unsigned int *)t39); t38 = (t38 & t41); t42 = (t36 + 4); t43 = *((unsigned int *)t36); *((unsigned int *)t36) = (t43 | t37); t44 = *((unsigned int *)t42); *((unsigned int *)t42) = (t44 | t38); xsi_driver_vfirst_trans(t32, 0, 0); t45 = (t0 + 6488); *((int *)t45) = 1; LAB1: return; LAB4: t16 = *((unsigned int *)t5); t17 = *((unsigned int *)t10); *((unsigned int *)t5) = (t16 | t17); t18 = (t3 + 4); t19 = (t4 + 4); t20 = *((unsigned int *)t18); t21 = (~(t20)); t22 = *((unsigned int *)t3); t23 = (t22 & t21); t24 = *((unsigned int *)t19); t25 = (~(t24)); t26 = *((unsigned int *)t4); t27 = (t26 & t25); t28 = (~(t23)); t29 = (~(t27)); t30 = *((unsigned int *)t10); *((unsigned int *)t10) = (t30 & t28); t31 = *((unsigned int *)t10); *((unsigned int *)t10) = (t31 & t29); goto LAB6; } static void Cont_51_1(char *t0) { char t5[8]; char t34[8]; char *t1; char *t2; char *t3; char *t4; unsigned int t6; unsigned int t7; unsigned int t8; char *t9; char *t10; unsigned int t11; unsigned int t12; unsigned int t13; unsigned int t14; unsigned int t15; unsigned int t16; unsigned int t17; char *t18; char *t19; unsigned int t20; unsigned int t21; unsigned int t22; int t23; unsigned int t24; unsigned int t25; unsigned int t26; int t27; unsigned int t28; unsigned int t29; unsigned int t30; unsigned int t31; char *t32; char *t33; unsigned int t35; unsigned int t36; unsigned int t37; char *t38; char *t39; unsigned int t40; unsigned int t41; unsigned int t42; unsigned int t43; unsigned int t44; unsigned int t45; unsigned int t46; char *t47; char *t48; unsigned int t49; unsigned int t50; unsigned int t51; int t52; unsigned int t53; unsigned int t54; unsigned int t55; int t56; unsigned int t57; unsigned int t58; unsigned int t59; unsigned int t60; char *t61; char *t62; char *t63; char *t64; char *t65; unsigned int t66; unsigned int t67; char *t68; unsigned int t69; unsigned int t70; char *t71; unsigned int t72; unsigned int t73; char *t74; LAB0: t1 = (t0 + 5176U); t2 = *((char **)t1); if (t2 == 0) goto LAB2; LAB3: goto *t2; LAB2: t2 = (t0 + 2328U); t3 = *((char **)t2); t2 = (t0 + 2488U); t4 = *((char **)t2); t6 = *((unsigned int *)t3); t7 = *((unsigned int *)t4); t8 = (t6 | t7); *((unsigned int *)t5) = t8; t2 = (t3 + 4); t9 = (t4 + 4); t10 = (t5 + 4); t11 = *((unsigned int *)t2); t12 = *((unsigned int *)t9); t13 = (t11 | t12); *((unsigned int *)t10) = t13; t14 = *((unsigned int *)t10); t15 = (t14 != 0); if (t15 == 1) goto LAB4; LAB5: LAB6: t32 = (t0 + 3768U); t33 = *((char **)t32); t35 = *((unsigned int *)t5); t36 = *((unsigned int *)t33); t37 = (t35 | t36); *((unsigned int *)t34) = t37; t32 = (t5 + 4); t38 = (t33 + 4); t39 = (t34 + 4); t40 = *((unsigned int *)t32); t41 = *((unsigned int *)t38); t42 = (t40 | t41); *((unsigned int *)t39) = t42; t43 = *((unsigned int *)t39); t44 = (t43 != 0); if (t44 == 1) goto LAB7; LAB8: LAB9: t61 = (t0 + 6712); t62 = (t61 + 56U); t63 = *((char **)t62); t64 = (t63 + 56U); t65 = *((char **)t64); memset(t65, 0, 8); t66 = 1U; t67 = t66; t68 = (t34 + 4); t69 = *((unsigned int *)t34); t66 = (t66 & t69); t70 = *((unsigned int *)t68); t67 = (t67 & t70); t71 = (t65 + 4); t72 = *((unsigned int *)t65); *((unsigned int *)t65) = (t72 | t66); t73 = *((unsigned int *)t71); *((unsigned int *)t71) = (t73 | t67); xsi_driver_vfirst_trans(t61, 0, 0); t74 = (t0 + 6504); *((int *)t74) = 1; LAB1: return; LAB4: t16 = *((unsigned int *)t5); t17 = *((unsigned int *)t10); *((unsigned int *)t5) = (t16 | t17); t18 = (t3 + 4); t19 = (t4 + 4); t20 = *((unsigned int *)t18); t21 = (~(t20)); t22 = *((unsigned int *)t3); t23 = (t22 & t21); t24 = *((unsigned int *)t19); t25 = (~(t24)); t26 = *((unsigned int *)t4); t27 = (t26 & t25); t28 = (~(t23)); t29 = (~(t27)); t30 = *((unsigned int *)t10); *((unsigned int *)t10) = (t30 & t28); t31 = *((unsigned int *)t10); *((unsigned int *)t10) = (t31 & t29); goto LAB6; LAB7: t45 = *((unsigned int *)t34); t46 = *((unsigned int *)t39); *((unsigned int *)t34) = (t45 | t46); t47 = (t5 + 4); t48 = (t33 + 4); t49 = *((unsigned int *)t47); t50 = (~(t49)); t51 = *((unsigned int *)t5); t52 = (t51 & t50); t53 = *((unsigned int *)t48); t54 = (~(t53)); t55 = *((unsigned int *)t33); t56 = (t55 & t54); t57 = (~(t52)); t58 = (~(t56)); t59 = *((unsigned int *)t39); *((unsigned int *)t39) = (t59 & t57); t60 = *((unsigned int *)t39); *((unsigned int *)t39) = (t60 & t58); goto LAB9; } static void Cont_56_2(char *t0) { char t5[8]; char *t1; char *t2; char *t3; char *t4; unsigned int t6; unsigned int t7; unsigned int t8; char *t9; char *t10; unsigned int t11; unsigned int t12; unsigned int t13; unsigned int t14; unsigned int t15; unsigned int t16; unsigned int t17; char *t18; char *t19; unsigned int t20; unsigned int t21; unsigned int t22; int t23; unsigned int t24; unsigned int t25; unsigned int t26; int t27; unsigned int t28; unsigned int t29; unsigned int t30; unsigned int t31; char *t32; char *t33; char *t34; char *t35; char *t36; unsigned int t37; unsigned int t38; char *t39; unsigned int t40; unsigned int t41; char *t42; unsigned int t43; unsigned int t44; char *t45; LAB0: t1 = (t0 + 5424U); t2 = *((char **)t1); if (t2 == 0) goto LAB2; LAB3: goto *t2; LAB2: t2 = (t0 + 2648U); t3 = *((char **)t2); t2 = (t0 + 3288U); t4 = *((char **)t2); t6 = *((unsigned int *)t3); t7 = *((unsigned int *)t4); t8 = (t6 | t7); *((unsigned int *)t5) = t8; t2 = (t3 + 4); t9 = (t4 + 4); t10 = (t5 + 4); t11 = *((unsigned int *)t2); t12 = *((unsigned int *)t9); t13 = (t11 | t12); *((unsigned int *)t10) = t13; t14 = *((unsigned int *)t10); t15 = (t14 != 0); if (t15 == 1) goto LAB4; LAB5: LAB6: t32 = (t0 + 6776); t33 = (t32 + 56U); t34 = *((char **)t33); t35 = (t34 + 56U); t36 = *((char **)t35); memset(t36, 0, 8); t37 = 1U; t38 = t37; t39 = (t5 + 4); t40 = *((unsigned int *)t5); t37 = (t37 & t40); t41 = *((unsigned int *)t39); t38 = (t38 & t41); t42 = (t36 + 4); t43 = *((unsigned int *)t36); *((unsigned int *)t36) = (t43 | t37); t44 = *((unsigned int *)t42); *((unsigned int *)t42) = (t44 | t38); xsi_driver_vfirst_trans(t32, 0, 0); t45 = (t0 + 6520); *((int *)t45) = 1; LAB1: return; LAB4: t16 = *((unsigned int *)t5); t17 = *((unsigned int *)t10); *((unsigned int *)t5) = (t16 | t17); t18 = (t3 + 4); t19 = (t4 + 4); t20 = *((unsigned int *)t18); t21 = (~(t20)); t22 = *((unsigned int *)t3); t23 = (t22 & t21); t24 = *((unsigned int *)t19); t25 = (~(t24)); t26 = *((unsigned int *)t4); t27 = (t26 & t25); t28 = (~(t23)); t29 = (~(t27)); t30 = *((unsigned int *)t10); *((unsigned int *)t10) = (t30 & t28); t31 = *((unsigned int *)t10); *((unsigned int *)t10) = (t31 & t29); goto LAB6; } static void Cont_60_3(char *t0) { char *t1; char *t2; char *t3; char *t4; char *t5; char *t6; char *t7; unsigned int t8; unsigned int t9; char *t10; unsigned int t11; unsigned int t12; char *t13; unsigned int t14; unsigned int t15; char *t16; LAB0: t1 = (t0 + 5672U); t2 = *((char **)t1); if (t2 == 0) goto LAB2; LAB3: goto *t2; LAB2: t2 = (t0 + 2808U); t3 = *((char **)t2); t2 = (t0 + 6840); t4 = (t2 + 56U); t5 = *((char **)t4); t6 = (t5 + 56U); t7 = *((char **)t6); memset(t7, 0, 8); t8 = 1U; t9 = t8; t10 = (t3 + 4); t11 = *((unsigned int *)t3); t8 = (t8 & t11); t12 = *((unsigned int *)t10); t9 = (t9 & t12); t13 = (t7 + 4); t14 = *((unsigned int *)t7); *((unsigned int *)t7) = (t14 | t8); t15 = *((unsigned int *)t13); *((unsigned int *)t13) = (t15 | t9); xsi_driver_vfirst_trans(t2, 0, 0); t16 = (t0 + 6536); *((int *)t16) = 1; LAB1: return; } static void Cont_62_4(char *t0) { char *t1; char *t2; char *t3; char *t4; char *t5; char *t6; char *t7; unsigned int t8; unsigned int t9; char *t10; unsigned int t11; unsigned int t12; char *t13; unsigned int t14; unsigned int t15; char *t16; LAB0: t1 = (t0 + 5920U); t2 = *((char **)t1); if (t2 == 0) goto LAB2; LAB3: goto *t2; LAB2: t2 = (t0 + 2968U); t3 = *((char **)t2); t2 = (t0 + 6904); t4 = (t2 + 56U); t5 = *((char **)t4); t6 = (t5 + 56U); t7 = *((char **)t6); memset(t7, 0, 8); t8 = 1U; t9 = t8; t10 = (t3 + 4); t11 = *((unsigned int *)t3); t8 = (t8 & t11); t12 = *((unsigned int *)t10); t9 = (t9 & t12); t13 = (t7 + 4); t14 = *((unsigned int *)t7); *((unsigned int *)t7) = (t14 | t8); t15 = *((unsigned int *)t13); *((unsigned int *)t13) = (t15 | t9); xsi_driver_vfirst_trans(t2, 0, 0); t16 = (t0 + 6552); *((int *)t16) = 1; LAB1: return; } static void Cont_64_5(char *t0) { char *t1; char *t2; char *t3; char *t4; char *t5; char *t6; char *t7; unsigned int t8; unsigned int t9; char *t10; unsigned int t11; unsigned int t12; char *t13; unsigned int t14; unsigned int t15; char *t16; LAB0: t1 = (t0 + 6168U); t2 = *((char **)t1); if (t2 == 0) goto LAB2; LAB3: goto *t2; LAB2: t2 = (t0 + 3608U); t3 = *((char **)t2); t2 = (t0 + 6968); t4 = (t2 + 56U); t5 = *((char **)t4); t6 = (t5 + 56U); t7 = *((char **)t6); memset(t7, 0, 8); t8 = 1U; t9 = t8; t10 = (t3 + 4); t11 = *((unsigned int *)t3); t8 = (t8 & t11); t12 = *((unsigned int *)t10); t9 = (t9 & t12); t13 = (t7 + 4); t14 = *((unsigned int *)t7); *((unsigned int *)t7) = (t14 | t8); t15 = *((unsigned int *)t13); *((unsigned int *)t13) = (t15 | t9); xsi_driver_vfirst_trans(t2, 0, 0); t16 = (t0 + 6568); *((int *)t16) = 1; LAB1: return; } extern void work_m_00000000003279699937_2175365797_init() { static char *pe[] = {(void *)Cont_47_0,(void *)Cont_51_1,(void *)Cont_56_2,(void *)Cont_60_3,(void *)Cont_62_4,(void *)Cont_64_5}; xsi_register_didat("work_m_00000000003279699937_2175365797", "isim/tb.exe.sim/work/m_00000000003279699937_2175365797.didat"); xsi_register_executes(pe); }
22.455414
131
0.467239
53007fb7697348d1b007dd3b20b66c3bf43964de
55,112
c
C
krb5/krb5ctx.c
twosigma/gsskrb5
1a8f4a98fa996daf7a2b39be52ba60d3a9218a04
[ "FSFAP" ]
2
2019-03-09T21:58:40.000Z
2020-08-07T18:37:03.000Z
krb5/krb5ctx.c
twosigma/gsskrb5
1a8f4a98fa996daf7a2b39be52ba60d3a9218a04
[ "FSFAP" ]
null
null
null
krb5/krb5ctx.c
twosigma/gsskrb5
1a8f4a98fa996daf7a2b39be52ba60d3a9218a04
[ "FSFAP" ]
null
null
null
#include "mysccs.h" SCCSID("@(#)$Id: //tools/src/freeware/gsskrb5/krb5/krb5ctx.c#7 $") /************************************************************************ * $Id: //tools/src/freeware/gsskrb5/krb5/krb5ctx.c#7 $ ************************************************************************ * * Copyright (c) 1997-2000 SAP AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by SAP AG" * * 4. The name "SAP AG" must not be used to endorse or promote products * derived from this software without prior written permission. * For written permission, please contact www.press@sap.com * * 5. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by SAP AG" * * THIS SOFTWARE IS PROVIDED BY SAP AG ``AS IS'' AND ANY EXPRESSED * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. SAP AG SHALL BE LIABLE FOR ANY DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE ONLY IF CAUSED BY SAP AG'S * INTENT OR GROSS NEGLIGENCE. IN CASE SAP AG IS LIABLE UNDER THIS * AGREEMENT FOR DAMAGES CAUSED BY SAP AG'S GROSS NEGLIGENCE SAP AG * FURTHER SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT, AND SHALL NOT BE LIABLE IN EXCESS OF THE AMOUNT OF * DAMAGES TYPICALLY FORESEEABLE FOR SAP AG, WHICH SHALL IN NO EVENT * EXCEED US$ 500.000.- * ************************************************************************/ #include "krb5defs.h" /* * krb5_check_ctx() * * */ OM_uint32 krb5_check_ctx( OM_uint32 * pp_min_stat, void ** pp_ctx, int p_flags, char * this_Call ) { krb5_ctx_desc * ctx; (*pp_min_stat) = MINOR_NO_ERROR; if ( pp_ctx==NULL || *pp_ctx==NULL ) { if ( (p_flags&CTX_ESTABLISH)!=0 && pp_ctx!=NULL ) return(GSS_S_COMPLETE); DEBUG_ERR((tf, "Internal ERROR: %s(): NULL priv_ctx handle!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } ctx = (krb5_ctx_desc *) *pp_ctx; if ( ctx->magic_cookie!=KRB5_CTX_COOKIE ) { DEBUG_ERR((tf, "Internal ERROR: %s(): invalid priv_ctx (bad cookie)!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } if ( ctx->flag_established==FALSE ) { if ( (p_flags&(CTX_DELETE|CTX_ESTABLISH|CTX_INQUIRE))==0 ) { DEBUG_ERR((tf, "Internal ERROR: %s(): incomplete priv_ctx!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } } else { /* else ctx->flag_established!=FALSE */ if ( (p_flags&CTX_ESTABLISH)!=0 ) { DEBUG_ERR((tf, "Internal ERROR: %s(): priv_ctx already established!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } } /* endif ctx->flag_established!=FALSE */ return(GSS_S_COMPLETE); } /* krb5_check_ctx() */ /* * krb5_release_token() * * */ OM_uint32 krb5_release_token( OM_uint32 * pp_min_stat, Uchar ** pp_token, size_t * pp_token_len ) { (*pp_min_stat) = 0; if ( *pp_token!=NULL ) { sy_clear_free( (void **)pp_token, (*pp_token_len) ); (*pp_token_len) = 0; } return(GSS_S_COMPLETE); } /* krb5_release_token() */ #if 0 /* no longer needed, we use ISC/ASC_REQ_ALLOC_MEMORY */ /* * krb5_alloc_ctx_token() * * */ OM_uint32 krb5_alloc_ctx_token( OM_uint32 * pp_min_stat, Uchar ** pp_token, size_t * pp_token_size ) { (*pp_min_stat) = 0; (*pp_token) = NULL; (*pp_token_size) = 0; (*pp_token) = sy_calloc( krb5_maxtoken ); if (*pp_token==NULL) { RETURN_MIN_MAJ( MINOR_OUT_OF_MEMORY, GSS_S_FAILURE ); } (*pp_token_size) = krb5_maxtoken; return(GSS_S_COMPLETE); } /* krb5_alloc_ctx_token() */ #endif /* * krb5_init_sec_context() * * */ OM_uint32 krb5_init_sec_context( OM_uint32 * pp_min_stat, /* in */ void * p_cred, /* in */ gss_channel_bindings_t p_channel_bindings, /* in */ Uchar * p_target, /* in */ size_t p_target_len, /* in */ Uchar * p_in_token, /* in */ size_t p_in_token_len, /* in */ OM_uint32 p_service_req, /* in */ void ** pp_ctx, /* out */ Uchar ** pp_out_token, /* out */ size_t * pp_out_token_len,/* out */ OM_uint32 * pp_service_rec, /* out */ time_t * pp_expires_at ) /* out */ { char * this_Call = "krb5_init_sec_context"; char * symbol, * desc; krb5_ctx_desc * ctx = NULL; CtxtHandle * pCtxt = NULL; SecBufferDesc OutBufDesc; SecBufferDesc InBufDesc; SecBufferDesc * pInBufDesc = NULL; SecBuffer OutSecToken; SecBuffer InSecToken; krb5_cred_desc * cred = NULL; SECURITY_STATUS SecStatus; ULONG CtxFlagsReq = 0; OM_uint32 maj_stat = GSS_S_COMPLETE; (*pp_min_stat) = 0; (*pp_out_token) = NULL; (*pp_out_token_len) = 0; (*pp_service_rec) = 0; (*pp_expires_at) = 0; OutSecToken.BufferType = SECBUFFER_TOKEN; OutSecToken.cbBuffer = 0u; OutSecToken.pvBuffer = NULL; /* quick validation of krb5 context handle */ maj_stat = krb5_check_ctx( pp_min_stat, pp_ctx, CTX_ESTABLISH, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); ctx = (krb5_ctx_desc *) (*pp_ctx); /* quick validation of krb5 credential handle */ maj_stat = krb5_check_cred( pp_min_stat, &p_cred, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); cred = (krb5_cred_desc *) p_cred; /* Kerberos currently still requires a target name ... */ if ( p_target==NULL || p_target_len==0 ) { DEBUG_ERR((tf, "ERR: %s(): missing target name!\n", this_Call)) RETURN_MIN_MAJ(MINOR_INTERNAL_ERROR, GSS_S_FAILURE); } /* The W2K Kerberos SSP doesn't implement GSS-API style channel bindings */ if ( p_channel_bindings!=GSS_C_NO_CHANNEL_BINDINGS ) { RETURN_MIN_MAJ( KRB5_MINOR(NO_CHBINDINGS_IN_SSPI), GSS_S_FAILURE ); } if (ctx==NULL) { /* No prior priv_ctx security context handle ==> create one */ if ( p_in_token!=NULL && p_in_token_len!=0 ) { DEBUG_ERR((tf, "Internal ERROR: %s(): Extra token to initial call!\n", this_Call)) RETURN_MIN_MAJ(MINOR_INTERNAL_ERROR, GSS_S_FAILURE); } /* There is no context handle yet, so this is the first step in */ /* the security context establishment procedure */ ctx = sy_calloc( sizeof(*ctx) ); if (ctx==NULL) { RETURN_MIN_MAJ(MINOR_OUT_OF_MEMORY, GSS_S_FAILURE); } ctx->magic_cookie = KRB5_CTX_COOKIE; ctx->flag_established = FALSE; ctx->role = KRB5_INITIATOR; ctx->nego_step = KRB5_1ST_TOKEN; SecInvalidateHandle( &(ctx->sspi_ctx) ); ctx->sspi_isc_req = krb5_gss_svc_to_ISC_REQ( p_service_req ); ctx->seq_ini2acc = 1; /* initiator->acceptor messages are odd numbered */ ctx->seq_acc2ini = 2; /* acceptor->initiator message are even numbered */ pCtxt = NULL; /* NOTICE: p_target is always a BINARY CANONICAL NAME */ /* (don't let this code mislead you) */ maj_stat = krb5_copy_name( pp_min_stat, p_target, p_target_len, &(ctx->acceptor), &(ctx->acceptor_len) ); if (maj_stat!=GSS_S_COMPLETE) goto error; /* And then we will also copy our name (the initiator) into */ /* our context attribute structure for future reference */ maj_stat = krb5_copy_name( pp_min_stat, cred->name, cred->name_len, &(ctx->initiator), &(ctx->initiator_len) ); if (maj_stat!=GSS_S_COMPLETE) goto error; /* no input token for initial call to InitializeSecurityContext() */ pInBufDesc = NULL; } else { /* There is a prior priv_ctx security context handle ==> use it */ if (ctx->nego_step!=KRB5_3RD_TOKEN) { /* since KRB5 doesn't error as it should, we'll do it here */ /* ... but actually, the generic layer should dispatch here */ /* any more once we flag "context established" */ DEBUG_ERR((tf, "ERR: %s(): there is no %d nego step!\n", this_Call, ctx->nego_step )) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } if ( p_in_token==NULL || p_in_token_len<3 ) { DEBUG_ERR((tf, "ERR: %s(): input token missing for continuation call!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } ctx->nego_step = KRB5_3RD_TOKEN; /* a single continuation call to gss_init_sec_context */ /* will return the final context establishment token */ pCtxt = &(ctx->sspi_ctx); /* There must be an input token for every continuation initial call to InitializeSecurityContext() */ InSecToken.pvBuffer = p_in_token; InSecToken.cbBuffer = (ULONG)p_in_token_len; InSecToken.BufferType = SECBUFFER_TOKEN | SECBUFFER_READONLY; InBufDesc.cBuffers = 1u; InBufDesc.pBuffers = &InSecToken; InBufDesc.ulVersion = SECBUFFER_VERSION; pInBufDesc = &InBufDesc; } OutBufDesc.cBuffers = 1u; OutBufDesc.pBuffers = &OutSecToken; OutBufDesc.ulVersion = SECBUFFER_VERSION; SecStatus = (fp_SSPI_krb5 ->InitializeSecurityContext)( /* PCredHandle phCredential */ &(cred->sspi_cred), /* PCtxtHandle phContext */ pCtxt, /* SEC_CHAR * pszTargetName */ (ctx->acceptor), /* ULONG fContextReq */ ctx->sspi_isc_req, /* ULONG Reserved1 */ 0, /* ULONG TargetDataRep */ SECURITY_NATIVE_DREP, /* PSecBufferDesc pInput */ pInBufDesc, /* ULONG Reserved2 */ 0, /* PCtxtHandle phNewContext */ &(ctx->sspi_ctx), /* PSecBufferDesc pOutput */ &OutBufDesc, /* PULONG pfContextAttr */ &(ctx->sspi_isc_ret), /* PTimeStamp ptsExpiry */ &(ctx->sspi_expiration) ); if ( SecStatus==SEC_I_CONTINUE_NEEDED || SecStatus==SEC_E_OK ) { DEBUG_ACTION((tf, " A: %s(): InitializeSecurityContext(target=\"%.256s\")==%s\n", this_Call, ctx->acceptor, SecStatus==SEC_E_OK ? "SEC_E_OK" : "CONTINUE_NEEDED" )); } if ( SecStatus==SEC_E_OK ) { SecStatus = (fp_SSPI_krb5 ->QueryContextAttributes)( /* PCtxtHandle phContext */ &(ctx->sspi_ctx), /* ULONG ulAttribute */ SECPKG_ATTR_SIZES, /* PVOID pBuffer */ &(ctx->sizes) ); if ( SecStatus!=SEC_E_OK ) { krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): QueryContextAttributes(SIZES) failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) ERROR_RETURN( KRB5_MINOR_SSPI(QueryContextAttributesSIZES,SecStatus), GSS_S_FAILURE ); } (ctx->flag_established) = TRUE; } else if ( SecStatus==SEC_I_CONTINUE_NEEDED ) { maj_stat = GSS_S_CONTINUE_NEEDED; if ( OutSecToken.cbBuffer==0 ) { DEBUG_ERR((tf, "ERR: %s(): CONTINUE_NEEDED but no token?!\n", this_Call)) ERROR_RETURN( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } } else if ( SecStatus!=SEC_E_OK ) { krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): InitializeSecurityContext(target=\"%.256s\") failed with %s\n\t(Desc=\"%s\")\n", this_Call, ctx->acceptor, symbol, desc)); if ( KRB5_1ST_TOKEN==ctx->nego_step ) { ERROR_RETURN( KRB5_MINOR_SSPI(InitializeSecurityContext1,SecStatus), GSS_S_FAILURE ); } ERROR_RETURN( KRB5_MINOR_SSPI(InitializeSecurityContextN,SecStatus), GSS_S_FAILURE ); } if ( maj_stat==GSS_S_COMPLETE || maj_stat==GSS_S_CONTINUE_NEEDED ) { (*pp_ctx) = ctx; (ctx->expires_at) = krb5_timestamp2time( &(ctx->sspi_expiration) ); (*pp_expires_at) = (ctx->expires_at); if ( OutSecToken.cbBuffer > 0 ) { OM_uint32 maj_stat2; OM_uint32 min_stat2; gn_mech_tag_et mech_tag; gss_buffer_desc out_token; gss_OID_desc token_oid; void * itoken; size_t itoken_len; (*pp_out_token) = sy_malloc( OutSecToken.cbBuffer ); if ( (*pp_out_token)==NULL ) ERROR_RETURN( MINOR_OUT_OF_MEMORY, GSS_S_FAILURE ); memcpy( (*pp_out_token), OutSecToken.pvBuffer, OutSecToken.cbBuffer ); (*pp_out_token_len) = OutSecToken.cbBuffer; out_token.value = (*pp_out_token); out_token.length = (*pp_out_token_len); maj_stat2 = gn_parse_gss_token( &min_stat2, &out_token, &token_oid, &mech_tag, &itoken, &itoken_len ); if (maj_stat2!=GSS_S_COMPLETE) { if ( maj_stat2==GSS_S_BAD_MECH && token_oid.length==krb5_w2k3_u2u_oid->length && 0==memcmp(token_oid.elements, krb5_w2k3_u2u_oid->elements, token_oid.length) ) { DEBUG_ERR((tf, "ERR: %s(): InitializeSecurityContext(target=\"%.256s\") returned U2U-token!?\n", this_Call, ctx->acceptor )); ERROR_RETURN( KRB5_MINOR(W2K3_U2U_TARGET), GSS_S_FAILURE ); } DEBUG_ERR((tf, "ERR: %s(): InitializeSecurityContext(target=\"%.256s\") returned non-GSSAPI-token!?\n", this_Call, ctx->acceptor )); ERROR_RETURN( KRB5_MINOR(SSPI_TALKS_GARBAGE), GSS_S_FAILURE ); } if (mech_tag!=krb5_mech_tag) { DEBUG_ERR((tf, "ERR: %s(): InitializeSecurityContext(target=\"%.256s\") returned non-Kerberos5-token!?\n", this_Call, ctx->acceptor )); ERROR_RETURN( KRB5_MINOR(SSPI_WRONG_MECH), GSS_S_FAILURE ); } } (ctx->service_rec) = krb5_ISC_RET_to_gss_svc( ctx->sspi_isc_ret ); (*pp_service_rec) = (ctx->service_rec); (ctx->nego_step) += 2; } else { OM_uint32 min_stat2; error: /* Release the output_token if there was one allocated */ (void)krb5_release_token( &min_stat2, pp_out_token, pp_out_token_len ); if (ctx->nego_step==KRB5_1ST_TOKEN) { /* This is the first negotiation step -- we have to drop */ /* everything after error situations in the initial step */ (void)krb5_delete_sec_context( &min_stat2, &ctx ); (*pp_ctx) = NULL; } } if ( OutSecToken.pvBuffer!=NULL && OutSecToken.cbBuffer>0 ) { (fp_SSPI_krb5->FreeContextBuffer)( OutSecToken.pvBuffer ); OutSecToken.pvBuffer = NULL; OutSecToken.cbBuffer = 0; } return(maj_stat); } /* krb5_init_sec_context() */ /* * krb5_accept_sec_context() * * */ OM_uint32 krb5_accept_sec_context( OM_uint32 * pp_min_stat, /* in */ void * p_cred, /* in */ gss_channel_bindings_t p_channel_bindings, /* in */ Uchar * p_in_token, /* in */ size_t p_in_token_len,/* in */ void ** pp_ctx, /* out */ Uchar ** pp_srcname, /* out */ size_t * pp_srcname_len,/* out */ gn_nt_tag_et * pp_nt_tag, /* out */ Uchar ** pp_out_token, /* out */ size_t * pp_out_token_len,/* out */ OM_uint32 * pp_service_rec,/* out */ time_t * pp_expires_at, /* out */ gn_cred_t * pp_deleg_cred )/* out */ { char * this_Call = "krb5_accept_sec_context"; krb5_ctx_desc * ctx = NULL; /* convenience pointer */ krb5_cred_desc * cred = NULL; /* convenience pointer */ CtxtHandle * pCtxt = NULL; /* returnable dynamic SSPI object */ char * symbol, * desc; char * user = NULL; /* temporary memory */ char * realm = NULL; /* temporary memory */ SecBufferDesc OutBufDesc; /* local scrap */ SecBufferDesc InBufDesc; /* local scrap */ SecBuffer OutSecToken; /* temporary dynamic SSPI object */ SecBuffer InSecToken; /* local scrap */ SECURITY_STATUS SecStatus; SECURITY_STATUS SecStatus1 = SEC_E_OK; SECURITY_STATUS SecStatus2 = SEC_E_OK; SECURITY_STATUS SecStatus3 = SEC_E_OK; SECURITY_STATUS SecStatus4 = SEC_E_OK; SecPkgContext_Names NamesBuffer; /* temporary dynamic SSPI object */ SecPkgContext_NativeNames NativeNamesBuffer; /* temporary dynamic SSPI object */ ULONG CtxFlagsReq = 0; OM_uint32 maj_stat = GSS_S_COMPLETE; NamesBuffer.sUserName = NULL; NativeNamesBuffer.sClientName = NULL; NativeNamesBuffer.sServerName = NULL; (*pp_min_stat) = 0; (*pp_out_token) = NULL; (*pp_out_token_len) = 0; (*pp_service_rec) = 0; (*pp_expires_at) = 0; (*pp_srcname) = NULL; (*pp_srcname_len) = 0; (*pp_nt_tag) = NT_INVALID_TAG; if ( pp_deleg_cred ) { (*pp_deleg_cred) = NULL; } OutSecToken.pvBuffer = NULL; OutSecToken.cbBuffer = 0; OutSecToken.BufferType = SECBUFFER_TOKEN; /* quick validation of krb5 context handle */ maj_stat = krb5_check_ctx( pp_min_stat, pp_ctx, CTX_ESTABLISH, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); ctx = (krb5_ctx_desc *) (*pp_ctx); /* quick validation of krb5 credential handle */ maj_stat = krb5_check_cred( pp_min_stat, &p_cred, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); cred = (krb5_cred_desc *) p_cred; if ( p_in_token==NULL || p_in_token_len<3 ) { DEBUG_ERR((tf, "ERR: %s(): input token missing!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } /* The W2K Kerberos SSP doesn't implement GSS-API style channel bindings */ if ( p_channel_bindings!=GSS_C_NO_CHANNEL_BINDINGS ) { RETURN_MIN_MAJ( KRB5_MINOR(NO_CHBINDINGS_IN_SSPI), GSS_S_FAILURE ); } if (ctx==NULL) { /* No prior priv_ctx security context handle ==> create one */ /* There is no context handle yet, so this is the first step in */ /* the security context establishment procedure */ ctx = sy_calloc( sizeof(*ctx) ); if (ctx==NULL) { RETURN_MIN_MAJ(MINOR_OUT_OF_MEMORY, GSS_S_FAILURE); } ctx->magic_cookie = KRB5_CTX_COOKIE; ctx->flag_established = FALSE; ctx->role = KRB5_ACCEPTOR; ctx->nego_step = KRB5_2ND_TOKEN; SecInvalidateHandle( &(ctx->sspi_ctx) ); ctx->sspi_asc_req = krb5_gss_svc_to_ASC_REQ(); /* get default ASC_REQs */ ctx->seq_ini2acc = 1; /* initiator->acceptor messages are odd numbered */ ctx->seq_acc2ini = 2; /* acceptor->initiator message are even numbered */ pCtxt = NULL; /* We have to copy our name (the acceptor) from our creds into */ /* our context attribute structure for future reference */ /* REMEMBER: this name is in BINARY CANONICAL format */ maj_stat = krb5_copy_name( pp_min_stat, cred->name, cred->name_len, &(ctx->acceptor), &(ctx->acceptor_len) ); if (maj_stat!=GSS_S_COMPLETE) goto error; } else { /* Kerberos security context establishment (rfc1964) is only 1-way or 2-way */ /* if we get another context-level token, then it must be SSPI garbage */ RETURN_MIN_MAJ( KRB5_MINOR(SSPI_TALKS_GARBAGE), GSS_S_FAILURE ); } /* accept_sec_context() must always be called with an input token. */ /* Create the correct buffer objects for the SSPI call AcceptSecurityContext() */ InSecToken.pvBuffer = p_in_token; InSecToken.cbBuffer = (ULONG)p_in_token_len; InSecToken.BufferType = SECBUFFER_TOKEN | SECBUFFER_READONLY; InBufDesc.cBuffers = 1u; InBufDesc.pBuffers = &InSecToken; InBufDesc.ulVersion = SECBUFFER_VERSION; OutBufDesc.cBuffers = 1u; OutBufDesc.pBuffers = &OutSecToken; OutBufDesc.ulVersion = SECBUFFER_VERSION; SecStatus = (fp_SSPI_krb5 ->AcceptSecurityContext)( /* PCredHandle phCredential */ &(cred->sspi_cred), /* PCtxtHandle phContext */ pCtxt, /* PSecBufferDesc pInput */ &InBufDesc, /* ULONG fContextReq */ ctx->sspi_asc_req, /* ULONG TargetDataRep */ SECURITY_NATIVE_DREP, /* PCtxtHandle phNewCount */ &(ctx->sspi_ctx), /* PSecBufferDesc pOutput */ &OutBufDesc, /* PULONG pfContextAttr */ &(ctx->sspi_asc_ret), /* PTimeStamp ptsExpiry */ &(ctx->sspi_expiration) ); if ( SecStatus==SEC_I_CONTINUE_NEEDED || SecStatus==SEC_E_OK ) { DEBUG_ACTION((tf, " A: %s(): AcceptSecurityContext #%d()==%s\n", this_Call, (int)(ctx->nego_step/2)+1, (SecStatus==SEC_E_OK) ? "SEC_E_OK" : "CONTINUE_NEEDED" )); } if (SecStatus==SEC_E_OK) { SecStatus = (fp_SSPI_krb5 ->QueryContextAttributes)( /* PCtxtHandle phContext */ &(ctx->sspi_ctx), /* ULONG ulAttribute */ SECPKG_ATTR_SIZES, /* PVOID pBuffer */ &(ctx->sizes) ); if ( SecStatus!=SEC_E_OK ) { krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): QueryContextAttributes(SIZES) failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) ERROR_RETURN( KRB5_MINOR_SSPI(QueryContextAttributesSIZES,SecStatus), GSS_S_FAILURE ); } /* Query the security context initiator from the underlying Kerberos5 */ /* name-based authentication through the new functionality of */ /* the QueryContextAttributes call in Windows 2000 */ SecStatus = (fp_SSPI_krb5->QueryContextAttributes)( /* PCtxtHandle phContext */ &(ctx->sspi_ctx), /* ULONG ulAttribute */ SECPKG_ATTR_NATIVE_NAMES, /* PVOID pBuffer */ &(NativeNamesBuffer) ); if ( SecStatus!=SEC_E_OK ) { krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): QueryContextAttributes(NATIVE_NAMES) failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )); ERROR_RETURN( KRB5_MINOR_SSPI(QueryContextAttributesNATNAMES,SecStatus), GSS_S_FAILURE ); } maj_stat = krb5_copy_name( pp_min_stat, NativeNamesBuffer.sClientName, strlen(NativeNamesBuffer.sClientName), &(ctx->initiator), &(ctx->initiator_len) ); if (maj_stat!=GSS_S_COMPLETE) goto error; /*********************************************************************/ /* (13-Feb-2012) Martin Rex */ /* BUGBUG: Workaround for S4U2Proxy misbehaviour of forging Kerberos */ /* tickets for incorrect principals, the username part of */ /* Samcompatible Name will more likely contain the correct */ /* spelling upon authentication */ /* In case the username part differs _only_ in case, we'll use the */ /* username part from NAMES rather that from NATIVE_NAMES */ /*********************************************************************/ SecStatus = (fp_SSPI_krb5->QueryContextAttributes)( /* PCtxtHandle phContext */ &(ctx->sspi_ctx), /* ULONG ulAttribute */ SECPKG_ATTR_NAMES, /* PVOID pBuffer */ &(NamesBuffer) ); if ( SecStatus!=SEC_E_OK ) { krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): QueryContextAttributes(NAMES) failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )); /* ignore this error */ /* ERROR_RETURN( KRB5_MINOR_SSPI(QueryContextAttributesNAMES,SecStatus), GSS_S_FAILURE ); */ } else if ( NULL!=ctx->initiator && NULL!=NamesBuffer.sUserName ) { char * ptrNN = strchr(ctx->initiator, '@'); char * ptrN = strchr(NamesBuffer.sUserName, '\\'); size_t NN_len; size_t N_len; if ( NULL!=ptrN && NULL!=ptrNN ) { NN_len = (size_t)(ptrNN - ctx->initiator); /* username@SOME.REALM */ N_len = strlen(&(ptrN[1])); /* NT4DOMAIN\username */ if ( NN_len==N_len && 0==_strnicmp(ctx->initiator,&(ptrN[1]),N_len) ) { memcpy(ctx->initiator, &(ptrN[1]), N_len); } } } if ( FALSE!=krb5_realm_to_upper && NULL!=ctx->initiator ) { char * ptr = strchr(ctx->initiator, '@'); if ( NULL!=ptr ) { /* Force Kerberos Realm name to uppercase */ /* It seems that in some scenarios using Microsofts proprietary */ /* "Protocol Transition with Constrained Delegation", Microsoft */ /* might forge Kerberos tickets with incorrect Realm names */ /* (lowercase) -- which breaks name-based authentication of */ /* gss-api acceptors */ CharUpper(ptr); } } (*pp_srcname) = ctx->initiator; (*pp_srcname_len) = ctx->initiator_len; (*pp_nt_tag) = krb5_nt_tag; ctx->flag_established = TRUE; if ( pp_deleg_cred!=NULL ) { OM_uint32 maj_stat2, min_stat2; OM_uint32 lifetime; SECURITY_STATUS SecStatus2; DEBUG_ACTION((tf, " A: %s(): Checking for delegated credentials\n", this_Call)); /* caller asks for delegated creds, try to get them */ SecStatus2 = (fp_SSPI_krb5->ImpersonateSecurityContext)(&(ctx->sspi_ctx)); if ( SecStatus2==SEC_E_OK ) { maj_stat2 = gn_new_cred( &min_stat2, NULL, GSS_C_INITIATE, krb5_mech_tag, pp_deleg_cred, &lifetime ); DEBUG_ACTION((tf, " A: %s(): Acquisition of delegated credential %s\n", this_Call, (maj_stat2==GSS_S_COMPLETE) ? "successful" : "failed" )); } else { char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): ImpersonateSecurityContext() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )); } (fp_SSPI_krb5->RevertSecurityContext)( &(ctx->sspi_ctx)); } } else if (SecStatus==SEC_I_CONTINUE_NEEDED) { maj_stat = GSS_S_CONTINUE_NEEDED; if ( OutSecToken.cbBuffer==0 ) { DEBUG_ERR((tf, "ERR: %s(): CONTINUE_NEEDED but no token?!\n", this_Call)) ERROR_RETURN( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } /* Kerberos security context establishment (rfc1964) is only 1-way or 2-way */ /* if we get SEC_I_CONTINUE_NEEDED, then it must be SSPI garbage */ DEBUG_ERR((tf, "ERR: %s(): AcquireSecurityContext() returned CONTINUE_NEEDED," "which is not permitted for rfc-1964 Kerberos!\n", this_Call)); ERROR_RETURN( KRB5_MINOR(SSPI_TALKS_GARBAGE), GSS_S_FAILURE ); } else if ( SecStatus!=SEC_E_OK ) { char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): AcceptSecurityContext() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc)); if ( KRB5_2ND_TOKEN==ctx->nego_step ) { ERROR_RETURN( KRB5_MINOR_SSPI(AcceptSecurityContext1,SecStatus), GSS_S_FAILURE ); } ERROR_RETURN( KRB5_MINOR_SSPI(AcceptSecurityContextN,SecStatus), GSS_S_FAILURE ); } if ( maj_stat==GSS_S_COMPLETE || maj_stat==GSS_S_CONTINUE_NEEDED ) { (*pp_ctx) = ctx; (ctx->expires_at) = krb5_timestamp2time( &(ctx->sspi_expiration) ); (*pp_expires_at) = (ctx->expires_at); if ( OutSecToken.cbBuffer > 0 ) { OM_uint32 maj_stat2; OM_uint32 min_stat2; gn_mech_tag_et mech_tag; gss_buffer_desc out_token; void * itoken; size_t itoken_len; (*pp_out_token) = sy_malloc( OutSecToken.cbBuffer ); if ( (*pp_out_token)==NULL ) ERROR_RETURN( MINOR_OUT_OF_MEMORY, GSS_S_FAILURE ); memcpy( (*pp_out_token), OutSecToken.pvBuffer, OutSecToken.cbBuffer ); (*pp_out_token_len) = OutSecToken.cbBuffer; out_token.value = (*pp_out_token); out_token.length = (*pp_out_token_len); maj_stat2 = gn_parse_gss_token( &min_stat2, &out_token, NULL, &mech_tag, &itoken, &itoken_len ); if (maj_stat2!=GSS_S_COMPLETE) ERROR_RETURN( KRB5_MINOR(SSPI_TALKS_GARBAGE), GSS_S_FAILURE ); if (mech_tag!=krb5_mech_tag) ERROR_RETURN( KRB5_MINOR(SSPI_WRONG_MECH), GSS_S_FAILURE ); } (ctx->service_rec) = krb5_ASC_RET_to_gss_svc( ctx->sspi_asc_ret ); (*pp_service_rec) = (ctx->service_rec); (ctx->nego_step) += 2; } else { OM_uint32 min_stat2; error: /* Release the output_token if there was one allocated */ (void)krb5_release_token( &min_stat2, pp_out_token, pp_out_token_len ); if (ctx->nego_step==KRB5_2ND_TOKEN) { /* This is the first negotiation step -- we have to drop */ /* everything after error situations in the initial step */ krb5_delete_sec_context( &min_stat2, &ctx ); (*pp_ctx) = NULL; } if ( pp_deleg_cred!=NULL && *pp_deleg_cred!=NULL ) { gn_release_cred( &min_stat2, pp_deleg_cred ); } } SecStatus1 = krb5_free_sspi_buffer( "NamesBuffer.sUserName", &(NamesBuffer.sUserName) ); SecStatus2 = krb5_free_sspi_buffer( "NativeNamesBuffer.sClientName", &(NativeNamesBuffer.sClientName) ); SecStatus3 = krb5_free_sspi_buffer( "NativeNamesBuffer.sServerName", &(NativeNamesBuffer.sServerName) ); if ( OutSecToken.cbBuffer>0 ) { SecStatus4 = krb5_free_sspi_buffer( "OutSecToken.pvBuffer", &(OutSecToken.pvBuffer) ); OutSecToken.cbBuffer = 0; } SecStatus = (SecStatus1!=SEC_E_OK) ? SecStatus1 : ( (SecStatus2!=SEC_E_OK) ? SecStatus2 : ( (SecStatus3!=SEC_E_OK) ? SecStatus3 : SecStatus4 ) ); if ( SecStatus!=SEC_E_OK ) { (*pp_min_stat) = KRB5_MINOR_WINERROR(FreeContextBuffer,SecStatus); maj_stat = GSS_S_FAILURE; } return(maj_stat); } /* krb5_accept_sec_context() */ /* * krb5_delete_sec_context() * * */ OM_uint32 krb5_delete_sec_context( OM_uint32 * pp_min_stat, void ** pp_ctx ) { char * this_Call = "krb5_delete_context"; krb5_ctx_desc * ctx = NULL; SECURITY_STATUS SecStatus; OM_uint32 maj_stat = GSS_S_COMPLETE; (*pp_min_stat) = 0; if ( *pp_ctx==NULL ) return(maj_stat); /* quick validation of krb5 context handle */ maj_stat = krb5_check_ctx( pp_min_stat, pp_ctx, CTX_DELETE, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); ctx = *pp_ctx; if ( IsValidSecurityHandle( &(ctx->sspi_ctx) ) ) { SecStatus = (fp_SSPI_krb5->DeleteSecurityContext)( &(ctx->sspi_ctx) ); if ( SecStatus!=SEC_E_OK ) { char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): DeleteSecurityContext() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) (*pp_min_stat) = KRB5_MINOR_SSPI(DeleteSecurityContext,SecStatus); maj_stat = GSS_S_FAILURE; } SecInvalidateHandle( &(ctx->sspi_ctx) ); } if ( ctx->initiator!=NULL ) { sy_clear_free( &(ctx->initiator), ctx->initiator_len ); } if ( ctx->acceptor!=NULL ) { sy_clear_free( &(ctx->acceptor), ctx->acceptor_len ); } sy_clear_free( (void **)&ctx, sizeof(*ctx) ); (*pp_ctx) = NULL; return(maj_stat); } /* krb5_delete_sec_context() */ /* * krb5_export_sec_context() * * */ OM_uint32 krb5_export_sec_context( OM_uint32 * pp_min_stat, void ** pp_ctx, void ** pp_ctx_buffer, size_t * pp_ctx_buffer_len ) { char * this_Call = "krb5_export_sec_context"; krb5_ctx_desc * ctx = NULL; /* convenience pointer */ krb5_exp_ctx_desc * expctx = NULL; Uchar * buffer = NULL; /* returnable dynamic object */ Uchar * ptr = NULL; /* convenience pointer */ Uchar * sspi_token = NULL; /* SSPI temporary memory */ SecBuffer SecBuf; SECURITY_STATUS SecStatus; size_t buffer_len = 0; size_t sspi_token_len = 0; OM_uint32 min_stat; OM_uint32 maj_stat = GSS_S_COMPLETE; (*pp_min_stat) = MINOR_NO_ERROR; (*pp_ctx_buffer) = NULL; (*pp_ctx_buffer_len) = 0; /* quick validation of krb5 context handle */ maj_stat = krb5_check_ctx( pp_min_stat, pp_ctx, CTX_TRANSFER, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); ctx = (krb5_ctx_desc *) (*pp_ctx); SecBuf.BufferType = SECBUFFER_EMPTY; SecBuf.cbBuffer = 0; SecBuf.pvBuffer = NULL; SecStatus = (fp_SSPI_krb5->ExportSecurityContext)( /* PCtxtHandle phContext */ &(ctx->sspi_ctx), /* ULONG fFlags */ SECPKG_CONTEXT_EXPORT_DELETE_OLD, /* PSecBuffer pPackedContext */ &SecBuf, /* void ** pToken */ NULL ); if ( SecStatus!=SEC_E_OK ) { char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): ExportSecurityContext() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) ERROR_RETURN( KRB5_MINOR_SSPI(ExportSecurityContext,SecStatus), GSS_S_FAILURE ); } else { DEBUG_ACTION((tf, " A: %s(): ExportSecurityContext()==SEC_E_OK, token_len = %lu\n", this_Call, (unsigned long)SecBuf.cbBuffer )); } SecInvalidateHandle( &(ctx->sspi_ctx) ); /* the SSPI security context will be dropped by the final */ /* call to krb5_delete_sec_context() */ /* only our shadowed information will survive context transfers */ sspi_token_len = SecBuf.cbBuffer; sspi_token = SecBuf.pvBuffer; buffer_len = sizeof(*expctx) + ctx->initiator_len + ctx->acceptor_len + sspi_token_len; if ( buffer_len>USHRT_MAX ) { DEBUG_ERR((tf, "ERR: %s(): Exported context token to large (%ld bytes) for this code!\n", this_Call, (unsigned long) buffer_len )); ERROR_RETURN( MINOR_INTERNAL_BUFFER_OVERRUN, GSS_S_FAILURE ); } buffer = sy_malloc( buffer_len ); /* we're filling everything anyways */ if (buffer==NULL) { ERROR_RETURN( MINOR_OUT_OF_MEMORY, GSS_S_FAILURE ); } expctx = (krb5_exp_ctx_desc *) buffer; /* clear structure body, avoid uninitalized memory copy warnings */ /* from purify if the struct contains padding at the end */ memset(buffer,0,sizeof(*expctx)); expctx->magic_cookie = KRB5_CTX_COOKIE; expctx->sspi_asc_req = ctx->sspi_asc_req; expctx->sspi_asc_ret = ctx->sspi_asc_ret; expctx->sspi_isc_req = ctx->sspi_isc_req; expctx->sspi_isc_ret = ctx->sspi_isc_ret; expctx->seq_ini2acc = ctx->seq_ini2acc; expctx->seq_acc2ini = ctx->seq_acc2ini; expctx->service_rec = ctx->service_rec; expctx->sizes = ctx->sizes; /* struct copy */ expctx->sspi_expiration = ctx->sspi_expiration; /* struct copy */ expctx->expires_at = ctx->expires_at; expctx->token_len = (Ushort) buffer_len; expctx->initiator_len = (Ushort) ctx->initiator_len; expctx->acceptor_len = (Ushort) ctx->acceptor_len; expctx->sspi_token_len = (Ushort) sspi_token_len; expctx->nego_step = (Uchar) ctx->nego_step; expctx->role = (Uchar) ctx->role; ptr = &(buffer[sizeof(*expctx)]); if ( ctx->initiator_len>0 ) { memcpy(ptr, ctx->initiator, ctx->initiator_len); ptr += ctx->initiator_len; } if ( ctx->acceptor_len>0 ) { memcpy(ptr, ctx->acceptor, ctx->acceptor_len); ptr += ctx->acceptor_len; } if ( sspi_token_len>0 ) { memcpy(ptr, sspi_token, sspi_token_len ); ptr += sspi_token_len; } if (maj_stat==GSS_S_COMPLETE) { (void) krb5_delete_sec_context( &min_stat, pp_ctx ); (*pp_ctx_buffer) = buffer; (*pp_ctx_buffer_len) = buffer_len; } else { error: if ( sspi_token!=NULL ) { /* try to reimport the security context */ SecStatus = (fp_SSPI_krb5->ImportSecurityContext)( /* PSECURITY_STRING pszPackage */ krb5_provider, /* PSecBuffer pPackedContext */ &SecBuf, /* void SEC_FAR * Token */ NULL, /* PCtxtHandle phContext */ &(ctx->sspi_ctx) ); if ( SecStatus!=SEC_E_OK ) { /* Too bad, we cannot even recover the exported security context ! */ /* So we do not just fail, but we also delete the damaged security context */ char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): ImportSecurityContext() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) krb5_delete_sec_context( &min_stat, pp_ctx ); (*pp_min_stat) = KRB5_MINOR_SSPI(ImportSecurityContext,SecStatus); maj_stat = GSS_S_FAILURE; } } sy_clear_free( (void **)&buffer, buffer_len ); (*pp_ctx_buffer) = NULL; (*pp_ctx_buffer_len) = 0; } if ( sspi_token!=NULL ) { (fp_SSPI_krb5->FreeContextBuffer)( sspi_token ); sspi_token = NULL; sspi_token_len = 0; } return(maj_stat); } /* krb5_export_sec_context() */ /* * krb5_import_sec_context() * * */ OM_uint32 krb5_import_sec_context( OM_uint32 * pp_min_stat, Uchar * p_ctx_buffer, size_t p_ctx_buffer_len, void ** pp_ctx ) { char * this_Call = "krb5_import_sec_context"; krb5_ctx_desc * ctx = NULL; /* returnable dynamic object */ krb5_exp_ctx_desc impctx; /* convenience struct */ Uchar * ptr = NULL; /* convenience pointer */ Uchar * alignedbuf = NULL; /* temporary dynamic memory, free() on exit */ size_t alignedbuf_len = 0; SecBuffer SecBuf; SECURITY_STATUS SecStatus; size_t buffer_len = 0; static int cred_bug_flag = 0; OM_uint32 min_stat; OM_uint32 maj_stat = GSS_S_COMPLETE; (*pp_min_stat) = MINOR_NO_ERROR; (*pp_ctx) = NULL; /****************************************************************/ /* Workaround for yet another Win2KSP2 and Win64 breakage */ /* There is a stupid initialization problem within Kerberos.dll */ /* which causes problems if a new process tries to import a */ /* security context without ever having previously acquired */ /* Kerberos SSP credentials. I reported this bug originally for*/ /* W2K beta3 and it is definitely fixed in W2K final, but */ /* it seems that the same or an error to the same effect was */ /* reintroduced in Win64 and one of the Win2K service packs. */ /* The workaround that seems to ensure proper kerberos.dll */ /* initialization is to call AcquireCredentialsHandle() once */ /* in a processes lifetime before the first call to */ /* ImportSecurityContext() -- which is what I do here */ /****************************************************************/ if ( cred_bug_flag==0 ) { void * tmpcred = NULL; time_t expires_at; OM_uint32 min_stat; DEBUG_ACTION((tf, " A: %s(): Calling AcquireCred() to workaround an SSPI initialization Bug\n", this_Call)); krb5_acquire_cred( &min_stat, NULL, 0, GN_CRED_INITIATE, &tmpcred, &expires_at ); cred_bug_flag = 1; if (tmpcred!=NULL) { krb5_release_cred( &min_stat, &tmpcred ); } } /* endif (cred_bug_flag==0) */ /* initial sanity checks on supplied interprocess context token */ if ( p_ctx_buffer==NULL || p_ctx_buffer_len==0 ) { DEBUG_ERR((tf, "ERR: %s(): missing interprocess token!\n", this_Call)) RETURN_MIN_MAJ( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } if ( p_ctx_buffer_len<sizeof(impctx) ) { DEBUG_ERR((tf, "ERR: %s(): invalid or truncated interprocess token!\n", this_Call )) RETURN_MIN_MAJ( MINOR_NO_ERROR, GSS_S_DEFECTIVE_TOKEN ); } /* copy the header into an aligned structure for convenience */ memcpy( &impctx, p_ctx_buffer, sizeof(impctx) ); buffer_len = sizeof(impctx) + impctx.initiator_len + impctx.acceptor_len + impctx.sspi_token_len; if ( impctx.magic_cookie!=KRB5_CTX_COOKIE || buffer_len != impctx.token_len || buffer_len != p_ctx_buffer_len ) { DEBUG_ERR((tf, "ERR: %s(): invalid or corrupted token?\n", this_Call)) RETURN_MIN_MAJ( MINOR_NO_ERROR, GSS_S_DEFECTIVE_TOKEN ); } ctx = sy_calloc( sizeof(*ctx) ); /* initialized with zeroes */ if (ctx==NULL) { RETURN_MIN_MAJ( MINOR_OUT_OF_MEMORY, GSS_S_FAILURE ); } ctx->magic_cookie = KRB5_CTX_COOKIE; SecInvalidateHandle( &(ctx->sspi_ctx) ); ctx->sspi_asc_req = impctx.sspi_asc_req; ctx->sspi_asc_ret = impctx.sspi_asc_ret; ctx->sspi_isc_req = impctx.sspi_isc_req; ctx->sspi_isc_ret = impctx.sspi_isc_ret; ctx->seq_ini2acc = impctx.seq_ini2acc; ctx->seq_acc2ini = impctx.seq_acc2ini; ctx->service_rec = impctx.service_rec; ctx->sizes = impctx.sizes; /* struct copy */ ctx->sspi_expiration = impctx.sspi_expiration; /* struct copy */ ctx->expires_at = impctx.expires_at; ctx->nego_step = (int)impctx.nego_step; ctx->role = (int)impctx.role; ctx->flag_established = TRUE; /* implicit */ ptr = &(p_ctx_buffer[sizeof(impctx)]); maj_stat = krb5_copy_name( pp_min_stat, ptr, (size_t)impctx.initiator_len, &(ctx->initiator), &(ctx->initiator_len) ); if (maj_stat!=GSS_S_COMPLETE) goto error; ptr += impctx.initiator_len; maj_stat = krb5_copy_name( pp_min_stat, ptr, (size_t)impctx.acceptor_len, &(ctx->acceptor), &(ctx->acceptor_len) ); if (maj_stat!=GSS_S_COMPLETE) goto error; ptr += impctx.acceptor_len; /******************************************************************/ /* Workaround for yet another W2K/Win64 Kerberos SSP BUG: */ /* If a mis-aligned context token is handed to the SSPI Function */ /* ImportSecurityContext() of Kerberos SSP on Win64 it results */ /* in a call for DrWatson within Kerberos.dll due to an unaligned */ /* access violation ... */ /******************************************************************/ alignedbuf_len = impctx.sspi_token_len; alignedbuf = sy_malloc( alignedbuf_len ); if ( alignedbuf==NULL ) { ERROR_RETURN(MINOR_OUT_OF_MEMORY, GSS_S_FAILURE); } memcpy(alignedbuf, ptr, alignedbuf_len); SecBuf.BufferType = SECBUFFER_TOKEN; SecBuf.cbBuffer = (ULONG)alignedbuf_len; SecBuf.pvBuffer = alignedbuf; SecStatus = (fp_SSPI_krb5->ImportSecurityContext)( /* PSECURITY_STRING pszPackage */ krb5_provider, /* PSecBuffer pPackedContext */ &SecBuf, /* void SEC_FAR * Token */ NULL, /* PCtxtHandle phContext */ &(ctx->sspi_ctx) ); if ( SecStatus!=SEC_E_OK ) { char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): ImportSecurityContext() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) ERROR_RETURN( KRB5_MINOR_SSPI(ImportSecurityContext,SecStatus), GSS_S_FAILURE ); } else { DEBUG_ACTION((tf, " A: %s(): ImportSecurityContext(token_len=%lu)==SEC_E_OK\n", this_Call, (unsigned long)alignedbuf_len )); } if (maj_stat==GSS_S_COMPLETE) { (*pp_ctx) = ctx; } else { error: if ( ctx!=NULL ) { (void) krb5_delete_sec_context( &min_stat, (void **)&ctx ); } } sy_clear_free( &alignedbuf, alignedbuf_len ); return(maj_stat); } /* krb5_import_sec_context() */ /* * krb5_context_time() * * */ OM_uint32 krb5_context_time( OM_uint32 * pp_min_stat, void * p_ctx, time_t * pp_expires_at ) { char * this_Call = "krb5_context_time"; krb5_ctx_desc * ctx = NULL; SecPkgContext_Lifespan LifeSpan; OM_uint32 maj_stat = GSS_S_COMPLETE; SECURITY_STATUS SecStatus; (*pp_min_stat) = MINOR_NO_ERROR; memset( &LifeSpan, 0, sizeof(LifeSpan) ); (*pp_expires_at) = 0; /* quick validation of krb5 context handle */ maj_stat = krb5_check_ctx( pp_min_stat, &p_ctx, CTX_TIME, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); ctx = (krb5_ctx_desc *) p_ctx; if ( FALSE!=krb5_ctx_noexpire ) { /* ForceCtxNoExpire registry tweak active */ ctx->expires_at = GSS_C_INDEFINITE; (*pp_expires_at) = GSS_C_INDEFINITE; } else { SecStatus = (fp_SSPI_krb5->QueryContextAttributes)( &(ctx->sspi_ctx), SECPKG_ATTR_LIFESPAN, &LifeSpan ); if ( SEC_E_OK!=SecStatus ) { char *symbol, *desc; krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: %s(): QueryContextAttributes() failed with %s\n\t(Desc=\"%s\")\n", this_Call, symbol, desc )) RETURN_MIN_MAJ( KRB5_MINOR_SSPI(QueryContextAttributesLIFESPAN,SecStatus), GSS_S_FAILURE ); } else { DEBUG_ACTION((tf, " A: %s(): QueryContextAttributes(LIFESPAN) == (0x%08lx,0x%08lx)\n", this_Call, (unsigned long)LifeSpan.tsExpiry.HighPart, (unsigned long)LifeSpan.tsExpiry.LowPart )); ctx->sspi_expiration.LowPart = LifeSpan.tsExpiry.LowPart; ctx->sspi_expiration.HighPart = LifeSpan.tsExpiry.HighPart; ctx->expires_at = krb5_timestamp2time( &(ctx->sspi_expiration) ); (*pp_expires_at) = ctx->expires_at; } } return(maj_stat); } /* krb5_context_time() */ /* * krb5_context_name() * * */ OM_uint32 krb5_context_name( OM_uint32 * pp_min_stat, void * p_ctx, int p_usage, gn_nt_tag_et * pp_nt_tag, void ** pp_cname, size_t * pp_cname_len ) { char * this_Call = "krb5_context_name"; krb5_ctx_desc * ctx = NULL; OM_uint32 maj_stat = GSS_S_COMPLETE; (*pp_min_stat) = MINOR_NO_ERROR; (*pp_nt_tag) = NT_INVALID_TAG; (*pp_cname) = NULL; (*pp_cname_len) = 0; /* quick validation of krb5 context handle */ maj_stat = krb5_check_ctx( pp_min_stat, &p_ctx, CTX_INQUIRE, this_Call ); if (maj_stat!=GSS_S_COMPLETE) return(maj_stat); ctx = (krb5_ctx_desc *) p_ctx; if ( ctx->flag_established==FALSE ) { if ( (ctx->role==KRB5_INITIATOR && p_usage==GSS_C_INITIATE) || (ctx->role==KRB5_ACCEPTOR && p_usage==GSS_C_ACCEPT) ) { ; } else { DEBUG_ERR((tf, "ERR: %s(): %s not available for proto-context!\n", this_Call, (p_usage==GSS_C_INITIATE) ? "initiator" : "acceptor" )) ERROR_RETURN( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } } /* Actually I'd really like to inquire the name of the acceptor */ /* and the initiator from the SSPI context, but */ /* SSPI doesn't store them consistently on both ends ... */ switch( p_usage ) { case GSS_C_ACCEPT: (*pp_cname) = ctx->acceptor; (*pp_cname_len) = ctx->acceptor_len; break; case GSS_C_INITIATE: (*pp_cname) = ctx->initiator; (*pp_cname_len) = ctx->initiator_len; break; default: ERROR_RETURN( MINOR_INTERNAL_ERROR, GSS_S_FAILURE ); } (*pp_nt_tag) = krb5_nt_tag; error: return(maj_stat); } /* krb5_context_name() */ /******************************************************************************/ /* Conversion routines from GSSAPI service flags to context attributes of */ /* Microsoft's SSPI. Unfortunately, SSPI uses different flags for every */ /* situation -- not only different in name, but also different in values. */ /* And on top of that, there is even another set of constants for */ /* QueryPackageInfo(). This makes about 5 sets of differing constants with */ /* similar names to describe equivalent attributes ... */ /* */ /* NOTE: don't take the SSPI documentation literally */ /* Although it's nice to read, all of the various NTLM SSP implementations */ /* in the various ServicePacks of Windows 95 and across available versions */ /* and service packs of NT differ considerably in non-compliance to this spec */ /* as well as missing of mandatory functionality ... */ /* */ /* For example the ASC_REQ_* and ISC_REQ_* input parameters are not context */ /* attribute requirements, but *requests*. That means with the exception of */ /* ALLOCATE_MEMORY, the security context will be established, no matter what */ /* attributes you ask for or receive. */ /******************************************************************************/ /* * krb5_gss_svc_to_ASC_REQ() * * GSS-API doesn't allow to specify flags for gss_accept_sec_context() */ ULONG krb5_gss_svc_to_ASC_REQ( void ) { ULONG CtxFlagsReq = 0; /* For GSS-API, the message protection services are always requested */ CtxFlagsReq |= ASC_REQ_CONFIDENTIALITY; CtxFlagsReq |= ASC_REQ_INTEGRITY; CtxFlagsReq |= ASC_REQ_DELEGATE; #if 0 /* SSPI doc says that one should request either SEQUENCE_DETECT or REPLAY_DETECT */ /* to be able to use message protection calls later on (Sign/Verify). */ /* This sounds somewhat broken ... */ CtxFlagsReq |= ASC_REQ_REPLAY_DETECT; #endif CtxFlagsReq |= ASC_REQ_ALLOCATE_MEMORY; /* this affects the context tokens from AcceptSecurityContext() */ /* CtxFlagsReq |= ASC_REQ_MUTUAL_AUTH; Let the client decide whether to do mutual authentication */ /* CtxFlagsReq |= ASC_REQ_IDENTIFY; Let the client decide whether this is to be permitted */ return(CtxFlagsReq); } /* krb5_gss_svc_to_ASC_REQ() */ /* * krb5_ASC_RET_to_gss_svc() * * convert ASC_RET_* flags into GSS_API service flags */ OM_uint32 krb5_ASC_RET_to_gss_svc( ULONG CtxFlagsRet ) { OM_uint32 svc_flags = 0; if ( (CtxFlagsRet&ASC_RET_DELEGATE)!=0 ) { svc_flags |= GSS_C_DELEG_FLAG; } if ( (CtxFlagsRet&ASC_RET_MUTUAL_AUTH)!=0 ) { svc_flags |= GSS_C_MUTUAL_FLAG; } if ( (CtxFlagsRet&ASC_RET_REPLAY_DETECT)!=0 ) { svc_flags |= GSS_C_REPLAY_FLAG; } if ( (CtxFlagsRet&ASC_RET_SEQUENCE_DETECT)!=0 ) { svc_flags |= GSS_C_SEQUENCE_FLAG; } if ( (CtxFlagsRet&ASC_RET_INTEGRITY)!=0 ) { svc_flags |= GSS_C_INTEG_FLAG; } /* in GSS-API, confidentiality requires integrity services */ if ( (CtxFlagsRet&ASC_RET_CONFIDENTIALITY)!=0 && (svc_flags&GSS_C_INTEG_FLAG)!=0 ) { svc_flags |= GSS_C_CONF_FLAG; } #if 0 /* disabled for now */ svc_flags |= GSS_C_PROT_READY_FLAG; #endif svc_flags |= GSS_C_TRANS_FLAG; /* indicate that export/import of security contexts is supported */ return( svc_flags ); } /* krb5_ASC_RET_to_gss_svc() */ /* * krb5_gss_svc_to_ISC_REQ() * * convert GSS-API service flags into ISC_REQ_* flags for InitializeSecurityContext() */ ULONG krb5_gss_svc_to_ISC_REQ( OM_uint32 p_svc_flags ) { ULONG CtxFlagsReq = 0; if ( (p_svc_flags&GSS_C_DELEG_FLAG)!=0 ) { CtxFlagsReq |= ISC_REQ_DELEGATE; } if ( (p_svc_flags&GSS_C_MUTUAL_FLAG)!=0 ) { CtxFlagsReq |= ISC_REQ_MUTUAL_AUTH; } if ( (p_svc_flags&GSS_C_REPLAY_FLAG)!=0 ) { CtxFlagsReq |= ISC_REQ_REPLAY_DETECT; } if ( (p_svc_flags&GSS_C_SEQUENCE_FLAG)!=0 ) { CtxFlagsReq |= ISC_REQ_SEQUENCE_DETECT; } /* For GSS-API, the message protection services are always requested */ CtxFlagsReq |= ISC_REQ_INTEGRITY; CtxFlagsReq |= ISC_REQ_CONFIDENTIALITY; #if 0 if ( (p_svc_flags&GSS_C_DELEG_FLAG)==0 ) { CtxFlagsReq |= ISC_REQ_IDENTIFY; /* According to the GSS-API spec, we must perform */ /* delegation ONLY when it was explicitly requested */ /* SSPI Impersonation level is a delegation, because */ /* it may create a significantly more powerful access */ /* token than that of the original server process */ } #endif CtxFlagsReq |= ISC_REQ_ALLOCATE_MEMORY; /* This affects context tokens from InitializeSecurityContext() */ return( CtxFlagsReq ); } /* krb5_gss_svc_to_ISC_REQ() */ /* * krb5_ISC_RET_to_gss_svc() * * */ OM_uint32 krb5_ISC_RET_to_gss_svc( ULONG CtxAttr ) { OM_uint32 svc_flags = 0; if ( (CtxAttr&ISC_RET_DELEGATE)!=0 ) { svc_flags |= GSS_C_DELEG_FLAG; } if ( (CtxAttr&ISC_RET_MUTUAL_AUTH)!=0 ) { svc_flags |= GSS_C_MUTUAL_FLAG; } if ( (CtxAttr&ISC_RET_REPLAY_DETECT)!=0 ) { svc_flags |= GSS_C_REPLAY_FLAG; } if ( (CtxAttr&ISC_RET_SEQUENCE_DETECT)!=0 ) { svc_flags |= GSS_C_SEQUENCE_FLAG; } if ( (CtxAttr&ISC_RET_INTEGRITY)!=0 ) { svc_flags |= GSS_C_INTEG_FLAG; } /* in GSS-API, confidentiality requires integrity services */ if ( (CtxAttr&ISC_RET_CONFIDENTIALITY)!=0 && (svc_flags&GSS_C_INTEG_FLAG)!=0 ) { svc_flags |= GSS_C_CONF_FLAG; } #if 0 /* disabled for now */ svc_flags |= GSS_C_PROT_READY_FLAG; #endif svc_flags |= GSS_C_TRANS_FLAG; /* indicate that export/import of security contexts is supported */ return(svc_flags); } /* krb5_ISC_RET_to_gss_svc( ) */ /* * krb5_free_sspi_buffer() * * */ SECURITY_STATUS krb5_free_sspi_buffer( char * p_buffer_name, void ** pp_sspi_buffer ) { SECURITY_STATUS SecStatus = SEC_E_OK; char * symbol; char * desc; if ( (*pp_sspi_buffer)!=NULL ) { SecStatus = (fp_SSPI_krb5->FreeContextBuffer)( (*pp_sspi_buffer) ); if ( SecStatus!=SEC_E_OK) { krb5_sec_error( SecStatus, &symbol, &desc ); DEBUG_ERR((tf, "ERR: FreeContextBuffer(%s) failed with %s\n\t(Desc=\"%s\")\n", p_buffer_name, symbol, desc )) } (*pp_sspi_buffer) = NULL; } return(SecStatus); } /* krb5_free_sspi_buffer() */
35.396275
113
0.619774
8863c383e500deea4709076fc0ac1a12e039d7e7
3,150
h
C
openmp/libomptarget/plugins/amdgpu/impl/rt.h
cmc-rep/llvm
678cd959ac9de7b48d1fb5d930e2197b10b60653
[ "Apache-2.0" ]
null
null
null
openmp/libomptarget/plugins/amdgpu/impl/rt.h
cmc-rep/llvm
678cd959ac9de7b48d1fb5d930e2197b10b60653
[ "Apache-2.0" ]
null
null
null
openmp/libomptarget/plugins/amdgpu/impl/rt.h
cmc-rep/llvm
678cd959ac9de7b48d1fb5d930e2197b10b60653
[ "Apache-2.0" ]
null
null
null
/*===-------------------------------------------------------------------------- * ATMI (Asynchronous Task and Memory Interface) * * This file is distributed under the MIT License. See LICENSE.txt for details. *===------------------------------------------------------------------------*/ #ifndef SRC_RUNTIME_INCLUDE_RT_H_ #define SRC_RUNTIME_INCLUDE_RT_H_ #include "atmi_runtime.h" #include "hsa.h" #include <cstdarg> #include <string> namespace core { #define DEFAULT_MAX_QUEUE_SIZE 4096 #define DEFAULT_MAX_KERNEL_TYPES 32 #define DEFAULT_NUM_GPU_QUEUES -1 // computed in code #define DEFAULT_NUM_CPU_QUEUES -1 // computed in code #define DEFAULT_DEBUG_MODE 0 class Environment { public: Environment() : max_queue_size_(DEFAULT_MAX_QUEUE_SIZE), max_kernel_types_(DEFAULT_MAX_KERNEL_TYPES), num_gpu_queues_(DEFAULT_NUM_GPU_QUEUES), num_cpu_queues_(DEFAULT_NUM_CPU_QUEUES), debug_mode_(DEFAULT_DEBUG_MODE) { GetEnvAll(); } ~Environment() {} void GetEnvAll(); int getMaxQueueSize() const { return max_queue_size_; } int getMaxKernelTypes() const { return max_kernel_types_; } int getNumGPUQueues() const { return num_gpu_queues_; } int getNumCPUQueues() const { return num_cpu_queues_; } // TODO(ashwinma): int may change to enum if we have more debug modes int getDebugMode() const { return debug_mode_; } // TODO(ashwinma): int may change to enum if we have more profile modes private: std::string GetEnv(const char *name) { char *env = getenv(name); std::string ret; if (env) { ret = env; } return ret; } int max_queue_size_; int max_kernel_types_; int num_gpu_queues_; int num_cpu_queues_; int debug_mode_; }; class Runtime final { public: static Runtime &getInstance() { static Runtime instance; return instance; } // init/finalize static atmi_status_t Initialize(); static atmi_status_t Finalize(); // modules static atmi_status_t RegisterModuleFromMemory( void *, size_t, atmi_place_t, atmi_status_t (*on_deserialized_data)(void *data, size_t size, void *cb_state), void *cb_state); // machine info static atmi_machine_t *GetMachineInfo(); // data static atmi_status_t Memcpy(void *, const void *, size_t); static atmi_status_t Memfree(void *); static atmi_status_t Malloc(void **, size_t, atmi_mem_place_t); // environment variables int getMaxQueueSize() const { return env_.getMaxQueueSize(); } int getMaxKernelTypes() const { return env_.getMaxKernelTypes(); } int getNumGPUQueues() const { return env_.getNumGPUQueues(); } int getNumCPUQueues() const { return env_.getNumCPUQueues(); } // TODO(ashwinma): int may change to enum if we have more debug modes int getDebugMode() const { return env_.getDebugMode(); } protected: Runtime() = default; ~Runtime() = default; Runtime(const Runtime &) = delete; Runtime &operator=(const Runtime &) = delete; protected: // variable to track environment variables Environment env_; }; } // namespace core #endif // SRC_RUNTIME_INCLUDE_RT_H_
28.899083
79
0.675556
bb036625737509e6dcd3aa6c8744c463f1bc57e7
378
c
C
navy-apps/libs/libc/src/libm/complex/crealf.c
diguage/ics2018
46d51bd0fd098754c7dcb383ed61a74cb85a2c10
[ "Apache-2.0" ]
null
null
null
navy-apps/libs/libc/src/libm/complex/crealf.c
diguage/ics2018
46d51bd0fd098754c7dcb383ed61a74cb85a2c10
[ "Apache-2.0" ]
null
null
null
navy-apps/libs/libc/src/libm/complex/crealf.c
diguage/ics2018
46d51bd0fd098754c7dcb383ed61a74cb85a2c10
[ "Apache-2.0" ]
null
null
null
/* $NetBSD: crealf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */ /* * Written by Matthias Drochner <drochner@NetBSD.org>. * Public domain. * * imported and modified include for newlib 2010/10/03 * Marco Atzeri <marco_atzeri@yahoo.it> */ #include <complex.h> #include "fdlibm.h" float crealf(float complex z) { float_complex w = { .z = z }; return (REAL_PART(w)); }
18
64
0.669312
18630743038d49f9ccd15a209642fd6b398f5d18
4,449
h
C
nodes/core_node/src/credentials_utility.h
J-Pai/EnvTrackerNode
c2c6f95b3d124e1a70262af271aef4313f776531
[ "MIT" ]
5
2021-01-01T11:42:36.000Z
2022-02-13T04:11:22.000Z
nodes/core_node/src/credentials_utility.h
J-Pai/EnvTrackerNode
c2c6f95b3d124e1a70262af271aef4313f776531
[ "MIT" ]
2
2021-01-11T17:50:23.000Z
2021-01-11T19:39:07.000Z
nodes/core_node/src/credentials_utility.h
J-Pai/EnvTrackerNode
c2c6f95b3d124e1a70262af271aef4313f776531
[ "MIT" ]
null
null
null
#ifndef ENVTRACKERNODE_CORENODE_CREDENTIALS_UTILITY_H_ #define ENVTRACKERNODE_CORENODE_CREDENTIALS_UTILITY_H_ #include <fstream> #include <iostream> #include <linux/limits.h> #include <memory> #include <regex> #include <sstream> #include <stdexcept> #include <string> #include <bsoncxx/stdx/make_unique.hpp> #include <grpcpp/grpcpp.h> #include <mongocxx/instance.hpp> #include <mongocxx/pool.hpp> #include <nlohmann/json.hpp> #define STR(x) #x #define XSTR(x) STR(x) namespace corenode { class CredentialsUtility final { public: /** * Creates an {@link corenode::CredentialsUtility} object which contains the GCP * project client information and supporting SSL documents. * * This constructor auto fills the SSL documents and client information * using the following environment variables: * <ul> * <li> SSL_KEY * <li> SSL_CERT * <li> SSL_ROOT_CERT * <li> CLIENT_SECRET_JSON * </ul> */ CredentialsUtility(); /** * Creates an {@link corenode::CredentialsUtility} object which contains the GCP * project client information and supporting SSL documents. * * @param env_json_path Path to GCP client secret ID JSON file. */ CredentialsUtility(const std::string& env_json_path); /** * Generates an {@link grpc::ServerCredentials} object. * Uses the stored SSL key, certificate, and root CA. */ std::shared_ptr<grpc::ServerCredentials> GenerateServerCredentials(); /** * Generates an {@link grpc::ServerCredentials} object. * Uses the stored SSL key, certificate, and root CA. */ std::shared_ptr<grpc::ChannelCredentials> GenerateChannelCredentials(); /** * Requests an Google OAuth2 token using the oauth2_cli application. * * @return {@link nlohmann::json} */ nlohmann::json RequestOAuthToken(); /** * Connects to MongoDB database using configured credentials. */ void SetupMongoConnection(); /** * Extracts an argument value from the commandline arguments. * * @param arg_name Flag argument name (must be in the format --arg_name=arg_value). * @param default_value Default value to return if flag not found. * @param argc Number of argument strings. * @param argv List of argument strings. * @return value associated with flag. */ static std::string GetFlagValue( const std::string& arg_name, const std::string& default_value, int argc, char** argv); std::string GetKey(); std::string GetCert(); std::string GetRoot(); std::string GetClientIdJsonPath(); nlohmann::json GetClientIdJson(); void SetOAuthToken(const std::string& token); nlohmann::json GetOAuthToken(); mongocxx::pool::entry GetMongoClient(); std::string GetDatabaseName(); private: std::string key_; std::string cert_; std::string root_; std::string client_id_path_; std::unique_ptr<mongocxx::instance> instance_ = nullptr; std::unique_ptr<mongocxx::pool> pool_ = nullptr; nlohmann::json mongo_connection_; nlohmann::json client_id_json_; nlohmann::json oauth_token_; nlohmann::json environment_json_; void InitFields( const std::string& key_path, const std::string& cert_path, const std::string& root_path, const std::string& json_path, const nlohmann::json& mongo); /** * Replaces every occurance of the string variable "from" with the string * variable "to". * * @param str string to do that needs replacement. * @param from target string to search for. * @param to string to replace target string with. */ void ReplaceAll(std::string& str, const std::string& from, const std::string& to); /** * Parses the file located at the path filename and dumps it's contents into * data. * * @param filename Path to file. * @return String with the contents of the files. */ std::string ReadFile(const std::array<char, PATH_MAX>& filename); /** * Contains the path to the oauth2_cli tool that can be used to obtain a * Google OAuth2 access token. */ const std::string kOAuth2CLI = XSTR(OAUTH2_CLI); const char* kHome = std::getenv("HOME"); const std::string kDefaultDatabase = "DataNode"; }; } // namespace corenode #endif // ENVTRACKERNODE_CORENODE_CREDENTIALS_UTILITY_H_
30.265306
87
0.672061
63aa99823f6cea8ad52bc0179a1c0d288f1c811e
11,539
h
C
syzygy/minidump/minidump.h
nzeh/syzygy
3573e3d458dbb4285753c28a7cb42ced739f9f55
[ "Apache-2.0" ]
343
2015-01-07T05:58:44.000Z
2022-03-15T14:55:21.000Z
syzygy/minidump/minidump.h
nzeh/syzygy-nzeh
3757e53f850644721284073de318e218224dd411
[ "Apache-2.0" ]
61
2015-03-19T18:20:21.000Z
2019-10-23T12:58:23.000Z
syzygy/minidump/minidump.h
nzeh/syzygy-nzeh
3757e53f850644721284073de318e218224dd411
[ "Apache-2.0" ]
66
2015-01-20T15:35:05.000Z
2021-11-25T16:49:41.000Z
// Copyright 2015 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // A utility class for reading minidumps. #ifndef SYZYGY_MINIDUMP_MINIDUMP_H_ #define SYZYGY_MINIDUMP_MINIDUMP_H_ #include <windows.h> // NOLINT #include <dbghelp.h> #include <stdint.h> #include <string> #include <vector> #include "base/macros.h" #include "base/files/file_path.h" #include "base/files/scoped_file.h" namespace minidump { namespace internal { // Provides the default header parsing for the TypedMinidumpStream class. class DefaultHeaderParser { public: static size_t Parse(const MINIDUMP_MEMORY_LIST& header); static size_t Parse(const MINIDUMP_MODULE_LIST& header); static size_t Parse(const MINIDUMP_THREAD_LIST& header); static size_t Parse(const MINIDUMP_THREAD_EX_LIST& header); }; } // namespace internal // fwd. template <typename HeaderType, typename ElementType, size_t (*ParseHeaderFunction)(const HeaderType& hdr) = internal::DefaultHeaderParser::Parse> class TypedMinidumpStream; template <typename ElementType> class TypedMinidumpStreamIterator; class Minidump { public: using TypedMemoryList = TypedMinidumpStream<MINIDUMP_MEMORY_LIST, MINIDUMP_MEMORY_DESCRIPTOR>; using TypedModuleList = TypedMinidumpStream<MINIDUMP_MODULE_LIST, MINIDUMP_MODULE>; using TypedThreadList = TypedMinidumpStream<MINIDUMP_THREAD_LIST, MINIDUMP_THREAD>; using TypedThreadExList = TypedMinidumpStream<MINIDUMP_THREAD_EX_LIST, MINIDUMP_THREAD_EX>; static const size_t kNoStreamId = static_cast<size_t>(-1); class Stream; Minidump(); ~Minidump(); // @name Typed stream accessors. // These functions retrieve typed stream accessors to particular well-known // streams in the mindump directory. // @{ TypedMemoryList GetMemoryList() const; TypedModuleList GetModuleList() const; TypedThreadList GetThreadList() const; TypedThreadExList GetThreadExList() const; // @} // Returns a stream for @p location. // @param location defines the offset and length of the returned stream. Stream GetStreamFor(const MINIDUMP_LOCATION_DESCRIPTOR& location) const; // Returns a stream for the file's @p stream_id. // @param stream_id the stream id to return, must be a valid stream id. Stream GetStream(size_t stream_id) const; // Find the next stream of type @p stream_type. // @param prev the previous stream of this type or nullptr. // @param stream_type the stream type to look for. // @returns a valid stream if one can be found, otherwise an invalid stream. Stream FindNextStream(const Stream* prev, size_t stream_type) const; // Accessors. const std::vector<MINIDUMP_DIRECTORY>& directory() const { return directory_; } protected: friend class Stream; // @name Data accessors. // Reads file contents. // @param offset the file offset to read from. // @param data_size the amount of data to read. // @param data where to write the data, must be of size @p data_data size or // larger. // @returns true on success, false on failure, including a short read. virtual bool ReadBytes(size_t offset, size_t data_size, void* data) const = 0; bool ReadDirectory(); std::vector<MINIDUMP_DIRECTORY> directory_; private: DISALLOW_COPY_AND_ASSIGN(Minidump); }; // Allows parsing a minidump from a file. class FileMinidump : public Minidump { public: // Opens the minidump file at @p path and verifies its header structure. // @param path the minidump file to open. // @return true on success, false on failure. bool Open(const base::FilePath& path); protected: bool ReadBytes(size_t offset, size_t data_size, void* data) const override; private: base::ScopedFILE file_; }; // Allows parsing a minidump from an in-memory buffer. class BufferMinidump : public Minidump { public: BufferMinidump(); // Initializes the minidump to the contents of @p buf[0.. @p buf_len]. // Note that @p buf must outlive this instance, as it does not take ownership // of the buffer, nor copy it. // @param buf pointer to the buffer containing the minidump. // @param buf_len the size of the @p buf buffer. // @returns true on success, false on failure. bool Initialize(const uint8_t* buf, size_t buf_len); protected: bool ReadBytes(size_t offset, size_t data_size, void* data) const override; private: // Not owned. const uint8_t* buf_; size_t buf_len_; }; // A forward-only reading class that bounds reads to streams that make it safe // and easy to parse minidump streams. Streams are lightweight objects that // can be freely copied. // Note that a stream has a current position and a remaining length, and no // independent start position. It's therefore not possible to "rewind" a // stream. class Minidump::Stream { public: Stream(); Stream(const Minidump* minidump, size_t offset, size_t length, size_t stream_id); bool IsValid() const { return minidump_ != nullptr; } // @name Functions that read and advance over the read data. // @{ bool ReadAndAdvanceBytes(size_t data_len, void* data); bool ReadAndAdvanceBytes(size_t data_len, std::string* data); template <class DataType> bool ReadAndAdvanceElement(DataType* element); bool ReadAndAdvanceString(std::wstring* data); // @} // @name Functions that will separately read and advance by a number of bytes. // @{ bool ReadBytes(size_t data_len, void* data); bool AdvanceBytes(size_t data_len); // @} // Accessors. size_t current_offset() const { return current_offset_; } size_t remaining_length() const { return remaining_length_; } size_t stream_id() const { return stream_id_; } const Minidump* minidump() const { return minidump_; } private: const Minidump* minidump_; size_t current_offset_; size_t remaining_length_; size_t stream_id_; }; // A forward only-iterator for Minidump Streams that yields elements of a // given, fixed type. template <typename ElementType> class TypedMinidumpStreamIterator { public: // Creates a new iterator on @p stream. This iterator will yield // @p stream.GetBytesRemaining() / sizeof(ElementType) elements. explicit TypedMinidumpStreamIterator(const minidump::Minidump::Stream& stream) : stream_(stream) { // Make sure the stream contains a range that covers whole elements. DCHECK(!stream_.IsValid() || (stream.remaining_length() % sizeof(ElementType) == 0)); if (stream.remaining_length() != 0) { // It's fatal if we can't pre-read the element that should be there. CHECK(stream_.ReadBytes(sizeof(element_), &element_)); } } TypedMinidumpStreamIterator(const TypedMinidumpStreamIterator& o) : stream_(o.stream), element_(o.element_) {} void operator++() { // It's invalid to advance the end iterator. DCHECK_NE(0u, stream_.remaining_length()); // It's fatal if we can't advance over the current element. CHECK(stream_.AdvanceBytes(sizeof(element_))); if (stream_.remaining_length()) { // Not yet at end, read the current element. Fatal if this fails. CHECK(stream_.ReadBytes(sizeof(element_), &element_)); } } bool operator!=(const TypedMinidumpStreamIterator& o) const { // Only iterators on the same minidump can be compared. DCHECK_EQ(stream_.minidump(), o.stream_.minidump()); return stream_.current_offset() != o.stream_.current_offset(); } const ElementType& operator*() const { DCHECK_NE(0u, stream_.remaining_length()); return element_; } private: // Disallow default construction. TypedMinidumpStreamIterator() {} minidump::Minidump::Stream stream_; ElementType element_; }; // A typed minidump stream allows reading a stream header and iterating over // the elements of the stream. template <typename HeaderType, typename ElementType, size_t (*ParseHeaderFunction)(const HeaderType& hdr)> class TypedMinidumpStream { public: using Iterator = TypedMinidumpStreamIterator<ElementType>; // Initializes this instance to a stream of type @p stream_type in // @p minidump. TypedMinidumpStream(const Minidump& minidump, size_t stream_type); TypedMinidumpStream(const TypedMinidumpStream& other) = default; bool IsValid() const { return element_stream_.IsValid(); } const HeaderType& header() const { return *reinterpret_cast<const HeaderType*>(header_storage_); } Iterator begin() const { return Iterator(element_stream_); } Iterator end() const { return Iterator(Minidump::Stream( element_stream_.minidump(), element_stream_.current_offset() + element_stream_.remaining_length(), 0, element_stream_.stream_id())); } private: // Initializes this instance to a stream of type @p stream_type in // @p minidump. // @returns true on success, false if the stream doesn't exist, is not // unique, or the stream header can't be read. bool Initialize(const Minidump& minidump, size_t stream_type); // The stream we read elements from, this must be constrained to the // range elements occupy, e.g. positioned at the start of the first element // and span a multiple of sizeof(ElementType) bytes. Minidump::Stream element_stream_; // Some of the MINIDUMP_* headers declare a zero element array as placeholder // for the elements. Since such structures can't be directly instantiated, // we read them into a byte array instead. uint8_t header_storage_[sizeof(HeaderType)]; }; template <typename HeaderType, typename ElementType, size_t (*ParseHeaderFunction)(const HeaderType& hdr)> TypedMinidumpStream<HeaderType, ElementType, ParseHeaderFunction>:: TypedMinidumpStream(const Minidump& minidump, size_t stream_type) { memset(header_storage_, 0, sizeof(header_storage_)); Initialize(minidump, stream_type); } template <typename HeaderType, typename ElementType, size_t (*ParseHeaderFunction)(const HeaderType& hdr)> bool TypedMinidumpStream<HeaderType, ElementType, ParseHeaderFunction>:: Initialize(const Minidump& minidump, size_t stream_type) { // Find the first stream of the requested type. Minidump::Stream stream = minidump.FindNextStream(nullptr, stream_type); if (!stream.IsValid()) return false; // Make sure the stream is unique. if (minidump.FindNextStream(&stream, stream_type).IsValid()) return false; // Read and advance over the header. if (!stream.ReadAndAdvanceBytes(sizeof(header_storage_), header_storage_)) return false; size_t number_of_elements = ParseHeaderFunction(header()); // Make sure the stream has appropriate byte length. if (stream.remaining_length() != number_of_elements * sizeof(ElementType)) return false; element_stream_ = stream; return true; } template <typename DataType> bool Minidump::Stream::ReadAndAdvanceElement(DataType* element) { return ReadAndAdvanceBytes(sizeof(DataType), element); } } // namespace minidump #endif // SYZYGY_MINIDUMP_MINIDUMP_H_
33.158046
80
0.733772
6f1d65a668db76c88aed8fd16adb7a1fcb9eb96e
1,281
h
C
System/Library/PrivateFrameworks/Trial.framework/TRILogger.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
1
2020-11-11T06:05:23.000Z
2020-11-11T06:05:23.000Z
System/Library/PrivateFrameworks/Trial.framework/TRILogger.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/Trial.framework/TRILogger.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.5 * on Tuesday, November 10, 2020 at 10:21:56 PM Mountain Standard Time * Operating System: Version 14.2 (Build 18K57) * Image Source: /System/Library/PrivateFrameworks/Trial.framework/Trial * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @protocol OS_dispatch_queue; @class NSObject; @interface TRILogger : NSObject { int _projectId; NSObject*<OS_dispatch_queue> _loggingQueue; } -(id)init; -(void)logEvent:(id)arg1 ; -(id)initWithProjectId:(int)arg1 ; -(unsigned long long)_incrementedLogEventCount; -(void)_dispatchLogEvent:(id)arg1 ; -(void)logWithTrackingId:(id)arg1 metrics:(id)arg2 dimensions:(id)arg3 ; -(void)logWithTrackingId:(id)arg1 metric:(id)arg2 dimensions:(id)arg3 ; -(id)messageWithOneofField:(id)arg1 withName:(id)arg2 ; -(void)logWithTrackingId:(id)arg1 logLevel:(long long)arg2 message:(id)arg3 args:(char*)arg4 ; -(void)logWithTrackingId:(id)arg1 message:(id)arg2 ; -(void)logWithTrackingId:(id)arg1 logLevel:(long long)arg2 message:(id)arg3 ; -(void)logWithTrackingId:(id)arg1 metric:(id)arg2 ; @end
38.818182
130
0.680718
c0cb8d10578cae2f3bc18e41bb60319d37e24fdb
1,734
h
C
StuFW/src/core/commands/gcode/feature/g60.h
onekk/StuFW
9dd7cd41c0cec2749ded8d1d97b7f9fcaa61489b
[ "RSA-MD" ]
1
2020-12-30T21:45:12.000Z
2020-12-30T21:45:12.000Z
StuFW/src/core/commands/gcode/feature/g60.h
onekk/StuFW
9dd7cd41c0cec2749ded8d1d97b7f9fcaa61489b
[ "RSA-MD" ]
1
2020-08-24T16:17:25.000Z
2020-08-24T16:17:25.000Z
StuFW/src/core/commands/gcode/feature/g60.h
onekk/StuFW
9dd7cd41c0cec2749ded8d1d97b7f9fcaa61489b
[ "RSA-MD" ]
null
null
null
/** * StuFW Firmware for 3D Printer * * Based on MK4duo, Marlin, Sprinter and grbl * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * Copyright (C) 2013 Alberto Cotronei @MagoKimbra * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * gcode.h * * Copyright (C) 2017 Alberto Cotronei @MagoKimbra */ #define CODE_G60 /** * G60: save current position * S<slot> specifies memory slot # (0-based) to save into (default 0) */ inline void gcode_G60(void) { const uint8_t slot = parser.byteval('S'); if (slot >= NUM_POSITON_SLOTS) { SERIAL_LMV(ER, MSG_INVALID_POS_SLOT, NUM_POSITON_SLOTS); return; } planner.synchronize(); COPY_ARRAY(mechanics.stored_position[slot], mechanics.current_position); printer.setPosSaved(true); SERIAL_MSG(MSG_SAVED_POS); SERIAL_MV(" S", slot); SERIAL_MV("<-X:", mechanics.stored_position[slot][X_AXIS]); SERIAL_MV(" Y:", mechanics.stored_position[slot][Y_AXIS]); SERIAL_MV(" Z:", mechanics.stored_position[slot][Z_AXIS]); SERIAL_EMV(" E:", mechanics.stored_position[slot][E_AXIS]); }
30.964286
77
0.693195
a029bf493fa1133769a27a3f1e7e9d120fce16e6
2,483
c
C
engine/src/core/move_function.c
Anglaisjulie/RPG-Manhattan-Aftermath-2048
a6695fc30c26cdd6ae4531893f691090e929427b
[ "MIT" ]
2
2020-05-04T13:46:07.000Z
2020-05-04T14:25:41.000Z
engine/src/core/move_function.c
Anglaisjulie/RPG-Manhattan-Aftermath-2048
a6695fc30c26cdd6ae4531893f691090e929427b
[ "MIT" ]
null
null
null
engine/src/core/move_function.c
Anglaisjulie/RPG-Manhattan-Aftermath-2048
a6695fc30c26cdd6ae4531893f691090e929427b
[ "MIT" ]
1
2020-05-06T17:49:37.000Z
2020-05-06T17:49:37.000Z
/* ** EPITECH PROJECT, 2020 ** engine ** File description: ** function to move entities */ #include "../../include/macro.h" #include "../../include/internal.h" void starset_entities_teleport(entities_t *entities, char *name , float x, float y) { entities_t *copy = entities; sfVector2f vector; while (copy != NULL) { if (internal__test_class(name, copy->name)) { vector.x = entities->spot.x - x; vector.y = entities->spot.y - y; copy->direction = internal__get_vector_direction(vector.x , vector.y); copy->spot.x = x; copy->spot.y = y; } copy = copy->next; } } void starset_entities_move(entities_t *entities, char *name, float x, float y) { entities_t *copy = entities; int ok = false; sfVector2f vector = (sfVector2f){x, y}; while (copy != NULL) { if (internal__test_class(name, copy->name)) { copy->direction = internal__follow_vector(&copy->spot, &vector , copy->speed); ok = true; } copy = copy->next; } if (!ok && !!LOG) put_err("bad entities name in starset_entities_move()\n"); } static void internal__sub_iterate_other(entities_t *copy , entities_t *entities, char *second, int *ok) { for (entities_t *sub_copy = entities; sub_copy != NULL ; sub_copy = sub_copy->next) { if (search_e(second, sub_copy->name) != -1) { copy->direction = internal__follow_vector(&copy->spot , &sub_copy->spot, copy->speed); *ok = true; } } } void starset_entities_move_to_other(entities_t *entities, char *first , char *second) { entities_t *copy = entities; int ok = false; while (copy != NULL) { if (internal__test_class(first, copy->name)) { internal__sub_iterate_other(copy, entities, second, &ok); } copy = copy->next; } if (!ok && !!LOG) put_err("bad entities name in starset_entities_move_to_other\n"); } void starset_move_from_angle(entities_t *entities, char *name , float angle, int speed) { entities_t *copy = entities; char **get = internal__get_class(name); while (copy != NULL) { if (internal__test_class(name, copy->name)) { copy->spot.x += (float)speed * cos((angle / 57)); copy->spot.y += (float)speed * sin((angle / 57)); } copy = copy->next; } free_array(get); }
26.414894
78
0.58679
ae516b8e36caeb9dbd8b6ca656770e0e9b2b94ab
512
h
C
src/login/LoginViewController.h
kitefishlabs/iOSClient
f71a6be0d879692cd5658e9867d0ccec9155b201
[ "MIT" ]
1
2016-04-28T03:06:23.000Z
2016-04-28T03:06:23.000Z
src/login/LoginViewController.h
kitefishlabs/iOSClient
f71a6be0d879692cd5658e9867d0ccec9155b201
[ "MIT" ]
null
null
null
src/login/LoginViewController.h
kitefishlabs/iOSClient
f71a6be0d879692cd5658e9867d0ccec9155b201
[ "MIT" ]
null
null
null
// // LoginViewController.h // ARIS // // Created by Ben Longoria on 2/11/09. // Copyright 2009 University of Wisconsin. All rights reserved. // #import <UIKit/UIKit.h> @class Player; @protocol LoginViewControllerDelegate - (void) loginCredentialsApprovedForPlayer:(Player *)p toGame:(int)gameId newPlayer:(BOOL)newPlayer disableLeaveGame:(BOOL)disableLeaveGame; @end @interface LoginViewController : UIViewController - (id) initWithDelegate:(id<LoginViewControllerDelegate>)d; - (void) resetState; @end
24.380952
140
0.769531
1d039f3270087c06cc3c58e4e5f622f4b0efc287
120,289
c
C
nuitka/build/static_src/HelpersOperationBinaryAdd.c
mkoppanen/Nuitka
5f8285a452b9aaf8d5bdd44db00da06ddbb267dc
[ "Apache-2.0" ]
null
null
null
nuitka/build/static_src/HelpersOperationBinaryAdd.c
mkoppanen/Nuitka
5f8285a452b9aaf8d5bdd44db00da06ddbb267dc
[ "Apache-2.0" ]
null
null
null
nuitka/build/static_src/HelpersOperationBinaryAdd.c
mkoppanen/Nuitka
5f8285a452b9aaf8d5bdd44db00da06ddbb267dc
[ "Apache-2.0" ]
null
null
null
// Copyright 2019, Kay Hayen, mailto:kay.hayen@gmail.com // // Part of "Nuitka", an optimizing Python compiler that is compatible and // integrates with CPython, but also works on its own. // // 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. // /* WARNING, this code is GENERATED. Modify the template instead! */ #include "HelpersOperationBinaryAddUtils.c" /* C helpers for type specialized "+" (Add) operations */ #if PYTHON_VERSION < 300 /* Code referring to "INT" corresponds to Python2 'int'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_INT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyInt_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyInt_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyInt_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_INT_INT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyInt_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'int'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_INT_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyInt_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyInt_Type; binaryfunc slot1 = PyInt_Type.tp_as_number->nb_add; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_INT_INT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = PyInt_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'int' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_INT_INT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyInt_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyInt_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyInt_Type; binaryfunc slot1 = PyInt_Type.tp_as_number->nb_add; PyTypeObject *type2 = &PyInt_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyInt_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_INT_INT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!1 || !1) { coercion c = PyInt_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyInt_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'int' and 'int'"); return NULL; } #endif #if PYTHON_VERSION < 300 /* Code referring to "STR" corresponds to Python2 'str'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_STR(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyString_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyString_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_STR_STR(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 0) if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'str'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_STR_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyString_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyString_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_STR_STR(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 1) if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_STR_OBJECT(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyString_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'str' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_STR_STR(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyString_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyString_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyString_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = &PyString_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_STR_STR(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!1 || !1) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_STR_STR(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyString_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'str' and 'str'"); return NULL; } #endif /* Code referring to "UNICODE" corresponds to Python2 'unicode', Python3 'str'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyUnicode_CheckExact(operand2)); assert(NEW_STYLE_NUMBER(operand2)); PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyUnicode_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_UNICODE_UNICODE(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 0) if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'UNICODE'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyUnicode_CheckExact(operand1)); assert(NEW_STYLE_NUMBER(operand1)); CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyUnicode_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_UNICODE_UNICODE(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 1) if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_UNICODE_OBJECT(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyUnicode_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'UNICODE' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyUnicode_CheckExact(operand1)); assert(NEW_STYLE_NUMBER(operand1)); CHECK_OBJECT(operand2); assert(PyUnicode_CheckExact(operand2)); assert(NEW_STYLE_NUMBER(operand2)); PyTypeObject *type1 = &PyUnicode_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = &PyUnicode_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_UNICODE_UNICODE(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!1 || !1) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_UNICODE_UNICODE(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyUnicode_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'UNICODE' and 'UNICODE'"); return NULL; } /* Code referring to "FLOAT" corresponds to Python 'float'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyFloat_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyFloat_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyFloat_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_FLOAT_FLOAT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyFloat_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'float'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyFloat_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyFloat_Type; binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_add; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_FLOAT_FLOAT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = PyFloat_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'float' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyFloat_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyFloat_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyFloat_Type; binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_add; PyTypeObject *type2 = &PyFloat_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyFloat_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_FLOAT_FLOAT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!1 || !1) { coercion c = PyFloat_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyFloat_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'float' and 'float'"); return NULL; } /* Code referring to "TUPLE" corresponds to Python 'tuple'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyTuple_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyTuple_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_TUPLE_TUPLE(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 0) if (!NEW_STYLE_NUMBER_TYPE(type1) || !0) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'tuple'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyTuple_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyTuple_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_TUPLE_TUPLE(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 1) if (!0 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_TUPLE_OBJECT(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyTuple_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'tuple' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyTuple_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyTuple_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyTuple_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = &PyTuple_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_TUPLE_TUPLE(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!0 || !0) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_TUPLE_TUPLE(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyTuple_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'tuple' and 'tuple'"); return NULL; } /* Code referring to "LIST" corresponds to Python 'list'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_LIST(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyList_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyList_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_LIST_LIST(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 0) if (!NEW_STYLE_NUMBER_TYPE(type1) || !0) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'list'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_LIST_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyList_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyList_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_LIST_LIST(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 1) if (!0 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_LIST_OBJECT(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyList_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'list' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_LIST_LIST(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyList_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyList_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyList_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = &PyList_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_LIST_LIST(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!0 || !0) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_LIST_LIST(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyList_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'list' and 'list'"); return NULL; } #if PYTHON_VERSION >= 300 /* Code referring to "BYTES" corresponds to Python3 'bytes'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyBytes_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyBytes_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_BYTES_BYTES(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 0) if (!NEW_STYLE_NUMBER_TYPE(type1) || !0) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'bytes'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyBytes_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyBytes_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_BYTES_BYTES(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 1) if (!0 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_BYTES_OBJECT(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyBytes_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'bytes' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_BYTES_BYTES(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyBytes_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyBytes_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(!NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyBytes_Type; binaryfunc slot1 = NULL; PyTypeObject *type2 = &PyBytes_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_sq_concat_BYTES_BYTES(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!0 || !0) { coercion c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif return SLOT_sq_concat_BYTES_BYTES(operand1, operand2); // Special case for "+", also works as sequence concat. binaryfunc slot3 = PyBytes_Type.tp_as_sequence->sq_concat; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'bytes' and 'bytes'"); return NULL; } #endif /* Code referring to "LONG" corresponds to Python2 'long', Python3 'int'. */ PyObject *BINARY_OPERATION_ADD_OBJECT_LONG(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); assert(PyLong_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = &PyLong_Type; binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyLong_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_LONG_LONG(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyLong_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and 'long'", type1->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_LONG_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyLong_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); PyTypeObject *type1 = &PyLong_Type; binaryfunc slot1 = PyLong_Type.tp_as_number->nb_add; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_LONG_LONG(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = PyLong_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'long' and '%s'", type2->tp_name); return NULL; } PyObject *BINARY_OPERATION_ADD_LONG_LONG(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyLong_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyLong_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyLong_Type; binaryfunc slot1 = PyLong_Type.tp_as_number->nb_add; PyTypeObject *type2 = &PyLong_Type; binaryfunc slot2 = NULL; if (!(1)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyLong_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_LONG_LONG(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (0 || 0) if (!1 || !1) { coercion c = PyLong_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyLong_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'long' and 'long'"); return NULL; } PyObject *BINARY_OPERATION_ADD_FLOAT_LONG(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyFloat_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyLong_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyFloat_Type; binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_add; PyTypeObject *type2 = &PyLong_Type; binaryfunc slot2 = NULL; if (!(0)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyLong_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_FLOAT_FLOAT(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!1 || !1) { coercion c = PyFloat_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyLong_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'float' and 'long'"); return NULL; } PyObject *BINARY_OPERATION_ADD_LONG_FLOAT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); assert(PyLong_CheckExact(operand1)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand1)); #endif CHECK_OBJECT(operand2); assert(PyFloat_CheckExact(operand2)); #if PYTHON_VERSION < 300 assert(NEW_STYLE_NUMBER(operand2)); #endif PyTypeObject *type1 = &PyLong_Type; binaryfunc slot1 = PyLong_Type.tp_as_number->nb_add; PyTypeObject *type2 = &PyFloat_Type; binaryfunc slot2 = NULL; if (!(0)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = PyFloat_Type.tp_as_number->nb_add; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); return SLOT_nb_add_LONG_LONG(operand1, operand2); } if (slot1 != NULL) { if (slot2 != NULL) { if (0) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!1 || !1) { coercion c = PyLong_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = PyFloat_Type.tp_as_number->nb_coerce; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: 'long' and 'float'"); return NULL; } /* Code referring to "OBJECT" corresponds to Any Python object. */ PyObject *BINARY_OPERATION_ADD_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) { CHECK_OBJECT(operand1); CHECK_OBJECT(operand2); PyTypeObject *type1 = Py_TYPE(operand1); binaryfunc slot1 = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_add : NULL; PyTypeObject *type2 = Py_TYPE(operand2); binaryfunc slot2 = NULL; if (!(type1 == type2)) { assert(type1 != type2); /* Different types, need to consider second value slot. */ slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_add : NULL; if (slot1 == slot2) { slot2 = NULL; } } else { assert(type1 == type2); } if (slot1 != NULL) { if (slot2 != NULL) { if (PyType_IsSubtype(type2, type1)) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); slot2 = NULL; } } PyObject *x = slot1(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } if (slot2 != NULL) { PyObject *x = slot2(operand1, operand2); if (x != Py_NotImplemented) { if (unlikely(x == NULL)) { return NULL; } return x; } Py_DECREF(x); } #if PYTHON_VERSION < 300 && (1 || 1) if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) { coercion c = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced1, &coerced2); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } c = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL; if (c != NULL) { PyObject *coerced1 = operand1; PyObject *coerced2 = operand2; int err = c(&coerced2, &coerced1); if (unlikely(err < 0)) { return NULL; } if (err == 0) { PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number; if (likely(mv == NULL)) { binaryfunc slot = mv->nb_add; if (likely(slot != NULL)) { PyObject *x = slot(coerced1, coerced2); Py_DECREF(coerced1); Py_DECREF(coerced2); if (unlikely(x == NULL)) { return NULL; } return x; } } // nb_coerce took a reference. Py_DECREF(coerced1); Py_DECREF(coerced2); } } } #endif // Special case for "+", also works as sequence concat. binaryfunc slot3 = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_concat : NULL; if (slot3 != NULL) { PyObject *result = slot3(operand1, operand2); if (unlikely(result == NULL)) { return NULL; } return result; } PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for +: '%s' and '%s'", type1->tp_name, type2->tp_name); return NULL; }
25.517395
118
0.456077
d9f7c2b8fedcfb3271075f57755795d0ef9d5671
216
c
C
test/small/func1.c
chrisvrose/deputy-old-mirror
657350639cfd358ff14090d31813473885c44c7e
[ "BSD-3-Clause" ]
null
null
null
test/small/func1.c
chrisvrose/deputy-old-mirror
657350639cfd358ff14090d31813473885c44c7e
[ "BSD-3-Clause" ]
null
null
null
test/small/func1.c
chrisvrose/deputy-old-mirror
657350639cfd358ff14090d31813473885c44c7e
[ "BSD-3-Clause" ]
null
null
null
int foo(int * COUNT(n), int n); // Now change the name of the variables. We must handle this gracefully. int foo(int * COUNT(m) p, int m) { p[2] = 1; } int main() { int buff[8]; foo(buff, 8); return 0; }
14.4
72
0.592593
a828ba809bd7de754f0944ec76241fe1ac411657
23,062
h
C
aws-cpp-sdk-connect/include/aws/connect/model/Contact.h
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2022-02-12T08:09:30.000Z
2022-02-12T08:09:30.000Z
aws-cpp-sdk-connect/include/aws/connect/model/Contact.h
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-connect/include/aws/connect/model/Contact.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2021-11-09T11:58:03.000Z
2021-11-09T11:58:03.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/connect/Connect_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/connect/model/ContactInitiationMethod.h> #include <aws/connect/model/Channel.h> #include <aws/connect/model/QueueInfo.h> #include <aws/connect/model/AgentInfo.h> #include <aws/core/utils/DateTime.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace Connect { namespace Model { /** * <p>Contains information about a contact.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/connect-2017-08-08/Contact">AWS API * Reference</a></p> */ class AWS_CONNECT_API Contact { public: Contact(); Contact(Aws::Utils::Json::JsonView jsonValue); Contact& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline const Aws::String& GetArn() const{ return m_arn; } /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline bool ArnHasBeenSet() const { return m_arnHasBeenSet; } /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline void SetArn(const Aws::String& value) { m_arnHasBeenSet = true; m_arn = value; } /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline void SetArn(Aws::String&& value) { m_arnHasBeenSet = true; m_arn = std::move(value); } /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline void SetArn(const char* value) { m_arnHasBeenSet = true; m_arn.assign(value); } /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline Contact& WithArn(const Aws::String& value) { SetArn(value); return *this;} /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline Contact& WithArn(Aws::String&& value) { SetArn(std::move(value)); return *this;} /** * <p>The Amazon Resource Name (ARN) for the contact.</p> */ inline Contact& WithArn(const char* value) { SetArn(value); return *this;} /** * <p>The identifier for the contact.</p> */ inline const Aws::String& GetId() const{ return m_id; } /** * <p>The identifier for the contact.</p> */ inline bool IdHasBeenSet() const { return m_idHasBeenSet; } /** * <p>The identifier for the contact.</p> */ inline void SetId(const Aws::String& value) { m_idHasBeenSet = true; m_id = value; } /** * <p>The identifier for the contact.</p> */ inline void SetId(Aws::String&& value) { m_idHasBeenSet = true; m_id = std::move(value); } /** * <p>The identifier for the contact.</p> */ inline void SetId(const char* value) { m_idHasBeenSet = true; m_id.assign(value); } /** * <p>The identifier for the contact.</p> */ inline Contact& WithId(const Aws::String& value) { SetId(value); return *this;} /** * <p>The identifier for the contact.</p> */ inline Contact& WithId(Aws::String&& value) { SetId(std::move(value)); return *this;} /** * <p>The identifier for the contact.</p> */ inline Contact& WithId(const char* value) { SetId(value); return *this;} /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline const Aws::String& GetInitialContactId() const{ return m_initialContactId; } /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline bool InitialContactIdHasBeenSet() const { return m_initialContactIdHasBeenSet; } /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline void SetInitialContactId(const Aws::String& value) { m_initialContactIdHasBeenSet = true; m_initialContactId = value; } /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline void SetInitialContactId(Aws::String&& value) { m_initialContactIdHasBeenSet = true; m_initialContactId = std::move(value); } /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline void SetInitialContactId(const char* value) { m_initialContactIdHasBeenSet = true; m_initialContactId.assign(value); } /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline Contact& WithInitialContactId(const Aws::String& value) { SetInitialContactId(value); return *this;} /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline Contact& WithInitialContactId(Aws::String&& value) { SetInitialContactId(std::move(value)); return *this;} /** * <p>If this contact is related to other contacts, this is the ID of the initial * contact.</p> */ inline Contact& WithInitialContactId(const char* value) { SetInitialContactId(value); return *this;} /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline const Aws::String& GetPreviousContactId() const{ return m_previousContactId; } /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline bool PreviousContactIdHasBeenSet() const { return m_previousContactIdHasBeenSet; } /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline void SetPreviousContactId(const Aws::String& value) { m_previousContactIdHasBeenSet = true; m_previousContactId = value; } /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline void SetPreviousContactId(Aws::String&& value) { m_previousContactIdHasBeenSet = true; m_previousContactId = std::move(value); } /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline void SetPreviousContactId(const char* value) { m_previousContactIdHasBeenSet = true; m_previousContactId.assign(value); } /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline Contact& WithPreviousContactId(const Aws::String& value) { SetPreviousContactId(value); return *this;} /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline Contact& WithPreviousContactId(Aws::String&& value) { SetPreviousContactId(std::move(value)); return *this;} /** * <p>If this contact is not the first contact, this is the ID of the previous * contact.</p> */ inline Contact& WithPreviousContactId(const char* value) { SetPreviousContactId(value); return *this;} /** * <p>Indicates how the contact was initiated.</p> */ inline const ContactInitiationMethod& GetInitiationMethod() const{ return m_initiationMethod; } /** * <p>Indicates how the contact was initiated.</p> */ inline bool InitiationMethodHasBeenSet() const { return m_initiationMethodHasBeenSet; } /** * <p>Indicates how the contact was initiated.</p> */ inline void SetInitiationMethod(const ContactInitiationMethod& value) { m_initiationMethodHasBeenSet = true; m_initiationMethod = value; } /** * <p>Indicates how the contact was initiated.</p> */ inline void SetInitiationMethod(ContactInitiationMethod&& value) { m_initiationMethodHasBeenSet = true; m_initiationMethod = std::move(value); } /** * <p>Indicates how the contact was initiated.</p> */ inline Contact& WithInitiationMethod(const ContactInitiationMethod& value) { SetInitiationMethod(value); return *this;} /** * <p>Indicates how the contact was initiated.</p> */ inline Contact& WithInitiationMethod(ContactInitiationMethod&& value) { SetInitiationMethod(std::move(value)); return *this;} /** * <p>The name of the contact.</p> */ inline const Aws::String& GetName() const{ return m_name; } /** * <p>The name of the contact.</p> */ inline bool NameHasBeenSet() const { return m_nameHasBeenSet; } /** * <p>The name of the contact.</p> */ inline void SetName(const Aws::String& value) { m_nameHasBeenSet = true; m_name = value; } /** * <p>The name of the contact.</p> */ inline void SetName(Aws::String&& value) { m_nameHasBeenSet = true; m_name = std::move(value); } /** * <p>The name of the contact.</p> */ inline void SetName(const char* value) { m_nameHasBeenSet = true; m_name.assign(value); } /** * <p>The name of the contact.</p> */ inline Contact& WithName(const Aws::String& value) { SetName(value); return *this;} /** * <p>The name of the contact.</p> */ inline Contact& WithName(Aws::String&& value) { SetName(std::move(value)); return *this;} /** * <p>The name of the contact.</p> */ inline Contact& WithName(const char* value) { SetName(value); return *this;} /** * <p>The description of the contact.</p> */ inline const Aws::String& GetDescription() const{ return m_description; } /** * <p>The description of the contact.</p> */ inline bool DescriptionHasBeenSet() const { return m_descriptionHasBeenSet; } /** * <p>The description of the contact.</p> */ inline void SetDescription(const Aws::String& value) { m_descriptionHasBeenSet = true; m_description = value; } /** * <p>The description of the contact.</p> */ inline void SetDescription(Aws::String&& value) { m_descriptionHasBeenSet = true; m_description = std::move(value); } /** * <p>The description of the contact.</p> */ inline void SetDescription(const char* value) { m_descriptionHasBeenSet = true; m_description.assign(value); } /** * <p>The description of the contact.</p> */ inline Contact& WithDescription(const Aws::String& value) { SetDescription(value); return *this;} /** * <p>The description of the contact.</p> */ inline Contact& WithDescription(Aws::String&& value) { SetDescription(std::move(value)); return *this;} /** * <p>The description of the contact.</p> */ inline Contact& WithDescription(const char* value) { SetDescription(value); return *this;} /** * <p>How the contact reached your contact center.</p> */ inline const Channel& GetChannel() const{ return m_channel; } /** * <p>How the contact reached your contact center.</p> */ inline bool ChannelHasBeenSet() const { return m_channelHasBeenSet; } /** * <p>How the contact reached your contact center.</p> */ inline void SetChannel(const Channel& value) { m_channelHasBeenSet = true; m_channel = value; } /** * <p>How the contact reached your contact center.</p> */ inline void SetChannel(Channel&& value) { m_channelHasBeenSet = true; m_channel = std::move(value); } /** * <p>How the contact reached your contact center.</p> */ inline Contact& WithChannel(const Channel& value) { SetChannel(value); return *this;} /** * <p>How the contact reached your contact center.</p> */ inline Contact& WithChannel(Channel&& value) { SetChannel(std::move(value)); return *this;} /** * <p>If this contact was queued, this contains information about the queue. </p> */ inline const QueueInfo& GetQueueInfo() const{ return m_queueInfo; } /** * <p>If this contact was queued, this contains information about the queue. </p> */ inline bool QueueInfoHasBeenSet() const { return m_queueInfoHasBeenSet; } /** * <p>If this contact was queued, this contains information about the queue. </p> */ inline void SetQueueInfo(const QueueInfo& value) { m_queueInfoHasBeenSet = true; m_queueInfo = value; } /** * <p>If this contact was queued, this contains information about the queue. </p> */ inline void SetQueueInfo(QueueInfo&& value) { m_queueInfoHasBeenSet = true; m_queueInfo = std::move(value); } /** * <p>If this contact was queued, this contains information about the queue. </p> */ inline Contact& WithQueueInfo(const QueueInfo& value) { SetQueueInfo(value); return *this;} /** * <p>If this contact was queued, this contains information about the queue. </p> */ inline Contact& WithQueueInfo(QueueInfo&& value) { SetQueueInfo(std::move(value)); return *this;} /** * <p>Information about the agent who accepted the contact.</p> */ inline const AgentInfo& GetAgentInfo() const{ return m_agentInfo; } /** * <p>Information about the agent who accepted the contact.</p> */ inline bool AgentInfoHasBeenSet() const { return m_agentInfoHasBeenSet; } /** * <p>Information about the agent who accepted the contact.</p> */ inline void SetAgentInfo(const AgentInfo& value) { m_agentInfoHasBeenSet = true; m_agentInfo = value; } /** * <p>Information about the agent who accepted the contact.</p> */ inline void SetAgentInfo(AgentInfo&& value) { m_agentInfoHasBeenSet = true; m_agentInfo = std::move(value); } /** * <p>Information about the agent who accepted the contact.</p> */ inline Contact& WithAgentInfo(const AgentInfo& value) { SetAgentInfo(value); return *this;} /** * <p>Information about the agent who accepted the contact.</p> */ inline Contact& WithAgentInfo(AgentInfo&& value) { SetAgentInfo(std::move(value)); return *this;} /** * <p>The date and time this contact was initiated, in UTC time. For * <code>INBOUND</code>, this is when the contact arrived. For * <code>OUTBOUND</code>, this is when the agent began dialing. For * <code>CALLBACK</code>, this is when the callback contact was created. For * <code>TRANSFER</code> and <code>QUEUE_TRANSFER</code>, this is when the transfer * was initiated. For <code>API</code>, this is when the request arrived.</p> */ inline const Aws::Utils::DateTime& GetInitiationTimestamp() const{ return m_initiationTimestamp; } /** * <p>The date and time this contact was initiated, in UTC time. For * <code>INBOUND</code>, this is when the contact arrived. For * <code>OUTBOUND</code>, this is when the agent began dialing. For * <code>CALLBACK</code>, this is when the callback contact was created. For * <code>TRANSFER</code> and <code>QUEUE_TRANSFER</code>, this is when the transfer * was initiated. For <code>API</code>, this is when the request arrived.</p> */ inline bool InitiationTimestampHasBeenSet() const { return m_initiationTimestampHasBeenSet; } /** * <p>The date and time this contact was initiated, in UTC time. For * <code>INBOUND</code>, this is when the contact arrived. For * <code>OUTBOUND</code>, this is when the agent began dialing. For * <code>CALLBACK</code>, this is when the callback contact was created. For * <code>TRANSFER</code> and <code>QUEUE_TRANSFER</code>, this is when the transfer * was initiated. For <code>API</code>, this is when the request arrived.</p> */ inline void SetInitiationTimestamp(const Aws::Utils::DateTime& value) { m_initiationTimestampHasBeenSet = true; m_initiationTimestamp = value; } /** * <p>The date and time this contact was initiated, in UTC time. For * <code>INBOUND</code>, this is when the contact arrived. For * <code>OUTBOUND</code>, this is when the agent began dialing. For * <code>CALLBACK</code>, this is when the callback contact was created. For * <code>TRANSFER</code> and <code>QUEUE_TRANSFER</code>, this is when the transfer * was initiated. For <code>API</code>, this is when the request arrived.</p> */ inline void SetInitiationTimestamp(Aws::Utils::DateTime&& value) { m_initiationTimestampHasBeenSet = true; m_initiationTimestamp = std::move(value); } /** * <p>The date and time this contact was initiated, in UTC time. For * <code>INBOUND</code>, this is when the contact arrived. For * <code>OUTBOUND</code>, this is when the agent began dialing. For * <code>CALLBACK</code>, this is when the callback contact was created. For * <code>TRANSFER</code> and <code>QUEUE_TRANSFER</code>, this is when the transfer * was initiated. For <code>API</code>, this is when the request arrived.</p> */ inline Contact& WithInitiationTimestamp(const Aws::Utils::DateTime& value) { SetInitiationTimestamp(value); return *this;} /** * <p>The date and time this contact was initiated, in UTC time. For * <code>INBOUND</code>, this is when the contact arrived. For * <code>OUTBOUND</code>, this is when the agent began dialing. For * <code>CALLBACK</code>, this is when the callback contact was created. For * <code>TRANSFER</code> and <code>QUEUE_TRANSFER</code>, this is when the transfer * was initiated. For <code>API</code>, this is when the request arrived.</p> */ inline Contact& WithInitiationTimestamp(Aws::Utils::DateTime&& value) { SetInitiationTimestamp(std::move(value)); return *this;} /** * <p>The timestamp when the customer endpoint disconnected from Amazon * Connect.</p> */ inline const Aws::Utils::DateTime& GetDisconnectTimestamp() const{ return m_disconnectTimestamp; } /** * <p>The timestamp when the customer endpoint disconnected from Amazon * Connect.</p> */ inline bool DisconnectTimestampHasBeenSet() const { return m_disconnectTimestampHasBeenSet; } /** * <p>The timestamp when the customer endpoint disconnected from Amazon * Connect.</p> */ inline void SetDisconnectTimestamp(const Aws::Utils::DateTime& value) { m_disconnectTimestampHasBeenSet = true; m_disconnectTimestamp = value; } /** * <p>The timestamp when the customer endpoint disconnected from Amazon * Connect.</p> */ inline void SetDisconnectTimestamp(Aws::Utils::DateTime&& value) { m_disconnectTimestampHasBeenSet = true; m_disconnectTimestamp = std::move(value); } /** * <p>The timestamp when the customer endpoint disconnected from Amazon * Connect.</p> */ inline Contact& WithDisconnectTimestamp(const Aws::Utils::DateTime& value) { SetDisconnectTimestamp(value); return *this;} /** * <p>The timestamp when the customer endpoint disconnected from Amazon * Connect.</p> */ inline Contact& WithDisconnectTimestamp(Aws::Utils::DateTime&& value) { SetDisconnectTimestamp(std::move(value)); return *this;} /** * <p>The timestamp when contact was last updated.</p> */ inline const Aws::Utils::DateTime& GetLastUpdateTimestamp() const{ return m_lastUpdateTimestamp; } /** * <p>The timestamp when contact was last updated.</p> */ inline bool LastUpdateTimestampHasBeenSet() const { return m_lastUpdateTimestampHasBeenSet; } /** * <p>The timestamp when contact was last updated.</p> */ inline void SetLastUpdateTimestamp(const Aws::Utils::DateTime& value) { m_lastUpdateTimestampHasBeenSet = true; m_lastUpdateTimestamp = value; } /** * <p>The timestamp when contact was last updated.</p> */ inline void SetLastUpdateTimestamp(Aws::Utils::DateTime&& value) { m_lastUpdateTimestampHasBeenSet = true; m_lastUpdateTimestamp = std::move(value); } /** * <p>The timestamp when contact was last updated.</p> */ inline Contact& WithLastUpdateTimestamp(const Aws::Utils::DateTime& value) { SetLastUpdateTimestamp(value); return *this;} /** * <p>The timestamp when contact was last updated.</p> */ inline Contact& WithLastUpdateTimestamp(Aws::Utils::DateTime&& value) { SetLastUpdateTimestamp(std::move(value)); return *this;} /** * <p>The timestamp, in Unix epoch time format, at which to start running the * inbound flow. </p> */ inline const Aws::Utils::DateTime& GetScheduledTimestamp() const{ return m_scheduledTimestamp; } /** * <p>The timestamp, in Unix epoch time format, at which to start running the * inbound flow. </p> */ inline bool ScheduledTimestampHasBeenSet() const { return m_scheduledTimestampHasBeenSet; } /** * <p>The timestamp, in Unix epoch time format, at which to start running the * inbound flow. </p> */ inline void SetScheduledTimestamp(const Aws::Utils::DateTime& value) { m_scheduledTimestampHasBeenSet = true; m_scheduledTimestamp = value; } /** * <p>The timestamp, in Unix epoch time format, at which to start running the * inbound flow. </p> */ inline void SetScheduledTimestamp(Aws::Utils::DateTime&& value) { m_scheduledTimestampHasBeenSet = true; m_scheduledTimestamp = std::move(value); } /** * <p>The timestamp, in Unix epoch time format, at which to start running the * inbound flow. </p> */ inline Contact& WithScheduledTimestamp(const Aws::Utils::DateTime& value) { SetScheduledTimestamp(value); return *this;} /** * <p>The timestamp, in Unix epoch time format, at which to start running the * inbound flow. </p> */ inline Contact& WithScheduledTimestamp(Aws::Utils::DateTime&& value) { SetScheduledTimestamp(std::move(value)); return *this;} private: Aws::String m_arn; bool m_arnHasBeenSet; Aws::String m_id; bool m_idHasBeenSet; Aws::String m_initialContactId; bool m_initialContactIdHasBeenSet; Aws::String m_previousContactId; bool m_previousContactIdHasBeenSet; ContactInitiationMethod m_initiationMethod; bool m_initiationMethodHasBeenSet; Aws::String m_name; bool m_nameHasBeenSet; Aws::String m_description; bool m_descriptionHasBeenSet; Channel m_channel; bool m_channelHasBeenSet; QueueInfo m_queueInfo; bool m_queueInfoHasBeenSet; AgentInfo m_agentInfo; bool m_agentInfoHasBeenSet; Aws::Utils::DateTime m_initiationTimestamp; bool m_initiationTimestampHasBeenSet; Aws::Utils::DateTime m_disconnectTimestamp; bool m_disconnectTimestampHasBeenSet; Aws::Utils::DateTime m_lastUpdateTimestamp; bool m_lastUpdateTimestampHasBeenSet; Aws::Utils::DateTime m_scheduledTimestamp; bool m_scheduledTimestampHasBeenSet; }; } // namespace Model } // namespace Connect } // namespace Aws
35.810559
154
0.662258
a3191570a720d13e04138d6c377c88cbeaab6e7e
602
h
C
pushquickview.h
net147/Push2Qml
a89b9b573312164ed670ac5e1fc0dd4ee3c5de58
[ "MIT" ]
21
2015-12-16T22:44:01.000Z
2022-01-03T03:10:39.000Z
pushquickview.h
net147/Push2Qml
a89b9b573312164ed670ac5e1fc0dd4ee3c5de58
[ "MIT" ]
1
2018-12-10T23:14:26.000Z
2018-12-11T12:16:59.000Z
pushquickview.h
net147/Push2Qml
a89b9b573312164ed670ac5e1fc0dd4ee3c5de58
[ "MIT" ]
2
2016-12-01T10:24:40.000Z
2018-11-11T20:12:27.000Z
#ifndef PUSHQUICKVIEW_H #define PUSHQUICKVIEW_H #include "fboquickview.h" #include <QScopedPointer> class PushQuickViewPrivate; class PushQuickView : public FboQuickView { Q_OBJECT Q_DECLARE_PRIVATE(PushQuickView) Q_PROPERTY(bool dithering READ dithering WRITE setDithering NOTIFY ditheringChanged) public: PushQuickView(const QUrl &url); ~PushQuickView(); bool isOpen() const; bool dithering() const; void setDithering(bool value); signals: void ditheringChanged(); private: const QScopedPointer<PushQuickViewPrivate> d_ptr; }; #endif // PUSHQUICKVIEW_H
20.066667
88
0.759136
b49bad7d307886df78ce9c64c1b4b32f420f0856
892
h
C
Wangscape/noise/module/codecs/NoiseQualityCodec.h
cheukyin699/Wangscape
b01cb310f97e33394c1c0fac23a7f40c34f632cf
[ "MIT" ]
60
2016-12-30T03:18:34.000Z
2022-02-15T21:43:59.000Z
Wangscape/noise/module/codecs/NoiseQualityCodec.h
cheukyin699/Wangscape
b01cb310f97e33394c1c0fac23a7f40c34f632cf
[ "MIT" ]
149
2016-12-29T19:38:36.000Z
2017-10-29T18:19:51.000Z
Wangscape/noise/module/codecs/NoiseQualityCodec.h
cheukyin699/Wangscape
b01cb310f97e33394c1c0fac23a7f40c34f632cf
[ "MIT" ]
16
2016-12-31T06:09:42.000Z
2021-09-10T05:34:51.000Z
#pragma once #include <spotify/json.hpp> #include <noise/noise.h> namespace spotify { namespace json { template<> struct default_codec_t<noise::NoiseQuality> { using NoiseQuality = noise::NoiseQuality; static codec::one_of_t< codec::enumeration_t<NoiseQuality, codec::number_t<int>>, codec::enumeration_t<NoiseQuality, codec::string_t>> codec() { auto codec_str = codec::enumeration<NoiseQuality, std::string>({ {NoiseQuality::QUALITY_FAST, "Fast"}, {NoiseQuality::QUALITY_STD, "Standard"}, {NoiseQuality::QUALITY_BEST, "Best"} }); auto codec_int = codec::enumeration<NoiseQuality, int>({ {NoiseQuality::QUALITY_FAST, 0}, {NoiseQuality::QUALITY_STD, 1}, {NoiseQuality::QUALITY_BEST, 2} }); return codec::one_of(codec_int, codec_str); } }; } }
24.777778
72
0.628924
33113a519d004b520dc15ff0c4c99e3636b1379b
1,336
h
C
RTAPI/RTstruct.h
RuinedStar/RayTracingIntegration
822ac95fb3f5aa2aa1172e813baa5a205b168450
[ "MIT" ]
null
null
null
RTAPI/RTstruct.h
RuinedStar/RayTracingIntegration
822ac95fb3f5aa2aa1172e813baa5a205b168450
[ "MIT" ]
null
null
null
RTAPI/RTstruct.h
RuinedStar/RayTracingIntegration
822ac95fb3f5aa2aa1172e813baa5a205b168450
[ "MIT" ]
null
null
null
#pragma once //emissive, diffuse, dielectric (palstic), mirror typedef enum { EMIS, DIFF, DIELEC, MIRR } BRDFType; //for host #ifndef __OPENCL_C_VERSION__ #include <glm\glm.hpp> typedef glm::vec4 float4; //for device #else typedef enum { MISS, LIGHT, TRI, SPH } PrimType; #endif #if defined(_MSC_VER) #define _CL_ALIGNED_(x) alignas(x) #else #define _CL_ALIGNED_(x) #endif #define CL_VEC4_ALIGN _CL_ALIGNED_(16) typedef struct PinholeCamera { CL_VEC4_ALIGN float4 pos; CL_VEC4_ALIGN float4 ulViewPos; //upper left corner on rendering image CL_VEC4_ALIGN float4 dxUnit; CL_VEC4_ALIGN float4 dyUnit; } PinholeCamera; typedef struct __Info { int tri_SIZE; //triangle size int pl_SIZE; //point light int samples; int maxdepth; int light_enable; //1 enable, 0 disable } Info; typedef struct __Material { CL_VEC4_ALIGN float4 color; float rIndex; //refractive index } Material; typedef struct __Triangle { BRDFType brdf_type; //emissive, diffuse, dielec, mirror CL_VEC4_ALIGN float4 v0, v1, v2; //vertex CL_VEC4_ALIGN float4 n0, n1, n2; //normal Material m0, m1, m2; } Triangle; typedef struct __Sphere { CL_VEC4_ALIGN float4 ori; float radius; Material mat; } Sphere; typedef struct __SphereLight { CL_VEC4_ALIGN float4 ori; Material mat; float radius; int enable; } SphereLight;
19.085714
71
0.741766
9887002b0c2c4c9c404c3e6b4acece0b0d642f89
2,725
h
C
OpenFeint/api/internal/Systems/AuroraLib/Kernel/Network/HTTP/OFHttpRequest.h
zichuanwang/TanChess_iOS
cbf2edbc90ea9a7d9dcbfec22664514754aadb4d
[ "Zlib", "MIT" ]
1
2016-06-15T18:03:45.000Z
2016-06-15T18:03:45.000Z
OpenFeint/api/internal/Systems/AuroraLib/Kernel/Network/HTTP/OFHttpRequest.h
zichuanwang/TanChess_iOS
cbf2edbc90ea9a7d9dcbfec22664514754aadb4d
[ "Zlib", "MIT" ]
null
null
null
OpenFeint/api/internal/Systems/AuroraLib/Kernel/Network/HTTP/OFHttpRequest.h
zichuanwang/TanChess_iOS
cbf2edbc90ea9a7d9dcbfec22664514754aadb4d
[ "Zlib", "MIT" ]
null
null
null
// Copyright 2009-2010 Aurora Feint, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #import <UIKit/UIKit.h> class OFHttpRequestObserver; // If these are declared as static const, we get tons of "defined but not used" warnings #define HttpMethodPost @"POST" #define HttpMethodGet @"GET" #define HttpMethodPut @"PUT" #define HttpMethodDelete @"DELETE" @interface OFHttpRequest : NSObject { NSString* mRequestPath; NSString* mRequestMethod; NSHTTPURLResponse* mHttpResponse; NSMutableData* mReceivedData; NSURLConnection* mURLConnection; NSString* mBaseUrl; OFRetainedPtr<NSString> mPassword; OFRetainedPtr<NSString> mEmail; bool mIsRequestInProgress; OFHttpRequestObserver* mObserver; bool mHandleCookies; } + (id)httpRequestWithBase:(NSString*)urlBase withObserver:(OFHttpRequestObserver*)observer; + (id)httpRequestWithBase:(NSString*)urlBase withObserver:(OFHttpRequestObserver*)observer withCookies:(bool)cookies; - (id)initWithBaseUrl:(NSString*)url withObserver:(OFHttpRequestObserver*)observer; - (id)initWithBaseUrl:(NSString*)url withObserver:(OFHttpRequestObserver*)observer withCookies:(bool)cookies; - (void)startRequestWithPath:(NSString*)path withMethod:(NSString*)httpMethod withBody:(NSData*)httpBody; - (void)startRequestWithPath:(NSString*)path withMethod:(NSString*)httpMethod withBody:(NSData*)httpBody withEmail:(NSString*)email withPassword:(NSString*)password multiPartBoundary:(NSString*)multiPartBoundary; - (void)changeObserver:(OFHttpRequestObserver*)newObserver; - (void)cancelImmediately; + (bool)hasCookies:urlBase; + (int)countCookies:urlBase; + (NSArray*)getCookies:urlBase; + (void)addCookies:(NSArray*)cookies withBase:urlBase; - (bool)hasCookies; - (int)countCookies; - (NSArray*)getCookies; - (void)addCookies:(NSArray*)cookies; - (NSHTTPURLResponse*)getResponse; @property(nonatomic, readonly) NSString* urlPath; @property(nonatomic, readonly) NSString* httpMethod; @property(nonatomic, readonly) NSURLConnection* url; @property(nonatomic, readonly) NSData* data; @property(nonatomic, readonly) NSString* contentType; @property(nonatomic, readonly) NSString* contentDisposition; - (void)_releaseConnectionResources; @end
36.824324
212
0.784587
debe9f95daa80fdfeaa33898a2f277d9ac9ed390
2,265
h
C
weex_core/Source/android/jsengine/dependence/bmalloc/bmalloc/List.h
sunshl/incubator-weex
40ae49e40c3dd725d6c546451075bd6e90001c9d
[ "Apache-2.0" ]
2
2017-10-18T01:36:31.000Z
2018-05-07T23:00:21.000Z
weex_core/Source/android/jsengine/dependence/bmalloc/bmalloc/List.h
sunshl/incubator-weex
40ae49e40c3dd725d6c546451075bd6e90001c9d
[ "Apache-2.0" ]
null
null
null
weex_core/Source/android/jsengine/dependence/bmalloc/bmalloc/List.h
sunshl/incubator-weex
40ae49e40c3dd725d6c546451075bd6e90001c9d
[ "Apache-2.0" ]
5
2019-05-28T11:48:42.000Z
2020-05-15T07:31:55.000Z
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef List_h #define List_h namespace bmalloc { template<typename T> struct ListNode { ListNode() : prev(this) , next(this) { } ListNode<T>* prev; ListNode<T>* next; }; template<typename T> class List { static_assert(std::is_trivially_destructible<T>::value, "List must have a trivial destructor."); public: bool isEmpty() { return m_root.next == &m_root; } T* head() { return static_cast<T*>(m_root.next); } T* tail() { return static_cast<T*>(m_root.prev); } void push(T* node) { ListNode<T>* it = tail(); insertAfter(it, node); } T* pop() { ListNode<T>* result = tail(); remove(result); return static_cast<T*>(result); } T* popFront() { ListNode<T>* result = head(); remove(result); return static_cast<T*>(result); } void insertAfter(ListNode<T>* it, ListNode<T>* node) { ListNode<T>* prev = it; ListNode<T>* next = it->next; node->next = next; next->prev = node; node->prev = prev; prev->next = node; } void remove(ListNode<T>* node) { ListNode<T>* next = node->next; ListNode<T>* prev = node->prev; next->prev = prev; prev->next = next; node->prev = node; node->next = node; } private: ListNode<T> m_root; }; } // namespace bmalloc #endif // List_h
23.59375
100
0.612362
7247394162c8ee72f7d638c264f7b5fd79968176
1,162
h
C
packages/repack/ios/ChunkConfig.h
blitzstudios/repack
b3f28e830f0c7997d5a0a455323ccd4539db8af0
[ "MIT" ]
587
2021-06-16T15:27:27.000Z
2022-03-31T17:47:36.000Z
packages/repack/ios/ChunkConfig.h
blitzstudios/repack
b3f28e830f0c7997d5a0a455323ccd4539db8af0
[ "MIT" ]
67
2021-06-16T23:19:43.000Z
2022-03-21T11:40:02.000Z
packages/repack/ios/ChunkConfig.h
blitzstudios/repack
b3f28e830f0c7997d5a0a455323ccd4539db8af0
[ "MIT" ]
33
2021-07-05T07:08:39.000Z
2022-03-29T07:29:32.000Z
#ifndef ChunkConfig_h #define ChunkConfig_h @interface ChunkConfig : NSObject @property (readonly, nonnull) NSString *chunkId; @property (readonly, nonnull) NSURL *url; @property (readonly, nonnull) NSString *method; @property (readonly, nullable) NSString *query; @property (readonly) BOOL fetch; @property (readonly) BOOL absolute; @property (readonly, nullable) NSData *body; @property (readonly, nullable) NSDictionary *headers; @property (readonly, nonnull) NSNumber *timeout; + (nonnull ChunkConfig *)fromConfigDictionary:(nonnull NSDictionary *)config withChunkId:(nonnull NSString*)chunkId; - (ChunkConfig *)initWithChunk:(nonnull NSString*)chunkId withURL:(nonnull NSURL*)url withMethod:(nonnull NSString*)method withQuery:(nullable NSString*)query withFetch:(BOOL)fetch withAbsolute:(BOOL)absolute withHeaders:(nullable NSDictionary *)headers withBody:(nullable NSData *)body withTimeout:(nonnull NSNumber *)timeout; @end #endif /* ChunkConfig_h */
36.3125
76
0.655766
4723896a3d0feb0bd43fee7fdeaf3b1c785badc0
2,197
h
C
include/flatbufserver/FlatBufferServer.h
awawa-dev/hyperion.ng
459aa9b81fe04bfd7a259d761a0fdff94178e10d
[ "MIT-0", "Apache-2.0", "CC-BY-4.0", "MIT" ]
2
2020-08-24T10:02:51.000Z
2020-08-24T20:03:50.000Z
include/flatbufserver/FlatBufferServer.h
awawa-dev/hyperion.ng
459aa9b81fe04bfd7a259d761a0fdff94178e10d
[ "MIT-0", "Apache-2.0", "CC-BY-4.0", "MIT" ]
null
null
null
include/flatbufserver/FlatBufferServer.h
awawa-dev/hyperion.ng
459aa9b81fe04bfd7a259d761a0fdff94178e10d
[ "MIT-0", "Apache-2.0", "CC-BY-4.0", "MIT" ]
null
null
null
#pragma once // util #include <utils/Logger.h> #include <utils/settings.h> #include <utils/Image.h> // qt #include <QVector> class BonjourServiceRegister; class QTcpServer; class QLocalServer; class FlatBufferClient; class NetOrigin; #define HYPERHDR_DOMAIN_SERVER QStringLiteral("hyperhdr-domain") /// /// @brief A TcpServer to receive images of different formats with Google Flatbuffer /// Images will be forwarded to all HyperHdr instances /// class FlatBufferServer : public QObject { Q_OBJECT public: FlatBufferServer(const QJsonDocument& config, const QString& configurationPath, QObject* parent = nullptr); ~FlatBufferServer() override; static FlatBufferServer* instance; static FlatBufferServer* getInstance() { return instance; } signals: void hdrToneMappingChanged(int mode, uint8_t* lutBuffer); void HdrChanged(int mode); public slots: /// /// @brief Handle settings update /// @param type The type from enum /// @param config The configuration /// void handleSettingsUpdate(settings::type type, const QJsonDocument& config); void initServer(); void setHdrToneMappingEnabled(int mode); int getHdrToneMappingEnabled(); void importFromProtoHandler(int priority, int duration, const Image<ColorRgb>& image); private slots: /// /// @brief Is called whenever a new socket wants to connect /// void newConnection(); /// /// @brief is called whenever a client disconnected /// void clientDisconnected(); private: /// /// @brief Start the server with current _port /// void startServer(); /// /// @brief Stop server /// void stopServer(); /// /// @brief Get shared LUT file folder /// QString GetSharedLut(); /// /// @brief Load LUT file /// void loadLutFile(); void setupClient(FlatBufferClient* client); private: QTcpServer* _server; QLocalServer* _domain; NetOrigin* _netOrigin; Logger* _log; int _timeout; quint16 _port; const QJsonDocument _config; BonjourServiceRegister* _serviceRegister = nullptr; QVector<FlatBufferClient*> _openConnections; // tone mapping int _hdrToneMappingMode; int _realHdrToneMappingMode; uint8_t* _lutBuffer; bool _lutBufferInit; QString _configurationPath; };
20.155963
108
0.737369
740e925aa28cc7d9fb22da6358d790be3282c8fd
735
h
C
XVim2/XcodeHeader/IDEKit/_TtC6IDEKit26WorkingCopyHistoryLocation.h
petergp/XVim2
4d53d0983544dd8385501ba8396b1ce753351de8
[ "MIT" ]
null
null
null
XVim2/XcodeHeader/IDEKit/_TtC6IDEKit26WorkingCopyHistoryLocation.h
petergp/XVim2
4d53d0983544dd8385501ba8396b1ce753351de8
[ "MIT" ]
1
2020-01-27T08:01:55.000Z
2020-01-27T08:09:38.000Z
XVim2/XcodeHeader/IDEKit/_TtC6IDEKit26WorkingCopyHistoryLocation.h
petergp/XVim2
4d53d0983544dd8385501ba8396b1ce753351de8
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Jun 6 2019 20:12:56). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <DVTFoundation/DVTDocumentLocation.h> @interface _TtC6IDEKit26WorkingCopyHistoryLocation : DVTDocumentLocation { // Error parsing type: , name: indexKey // Error parsing type: , name: index } - (void).cxx_destruct; - (id)init; - (id)initWithDocumentURL:(id)arg1 timestamp:(id)arg2; - (BOOL)isEqualDisregardingTimestamp:(id)arg1; - (id)copyWithURL:(id)arg1; - (long long)compare:(id)arg1; @property(nonatomic, readonly) long long hash; - (BOOL)isEqual:(id)arg1; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; @end
26.25
90
0.711565
74edec12e7aae614ca30415677d62975b669502d
1,176
h
C
PrivateFrameworks/IMSharedUtilities/IMNotificationCenterEventListener.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/IMSharedUtilities/IMNotificationCenterEventListener.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/IMSharedUtilities/IMNotificationCenterEventListener.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 <IMSharedUtilities/IMEventListener.h> @class NSString; @interface IMNotificationCenterEventListener : IMEventListener { NSString *_registeredNotificationName; NSString *_notificationName; id _notificationObject; } + (id)eventListenerForNotificationName:(id)arg1 object:(id)arg2; + (id)eventListenerForNotificationName:(id)arg1; @property(readonly) __weak id notificationObject; // @synthesize notificationObject=_notificationObject; @property(readonly, copy) NSString *notificationName; // @synthesize notificationName=_notificationName; @property(readonly, nonatomic) NSString *registeredNotificationName; // @synthesize registeredNotificationName=_registeredNotificationName; - (void).cxx_destruct; - (void)willReset; - (void)willStopListening; - (void)willStartListening; - (BOOL)isListening; - (void)dealloc; - (void)registerForNotificationName:(id)arg1 object:(id)arg2; - (void)registerForNotificationName:(id)arg1; - (void)_notification:(id)arg1; @property(readonly) BOOL isRegisteredForNotification; @end
32.666667
139
0.784014
2d0da6e9ff6ecd93b8b81a8dcd45650c95a47410
8,027
h
C
Descending Europa/Temp/StagingArea/Data/il2cppOutput/AssemblyU2DCSharpU2Dfirstpass_UnityStandardAssets_1756613902.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
Descending Europa/Temp/StagingArea/Data/il2cppOutput/AssemblyU2DCSharpU2Dfirstpass_UnityStandardAssets_1756613902.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
Descending Europa/Temp/StagingArea/Data/il2cppOutput/AssemblyU2DCSharpU2Dfirstpass_UnityStandardAssets_1756613902.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> // UnityEngine.AnimationCurve struct AnimationCurve_t3667593487; // UnityEngine.Texture2D struct Texture2D_t3884108195; // UnityEngine.Shader struct Shader_t3191267369; // UnityEngine.Material struct Material_t3870600107; // UnityEngine.RenderTexture struct RenderTexture_t1963041563; #include "AssemblyU2DCSharpU2Dfirstpass_UnityStandardAssets_1415309093.h" #include "AssemblyU2DCSharpU2Dfirstpass_UnityStandardAssets_2681627918.h" #include "AssemblyU2DCSharpU2Dfirstpass_UnityStandardAssets_1393266833.h" #include "UnityEngine_UnityEngine_RenderTextureFormat2841883826.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // UnityStandardAssets.ImageEffects.Tonemapping struct Tonemapping_t1756613902 : public PostEffectsBase_t1415309093 { public: // UnityStandardAssets.ImageEffects.Tonemapping/TonemapperType UnityStandardAssets.ImageEffects.Tonemapping::type int32_t ___type_5; // UnityStandardAssets.ImageEffects.Tonemapping/AdaptiveTexSize UnityStandardAssets.ImageEffects.Tonemapping::adaptiveTextureSize int32_t ___adaptiveTextureSize_6; // UnityEngine.AnimationCurve UnityStandardAssets.ImageEffects.Tonemapping::remapCurve AnimationCurve_t3667593487 * ___remapCurve_7; // UnityEngine.Texture2D UnityStandardAssets.ImageEffects.Tonemapping::curveTex Texture2D_t3884108195 * ___curveTex_8; // System.Single UnityStandardAssets.ImageEffects.Tonemapping::exposureAdjustment float ___exposureAdjustment_9; // System.Single UnityStandardAssets.ImageEffects.Tonemapping::middleGrey float ___middleGrey_10; // System.Single UnityStandardAssets.ImageEffects.Tonemapping::white float ___white_11; // System.Single UnityStandardAssets.ImageEffects.Tonemapping::adaptionSpeed float ___adaptionSpeed_12; // UnityEngine.Shader UnityStandardAssets.ImageEffects.Tonemapping::tonemapper Shader_t3191267369 * ___tonemapper_13; // System.Boolean UnityStandardAssets.ImageEffects.Tonemapping::validRenderTextureFormat bool ___validRenderTextureFormat_14; // UnityEngine.Material UnityStandardAssets.ImageEffects.Tonemapping::tonemapMaterial Material_t3870600107 * ___tonemapMaterial_15; // UnityEngine.RenderTexture UnityStandardAssets.ImageEffects.Tonemapping::rt RenderTexture_t1963041563 * ___rt_16; // UnityEngine.RenderTextureFormat UnityStandardAssets.ImageEffects.Tonemapping::rtFormat int32_t ___rtFormat_17; public: inline static int32_t get_offset_of_type_5() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___type_5)); } inline int32_t get_type_5() const { return ___type_5; } inline int32_t* get_address_of_type_5() { return &___type_5; } inline void set_type_5(int32_t value) { ___type_5 = value; } inline static int32_t get_offset_of_adaptiveTextureSize_6() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___adaptiveTextureSize_6)); } inline int32_t get_adaptiveTextureSize_6() const { return ___adaptiveTextureSize_6; } inline int32_t* get_address_of_adaptiveTextureSize_6() { return &___adaptiveTextureSize_6; } inline void set_adaptiveTextureSize_6(int32_t value) { ___adaptiveTextureSize_6 = value; } inline static int32_t get_offset_of_remapCurve_7() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___remapCurve_7)); } inline AnimationCurve_t3667593487 * get_remapCurve_7() const { return ___remapCurve_7; } inline AnimationCurve_t3667593487 ** get_address_of_remapCurve_7() { return &___remapCurve_7; } inline void set_remapCurve_7(AnimationCurve_t3667593487 * value) { ___remapCurve_7 = value; Il2CppCodeGenWriteBarrier(&___remapCurve_7, value); } inline static int32_t get_offset_of_curveTex_8() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___curveTex_8)); } inline Texture2D_t3884108195 * get_curveTex_8() const { return ___curveTex_8; } inline Texture2D_t3884108195 ** get_address_of_curveTex_8() { return &___curveTex_8; } inline void set_curveTex_8(Texture2D_t3884108195 * value) { ___curveTex_8 = value; Il2CppCodeGenWriteBarrier(&___curveTex_8, value); } inline static int32_t get_offset_of_exposureAdjustment_9() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___exposureAdjustment_9)); } inline float get_exposureAdjustment_9() const { return ___exposureAdjustment_9; } inline float* get_address_of_exposureAdjustment_9() { return &___exposureAdjustment_9; } inline void set_exposureAdjustment_9(float value) { ___exposureAdjustment_9 = value; } inline static int32_t get_offset_of_middleGrey_10() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___middleGrey_10)); } inline float get_middleGrey_10() const { return ___middleGrey_10; } inline float* get_address_of_middleGrey_10() { return &___middleGrey_10; } inline void set_middleGrey_10(float value) { ___middleGrey_10 = value; } inline static int32_t get_offset_of_white_11() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___white_11)); } inline float get_white_11() const { return ___white_11; } inline float* get_address_of_white_11() { return &___white_11; } inline void set_white_11(float value) { ___white_11 = value; } inline static int32_t get_offset_of_adaptionSpeed_12() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___adaptionSpeed_12)); } inline float get_adaptionSpeed_12() const { return ___adaptionSpeed_12; } inline float* get_address_of_adaptionSpeed_12() { return &___adaptionSpeed_12; } inline void set_adaptionSpeed_12(float value) { ___adaptionSpeed_12 = value; } inline static int32_t get_offset_of_tonemapper_13() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___tonemapper_13)); } inline Shader_t3191267369 * get_tonemapper_13() const { return ___tonemapper_13; } inline Shader_t3191267369 ** get_address_of_tonemapper_13() { return &___tonemapper_13; } inline void set_tonemapper_13(Shader_t3191267369 * value) { ___tonemapper_13 = value; Il2CppCodeGenWriteBarrier(&___tonemapper_13, value); } inline static int32_t get_offset_of_validRenderTextureFormat_14() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___validRenderTextureFormat_14)); } inline bool get_validRenderTextureFormat_14() const { return ___validRenderTextureFormat_14; } inline bool* get_address_of_validRenderTextureFormat_14() { return &___validRenderTextureFormat_14; } inline void set_validRenderTextureFormat_14(bool value) { ___validRenderTextureFormat_14 = value; } inline static int32_t get_offset_of_tonemapMaterial_15() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___tonemapMaterial_15)); } inline Material_t3870600107 * get_tonemapMaterial_15() const { return ___tonemapMaterial_15; } inline Material_t3870600107 ** get_address_of_tonemapMaterial_15() { return &___tonemapMaterial_15; } inline void set_tonemapMaterial_15(Material_t3870600107 * value) { ___tonemapMaterial_15 = value; Il2CppCodeGenWriteBarrier(&___tonemapMaterial_15, value); } inline static int32_t get_offset_of_rt_16() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___rt_16)); } inline RenderTexture_t1963041563 * get_rt_16() const { return ___rt_16; } inline RenderTexture_t1963041563 ** get_address_of_rt_16() { return &___rt_16; } inline void set_rt_16(RenderTexture_t1963041563 * value) { ___rt_16 = value; Il2CppCodeGenWriteBarrier(&___rt_16, value); } inline static int32_t get_offset_of_rtFormat_17() { return static_cast<int32_t>(offsetof(Tonemapping_t1756613902, ___rtFormat_17)); } inline int32_t get_rtFormat_17() const { return ___rtFormat_17; } inline int32_t* get_address_of_rtFormat_17() { return &___rtFormat_17; } inline void set_rtFormat_17(int32_t value) { ___rtFormat_17 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
44.594444
166
0.826461
e1807affdd029d1fa95c9bdd646cd2c726e79d4b
4,777
h
C
pomi/hw/Core.h
jpfli/Pomifactory
ee736a97bcbb5f16625aedae492c267e4911378c
[ "MIT" ]
2
2020-06-16T18:14:53.000Z
2020-10-07T10:42:28.000Z
pomi/hw/Core.h
jpfli/FMSynth
7c70fbccc22e3a83afe4eef69bd4e76fbdd41003
[ "MIT" ]
null
null
null
pomi/hw/Core.h
jpfli/FMSynth
7c70fbccc22e3a83afe4eef69bd4e76fbdd41003
[ "MIT" ]
null
null
null
#pragma once namespace Pomi { namespace Hw { class Core { public: Core() = delete; Core(const Core&) = delete; Core& operator =(const Core&) = delete; static inline void enableSysTick() { volatile unsigned int *SYSTICK = reinterpret_cast<unsigned int*>(0xe000e010); // sysTick[1] = 4800000 - 1; // OSCT = 0 SYSTICK[1] = 7200000 - 1; // OSCT = 2 SYSTICK[2] = 0; constexpr unsigned int CPU_CLOCK = 4; constexpr unsigned int TICKINT = 2; constexpr unsigned int ENABLE = 1; SYSTICK[0] = CPU_CLOCK | TICKINT | ENABLE; } static inline unsigned int sysTickMillis() { volatile unsigned int* SYSTICK = reinterpret_cast<unsigned int*>(0xe000e010); // return (((SYSTICK[1] - SYSTICK[2]) >> 7) * 89478) >> 25; // Divide by 48000 (OSCT = 0) return (((SYSTICK[1] - SYSTICK[2]) >> 7) * 59652) >> 25; // Divide by 72000 (OSCT = 2) } static inline unsigned int sysTickMicros() { volatile unsigned int* SYSTICK = reinterpret_cast<unsigned int*>(0xe000e010); // return (((SYSTICK[1] - SYSTICK[2]) >> 7) * 87381) >> 15; // Divide by 48 (OSCT = 0) return (((SYSTICK[1] - SYSTICK[2]) >> 7) * 58254) >> 15; // Divide by 72 (OSCT = 2) } static inline void enableDAC() { volatile unsigned int* PIO1 = reinterpret_cast<unsigned int*>(0x40044060); volatile unsigned int* PIO2 = reinterpret_cast<unsigned int*>(0x400440f0); volatile unsigned int* DIR = reinterpret_cast<unsigned int*>(0xa0002000); PIO1[28] = PIO1[29] = PIO1[30] = PIO1[31] = 1 << 7; PIO2[20] = PIO2[21] = PIO2[22] = PIO2[23] = 1 << 7; DIR[1] |= (1 << 28) | (1 << 29) | (1 << 30) | (1 << 31); DIR[2] |= (1 << 20) | (1 << 21) | (1 << 22) | (1 << 23); } static inline void writeDAC(unsigned char out) { volatile unsigned char* P1 = reinterpret_cast<unsigned char*>(0xa0000020); volatile unsigned char* P2 = reinterpret_cast<unsigned char*>(0xa0000040); P1[28] = out & 1; out >>= 1; P1[29] = out & 1; out >>= 1; P1[30] = out & 1; out >>= 1; P1[31] = out & 1; out >>= 1; P2[20] = out & 1; out >>= 1; P2[21] = out & 1; out >>= 1; P2[22] = out & 1; out >>= 1; P2[23] = out; } static inline unsigned int clockFrequency() { volatile unsigned int* SYSCON = reinterpret_cast<unsigned int*>(0x40048000); unsigned int msel = (SYSCON[2] & 0x1f) + 1; // Get feedback divider value return 12000000 * msel / SYSCON[30]; } static inline void enableTimer(unsigned int number, unsigned int matchnum, unsigned int frequency) { volatile unsigned int* SYSCON = reinterpret_cast<unsigned int*>(0x40048000); SYSCON[32] |= (number == 0) ? (1 << 9) : (1 << 10); // Enable clock for the timer volatile unsigned int* TIMER = reinterpret_cast<unsigned int*>((number == 0) ? 0x40014000 : 0x40018000); TIMER[1] = 1 << 1; // Reset and disable timer counters TIMER[6 + matchnum] = clockFrequency() / frequency; // Set match value (timer's duration) TIMER[5] |= 1 << (3 * matchnum); // Generate interrupt when timer equals match value TIMER[5] |= 1 << (3 * matchnum + 1); // Reset timer on match TIMER[1] = 1 << 0; // Enable the timer counter // Enable timer interrupt volatile unsigned int* NVIC_ISER0 = reinterpret_cast<unsigned int*>(0xe000e100); *NVIC_ISER0 = (number == 0) ? (1 << 18) : (1 << 19); } static inline void disableTimer(unsigned int number) { // Disable timer interrupt volatile unsigned int* NVIC_ICER0 = reinterpret_cast<unsigned int*>(0xe000e180); *NVIC_ICER0 = (number == 0) ? (1 << 18) : (1 << 19); volatile unsigned int* TIMER = reinterpret_cast<unsigned int*>((number == 0) ? 0x40014000 : 0x40018000); TIMER[1] = 1 << 1; // Reset and disable timer counters } static inline void enableIRQ() { __asm volatile ("cpsie i" : : : "memory"); } static inline void disableIRQ() { __asm volatile ("cpsid i" : : : "memory"); } }; } // namespace Hw } // namespace Pomi
46.378641
116
0.512665
7c2b7e8a0204c9267da70c3f3bd6d71d8388832a
10,927
h
C
3rd/vrep/cpp/include/QMLAdapter.h
Tadinu/my_arm
ac4fb295ddad7c7ee999a03d2e7d229802b64226
[ "BSD-3-Clause" ]
4
2021-02-20T15:59:42.000Z
2022-03-25T04:04:21.000Z
3rd/vrep/cpp/include/QMLAdapter.h
Tadinu/my_arm
ac4fb295ddad7c7ee999a03d2e7d229802b64226
[ "BSD-3-Clause" ]
1
2021-04-14T04:12:48.000Z
2021-04-14T04:12:48.000Z
3rd/vrep/cpp/include/QMLAdapter.h
Tadinu/my_arm
ac4fb295ddad7c7ee999a03d2e7d229802b64226
[ "BSD-3-Clause" ]
2
2019-10-29T12:41:16.000Z
2021-03-22T16:38:27.000Z
#ifndef QML_ADAPTER_H #define QML_ADAPTER_H #include <QObject> #include <QQmlProperty> #include "RbGlobal.h" #include "QMLQuickImageProvider.h" class QJSEngine; class QQmlEngine; class RbMainWindowAgent; // ======================================================================================================================= // typedef QVariant (RbMainWindowAgent::*RBOP_VOID)(void); typedef QVariant (RbMainWindowAgent::*RBOP_VAR)(QVariant); typedef QVariant (RbMainWindowAgent::*RBOP_VAR_VAR)(QVariant, QVariant); // VOID PARAM -- #define RB_VOID_OPERATION_INVOKE(rbOpId) \ if(_rbOpVoid[rbOpId] != nullptr) { \ return RB_MEMFUNC_CALL(*RbMainWindowAgent::getInstance(), _rbOpVoid[rbOpId])(); \ } \ else { \ return -1; \ } // SINGLE VARIANT PARAM -- #define RB_1VARIANT_OPERATION_INVOKE(rbOpId, param) \ if(_rbOpVariant[rbOpId] != nullptr) { \ return RB_MEMFUNC_CALL(*RbMainWindowAgent::getInstance(), _rbOpVariant[rbOpId])(param); \ } \ else { \ return -1; \ } // DOUBLE VARIANT PARAM -- #define RB_2VARIANT_OPERATION_INVOKE(rbOpId, param1, param2) \ if(_rbOpDoubleVariant[rbOpId] != nullptr) { \ return RB_MEMFUNC_CALL(*RbMainWindowAgent::getInstance(), _rbOpDoubleVariant[rbOpId])(param1, param2); \ } \ else { \ return -1; \ } // DIALOG OPERATION -- #define RB_DIALOG_OPERATION_INVOKE(dialogId, eventType) \ if(_rbOpDialogAgent != nullptr) { \ return RB_MEMFUNC_CALL(*RbMainWindowAgent::getInstance(), _rbOpDialogAgent)(QVariant(dialogId), QVariant(eventType));\ } \ else { \ return -1; \ } // ----------------------------------------------------------------------------------- // LOCAL <QML_ITEM>.QML funcs: #define QML_ITEM_INVOKE(qmlItemId, func) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func); #define QML_ITEM_LOCAL_INVOKE(func) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func); #define QML_ITEM_INVOKE_I(qmlItemId, func, param) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func, \ Q_ARG(QVariant, param)); #define QML_ITEM_LOCAL_INVOKE_I(func, param) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func, \ Q_ARG(QVariant, param)); #define QML_ITEM_INVOKE_II(qmlItemId, func, param1, param2) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func, \ Q_ARG(QVariant, param1), \ Q_ARG(QVariant, param2)); #define QML_ITEM_LOCAL_INVOKE_II(func, param1, param2) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func, \ Q_ARG(QVariant, param1), \ Q_ARG(QVariant, param2)); #define QML_ITEM_INVOKE_III(qmlItemId, func, param1, param2, param3) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func, \ Q_ARG(QVariant, param1), \ Q_ARG(QVariant, param2), \ Q_ARG(QVariant, param3)); #define QML_ITEM_LOCAL_INVOKE_III(func, param1, param2, param3) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func, \ Q_ARG(QVariant, param1), \ Q_ARG(QVariant, param2), \ Q_ARG(QVariant, param3)); #define QML_ITEM_INVOKE_RET(qmlItemId, func, ret) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func, \ Q_RETURN_ARG(QVariant, ret)); #define QML_ITEM_LOCAL_INVOKE_RET(func, ret) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func, \ Q_RETURN_ARG(QVariant, ret)); #define QML_ITEM_INVOKE_RET_I(qmlItemId, func, ret, param) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func, \ Q_RETURN_ARG(QVariant, ret), \ Q_ARG(QVariant, param)); #define QML_ITEM_LOCAL_INVOKE_RET_I(func, ret, param) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func, \ Q_RETURN_ARG(QVariant, ret), \ Q_ARG(QVariant, param)); #define QML_ITEM_INVOKE_RET_II(qmlItemId, func, ret, param1, param2) \ QMetaObject::invokeMethod(QMLAdapter::getInstance()->getRbQMLItem(qmlItemId), #func, \ Q_RETURN_ARG(QVariant, ret), \ Q_ARG(QVariant, param1), \ Q_ARG(QVariant, param2)); #define QML_ITEM_LOCAL_INVOKE_RET_II(func, ret, param1, param2) \ QMetaObject::invokeMethod(this->QMLItemAgent::UI(), #func, \ Q_RETURN_ARG(QVariant, ret), \ Q_ARG(QVariant, param1), \ Q_ARG(QVariant, param2)); class QMLAdapter : public QObject { Q_OBJECT Q_ENUMS(RB_VOID_OPERATION) Q_ENUMS(RB_PARAM_OPERATION) Q_ENUMS(RB_DOUBLE_PARAM_OPERATION) Q_ENUMS(RB_TRIPLE_PARAM_OPERATION) Q_ENUMS(QML_ITEM) Q_ENUMS(QML_ROBOT_TYPE) public: static const int OBJECT_IMAGE_WIDTH = 80; static const int OBJECT_IMAGE_HEIGHT = 80; enum RB_ACTION { RB_ACTION_VOID, RB_ACTION_TOTAL }; enum RB_QML_CONTEXT_PROPERTY { ROBOT_APPLICATION, MAIN_WINDOW_AGENT, RB_QML_ADAPTER, RB_QML_CONTEXT_PROPERTY_TOTAL }; // These names are canonical, which will be used DIRECTLY in QML: static const QString CONTEXT_PROPERTY[RB_QML_CONTEXT_PROPERTY_TOTAL]; enum RB_VOID_OPERATION { RB_OP_V, RB_OP_VOID_TOTAL }; enum RB_PARAM_OPERATION { RB_OP_SINGLE_PARAM, RB_OP_SINGLE_PARAM_TOTAL }; enum RB_DOUBLE_PARAM_OPERATION { RB_OP_DOUBLE_PARAM, RB_OP_DOUBLE_PARAM_TOTAL }; enum RB_TRIPLE_PARAM_OPERATION { RB_OP_TRIPLE_PARAM, RB_OP_TRIPLE_PARAM_TOTAL }; // ----------------------------------- // FUNCTION OPERATION DIALOS -- // enum RB_OPERATION_DIALOG_EVENT { RB_DIALOG_EVENT, RB_DIALOG_EVENT_TOTAL }; enum QML_ITEM { // DIALOGS -- QML_ITEM_I, /* Add more dialog id here */ QML_ITEM_TOTAL }; static const QString QML_PROPERTY_ITEM[QML_ITEM_TOTAL]; //KDialog* getKsDialog(int dialogId); // enum QML_ROBOT_TYPE { ROBOT_CAR = RbGlobal::RB_ROBOT_CAR }; public: QMLAdapter(); static QObject* qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine); static QMLAdapter* getInstance(); ~QMLAdapter(); RBOP_VOID _rbOpVoid[RB_OP_VOID_TOTAL]; Q_INVOKABLE QVariant runOpVoid(int rbOpId); RBOP_VAR _rbOpVariant[RB_OP_SINGLE_PARAM_TOTAL]; Q_INVOKABLE QVariant runOpParam(int rbOpId, QVariant param); RBOP_VAR_VAR _rbOpDoubleVariant[RB_OP_DOUBLE_PARAM_TOTAL]; Q_INVOKABLE QVariant runOpDoubleParam(int rbOpId, QVariant param1, QVariant param2); RBOP_VAR_VAR _rbOpDialogAgent; Q_INVOKABLE QVariant runDialogOp(int dialogId, int eventType); void registerOperations(); // Global Quick Image Provider QMLQuickImageProvider* frontVisionImageProvider() { return &_frontVisionImageProvider; } QMLQuickImageProvider* groundVisionImageProvider() { return &_groundVisionImageProvider; } // QML Items -- void openQMLItem(int qmlItemId); // Open a QML Item QObject* getRbQMLItem(int qmlItemId); private: static QMLAdapter* s_instance; QMLQuickImageProvider _frontVisionImageProvider; QMLQuickImageProvider _groundVisionImageProvider; }; #endif // QML_ADAPTER_H
48.136564
131
0.449437
f54565e48f1744d877ed15b9789655f347b5d2a3
423
h
C
Classes/CMClosestPoint.h
chucklab/CMSlider
930e6f69246098dfc95e23df600f613523f5737c
[ "MIT" ]
2
2017-03-02T09:46:10.000Z
2018-05-02T03:15:19.000Z
Classes/CMClosestPoint.h
chucklab/CMSlider
930e6f69246098dfc95e23df600f613523f5737c
[ "MIT" ]
null
null
null
Classes/CMClosestPoint.h
chucklab/CMSlider
930e6f69246098dfc95e23df600f613523f5737c
[ "MIT" ]
null
null
null
// // CMClosestPoint.h // CMSlider // // Created by Chuck MA on 02/27/2017. // Copyright © 2017 Chuck's Lab. All rights reserved. // #import <UIKit/UIKit.h> @interface CMClosestPoint : NSObject @property (nonatomic, assign) CGPoint closestPoint; @property (nonatomic, assign) double distance; + (CMClosestPoint *)closestPointAtLineSegmentWithPointOne:(CGPoint)pt1 pointTwo:(CGPoint)pt2 fromPoint:(CGPoint)pt; @end
22.263158
115
0.744681
ed148958971be5ce73d6866d4027ab202b9ec2d3
574
c
C
nitan/d/kunlun/kuhanlou.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/d/kunlun/kuhanlou.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/d/kunlun/kuhanlou.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// Room: /d/kunlun/kuhanlou.c // Last Modified by Winder on Nov. 15 2000 #include <ansi.h> #include <room.h> inherit ROOM; void create() { set("short", "苦寒樓"); set("long",@long 這裏是崑崙派的苦寒樓,取名自“梅花香自苦寒來”之意,乃是昆 侖派前輩為了激勵後進崑崙派弟子而建的,是崑崙弟子靜修之所。 long); set("exits",([ "west" : __DIR__"shanlin"+(random(5)+1), "enter" : __DIR__"kuhanlou1", ])); set("outdoors", "kunlun"); set("coor/x", -119900); set("coor/y", 40130); set("coor/z", 90); setup(); replace_program(ROOM); }
22.96
56
0.534843
ded07e912443d9bea3e5e380f6e84a5fc33e666c
1,985
h
C
llvm-3.5/lib/Target/SystemZ/SystemZTargetMachine.h
randolphwong/mcsema
eb5b376736e7f57ff0a61f7e4e5a436bbb874720
[ "BSD-3-Clause" ]
3
2015-03-08T22:21:34.000Z
2018-06-25T00:18:51.000Z
llvm-3.5/lib/Target/SystemZ/SystemZTargetMachine.h
randolphwong/mcsema
eb5b376736e7f57ff0a61f7e4e5a436bbb874720
[ "BSD-3-Clause" ]
1
2016-09-22T06:35:24.000Z
2016-09-23T08:33:57.000Z
llvm-3.5/lib/Target/SystemZ/SystemZTargetMachine.h
randolphwong/mcsema
eb5b376736e7f57ff0a61f7e4e5a436bbb874720
[ "BSD-3-Clause" ]
1
2021-03-24T06:40:32.000Z
2021-03-24T06:40:32.000Z
//==- SystemZTargetMachine.h - Define TargetMachine for SystemZ ---*- C++ -*-=// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file declares the SystemZ specific subclass of TargetMachine. // //===----------------------------------------------------------------------===// #ifndef SYSTEMZTARGETMACHINE_H #define SYSTEMZTARGETMACHINE_H #include "SystemZSubtarget.h" #include "llvm/Target/TargetMachine.h" namespace llvm { class TargetFrameLowering; class SystemZTargetMachine : public LLVMTargetMachine { SystemZSubtarget Subtarget; public: SystemZTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL); // Override TargetMachine. const TargetFrameLowering *getFrameLowering() const override { return getSubtargetImpl()->getFrameLowering(); } const SystemZInstrInfo *getInstrInfo() const override { return getSubtargetImpl()->getInstrInfo(); } const SystemZSubtarget *getSubtargetImpl() const override { return &Subtarget; } const DataLayout *getDataLayout() const override { return getSubtargetImpl()->getDataLayout(); } const SystemZRegisterInfo *getRegisterInfo() const override { return getSubtargetImpl()->getRegisterInfo(); } const SystemZTargetLowering *getTargetLowering() const override { return getSubtargetImpl()->getTargetLowering(); } const TargetSelectionDAGInfo *getSelectionDAGInfo() const override { return getSubtargetImpl()->getSelectionDAGInfo(); } // Override LLVMTargetMachine TargetPassConfig *createPassConfig(PassManagerBase &PM) override; }; } // end namespace llvm #endif
31.015625
80
0.659446
074c94a90e3a18e51f40a56015fb67194b078885
2,492
h
C
Applications/Podcasts/MTPlaylistSelectPodcastListViewController.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
11
2019-11-06T04:48:48.000Z
2022-02-09T17:48:15.000Z
Applications/Podcasts/MTPlaylistSelectPodcastListViewController.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
1
2020-04-16T01:41:56.000Z
2020-04-16T04:32:00.000Z
Applications/Podcasts/MTPlaylistSelectPodcastListViewController.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
3
2019-12-22T20:17:53.000Z
2021-01-25T09:47:49.000Z
/* * This header is generated by classdump-dyld 1.0 * on Tuesday, November 5, 2019 at 1:50:20 PM Mountain Standard Time * Operating System: Version 13.0 (Build 17J586) * Image Source: /Applications/Podcasts.app/Podcasts * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <Podcasts/MTBasePodcastListViewController.h> @protocol MTPlaylistSelectPodcastListViewControllerSaveDelegate; @class NSString, NSMutableSet; @interface MTPlaylistSelectPodcastListViewController : MTBasePodcastListViewController { BOOL _allPodcastsSelected; NSString* _playlistName; NSMutableSet* _podcastUuids; NSString* _playlistUuid; id<MTPlaylistSelectPodcastListViewControllerSaveDelegate> _saveDelegate; } @property (nonatomic,retain) NSString * playlistName; //@synthesize playlistName=_playlistName - In the implementation block @property (nonatomic,retain) NSMutableSet * podcastUuids; //@synthesize podcastUuids=_podcastUuids - In the implementation block @property (assign,nonatomic) BOOL allPodcastsSelected; //@synthesize allPodcastsSelected=_allPodcastsSelected - In the implementation block @property (nonatomic,retain) NSString * playlistUuid; //@synthesize playlistUuid=_playlistUuid - In the implementation block @property (retain) id<MTPlaylistSelectPodcastListViewControllerSaveDelegate> saveDelegate; //@synthesize saveDelegate=_saveDelegate - In the implementation block -(void)tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 ; -(NSString *)playlistName; -(void)setPlaylistName:(NSString *)arg1 ; -(void)viewWillDisappear:(BOOL)arg1 ; -(void)viewDidLoad; -(void)viewWillLayoutSubviews; -(NSMutableSet *)podcastUuids; -(id)reuseIdentifierForRow:(id)arg1 ; -(void)restoreSelection; -(id)newCellInstanceWithReuseIdentifier:(id)arg1 ; -(void)configureCell:(id)arg1 withObject:(id)arg2 atIndexPath:(id)arg3 ; -(BOOL)allPodcastsSelected; -(void)setAllPodcastsSelected:(BOOL)arg1 ; -(void)setPodcastUuids:(NSMutableSet *)arg1 ; -(id<MTPlaylistSelectPodcastListViewControllerSaveDelegate>)saveDelegate; -(NSString *)playlistUuid; -(void)setPlaylistUuid:(NSString *)arg1 ; -(void)setSaveDelegate:(id<MTPlaylistSelectPodcastListViewControllerSaveDelegate>)arg1 ; -(void)updateAllPodcastsTo:(BOOL)arg1 ; -(void)togglePodcastUuid:(id)arg1 ; @end
48.862745
188
0.74679
60f41cdcd10e4219c1544d52c8575aa26b0a4894
387
c
C
software/libs/mpatch/mpatch/checkpoint_mpatch.c
bzier/ENGAGE
3d47a9ee20f02d83c2d032bd4b9567b32e43b61f
[ "MIT" ]
64
2020-12-09T05:25:43.000Z
2022-03-31T00:21:51.000Z
software/libs/mpatch/mpatch/checkpoint_mpatch.c
bzier/ENGAGE
3d47a9ee20f02d83c2d032bd4b9567b32e43b61f
[ "MIT" ]
1
2020-12-04T16:56:58.000Z
2020-12-08T20:08:13.000Z
software/libs/mpatch/mpatch/checkpoint_mpatch.c
bzier/ENGAGE
3d47a9ee20f02d83c2d032bd4b9567b32e43b61f
[ "MIT" ]
6
2020-12-23T05:43:44.000Z
2022-03-23T08:51:25.000Z
#include <stdlib.h> #include "mpatch.h" #include "checkpoint_mpatch.h" size_t checkpoint_mpatch(void) { mpatch_stage(); mpatch_core_checkpoint(false); return 0; } size_t restore_mpatch(void) { mpatch_core_restore(); mpatch_recover(); mpatch_apply_all(false); return 0; } size_t setup_mpatch(void) { size_t blocks = mpatch_init(); return blocks; }
14.884615
34
0.692506
c25e5a32fe2ff6b20abd44adf1c797d05bac3958
3,444
h
C
gpac-0.7.1/src/terminal/media_control.h
xu5343/ffmpegtoolkit_CentOS7
974496c709a1c8c69034e46ae5ce7101cf03716f
[ "Apache-2.0" ]
null
null
null
gpac-0.7.1/src/terminal/media_control.h
xu5343/ffmpegtoolkit_CentOS7
974496c709a1c8c69034e46ae5ce7101cf03716f
[ "Apache-2.0" ]
null
null
null
gpac-0.7.1/src/terminal/media_control.h
xu5343/ffmpegtoolkit_CentOS7
974496c709a1c8c69034e46ae5ce7101cf03716f
[ "Apache-2.0" ]
1
2021-04-15T18:27:37.000Z
2021-04-15T18:27:37.000Z
/* * GPAC - Multimedia Framework C SDK * * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * * This file is part of GPAC / Media terminal sub-project * * GPAC 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, or (at your option) * any later version. * * GPAC 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; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef _MEDIA_CONTROL_H_ #define _MEDIA_CONTROL_H_ #include <gpac/internal/terminal_dev.h> /*MediaControl definition*/ #include <gpac/nodes_mpeg4.h> /*restart object and takes care of media control/clock dependencies*/ void mediacontrol_restart(GF_ObjectManager *odm); void mediacontrol_pause(GF_ObjectManager *odm); //resumes object. //If @resume_to_live is set, will deactivate main addon acting as PVR void mediacontrol_resume(GF_ObjectManager *odm, Bool resume_to_live); Bool MC_URLChanged(MFURL *old_url, MFURL *new_url); void mediasensor_update_timing(GF_ObjectManager *odm, Bool is_eos); #ifndef GPAC_DISABLE_VRML /*to do: add preroll support*/ typedef struct _media_control { M_MediaControl *control; /*store current values to detect changes*/ Double media_start, media_stop; Fixed media_speed; Bool enabled; MFURL url; GF_Scene *parent; /*stream owner*/ GF_MediaObject *stream; /*stream owner's clock*/ GF_Clock *ck; u32 changed; Bool is_init; Bool paused; u32 prev_active; /*stream object list (segments)*/ GF_List *seg; /*current active segment index (ie, controling the PLAY range of the media)*/ u32 current_seg; } MediaControlStack; void InitMediaControl(GF_Scene *scene, GF_Node *node); void MC_Modified(GF_Node *node); void MC_GetRange(MediaControlStack *ctrl, Double *start_range, Double *end_range); /*assign mediaControl for this object*/ void gf_odm_set_mediacontrol(GF_ObjectManager *odm, struct _media_control *ctrl); /*get media control ruling the clock the media is running on*/ struct _media_control *gf_odm_get_mediacontrol(GF_ObjectManager *odm); /*removes control from OD context*/ void gf_odm_remove_mediacontrol(GF_ObjectManager *odm, struct _media_control *ctrl); /*switches control (propagates enable=FALSE), returns 1 if control associated with OD has changed to new one*/ Bool gf_odm_switch_mediacontrol(GF_ObjectManager *odm, struct _media_control *ctrl); /*returns 1 if this is a segment switch, 0 otherwise - takes care of object restart if segment switch*/ Bool gf_odm_check_segment_switch(GF_ObjectManager *odm); typedef struct _media_sensor { M_MediaSensor *sensor; GF_Scene *parent; GF_List *seg; Bool is_init; /*stream owner*/ GF_MediaObject *stream; /*private cache (avoids browsing all sensor*/ u32 active_seg; } MediaSensorStack; void InitMediaSensor(GF_Scene *scene, GF_Node *node); void MS_Modified(GF_Node *node); void MS_Stop(MediaSensorStack *st); #endif /*GPAC_DISABLE_VRML*/ #endif /*_MEDIA_CONTROL_H_*/
29.689655
110
0.768002
b85e9aa98b9919581a8c4e5ce03a07c49cfdf601
1,036
h
C
src/core/impgeneration.h
TimoBx/pbrt
1d5634953a79eb251b1a245382cc3587b6e0a15a
[ "BSD-2-Clause" ]
null
null
null
src/core/impgeneration.h
TimoBx/pbrt
1d5634953a79eb251b1a245382cc3587b6e0a15a
[ "BSD-2-Clause" ]
null
null
null
src/core/impgeneration.h
TimoBx/pbrt
1d5634953a79eb251b1a245382cc3587b6e0a15a
[ "BSD-2-Clause" ]
null
null
null
#if defined(_MSC_VER) #define NOMINMAX #pragma once #endif #ifndef PBRT_CORE_IMPGENERATION_H #define PBRT_CORE_IMPGENERATION_H // core/impgeneration.h* #include "pbrt.h" namespace pbrt { std::string computeNewFilename(std::string filename, std::string prefix, std::string suffix, std::string extension); void computeImpMapNames(Options &options); void changeImpOptions(Options &options); void changeIntegrator(const std::string &name, const ParamSet &params, std::string &IntegratorName, ParamSet &IntegratorParams); void changeLights(Options &PbrtOptions, std::vector<std::shared_ptr<Light>> &lights, const Transform &light2world); Float* normalizeImpMap(Float *impmap, int width, int height); Float getTotal(Float* t, int w, int h); Float getMax(Float* t, int w, int h); Float getMean(Float* t, int w, int h); Float getMedian(Float* t, int w, int h); void normalizeMaps(Options &options, Float value); void writeImpImages(Options &options); } // namespace pbrt #endif // PBRT_CORE_IMPGENERATION_H
29.6
130
0.751931
fc4457a3070fb774910e2b40232c7b8b18bc4e9b
2,953
h
C
ASLogger/ASLQuery.h
nxtstep/aqtoolkit
93f4a11a75b41c9651d37898bd0b7fddb39c6b3d
[ "BSD-3-Clause" ]
182
2015-01-05T17:18:39.000Z
2021-11-08T08:45:32.000Z
ASLogger/ASLQuery.h
zhenhuamu/aqtoolkit
880081dfde17345f50d6e0277ee524b120925fbc
[ "BSD-3-Clause" ]
2
2017-10-02T12:00:46.000Z
2017-12-21T09:06:37.000Z
ASLogger/ASLQuery.h
zhenhuamu/aqtoolkit
880081dfde17345f50d6e0277ee524b120925fbc
[ "BSD-3-Clause" ]
51
2015-01-12T01:49:32.000Z
2020-11-27T05:30:05.000Z
/* * ASLQuery.h * AQToolkit * * Created by Jim Dovey on 31/8/2008. * * Copyright (c) 2008-2009, Jim Dovey * 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 this project's author 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. * */ #import <Foundation/Foundation.h> #import <asl.h> #import "ASLMessage.h" enum { // these values are mutually exclusive ASLQueryOperationEqual = ASL_QUERY_OP_EQUAL, ASLQueryOperationGreater = ASL_QUERY_OP_GREATER, ASLQueryOperationGreaterOrEqual = ASL_QUERY_OP_GREATER_EQUAL, ASLQueryOperationLess = ASL_QUERY_OP_LESS, ASLQueryOperationLessOrEqual = ASL_QUERY_OP_LESS_EQUAL, ASLQueryOperationNotEqual = ASL_QUERY_OP_NOT_EQUAL, ASLQueryOperationTrue = ASL_QUERY_OP_TRUE, // these values can be bitwise-OR'd along with one of those above // you may use any number of these (they are all bitflags) ASLQueryOperationCaseFold = ASL_QUERY_OP_CASEFOLD, ASLQueryOperationPrefix = ASL_QUERY_OP_PREFIX, ASLQueryOperationSuffix = ASL_QUERY_OP_SUFFIX, ASLQueryOperationSubstring = ASL_QUERY_OP_SUBSTRING, ASLQueryOperationNumeric = ASL_QUERY_OP_NUMERIC, ASLQueryOperationRegularExpression = ASL_QUERY_OP_REGEX }; typedef uint32_t ASLQueryOperation; @interface ASLQuery : ASLMessage // attributes tested for equality can be set using the interface provided by // ASLMessage; for other operations, the following method is provided - (void) setValue: (id) value forKey: (NSString *) key withOperation: (ASLQueryOperation) operation; @end
40.452055
100
0.772096
11ae2b72f536168e0b6a4f12027de92fdd65c62e
203
h
C
src/ar/read_landmarks.h
huskyroboticsteam/Resurgence
649f78103b6d76709fdf55bb38d08c0ff50da140
[ "Apache-2.0" ]
3
2021-12-23T23:31:42.000Z
2022-02-16T07:17:41.000Z
src/ar/read_landmarks.h
huskyroboticsteam/Resurgence
649f78103b6d76709fdf55bb38d08c0ff50da140
[ "Apache-2.0" ]
2
2021-11-22T05:33:43.000Z
2022-01-23T07:01:47.000Z
src/ar/read_landmarks.h
huskyroboticsteam/Resurgence
649f78103b6d76709fdf55bb38d08c0ff50da140
[ "Apache-2.0" ]
null
null
null
#pragma once #include "../world_interface/data.h" namespace AR { bool initializeLandmarkDetection(); bool isLandmarkDetectionInitialized(); robot::types::landmarks_t readLandmarks(); } // namespace AR
20.3
42
0.778325
e65c7c8962563323bfd0fc1bf1808bfa5d54ead8
5,773
h
C
src/digits/digit_anim.h
CleyFaye/Pebble-LiveDigits0
e7a80140e0938c387d1e1118354bddd2af39588d
[ "MIT" ]
2
2015-02-07T13:09:25.000Z
2015-02-23T03:12:01.000Z
src/digits/digit_anim.h
CleyFaye/Pebble-LiveDigits0
e7a80140e0938c387d1e1118354bddd2af39588d
[ "MIT" ]
12
2015-02-04T12:09:05.000Z
2015-07-06T19:59:21.000Z
src/digits/digit_anim.h
CleyFaye/Pebble-LiveDigits0
e7a80140e0938c387d1e1118354bddd2af39588d
[ "MIT" ]
null
null
null
/** @file * Control digit's segments animation. * * Animations informations tells what segments should be drawn, and the position * of each segments. * * An "animation" is identified by a numeric id. Each animation is made of 9 * steps, and some animations are marked as either "solo" or "double". Double * animations mean that two animations steps are needed to move from one digit * to another, and are sped up in "merge" animation speed. * * To summarize: * A digit animation = [fixed segments, two animated segments, next animation] * An animated segments = 9 steps of [position, orientation] * To animate, first get through the 9 steps of a segment animation, placing the * segments as indicated, then move to the next animation step of the digit. * * Segments images are provided by digit_images * Actual animation logic with different speed is handled in digitlayer * * @author Cley Faye * Licensing informations in LICENSE.md file. */ #ifndef INCL_DIGIT_ANIM_H #define INCL_DIGIT_ANIM_H #include <pebble.h> #include "digit_info.h" // ======= // TYPES = // ======= /** A single segment animation. * Numbers are relative to the explanation in digit_info.h header. */ typedef enum { SA_3_TO_1 = -7, SA_4_TO_3, SA_3_TO_2, SA_5_TO_6, SA_2_TO_0, SA_6_TO_4, SA_0_TO_1, SA_NOANIM, SA_1_TO_0, SA_4_TO_6, SA_0_TO_2, SA_6_TO_5, SA_2_TO_3, SA_3_TO_4, SA_1_TO_3 } segment_anim_t; /** A digit animation step. * * Steps are named after the number they transition from/to. Animations in two * steps are suffixed with _a and _b. * Full digits are treated as "special" animations. They animate no digit but * provide the list of segments that must be displayed for a given number. */ typedef enum { DA_9 = -10, DA_8, DA_7, DA_6, DA_5, DA_4, DA_3, DA_2, DA_1, DA_0, DA_0_TO_1_a = 1, DA_0_TO_1_b, DA_1_TO_2_a, DA_1_TO_2_b, DA_2_TO_3_a, DA_2_TO_3_b, DA_3_TO_4, DA_4_TO_5, DA_5_TO_6, DA_6_TO_7_a, DA_6_TO_7_b, DA_7_TO_8_a, DA_7_TO_8_b, DA_8_TO_9, DA_9_TO_0, DA_1_TO_0_a, DA_1_TO_0_b, DA_2_TO_0, DA_3_TO_0, DA_4_TO_0_a, DA_4_TO_0_b, DA_5_TO_0, DA_6_TO_0, DA_7_TO_0_a, DA_7_TO_0_b, DA_8_TO_0 } digit_anim_t; /** Indicate which segment should be displayed statically during an animation * step. * LSB is segment 0. */ typedef uint8_t digit_fixed_segments_t; /** Represent which segments animation must be displayed. * Each animation step can have at most two segment animations. * These values are passed back to anim_segment_get() to get the actual segment * placement. */ typedef segment_anim_t digit_segment_animation_t[2]; // =============================== // PUBLIC FUNCTIONS DECLARATIONS = // =============================== /** Return the placement of a given segment. * * This function return the placement and orientation of a segment for a given * segment animation and animation step. * * From a technical point of view, negative animation id are just positive ones * reversed. It is handled transparently with the appropriate enum values. * * @param anim_pos The animation position. From 0 to 9. */ segment_orientation_t anim_segment_get(segment_anim_t segment_anim, int anim_pos, digit_size_t digit_size, GPoint* offset); /** Return the segments that must be drawn at a fixed position for a given * animation step. */ digit_fixed_segments_t anim_get_fixed_segments(digit_anim_t digit_anim); /** Return true if the given segment is on */ inline bool anim_get_fixed_segment_state(digit_fixed_segments_t segments, unsigned segment_id) { return (segments & (1u << segment_id)) != 0; } /** Return the animated segments from a given animation step. */ const digit_segment_animation_t* anim_get_segment_anim(digit_anim_t digit_anim); /** Return the next animation in a sequence. * The next animation is the animation step that must follow the given step. * * @param digit_anim The current animation step */ digit_anim_t anim_get_next_anim(digit_anim_t digit_anim); /** Return the next animation to 0. * The next animation to 0 is the shortest animation path that return from the * given animation step to 0. * * @param digit_anim The current animation step */ digit_anim_t anim_get_next_quick_anim(digit_anim_t digit_anim); /** Return true if the given animation step is a static digit. */ inline bool anim_is_static_digit(digit_anim_t digit_anim) { return digit_anim < 0; } /** Return true if the given animation step is part of a two-step transition. * * This is relevant for "merged" animations speed. If a whole transition needs * two animation step, half of their frames are skipped to merge them into one. */ bool anim_is_multipart(digit_anim_t digit_anim); /** Determine if an animation step is complete. */ inline bool anim_is_complete(digit_anim_t digit_anim, int step) { return (digit_anim < 0) ? true : (step >= 9); } /** Return the number actually displayed by a given animation step. * * Transition steps will return -1, while static digits will return the * appropriate number. */ inline int anim_get_displayed_number(digit_anim_t digit_anim) { return (digit_anim < 0) ? (-digit_anim - 1) : -1; } /** Return the number of steps of an animation step. * * @return 9 for animation step, 0, for static digit. */ inline int anim_get_step_count(digit_anim_t digit_anim) { return (digit_anim < 0) ? 0 : 9; } /** Return the static digit animation step for a given number. */ inline digit_anim_t anim_get_anim_for_number(int number) { return -number - 1; } #endif
26.360731
80
0.705872
0a787bdba704953f4c457d1a570f94c3316c5b26
473
h
C
Source/Cannon.h
Memory-Leakers/Pinball
d07228aa92be7988aa2da31f0a86cfd836b8c5a5
[ "MIT" ]
null
null
null
Source/Cannon.h
Memory-Leakers/Pinball
d07228aa92be7988aa2da31f0a86cfd836b8c5a5
[ "MIT" ]
null
null
null
Source/Cannon.h
Memory-Leakers/Pinball
d07228aa92be7988aa2da31f0a86cfd836b8c5a5
[ "MIT" ]
null
null
null
#pragma once #include "GameObject.h" class Cannon : public GameObject { public: Cannon(std::string name, std::string tag, Application* _app, iPoint pos); void Update() override; void PostUpdate() override; void OnCollision(PhysBody* col) override; void ShowCannon(); int renderState = 0; float holeSize = 0.0f; float cannonSize = 0.25f; float cannonForce = 200.0f; bool isPlayerIn = false; SDL_Rect holeSection = { 256,0,256,256 }; void Reset(); };
15.258065
74
0.701903
112913a8888aafb9fa8327cea55423f7c1bbcef5
6,710
c
C
cmake_targets/lte_build_oai/build/CMakeFiles/Rel14/SL-TypeTxSync-r14.c
davidraditya/OAI-Powder
a082c3e8af06cd7583c003a69ec517eb73d175b3
[ "Apache-2.0" ]
null
null
null
cmake_targets/lte_build_oai/build/CMakeFiles/Rel14/SL-TypeTxSync-r14.c
davidraditya/OAI-Powder
a082c3e8af06cd7583c003a69ec517eb73d175b3
[ "Apache-2.0" ]
null
null
null
cmake_targets/lte_build_oai/build/CMakeFiles/Rel14/SL-TypeTxSync-r14.c
davidraditya/OAI-Powder
a082c3e8af06cd7583c003a69ec517eb73d175b3
[ "Apache-2.0" ]
null
null
null
/* * Generated by asn1c-0.9.24 (http://lionet.info/asn1c) * From ASN.1 module "EUTRA-RRC-Definitions" * found in "fixed_grammar.asn" * `asn1c -gen-PER` */ #include "SL-TypeTxSync-r14.h" int SL_TypeTxSync_r14_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_NativeEnumerated.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ static void SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_NativeEnumerated.free_struct; td->print_struct = asn_DEF_NativeEnumerated.print_struct; td->ber_decoder = asn_DEF_NativeEnumerated.ber_decoder; td->der_encoder = asn_DEF_NativeEnumerated.der_encoder; td->xer_decoder = asn_DEF_NativeEnumerated.xer_decoder; td->xer_encoder = asn_DEF_NativeEnumerated.xer_encoder; td->uper_decoder = asn_DEF_NativeEnumerated.uper_decoder; td->uper_encoder = asn_DEF_NativeEnumerated.uper_encoder; td->aper_decoder = asn_DEF_NativeEnumerated.aper_decoder; td->aper_encoder = asn_DEF_NativeEnumerated.aper_encoder; td->compare = asn_DEF_NativeEnumerated.compare; if(!td->per_constraints) td->per_constraints = asn_DEF_NativeEnumerated.per_constraints; td->elements = asn_DEF_NativeEnumerated.elements; td->elements_count = asn_DEF_NativeEnumerated.elements_count; /* td->specifics = asn_DEF_NativeEnumerated.specifics; // Defined explicitly */ } void SL_TypeTxSync_r14_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int SL_TypeTxSync_r14_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t SL_TypeTxSync_r14_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t SL_TypeTxSync_r14_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t SL_TypeTxSync_r14_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t SL_TypeTxSync_r14_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } asn_dec_rval_t SL_TypeTxSync_r14_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); } asn_enc_rval_t SL_TypeTxSync_r14_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *structure, asn_per_outp_t *per_out) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->uper_encoder(td, constraints, structure, per_out); } asn_enc_rval_t SL_TypeTxSync_r14_encode_aper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *structure, asn_per_outp_t *per_out) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->aper_encoder(td, constraints, structure, per_out); } asn_comp_rval_t * SL_TypeTxSync_r14_compare(asn_TYPE_descriptor_t *td1, const void *structure1, asn_TYPE_descriptor_t *td2, const void *structure2) { asn_comp_rval_t * res = NULL; SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td1); SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td2); res = td1->compare(td1, structure1, td2, structure2); return res; } asn_dec_rval_t SL_TypeTxSync_r14_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { SL_TypeTxSync_r14_1_inherit_TYPE_descriptor(td); return td->aper_decoder(opt_codec_ctx, td, constraints, structure, per_data); } static asn_per_constraints_t asn_PER_type_SL_TypeTxSync_r14_constr_1 GCC_NOTUSED = { { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static asn_INTEGER_enum_map_t asn_MAP_SL_TypeTxSync_r14_value2enum_1[] = { { 0, 4, "gnss" }, { 1, 3, "enb" }, { 2, 2, "ue" } }; static unsigned int asn_MAP_SL_TypeTxSync_r14_enum2value_1[] = { 1, /* enb(1) */ 0, /* gnss(0) */ 2 /* ue(2) */ }; static asn_INTEGER_specifics_t asn_SPC_SL_TypeTxSync_r14_specs_1 = { asn_MAP_SL_TypeTxSync_r14_value2enum_1, /* "tag" => N; sorted by tag */ asn_MAP_SL_TypeTxSync_r14_enum2value_1, /* N => "tag"; sorted by N */ 3, /* Number of elements in the maps */ 0, /* Enumeration is not extensible */ 1, /* Strict enumeration */ 0, /* Native long size */ 0 }; static ber_tlv_tag_t asn_DEF_SL_TypeTxSync_r14_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; asn_TYPE_descriptor_t asn_DEF_SL_TypeTxSync_r14 = { "SL-TypeTxSync-r14", "SL-TypeTxSync-r14", SL_TypeTxSync_r14_free, SL_TypeTxSync_r14_print, SL_TypeTxSync_r14_constraint, SL_TypeTxSync_r14_decode_ber, SL_TypeTxSync_r14_encode_der, SL_TypeTxSync_r14_decode_xer, SL_TypeTxSync_r14_encode_xer, SL_TypeTxSync_r14_decode_uper, SL_TypeTxSync_r14_encode_uper, SL_TypeTxSync_r14_decode_aper, SL_TypeTxSync_r14_encode_aper, SL_TypeTxSync_r14_compare, 0, /* Use generic outmost tag fetcher */ asn_DEF_SL_TypeTxSync_r14_tags_1, sizeof(asn_DEF_SL_TypeTxSync_r14_tags_1) /sizeof(asn_DEF_SL_TypeTxSync_r14_tags_1[0]), /* 1 */ asn_DEF_SL_TypeTxSync_r14_tags_1, /* Same as above */ sizeof(asn_DEF_SL_TypeTxSync_r14_tags_1) /sizeof(asn_DEF_SL_TypeTxSync_r14_tags_1[0]), /* 1 */ &asn_PER_type_SL_TypeTxSync_r14_constr_1, 0, 0, /* Defined elsewhere */ &asn_SPC_SL_TypeTxSync_r14_specs_1 /* Additional specs */ };
36.868132
89
0.790313
20e38d08086429c1704a04fcb5c658c777750d95
408
h
C
misc.h
apparentorder/r53db
8c66a3f954918c2d292700b7494f5315506b169d
[ "BSD-2-Clause" ]
21
2020-10-01T09:35:30.000Z
2022-02-12T20:01:23.000Z
misc.h
apparentorder/r53db
8c66a3f954918c2d292700b7494f5315506b169d
[ "BSD-2-Clause" ]
null
null
null
misc.h
apparentorder/r53db
8c66a3f954918c2d292700b7494f5315506b169d
[ "BSD-2-Clause" ]
null
null
null
#ifndef R53DB_MISC_H #define R53DB_MISC_H #include <postgres.h> #include <access/tupdesc.h> char *get_relation_hosted_zone_id(Oid relation_id); List *get_column_positions(TupleDesc td); r53dbDNSRR *get_rr_from_values(Datum *values, bool *isnulls, List *column_positions); void palloc_string(char **s); void make_dns_identifier(char *s); Datum CStringGetTextDatumOrNULL(char *s); #endif // R53DB_MISC_H
22.666667
85
0.796569
9740cf0c8ccd078048ae6dab01dbd432420abf54
1,604
h
C
src/gc/variable_size_pool.h
winnit-myself/Wifie
53284177b4f4107da5b7e2394cefccaa98194ec3
[ "Artistic-2.0" ]
312
2015-01-15T01:00:51.000Z
2022-03-31T11:45:50.000Z
src/gc/variable_size_pool.h
allisonrandal/pkg-parrot
cb37148cef4a6857ba848482da15f7eb7cf74331
[ "Artistic-2.0" ]
108
2015-01-01T18:24:22.000Z
2022-02-25T16:53:52.000Z
src/gc/variable_size_pool.h
allisonrandal/pkg-parrot
cb37148cef4a6857ba848482da15f7eb7cf74331
[ "Artistic-2.0" ]
80
2015-01-14T01:33:52.000Z
2022-02-26T03:47:55.000Z
/* Copyright (C) 2001-2010, Parrot Foundation. =head1 NAME src/gc/variable_size_pool.h - implementation of allocator variable size objects. E.g. strings. =head1 DESCRIPTION */ #ifndef PARROT_GC_VARIABLE_SIZE_POOL_H_GUARD #define PARROT_GC_VARIABLE_SIZE_POOL_H_GUARD #include "parrot/settings.h" struct GC_Statistics; typedef struct Memory_Block { size_t free; size_t size; struct Memory_Block *prev; struct Memory_Block *next; char *start; char *top; /* Amount of freed memory. Used in compact_pool */ size_t freed; } Memory_Block; typedef struct Variable_Size_Pool { Memory_Block *top_block; void (*compact)(PARROT_INTERP, struct GC_Statistics *, struct Variable_Size_Pool *); size_t minimum_block_size; size_t total_allocated; /* total bytes allocated to this pool */ size_t guaranteed_reclaimable; /* bytes that can definitely be reclaimed*/ size_t possibly_reclaimable; /* bytes that can possibly be reclaimed * (above plus COW-freed bytes) */ FLOATVAL reclaim_factor; /* minimum percentage we will reclaim */ } Variable_Size_Pool; /* HEADERIZER BEGIN: src/gc/variable_size_pool.c */ /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* HEADERIZER END: src/gc/variable_size_pool.c */ #endif /* PARROT_GC_VARIABLE_SIZE_POOL_H_GUARD */ /* * Local variables: * c-file-style: "parrot" * End: * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : */
27.655172
89
0.714464
7c5cc069b016231961f7241f4fd419391c98818f
2,137
h
C
components/signin/core/browser/signin_account_id_helper.h
Fusion-Rom/android_external_chromium_org
d8b126911c6ea9753e9f526bee5654419e1d0ebd
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2020-01-25T09:58:49.000Z
2020-01-25T09:58:49.000Z
components/signin/core/browser/signin_account_id_helper.h
Fusion-Rom/android_external_chromium_org
d8b126911c6ea9753e9f526bee5654419e1d0ebd
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
components/signin/core/browser/signin_account_id_helper.h
Fusion-Rom/android_external_chromium_org
d8b126911c6ea9753e9f526bee5654419e1d0ebd
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2020-11-04T07:19:17.000Z
2020-11-04T07:19:17.000Z
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_ACCOUNT_ID_HELPER_H_ #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_ACCOUNT_ID_HELPER_H_ #include "components/signin/core/browser/signin_manager.h" #include "google_apis/gaia/gaia_oauth_client.h" #include "google_apis/gaia/oauth2_token_service.h" class CookieSettings; class GaiaAuthFetcher; class ProfileOAuth2TokenService; class SigninClient; // The helper class for managing the obfuscated GAIA ID of the primary // account. It fetches the ID when user first signs into Chrome or when user // opens a connected Chrome profile without an obfuscated GAIA ID, and stores // the ID in the profile preference. class SigninAccountIdHelper : public SigninManagerBase::Observer, public OAuth2TokenService::Observer { public: SigninAccountIdHelper(SigninClient* client, ProfileOAuth2TokenService* token_service, SigninManagerBase* signin_manager); virtual ~SigninAccountIdHelper(); // SigninManagerBase::Observer: virtual void GoogleSignedOut(const std::string& account_id, const std::string& username) OVERRIDE; // OAuth2TokenService::Observer: virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; // Disables network requests for testing to avoid messing up with irrelevant // tests. static void SetDisableForTest(bool disable_for_test); private: // Invoked when receiving the response for |account_id_fetcher_|. void OnPrimaryAccountIdFetched(const std::string& gaia_id); // Helper class for fetching the obfuscated account ID. class GaiaIdFetcher; scoped_ptr<GaiaIdFetcher> id_fetcher_; static bool disable_for_test_; SigninClient* client_; ProfileOAuth2TokenService* token_service_; SigninManagerBase* signin_manager_; DISALLOW_COPY_AND_ASSIGN(SigninAccountIdHelper); }; #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_ACCOUNT_ID_HELPER_H_
36.844828
79
0.771642
6eb54a7f4fbc9177d992f8f3e2ecf0ac25384ba2
2,139
h
C
grasp_generation/graspitmodified_lm/Coin-3.1.3/include/Inventor/elements/SoCacheHintElement.h
KraftOreo/EBM_Hand
9ab1722c196b7eb99b4c3ecc85cef6e8b1887053
[ "MIT" ]
null
null
null
grasp_generation/graspitmodified_lm/Coin-3.1.3/include/Inventor/elements/SoCacheHintElement.h
KraftOreo/EBM_Hand
9ab1722c196b7eb99b4c3ecc85cef6e8b1887053
[ "MIT" ]
null
null
null
grasp_generation/graspitmodified_lm/Coin-3.1.3/include/Inventor/elements/SoCacheHintElement.h
KraftOreo/EBM_Hand
9ab1722c196b7eb99b4c3ecc85cef6e8b1887053
[ "MIT" ]
null
null
null
#ifndef COIN_SOCACHEHINTELEMENT_H #define COIN_SOCACHEHINTELEMENT_H /**************************************************************************\ * * This file is part of the Coin 3D visualization library. * Copyright (C) by Kongsberg Oil & Gas Technologies. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.GPL at the root directory of this source * distribution for additional information about the GNU GPL. * * For using Coin with software that can not be combined with the GNU * GPL, and for taking advantage of the additional benefits of our * support services, please contact Kongsberg Oil & Gas Technologies * about acquiring a Coin Professional Edition License. * * See http://www.coin3d.org/ for more information. * * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY. * http://www.sim.no/ sales@sim.no coin-support@coin3d.org * \**************************************************************************/ #include <Inventor/elements/SoSubElement.h> class SoCacheHintElementP; // Please note that this is an experimental class. The API might // change a lot before/if it's included in any official Coin // release. pederb, 2004-07-02 class COIN_DLL_API SoCacheHintElement : public SoElement { typedef SoElement inherited; SO_ELEMENT_HEADER(SoCacheHintElement); public: static void initClass(void); protected: virtual ~SoCacheHintElement(); public: virtual void init(SoState * state); virtual void push(SoState * state); virtual void pop(SoState * state, const SoElement * prevtopelement); virtual SbBool matches(const SoElement * element) const; virtual SoElement * copyMatchInfo(void) const; static void set(SoState * state, SoNode * node, const float memvalue, const float gfxvalue); static void get(SoState * state, float & memvalue, float & gfxvalue); protected: SoCacheHintElementP * pimpl; }; #endif // !COIN_SOCACHEHINTELEMENT_H
33.952381
76
0.684432
dc3811bf96e6ce1fa0bbdf5994a72cec6b715bee
2,744
h
C
PrivateFrameworks/PassKitCore/PKImage.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/PassKitCore/PKImage.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/PassKitCore/PKImage.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 "NSSecureCoding.h" @class NSData, NSObject<OS_dispatch_queue>; @interface PKImage : NSObject <NSSecureCoding> { NSObject<OS_dispatch_queue> *_queue; BOOL _shouldTile; BOOL _shouldStretch; struct PKEdgeInsets _capInsets; NSData *_imageData; struct CGImage *_imageRef; double _scale; long long _orientation; } + (BOOL)supportsSecureCoding; + (id)passesImageNamed:(id)arg1; + (id)hashOfImageNamed:(id)arg1 inBundle:(id)arg2; + (id)newImageNamed:(id)arg1 inBundle:(id)arg2 screenScale:(double)arg3 suffix:(id)arg4; + (id)imageNamed:(id)arg1 inBundle:(id)arg2 screenScale:(double)arg3 suffix:(id)arg4; + (id)newImageNamed:(id)arg1 inBundle:(id)arg2; + (id)imageNamed:(id)arg1 inBundle:(id)arg2; + (id)URLForImageNamed:(id)arg1 inBundle:(id)arg2 scale:(double *)arg3 preferredScreenScale:(double)arg4 suffix:(id)arg5; + (id)URLForImageNamed:(id)arg1 inBundle:(id)arg2 scale:(double *)arg3; @property(readonly, nonatomic) double scale; // @synthesize scale=_scale; - (void).cxx_destruct; - (BOOL)_isTiledWhenStretchedToSize:(struct CGSize)arg1; - (void)_queue_createImageRefIfNecessary; - (id)initWithCoder:(id)arg1; - (void)encodeWithCoder:(id)arg1; - (void)drawInRect:(struct CGRect)arg1 inContext:(struct CGContext *)arg2 withBlendMode:(int)arg3 alpha:(double)arg4; - (void)drawInRect:(struct CGRect)arg1 inContext:(struct CGContext *)arg2; - (id)resizableImageByTilingCenterPixel; - (id)resizableImageByStretchingWithCapInsets:(struct PKEdgeInsets)arg1; - (id)resizableImageByTilingWithCapInsets:(struct PKEdgeInsets)arg1; - (id)resizedImageWithConstraints:(id)arg1; - (id)imageWithoutCapInsets; - (id)croppedImageWithInsets:(struct PKEdgeInsets)arg1; - (id)blurredImageWithRadius:(unsigned long long)arg1 constraints:(id)arg2; @property(readonly, nonatomic) struct PKEdgeInsets capInsets; @property(readonly, nonatomic) BOOL stretches; @property(readonly, nonatomic) BOOL tiles; - (void)preheatBitmapData; @property(readonly, nonatomic) NSData *imageData; // @synthesize imageData=_imageData; @property(readonly, nonatomic) long long orientation; // @synthesize orientation=_orientation; @property(readonly, nonatomic) struct CGImage *imageRef; // @synthesize imageRef=_imageRef; - (struct CGSize)downscaleSizeMatchingScale:(double)arg1; @property(readonly, nonatomic) struct CGSize size; - (void)dealloc; - (id)initWithCGImage:(struct CGImage *)arg1 scale:(double)arg2 orientation:(long long)arg3; - (id)initWithData:(id)arg1 scale:(double)arg2; - (id)init; - (BOOL)isEqualToImage:(id)arg1; - (BOOL)isEqual:(id)arg1; - (id)imageHash; @end
40.352941
121
0.764577
2938a89a7f284624f804e745e85c0864fd1b5142
1,505
h
C
VS2005/Common/Controls/TabSDIFrameWnd.h
cuongquay/led-matrix-display
6dd0e3be9ee23862610dab7b0d40970c6900e5e4
[ "Apache-2.0" ]
null
null
null
VS2005/Common/Controls/TabSDIFrameWnd.h
cuongquay/led-matrix-display
6dd0e3be9ee23862610dab7b0d40970c6900e5e4
[ "Apache-2.0" ]
null
null
null
VS2005/Common/Controls/TabSDIFrameWnd.h
cuongquay/led-matrix-display
6dd0e3be9ee23862610dab7b0d40970c6900e5e4
[ "Apache-2.0" ]
1
2020-06-13T08:34:26.000Z
2020-06-13T08:34:26.000Z
/********************************************************************** ** ** TabSDIFrameWnd.h : include file ** ** by Andrzej Markowski July 2005 ** **********************************************************************/ #pragma once #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "CustomTabCtrl.h" #define IDC_TABCTRL 100 ///////////////////////////////////////////////////////////////////////////// // CTabSDIFrameWnd frame class CTabSDIFrameWnd : public CFrameWnd { DECLARE_DYNCREATE(CTabSDIFrameWnd) protected: CTabSDIFrameWnd(); // protected constructor used by dynamic creation // Attributes public: // Operations public: CCustomTabCtrl& GetTabCtrl() {return m_wndTab;} // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTabSDIFrameWnd) //}}AFX_VIRTUAL // Implementation protected: virtual ~CTabSDIFrameWnd(); // Generated message map functions //{{AFX_MSG(CTabSDIFrameWnd) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG afx_msg void OnSelchangeTabctrl(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnClickTabctrl(NMHDR* pNMHDR, LRESULT* pResult); DECLARE_MESSAGE_MAP() protected: CCustomTabCtrl m_wndTab; }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
25.083333
98
0.574086
34dfa7cf4ae4b73032e2039e9d6a29ac98284f98
2,745
h
C
engine/source/gui/buttons/guiCheckBoxCtrl.h
Jozor/Torque2D
be8ca31307eac572077b28e546b31c84dd9bdb11
[ "MIT" ]
412
2020-06-01T14:41:18.000Z
2022-03-31T01:48:15.000Z
engine/source/gui/buttons/guiCheckBoxCtrl.h
Jozor/Torque2D
be8ca31307eac572077b28e546b31c84dd9bdb11
[ "MIT" ]
20
2020-06-16T03:17:16.000Z
2022-02-06T21:29:11.000Z
engine/source/gui/buttons/guiCheckBoxCtrl.h
Jozor/Torque2D
be8ca31307eac572077b28e546b31c84dd9bdb11
[ "MIT" ]
64
2020-06-01T06:00:38.000Z
2022-03-12T15:47:42.000Z
//----------------------------------------------------------------------------- // Copyright (c) 2013 GarageGames, LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- #ifndef _GUICHECKBOXCTRL_H_ #define _GUICHECKBOXCTRL_H_ #ifndef _GUIBUTTONCTRL_H_ #include "gui/buttons/guiButtonCtrl.h" #endif class GuiCheckBoxCtrl : public GuiButtonCtrl { typedef GuiButtonCtrl Parent; protected: bool mStateOn; Point2I mBoxOffset; Point2I mBoxExtent; Point2I mTextOffset; Point2I mTextExtent; public: DECLARE_CONOBJECT(GuiCheckBoxCtrl); GuiCheckBoxCtrl(); bool onWake(); static void initPersistFields(); bool getStateOn(void) { return mStateOn; } void setStateOn(bool bStateOn); const Point2I& getBoxOffset() { return mBoxOffset; } const Point2I& getBoxExtent() { return mBoxExtent; } void setBoxOffset(const Point2I &newOffset) { mBoxOffset = newOffset; } void setBoxExtent(const Point2I &newExtent) { mBoxExtent = newExtent; } const Point2I& getTextOffset() { return mTextOffset; } const Point2I& getTextExtent() { return mTextExtent; } void setTextOffset(const Point2I &newOffset) { mTextOffset = newOffset; } void setTextExtent(const Point2I &newExtent) { mTextExtent = newExtent; } void onRender(Point2I offset, const RectI &updateRect); virtual void renderInnerControl(RectI &boxRect, const GuiControlState currentState); void setScriptValue(const char *value); const char *getScriptValue(); void onMessage(GuiControl *, S32 msg); void onAction(); }; #endif //_GUI_CHECKBOX_CTRL_H
37.60274
88
0.691439
1fb0c6ad03d23a054b2effd4a75dba9750d7007f
1,961
h
C
tests/TestFixtures/Marshalling/TNSRecords.h
aaayushsingh/ios-runtime
f8714aaf20ba9cdd288fc34e53d181a4d7f8cd6e
[ "Apache-2.0" ]
1
2021-11-14T02:57:26.000Z
2021-11-14T02:57:26.000Z
tests/TestFixtures/Marshalling/TNSRecords.h
aaayushsingh/ios-runtime
f8714aaf20ba9cdd288fc34e53d181a4d7f8cd6e
[ "Apache-2.0" ]
null
null
null
tests/TestFixtures/Marshalling/TNSRecords.h
aaayushsingh/ios-runtime
f8714aaf20ba9cdd288fc34e53d181a4d7f8cd6e
[ "Apache-2.0" ]
1
2021-11-14T02:56:06.000Z
2021-11-14T02:56:06.000Z
// // TNSRecords.h // NativeScriptTests // // Created by Jason Zhekov on 2/19/14. // Copyright (c) 2014 Jason Zhekov. All rights reserved. // #import <simd/simd.h> typedef struct TNSSimpleStruct { int x; int y; } TNSSimpleStruct; typedef struct TNSStruct16 { int64_t x; int32_t y; int32_t z; } TNSStruct16; typedef struct TNSStruct24 { int64_t x; int32_t y; int64_t z; } TNSStruct24; typedef struct TNSStruct32 { int64_t x; int64_t y; int64_t z; } TNSStruct32; typedef struct TNSNestedStruct { struct TNSSimpleStruct a; struct TNSSimpleStruct b; } TNSNestedStruct; typedef struct TNSStructWithArray { int32_t x; int8_t arr[4]; } TNSStructWithArray; typedef struct TNSNestedAnonymousStruct { int x1; struct { int x2; struct { int x3; } y2; } y1; } TNSNestedAnonymousStruct; typedef struct TNSComplexStruct { int32_t x1; struct { int16_t x2; struct { int8_t x3[2]; } y2; } y1[2]; int64_t x4; } TNSComplexStruct; typedef struct TNSVerySimpleStruct { int32_t x1; struct { int16_t x2; int32_t x3; } y1[2]; } TNSVerySimpleStruct; typedef struct NestedSimpleStruct { struct { float x2; float x3; } y1; struct { float x2; float x3; } y2; } NestedSimpleStruct; typedef struct TNSStructWithPointers { void (*a)(); int* x; TNSSimpleStruct* y; struct TNSStructWithPointers* z; } TNSStructWithPointers; TNSVerySimpleStruct getSimpleStruct(); TNSComplexStruct getComplexStruct(); matrix_float2x2 getMatrix2x2(); matrix_float2x3 getMatrix2x3(); matrix_float2x4 getMatrix2x4(); matrix_float3x2 getMatrix3x2(); matrix_float3x3 getMatrix3x3(); matrix_float3x4 getMatrix3x4(); matrix_float4x2 getMatrix4x2(); matrix_float4x3 getMatrix4x3(); matrix_float4x4 getMatrix4x4(); NestedSimpleStruct getNestedStruct();
19.038835
57
0.670066
b6f2390037fa34d9bfbd14b3521824ab59ae5dab
1,115
h
C
src/MyPinDetails/UserCreatedMyPinDetailsModelSelectedMessage.h
usamakhan049/assignment
40eb153e8fd74f73ba52ce29417d8220ab744b5d
[ "BSD-2-Clause" ]
69
2017-06-07T10:47:03.000Z
2022-03-24T08:33:33.000Z
src/MyPinDetails/UserCreatedMyPinDetailsModelSelectedMessage.h
usamakhan049/assignment
40eb153e8fd74f73ba52ce29417d8220ab744b5d
[ "BSD-2-Clause" ]
23
2017-06-07T10:47:00.000Z
2020-07-09T10:31:17.000Z
src/MyPinDetails/UserCreatedMyPinDetailsModelSelectedMessage.h
usamakhan049/assignment
40eb153e8fd74f73ba52ce29417d8220ab744b5d
[ "BSD-2-Clause" ]
31
2017-08-12T13:19:32.000Z
2022-01-04T20:33:40.000Z
// Copyright eeGeo Ltd (2012-2015), All Rights Reserved #pragma once #include <string> #include "MyPinModel.h" namespace ExampleApp { namespace MyPinDetails { class UserCreatedMyPinDetailsModelSelectedMessage { private: MyPins::SdkModel::MyPinModel::TPinIdType m_pinId; std::string m_title; std::string m_description; std::string m_imagePath; public: UserCreatedMyPinDetailsModelSelectedMessage(MyPins::SdkModel::MyPinModel::TPinIdType pinId, const std::string& title, const std::string& description, const std::string& imagePath); MyPins::SdkModel::MyPinModel::TPinIdType GetMyPinId() const; const std::string& GetMyPinTitle() const; const std::string& GetMyPinDescription() const; const std::string& GetImagePath() const; }; } }
30.972222
103
0.521973
19618501c35c37687c86afca6f03d3398a62ae9d
22,812
c
C
STM32 Discovery/STM32L476G_Discovery_LCD/Src/lcd.c
UdayanSinha/Code_Blocks
43c010dcfb587942b6e6f8ba72b93862042afa1d
[ "MIT" ]
3
2016-10-30T05:54:44.000Z
2021-05-17T20:24:42.000Z
STM32 Discovery/STM32L476G_Discovery_LCD/Src/lcd.c
UdayanSinha/Code_Blocks
43c010dcfb587942b6e6f8ba72b93862042afa1d
[ "MIT" ]
null
null
null
STM32 Discovery/STM32L476G_Discovery_LCD/Src/lcd.c
UdayanSinha/Code_Blocks
43c010dcfb587942b6e6f8ba72b93862042afa1d
[ "MIT" ]
1
2018-10-04T08:20:25.000Z
2018-10-04T08:20:25.000Z
/** ****************************************************************************** * File Name : LCD.c * Description : This file provides code for the configuration * of the LCD instances. ****************************************************************************** * * COPYRIGHT(c) 2016 STMicroelectronics * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics 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. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "lcd.h" #include "gpio.h" /* USER CODE BEGIN 0 */ #define ASCII_CHAR_0 0x30 /* 0 */ #define ASCII_CHAR_AT_SYMBOL 0x40 /* @ */ #define ASCII_CHAR_LEFT_OPEN_BRACKET 0x5B /* [ */ #define ASCII_CHAR_APOSTROPHE 0x60 /* ` */ #define ASCII_CHAR_LEFT_OPEN_BRACE 0x7B /* ( */ /** @verbatim ================================================================================ GLASS LCD MAPPING ================================================================================ LCD allows to display informations on six 14-segment digits and 4 bars: 1 2 3 4 5 6 ----- ----- ----- ----- ----- ----- |\|/| o |\|/| o |\|/| o |\|/| o |\|/| |\|/| BAR3 -- -- -- -- -- -- -- -- -- -- -- -- BAR2 |/|\| o |/|\| o |/|\| o |/|\| o |/|\| |/|\| BAR1 ----- * ----- * ----- * ----- * ----- ----- BAR0 LCD segment mapping: -------------------- -----A----- _ |\ | /| COL |_| F H J K B | \ | / | _ --G-- --M-- COL |_| | / | \ | E Q P N C |/ | \| _ -----D----- DP |_| An LCD character coding is based on the following matrix: COM 0 1 2 3 SEG(n) { E , D , P , N } SEG(n+1) { M , C , COL , DP } SEG(23-n-1) { B , A , K , J } SEG(23-n) { G , F , Q , H } with n positive odd number. The character 'A' for example is: ------------------------------- LSB { 1 , 0 , 0 , 0 } { 1 , 1 , 0 , 0 } { 1 , 1 , 0 , 0 } MSB { 1 , 1 , 0 , 0 } ------------------- 'A' = F E 0 0 hexa @endverbatim */ /* Constant table for cap characters 'A' --> 'Z' */ const uint16_t CapLetterMap[26]= { /* A B C D E F G H I */ 0xFE00, 0x6714, 0x1D00, 0x4714, 0x9D00, 0x9C00, 0x3F00, 0xFA00, 0x0014, /* J K L M N O P Q R */ 0x5300, 0x9841, 0x1900, 0x5A48, 0x5A09, 0x5F00, 0xFC00, 0x5F01, 0xFC01, /* S T U V W X Y Z */ 0xAF00, 0x0414, 0x5b00, 0x18C0, 0x5A81, 0x00C9, 0x0058, 0x05C0 }; /* Constant table for number '0' --> '9' */ const uint16_t NumberMap[10]= { /* 0 1 2 3 4 5 6 7 8 9 */ 0x5F00,0x4200,0xF500,0x6700,0xEa00,0xAF00,0xBF00,0x04600,0xFF00,0xEF00 }; uint32_t Digit[4]; /* Digit frame buffer */ static void WriteChar(uint8_t* ch, Point_Typedef Point, DoublePoint_Typedef Colon, DigitPosition_Typedef Position); static void Convert(uint8_t* Char, Point_Typedef Point, DoublePoint_Typedef Colon); /* USER CODE END 0 */ LCD_HandleTypeDef hlcd; /* LCD init function */ void MX_LCD_Init(void) { hlcd.Instance = LCD; hlcd.Init.Prescaler = LCD_PRESCALER_1; hlcd.Init.Divider = LCD_DIVIDER_31; hlcd.Init.Duty = LCD_DUTY_1_4; hlcd.Init.Bias = LCD_BIAS_1_3; hlcd.Init.VoltageSource = LCD_VOLTAGESOURCE_INTERNAL; hlcd.Init.Contrast = LCD_CONTRASTLEVEL_5; hlcd.Init.DeadTime = LCD_DEADTIME_0; hlcd.Init.PulseOnDuration = LCD_PULSEONDURATION_5; hlcd.Init.MuxSegment = LCD_MUXSEGMENT_DISABLE; hlcd.Init.BlinkMode = LCD_BLINKMODE_OFF; hlcd.Init.BlinkFrequency = LCD_BLINKFREQUENCY_DIV8; hlcd.Init.HighDrive = LCD_HIGHDRIVE_DISABLE; if (HAL_LCD_Init(&hlcd) != HAL_OK) { Error_Handler(); } } void HAL_LCD_MspInit(LCD_HandleTypeDef* lcdHandle) { GPIO_InitTypeDef GPIO_InitStruct; if(lcdHandle->Instance==LCD) { /* USER CODE BEGIN LCD_MspInit 0 */ /* USER CODE END LCD_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_LCD_CLK_ENABLE(); /**LCD GPIO Configuration PC3 ------> LCD_VLCD PA6 ------> LCD_SEG3 PA7 ------> LCD_SEG4 PC4 ------> LCD_SEG22 PC5 ------> LCD_SEG23 PB0 ------> LCD_SEG5 PB1 ------> LCD_SEG6 PB12 ------> LCD_SEG12 PB13 ------> LCD_SEG13 PB14 ------> LCD_SEG14 PB15 ------> LCD_SEG15 PD8 ------> LCD_SEG28 PD9 ------> LCD_SEG29 PD10 ------> LCD_SEG30 PD11 ------> LCD_SEG31 PD12 ------> LCD_SEG32 PD13 ------> LCD_SEG33 PD14 ------> LCD_SEG34 PD15 ------> LCD_SEG35 PC6 ------> LCD_SEG24 PC7 ------> LCD_SEG25 PC8 ------> LCD_SEG26 PA8 ------> LCD_COM0 PA9 ------> LCD_COM1 PA10 ------> LCD_COM2 PA15 ------> LCD_SEG17 PB4 ------> LCD_SEG8 PB5 ------> LCD_SEG9 PB9 ------> LCD_COM3 */ GPIO_InitStruct.Pin = VLCD_Pin|SEG22_Pin|SEG1_Pin|SEG14_Pin |SEG9_Pin|SEG13_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF11_LCD; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); GPIO_InitStruct.Pin = SEG23_Pin|SEG0_Pin|COM0_Pin|COM1_Pin |COM2_Pin|SEG10_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF11_LCD; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = SEG21_Pin|SEG2_Pin|SEG20_Pin|SEG3_Pin |SEG19_Pin|SEG4_Pin|SEG11_Pin|SEG12_Pin |COM3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF11_LCD; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_InitStruct.Pin = SEG18_Pin|SEG5_Pin|SEG17_Pin|SEG6_Pin |SEG16_Pin|SEG7_Pin|SEG15_Pin|SEG8_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF11_LCD; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /* USER CODE BEGIN LCD_MspInit 1 */ /* USER CODE END LCD_MspInit 1 */ } } void HAL_LCD_MspDeInit(LCD_HandleTypeDef* lcdHandle) { if(lcdHandle->Instance==LCD) { /* USER CODE BEGIN LCD_MspDeInit 0 */ /* USER CODE END LCD_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_LCD_CLK_DISABLE(); /**LCD GPIO Configuration PC3 ------> LCD_VLCD PA6 ------> LCD_SEG3 PA7 ------> LCD_SEG4 PC4 ------> LCD_SEG22 PC5 ------> LCD_SEG23 PB0 ------> LCD_SEG5 PB1 ------> LCD_SEG6 PB12 ------> LCD_SEG12 PB13 ------> LCD_SEG13 PB14 ------> LCD_SEG14 PB15 ------> LCD_SEG15 PD8 ------> LCD_SEG28 PD9 ------> LCD_SEG29 PD10 ------> LCD_SEG30 PD11 ------> LCD_SEG31 PD12 ------> LCD_SEG32 PD13 ------> LCD_SEG33 PD14 ------> LCD_SEG34 PD15 ------> LCD_SEG35 PC6 ------> LCD_SEG24 PC7 ------> LCD_SEG25 PC8 ------> LCD_SEG26 PA8 ------> LCD_COM0 PA9 ------> LCD_COM1 PA10 ------> LCD_COM2 PA15 ------> LCD_SEG17 PB4 ------> LCD_SEG8 PB5 ------> LCD_SEG9 PB9 ------> LCD_COM3 */ HAL_GPIO_DeInit(GPIOC, VLCD_Pin|SEG22_Pin|SEG1_Pin|SEG14_Pin |SEG9_Pin|SEG13_Pin); HAL_GPIO_DeInit(GPIOA, SEG23_Pin|SEG0_Pin|COM0_Pin|COM1_Pin |COM2_Pin|SEG10_Pin); HAL_GPIO_DeInit(GPIOB, SEG21_Pin|SEG2_Pin|SEG20_Pin|SEG3_Pin |SEG19_Pin|SEG4_Pin|SEG11_Pin|SEG12_Pin |COM3_Pin); HAL_GPIO_DeInit(GPIOD, SEG18_Pin|SEG5_Pin|SEG17_Pin|SEG6_Pin |SEG16_Pin|SEG7_Pin|SEG15_Pin|SEG8_Pin); } /* USER CODE BEGIN LCD_MspDeInit 1 */ /* USER CODE END LCD_MspDeInit 1 */ } /* USER CODE BEGIN 1 */ /** * @brief Write a character string in the LCD RAM buffer. * @param ptr: Pointer to string to display on the LCD Glass. * @retval None */ void LCD_GLASS_DisplayString(uint8_t* ptr) { DigitPosition_Typedef position = LCD_DIGIT_POSITION_1; /* Send the string character by character on lCD */ while ((*ptr != 0) & (position <= LCD_DIGIT_POSITION_6)) { /* Write one character on LCD */ WriteChar(ptr, POINT_OFF, DOUBLEPOINT_OFF, position); /* Point on the next character */ ptr++; /* Increment the character counter */ position++; } /* Update the LCD display */ HAL_LCD_UpdateDisplayRequest(&hlcd); } /** * @brief Clear the whole LCD RAM buffer. * @retval None */ void LCD_GLASS_Clear(void) { HAL_LCD_Clear(&hlcd); } /** * @brief Write a character in the LCD frame buffer. * @param ch: the character to display. * @param Point: a point to add in front of char * This parameter can be: POINT_OFF or POINT_ON * @param Colon: flag indicating if a colon character has to be added in front * of displayed character. * This parameter can be: DOUBLEPOINT_OFF or DOUBLEPOINT_ON. * @param Position: position in the LCD of the character to write [1:6] * @retval None */ static void WriteChar(uint8_t* ch, Point_Typedef Point, DoublePoint_Typedef Colon, DigitPosition_Typedef Position) { uint32_t data =0x00; /* To convert displayed character in segment in array digit */ Convert(ch, (Point_Typedef)Point, (DoublePoint_Typedef)Colon); switch (Position) { /* Position 1 on LCD (Digit1)*/ case LCD_DIGIT_POSITION_1: data = ((Digit[0] & 0x1) << LCD_SEG0_SHIFT) | (((Digit[0] & 0x2) >> 1) << LCD_SEG1_SHIFT) | (((Digit[0] & 0x4) >> 2) << LCD_SEG22_SHIFT) | (((Digit[0] & 0x8) >> 3) << LCD_SEG23_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT1_COM0, LCD_DIGIT1_COM0_SEG_MASK, data); /* 1G 1B 1M 1E */ data = ((Digit[1] & 0x1) << LCD_SEG0_SHIFT) | (((Digit[1] & 0x2) >> 1) << LCD_SEG1_SHIFT) | (((Digit[1] & 0x4) >> 2) << LCD_SEG22_SHIFT) | (((Digit[1] & 0x8) >> 3) << LCD_SEG23_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT1_COM1, LCD_DIGIT1_COM1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = ((Digit[2] & 0x1) << LCD_SEG0_SHIFT) | (((Digit[2] & 0x2) >> 1) << LCD_SEG1_SHIFT) | (((Digit[2] & 0x4) >> 2) << LCD_SEG22_SHIFT) | (((Digit[2] & 0x8) >> 3) << LCD_SEG23_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT1_COM2, LCD_DIGIT1_COM2_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = ((Digit[3] & 0x1) << LCD_SEG0_SHIFT) | (((Digit[3] & 0x2) >> 1) << LCD_SEG1_SHIFT) | (((Digit[3] & 0x4) >> 2) << LCD_SEG22_SHIFT) | (((Digit[3] & 0x8) >> 3) << LCD_SEG23_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT1_COM3, LCD_DIGIT1_COM3_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ break; /* Position 2 on LCD (Digit2)*/ case LCD_DIGIT_POSITION_2: data = ((Digit[0] & 0x1) << LCD_SEG2_SHIFT) | (((Digit[0] & 0x2) >> 1) << LCD_SEG3_SHIFT) | (((Digit[0] & 0x4) >> 2) << LCD_SEG20_SHIFT) | (((Digit[0] & 0x8) >> 3) << LCD_SEG21_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT2_COM0, LCD_DIGIT2_COM0_SEG_MASK, data); /* 1G 1B 1M 1E */ data = ((Digit[1] & 0x1) << LCD_SEG2_SHIFT) | (((Digit[1] & 0x2) >> 1) << LCD_SEG3_SHIFT) | (((Digit[1] & 0x4) >> 2) << LCD_SEG20_SHIFT) | (((Digit[1] & 0x8) >> 3) << LCD_SEG21_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT2_COM1, LCD_DIGIT2_COM1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = ((Digit[2] & 0x1) << LCD_SEG2_SHIFT) | (((Digit[2] & 0x2) >> 1) << LCD_SEG3_SHIFT) | (((Digit[2] & 0x4) >> 2) << LCD_SEG20_SHIFT) | (((Digit[2] & 0x8) >> 3) << LCD_SEG21_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT2_COM2, LCD_DIGIT2_COM2_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = ((Digit[3] & 0x1) << LCD_SEG2_SHIFT) | (((Digit[3] & 0x2) >> 1) << LCD_SEG3_SHIFT) | (((Digit[3] & 0x4) >> 2) << LCD_SEG20_SHIFT) | (((Digit[3] & 0x8) >> 3) << LCD_SEG21_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT2_COM3, LCD_DIGIT2_COM3_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ break; /* Position 3 on LCD (Digit3)*/ case LCD_DIGIT_POSITION_3: data = ((Digit[0] & 0x1) << LCD_SEG4_SHIFT) | (((Digit[0] & 0x2) >> 1) << LCD_SEG5_SHIFT) | (((Digit[0] & 0x4) >> 2) << LCD_SEG18_SHIFT) | (((Digit[0] & 0x8) >> 3) << LCD_SEG19_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT3_COM0, LCD_DIGIT3_COM0_SEG_MASK, data); /* 1G 1B 1M 1E */ data = ((Digit[1] & 0x1) << LCD_SEG4_SHIFT) | (((Digit[1] & 0x2) >> 1) << LCD_SEG5_SHIFT) | (((Digit[1] & 0x4) >> 2) << LCD_SEG18_SHIFT) | (((Digit[1] & 0x8) >> 3) << LCD_SEG19_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT3_COM1, LCD_DIGIT3_COM1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = ((Digit[2] & 0x1) << LCD_SEG4_SHIFT) | (((Digit[2] & 0x2) >> 1) << LCD_SEG5_SHIFT) | (((Digit[2] & 0x4) >> 2) << LCD_SEG18_SHIFT) | (((Digit[2] & 0x8) >> 3) << LCD_SEG19_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT3_COM2, LCD_DIGIT3_COM2_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = ((Digit[3] & 0x1) << LCD_SEG4_SHIFT) | (((Digit[3] & 0x2) >> 1) << LCD_SEG5_SHIFT) | (((Digit[3] & 0x4) >> 2) << LCD_SEG18_SHIFT) | (((Digit[3] & 0x8) >> 3) << LCD_SEG19_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT3_COM3, LCD_DIGIT3_COM3_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ break; /* Position 4 on LCD (Digit4)*/ case LCD_DIGIT_POSITION_4: data = ((Digit[0] & 0x1) << LCD_SEG6_SHIFT) | (((Digit[0] & 0x8) >> 3) << LCD_SEG17_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM0, LCD_DIGIT4_COM0_SEG_MASK, data); /* 1G 1B 1M 1E */ data = (((Digit[0] & 0x2) >> 1) << LCD_SEG7_SHIFT) | (((Digit[0] & 0x4) >> 2) << LCD_SEG16_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM0_1, LCD_DIGIT4_COM0_1_SEG_MASK, data); /* 1G 1B 1M 1E */ data = ((Digit[1] & 0x1) << LCD_SEG6_SHIFT) | (((Digit[1] & 0x8) >> 3) << LCD_SEG17_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM1, LCD_DIGIT4_COM1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = (((Digit[1] & 0x2) >> 1) << LCD_SEG7_SHIFT) | (((Digit[1] & 0x4) >> 2) << LCD_SEG16_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM1_1, LCD_DIGIT4_COM1_1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = ((Digit[2] & 0x1) << LCD_SEG6_SHIFT) | (((Digit[2] & 0x8) >> 3) << LCD_SEG17_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM2, LCD_DIGIT4_COM2_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = (((Digit[2] & 0x2) >> 1) << LCD_SEG7_SHIFT) | (((Digit[2] & 0x4) >> 2) << LCD_SEG16_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM2_1, LCD_DIGIT4_COM2_1_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = ((Digit[3] & 0x1) << LCD_SEG6_SHIFT) | (((Digit[3] & 0x8) >> 3) << LCD_SEG17_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM3, LCD_DIGIT4_COM3_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ data = (((Digit[3] & 0x2) >> 1) << LCD_SEG7_SHIFT) | (((Digit[3] & 0x4) >> 2) << LCD_SEG16_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT4_COM3_1, LCD_DIGIT4_COM3_1_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ break; /* Position 5 on LCD (Digit5)*/ case LCD_DIGIT_POSITION_5: data = (((Digit[0] & 0x2) >> 1) << LCD_SEG9_SHIFT) | (((Digit[0] & 0x4) >> 2) << LCD_SEG14_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM0, LCD_DIGIT5_COM0_SEG_MASK, data); /* 1G 1B 1M 1E */ data = ((Digit[0] & 0x1) << LCD_SEG8_SHIFT) | (((Digit[0] & 0x8) >> 3) << LCD_SEG15_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM0_1, LCD_DIGIT5_COM0_1_SEG_MASK, data); /* 1G 1B 1M 1E */ data = (((Digit[1] & 0x2) >> 1) << LCD_SEG9_SHIFT) | (((Digit[1] & 0x4) >> 2) << LCD_SEG14_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM1, LCD_DIGIT5_COM1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = ((Digit[1] & 0x1) << LCD_SEG8_SHIFT) | (((Digit[1] & 0x8) >> 3) << LCD_SEG15_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM1_1, LCD_DIGIT5_COM1_1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = (((Digit[2] & 0x2) >> 1) << LCD_SEG9_SHIFT) | (((Digit[2] & 0x4) >> 2) << LCD_SEG14_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM2, LCD_DIGIT5_COM2_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = ((Digit[2] & 0x1) << LCD_SEG8_SHIFT) | (((Digit[2] & 0x8) >> 3) << LCD_SEG15_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM2_1, LCD_DIGIT5_COM2_1_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = (((Digit[3] & 0x2) >> 1) << LCD_SEG9_SHIFT) | (((Digit[3] & 0x4) >> 2) << LCD_SEG14_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM3, LCD_DIGIT5_COM3_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ data = ((Digit[3] & 0x1) << LCD_SEG8_SHIFT) | (((Digit[3] & 0x8) >> 3) << LCD_SEG15_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT5_COM3_1, LCD_DIGIT5_COM3_1_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ break; /* Position 6 on LCD (Digit6)*/ case LCD_DIGIT_POSITION_6: data = ((Digit[0] & 0x1) << LCD_SEG10_SHIFT) | (((Digit[0] & 0x2) >> 1) << LCD_SEG11_SHIFT) | (((Digit[0] & 0x4) >> 2) << LCD_SEG12_SHIFT) | (((Digit[0] & 0x8) >> 3) << LCD_SEG13_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT6_COM0, LCD_DIGIT6_COM0_SEG_MASK, data); /* 1G 1B 1M 1E */ data = ((Digit[1] & 0x1) << LCD_SEG10_SHIFT) | (((Digit[1] & 0x2) >> 1) << LCD_SEG11_SHIFT) | (((Digit[1] & 0x4) >> 2) << LCD_SEG12_SHIFT) | (((Digit[1] & 0x8) >> 3) << LCD_SEG13_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT6_COM1, LCD_DIGIT6_COM1_SEG_MASK, data) ; /* 1F 1A 1C 1D */ data = ((Digit[2] & 0x1) << LCD_SEG10_SHIFT) | (((Digit[2] & 0x2) >> 1) << LCD_SEG11_SHIFT) | (((Digit[2] & 0x4) >> 2) << LCD_SEG12_SHIFT) | (((Digit[2] & 0x8) >> 3) << LCD_SEG13_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT6_COM2, LCD_DIGIT6_COM2_SEG_MASK, data) ; /* 1Q 1K 1Col 1P */ data = ((Digit[3] & 0x1) << LCD_SEG10_SHIFT) | (((Digit[3] & 0x2) >> 1) << LCD_SEG11_SHIFT) | (((Digit[3] & 0x4) >> 2) << LCD_SEG12_SHIFT) | (((Digit[3] & 0x8) >> 3) << LCD_SEG13_SHIFT); HAL_LCD_Write(&hlcd, LCD_DIGIT6_COM3, LCD_DIGIT6_COM3_SEG_MASK, data) ; /* 1H 1J 1DP 1N */ break; default: break; } } /** * @brief Convert an ascii char to the a LCD digit. * @param Char: a char to display. * @param Point: a point to add in front of char * This parameter can be: POINT_OFF or POINT_ON * @param Colon : flag indicating if a colon character has to be added in front * of displayed character. * This parameter can be: DOUBLEPOINT_OFF or DOUBLEPOINT_ON. * @retval None */ static void Convert(uint8_t* Char, Point_Typedef Point, DoublePoint_Typedef Colon) { uint16_t ch = 0 ; uint8_t loop = 0, index = 0; switch (*Char) { case ' ' : ch = 0x00; break; case '*': ch = C_STAR; break; case '(' : ch = C_OPENPARMAP; break; case ')' : ch = C_CLOSEPARMAP; break; case 'd' : ch = C_DMAP; break; case 'm' : ch = C_MMAP; break; case 'n' : ch = C_NMAP; break; case 'µ' : ch = C_UMAP; break; case '-' : ch = C_MINUS; break; case '+' : ch = C_PLUS; break; case '/' : ch = C_SLATCH; break; case '°' : ch = C_PERCENT_1; break; case '%' : ch = C_PERCENT_2; break; case 255 : ch = C_FULL; break ; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ch = NumberMap[*Char - ASCII_CHAR_0]; break; default: /* The character Char is one letter in upper case*/ if ( (*Char < ASCII_CHAR_LEFT_OPEN_BRACKET) && (*Char > ASCII_CHAR_AT_SYMBOL) ) { ch = CapLetterMap[*Char - 'A']; } /* The character Char is one letter in lower case*/ if ( (*Char < ASCII_CHAR_LEFT_OPEN_BRACE) && ( *Char > ASCII_CHAR_APOSTROPHE) ) { ch = CapLetterMap[*Char - 'a']; } break; } /* Set the digital point can be displayed if the point is on */ if (Point == POINT_ON) { ch |= 0x0002; } /* Set the "COL" segment in the character that can be displayed if the colon is on */ if (Colon == DOUBLEPOINT_ON) { ch |= 0x0020; } for (loop = 12,index=0 ;index < 4; loop -= 4,index++) { Digit[index] = (ch >> loop) & 0x0f; /*To isolate the less significant digit */ } } /* USER CODE END 1 */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
37.705785
115
0.561547
c3fa32802f92ce5960f396eae259d927a5b44f16
11,595
c
C
sdk/sdk/driver/net/ameba_sdio/osdep/linux/sdio_ops_linux.c
doyaGu/C0501Q_HWJL01
07a71328bd9038453cbb1cf9c276a3dd1e416d63
[ "MIT" ]
1
2021-10-09T08:05:50.000Z
2021-10-09T08:05:50.000Z
sdk/sdk/driver/net/ameba_sdio/osdep/linux/sdio_ops_linux.c
doyaGu/C0501Q_HWJL01
07a71328bd9038453cbb1cf9c276a3dd1e416d63
[ "MIT" ]
null
null
null
sdk/sdk/driver/net/ameba_sdio/osdep/linux/sdio_ops_linux.c
doyaGu/C0501Q_HWJL01
07a71328bd9038453cbb1cf9c276a3dd1e416d63
[ "MIT" ]
null
null
null
#include <sdio_ops_linux.h> #if 1 /** * sdio_register_driver - register a function driver * @drv: SDIO function driver */ extern int sdio_register_driver(struct sdio_driver *); /** * sdio_unregister_driver - unregister a function driver * @drv: SDIO function driver */ extern void sdio_unregister_driver(struct sdio_driver *); /* * SDIO I/O operations */ /** * sdio_claim_host - exclusively claim a bus for a certain SDIO function * @func: SDIO function that will be accessed * * Claim a bus for a set of operations. The SDIO function given * is used to figure out which bus is relevant. */ extern void sdio_claim_host(struct sdio_func *func); /** * sdio_release_host - release a bus for a certain SDIO function * @func: SDIO function that was accessed * * Release a bus, allowing others to claim the bus for their * operations. */ extern void sdio_release_host(struct sdio_func *func); /** * sdio_enable_func - enables a SDIO function for usage * @func: SDIO function to enable * * Powers up and activates a SDIO function so that register * access is possible. */ extern int sdio_enable_func(struct sdio_func *func); /** * sdio_disable_func - disable a SDIO function * @func: SDIO function to disable * * Powers down and deactivates a SDIO function. Register access * to this function will fail until the function is reenabled. */ extern int sdio_disable_func(struct sdio_func *func); /** * sdio_set_block_size - set the block size of an SDIO function * @func: SDIO function to change * @blksz: new block size or 0 to use the default. * * The default block size is the largest supported by both the function * and the host, with a maximum of 512 to ensure that arbitrarily sized * data transfer use the optimal (least) number of commands. * * A driver may call this to override the default block size set by the * core. This can be used to set a block size greater than the maximum * that reported by the card; it is the driver's responsibility to ensure * it uses a value that the card supports. * * Returns 0 on success, -EINVAL if the host does not support the * requested block size, or -EIO (etc.) if one of the resultant FBR block * size register writes failed. * */ extern int sdio_set_block_size(struct sdio_func *func, unsigned blksz); /** * sdio_claim_irq - claim the IRQ for a SDIO function * @func: SDIO function * @handler: IRQ handler callback * * Claim and activate the IRQ for the given SDIO function. The provided * handler will be called when that IRQ is asserted. The host is always * claimed already when the handler is called so the handler must not * call sdio_claim_host() nor sdio_release_host(). */ extern int sdio_claim_irq(struct sdio_func *func, sdio_irq_handler_t *handler); /** * sdio_release_irq - release the IRQ for a SDIO function * @func: SDIO function * * Disable and release the IRQ for the given SDIO function. */ extern int sdio_release_irq(struct sdio_func *func); /** * sdio_align_size - pads a transfer size to a more optimal value * @func: SDIO function * @sz: original transfer size * * Pads the original data size with a number of extra bytes in * order to avoid controller bugs and/or performance hits * (e.g. some controllers revert to PIO for certain sizes). * * If possible, it will also adjust the size so that it can be * handled in just a single request. * * Returns the improved size, which might be unmodified. */ extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); /** * sdio_readb - read a single byte from a SDIO function * @func: SDIO function to access * @addr: address to read * @err_ret: optional status value from transfer * * Reads a single byte from the address space of a given SDIO * function. If there is a problem reading the address, 0xff * is returned and @err_ret will contain the error code. */ extern u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret); /** * sdio_readw - read a 16 bit integer from a SDIO function * @func: SDIO function to access * @addr: address to read * @err_ret: optional status value from transfer * * Reads a 16 bit integer from the address space of a given SDIO * function. If there is a problem reading the address, 0xffff * is returned and @err_ret will contain the error code. */ extern u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret); /** * sdio_readl - read a 32 bit integer from a SDIO function * @func: SDIO function to access * @addr: address to read * @err_ret: optional status value from transfer * * Reads a 32 bit integer from the address space of a given SDIO * function. If there is a problem reading the address, * 0xffffffff is returned and @err_ret will contain the error * code. */ extern u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret); /** * sdio_memcpy_fromio - read a chunk of memory from a SDIO function * @func: SDIO function to access * @dst: buffer to store the data * @addr: address to begin reading from * @count: number of bytes to read * * Reads from the address space of a given SDIO function. Return * value indicates if the transfer succeeded or not. */ extern int sdio_memcpy_fromio(struct sdio_func *func, void *dst, unsigned int addr, int count); /** * sdio_readsb - read from a FIFO on a SDIO function * @func: SDIO function to access * @dst: buffer to store the data * @addr: address of (single byte) FIFO * @count: number of bytes to read * * Reads from the specified FIFO of a given SDIO function. Return * value indicates if the transfer succeeded or not. */ extern int sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr, int count); /** * sdio_writeb - write a single byte to a SDIO function * @func: SDIO function to access * @b: byte to write * @addr: address to write to * @err_ret: optional status value from transfer * * Writes a single byte to the address space of a given SDIO * function. @err_ret will contain the status of the actual * transfer. */ extern void sdio_writeb(struct sdio_func *func, u8 b, unsigned int addr, int *err_ret); /** * sdio_writew - write a 16 bit integer to a SDIO function * @func: SDIO function to access * @b: integer to write * @addr: address to write to * @err_ret: optional status value from transfer * * Writes a 16 bit integer to the address space of a given SDIO * function. @err_ret will contain the status of the actual * transfer. */ extern void sdio_writew(struct sdio_func *func, u16 b, unsigned int addr, int *err_ret); /** * sdio_writel - write a 32 bit integer to a SDIO function * @func: SDIO function to access * @b: integer to write * @addr: address to write to * @err_ret: optional status value from transfer * * Writes a 32 bit integer to the address space of a given SDIO * function. @err_ret will contain the status of the actual * transfer. */ extern void sdio_writel(struct sdio_func *func, u32 b, unsigned int addr, int *err_ret); /** * sdio_writeb_readb - write and read a byte from SDIO function * @func: SDIO function to access * @write_byte: byte to write * @addr: address to write to * @err_ret: optional status value from transfer * * Performs a RAW (Read after Write) operation as defined by SDIO spec - * single byte is written to address space of a given SDIO function and * response is read back from the same address, both using single request. * If there is a problem with the operation, 0xff is returned and * @err_ret will contain the error code. */ extern u8 sdio_writeb_readb(struct sdio_func *func, u8 write_byte, unsigned int addr, int *err_ret); /** * sdio_memcpy_toio - write a chunk of memory to a SDIO function * @func: SDIO function to access * @addr: address to start writing to * @src: buffer that contains the data to write * @count: number of bytes to write * * Writes to the address space of a given SDIO function. Return * value indicates if the transfer succeeded or not. */ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, void *src, int count); /** * sdio_writesb - write to a FIFO of a SDIO function * @func: SDIO function to access * @addr: address of (single byte) FIFO * @src: buffer that contains the data to write * @count: number of bytes to write * * Writes to the specified FIFO of a given SDIO function. Return * value indicates if the transfer succeeded or not. */ extern int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src, int count); /** * sdio_f0_readb - read a single byte from SDIO function 0 * @func: an SDIO function of the card * @addr: address to read * @err_ret: optional status value from transfer * * Reads a single byte from the address space of SDIO function 0. * If there is a problem reading the address, 0xff is returned * and @err_ret will contain the error code. */ extern unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr, int *err_ret); /** * sdio_f0_writeb - write a single byte to SDIO function 0 * @func: an SDIO function of the card * @b: byte to write * @addr: address to write to * @err_ret: optional status value from transfer * * Writes a single byte to the address space of SDIO function 0. * @err_ret will contain the status of the actual transfer. * * Only writes to the vendor specific CCCR registers (0xF0 - * 0xFF) are permiited; @err_ret will be set to -EINVAL for * * writes outside this range. */ extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, int *err_ret); /** * sdio_get_host_pm_caps - get host power management capabilities * @func: SDIO function attached to host * * Returns a capability bitmask corresponding to power management * features supported by the host controller that the card function * might rely upon during a system suspend. The host doesn't need * to be claimed, nor the function active, for this information to be * obtained. */ extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func); /** * sdio_set_host_pm_flags - set wanted host power management capabilities * @func: SDIO function attached to host * * Set a capability bitmask corresponding to wanted host controller * power management features for the upcoming suspend state. * This must be called, if needed, each time the suspend method of * the function driver is called, and must contain only bits that * were returned by sdio_get_host_pm_caps(). * The host doesn't need to be claimed, nor the function active, * for this information to be set. */ extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags); #endif int rtw_sdio_set_drvdata(struct sdio_func *func, void *data){ sdio_set_drvdata(func, data); return 0; } void *rtw_sdio_get_drvdata(struct sdio_func *func){ return sdio_get_drvdata(func); } int rtw_sdio_set_block_size(struct sdio_func *func, unsigned int blksz){ return sdio_set_block_size(func, blksz); } const SDIO_BUS_OPS rtw_sdio_bus_ops = { // 0 NULL, //bus_probe NULL, //bus_remove sdio_enable_func,//enable_func sdio_disable_func,//disable_func sdio_register_driver,//reg_driver sdio_unregister_driver,//unreg_driver // 6 sdio_claim_irq,//claim_irq sdio_release_irq,//release_irq sdio_claim_host,//claim_host sdio_release_host,//release_host // 10 sdio_readb,//readb sdio_readw,//readw sdio_readl,//readl // 13 sdio_writeb,//writeb sdio_writew,//writew sdio_writel,//writel // 16 sdio_memcpy_fromio,//memcpy_fromio sdio_memcpy_toio,//memcpy_toio sdio_f0_readb, //f0_readb sdio_f0_writeb//f0_writeb };
34.81982
79
0.741182
c3403921db5109845db109685f49eb32e843a6b2
791
c
C
structDemo2.c
saransh4975/c-codes
3d6a055a972a6cc5d89a95a186a08bf1019ca575
[ "MIT" ]
null
null
null
structDemo2.c
saransh4975/c-codes
3d6a055a972a6cc5d89a95a186a08bf1019ca575
[ "MIT" ]
null
null
null
structDemo2.c
saransh4975/c-codes
3d6a055a972a6cc5d89a95a186a08bf1019ca575
[ "MIT" ]
null
null
null
#include<stdio.h> #include<string.h> struct student{ int rollNo,standard; char name[10],section; }; void main(){ struct student s[3]; for(int i=0; i<3; i++){ printf("Enter name\n"); fflush(stdin); scanf("%[^\n]",&s[i].name); printf("Enter roll No.\n"); scanf("%d",&s[i].rollNo); printf("Enter standard.\n"); scanf("%d",&s[i].standard); printf("Enter section.\n"); fflush(stdin); scanf("%c",&s[i].section); } for(int i=0; i<=2; i++){ printf("Name : %s RollNo %d Standard %d Section %c\n",s[i].name,s[i].rollNo,s[i].standard,s[i].section); } int tempId; printf("Enter the id of student to find"); scanf("%d",&tempId); printf("Name : %s RollNo %d Standard %d Section %c\n",s[tempId].name,s[tempId].rollNo,s[tempId].standard,s[tempId].section); }
20.815789
126
0.608091
c9b82bbeb0dd5d854fe1b1a29e2547180b82536a
1,118
h
C
thirdparty/vesta/KeplerianTrajectory.h
hoehnp/SpaceDesignTool
9abd34048274b2ce9dbbb685124177b02d6a34ca
[ "IJG" ]
6
2018-09-05T12:41:59.000Z
2021-07-01T05:34:23.000Z
thirdparty/vesta/KeplerianTrajectory.h
hoehnp/SpaceDesignTool
9abd34048274b2ce9dbbb685124177b02d6a34ca
[ "IJG" ]
2
2015-02-07T19:09:21.000Z
2015-08-14T03:15:42.000Z
thirdparty/vesta/KeplerianTrajectory.h
hoehnp/SpaceDesignTool
9abd34048274b2ce9dbbb685124177b02d6a34ca
[ "IJG" ]
2
2015-03-25T15:50:31.000Z
2017-12-06T12:16:47.000Z
/* * $Revision: 223 $ $Date: 2010-03-30 05:44:44 -0700 (Tue, 30 Mar 2010) $ * * Copyright by Astos Solutions GmbH, Germany * * this file is published under the Astos Solutions Free Public License * For details on copyright and terms of use see * http://www.astos.de/Astos_Solutions_Free_Public_License.html */ #ifndef _VESTA_KEPLERIAN_TRAJECTORY_H_ #define _VESTA_KEPLERIAN_TRAJECTORY_H_ #include "Trajectory.h" #include "OrbitalElements.h" #include <Eigen/Geometry> namespace vesta { class KeplerianTrajectory : public Trajectory { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW KeplerianTrajectory(const OrbitalElements& elements); virtual StateVector state(double t) const; virtual double boundingSphereRadius() const; virtual bool isPeriodic() const { // Circular and elliptical orbits are periodic; hyperbolic // and parabolic orbits are not. return m_elements.eccentricity < 1.0; } virtual double period() const; private: OrbitalElements m_elements; Eigen::Quaterniond m_orbitOrientation; }; } #endif // _VESTA_KEPLERIAN_TRAJECTORY_H_
23.291667
73
0.738819
445904969eb06876e402a39a7c4fb00e00a25f41
1,756
h
C
gnuradio-3.7.13.4/gr-digital/include/gnuradio/digital/glfsr.h
v1259397/cosmic-gnuradio
64c149520ac6a7d44179c3f4a38f38add45dd5dc
[ "BSD-3-Clause" ]
1
2021-03-09T07:32:37.000Z
2021-03-09T07:32:37.000Z
gnuradio-3.7.13.4/gr-digital/include/gnuradio/digital/glfsr.h
v1259397/cosmic-gnuradio
64c149520ac6a7d44179c3f4a38f38add45dd5dc
[ "BSD-3-Clause" ]
null
null
null
gnuradio-3.7.13.4/gr-digital/include/gnuradio/digital/glfsr.h
v1259397/cosmic-gnuradio
64c149520ac6a7d44179c3f4a38f38add45dd5dc
[ "BSD-3-Clause" ]
null
null
null
/* -*- c++ -*- */ /* * Copyright 2007,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_DIGITAL_GLFSR_H #define INCLUDED_DIGITAL_GLFSR_H #include <gnuradio/digital/api.h> namespace gr { namespace digital { /*! * \brief Galois Linear Feedback Shift Register using specified polynomial mask * \ingroup waveform_generators_blk * * \details * Generates a maximal length pseudo-random sequence of length 2^degree-1 */ class DIGITAL_API glfsr { private: int d_shift_register; int d_mask; public: glfsr(int mask, int seed) { d_shift_register = seed; d_mask = mask; } ~glfsr(); static int glfsr_mask(int degree); unsigned char next_bit() { unsigned char bit = d_shift_register & 1; d_shift_register >>= 1; if(bit) d_shift_register ^= d_mask; return bit; } int mask() const { return d_mask; } }; } /* namespace digital */ } /* namespace gr */ #endif /* INCLUDED_DIGITAL_GLFSR_H */
26.606061
83
0.683371
68e664f8c3683cd45932b4f1cad7cb938d3acacc
694
h
C
src/camera_control.h
paulmiller/glFun
39df2c7f92b41c09d618b81e2016f1c530fb2108
[ "Unlicense" ]
null
null
null
src/camera_control.h
paulmiller/glFun
39df2c7f92b41c09d618b81e2016f1c530fb2108
[ "Unlicense" ]
null
null
null
src/camera_control.h
paulmiller/glFun
39df2c7f92b41c09d618b81e2016f1c530fb2108
[ "Unlicense" ]
null
null
null
#ifndef CAMERA_CONTROL_H #define CAMERA_CONTROL_H #include "camera.h" #include "glfw_window.h" class CameraControl : public GlfwWindow::Observer { public: CameraControl(int width, int height); Camera *getCam(); void onFramebufferSize(int width, int height) override; void onMouseButton(int button, int action, int mods) override; void onCursorPosition(double x, double y) override; private: Camera cam_; double rotation_; double declination_; double distance_; bool dragging_; double drag_scale_; double drag_start_x_, drag_start_y_; double drag_end_x_, drag_end_y_; double draggedRotation(); double draggedDeclination(); void updateCamPos(); }; #endif
19.828571
64
0.757925
70a0185e11900db6da419dc35063451f93102e09
23,538
c
C
src/drivers/tsamurai.c
FlexingTiger/mame4allds
9159c67974609a1099a92afa2fc98c0e42edd33c
[ "Linux-OpenIB" ]
null
null
null
src/drivers/tsamurai.c
FlexingTiger/mame4allds
9159c67974609a1099a92afa2fc98c0e42edd33c
[ "Linux-OpenIB" ]
null
null
null
src/drivers/tsamurai.c
FlexingTiger/mame4allds
9159c67974609a1099a92afa2fc98c0e42edd33c
[ "Linux-OpenIB" ]
null
null
null
#include "../vidhrdw/tsamurai.c" /**************************************************************************** Preliminary driver for Samurai, Nunchackun, Yuke Yuke Yamaguchi-kun (c) Taito 1985 Known Issues: - some color problems (need screenshots) - Nunchackun has wrong colors; sprites look better if you subtract sprite color from 0x2d - Yuke Yuke Yamaguchi-kun isn't playable (sprite problem only?) driver by Phil Stroffolino ****************************************************************************/ #include "driver.h" #include "cpu/z80/z80.h" #include "vidhrdw/generic.h" WRITE_HANDLER( tsamurai_bgcolor_w ); WRITE_HANDLER( tsamurai_textbank_w ); WRITE_HANDLER( tsamurai_scrolly_w ); WRITE_HANDLER( tsamurai_scrollx_w ); extern void tsamurai_vh_screenrefresh( struct osd_bitmap *bitmap, int fullrefresh ); extern void tsamurai_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); WRITE_HANDLER( tsamurai_bg_videoram_w ); WRITE_HANDLER( tsamurai_fg_videoram_w ); WRITE_HANDLER( tsamurai_fg_colorram_w ); extern int tsamurai_vh_start( void ); extern unsigned char *tsamurai_videoram; static struct AY8910interface ay8910_interface = { 1, /* number of chips */ 2000000, /* 2 MHz */ { 10 }, { 0 }, { 0 }, { 0 }, { 0 } }; static struct DACinterface dac_interface = { 2, /* number of chips */ { 20, 20 } }; static int nmi_enabled; static int sound_command1, sound_command2; static WRITE_HANDLER( nmi_enable_w ){ nmi_enabled = data; } static int samurai_interrupt( void ){ return nmi_enabled? nmi_interrupt():ignore_interrupt(); } READ_HANDLER( unknown_d803_r ) { return 0x6b; // nogi } READ_HANDLER( unknown_d806_r ) { return 0x40; } READ_HANDLER( unknown_d900_r ) { return 0x6a; } READ_HANDLER( unknown_d938_r ) { return 0xfb; // nogi } static WRITE_HANDLER( sound_command1_w ) { sound_command1 = data; cpu_cause_interrupt( 1, Z80_IRQ_INT ); } static WRITE_HANDLER( sound_command2_w ) { sound_command2 = data; cpu_cause_interrupt( 2, Z80_IRQ_INT ); } static struct MemoryReadAddress readmem[] = { { 0x0000, 0xbfff, MRA_ROM }, { 0xc000, 0xcfff, MRA_RAM }, /* protection? */ { 0xd803, 0xd803, unknown_d803_r }, { 0xd806, 0xd806, unknown_d806_r }, { 0xd900, 0xd900, unknown_d900_r }, { 0xd938, 0xd938, unknown_d938_r }, { 0xe000, 0xe3ff, MRA_RAM }, { 0xe400, 0xe7ff, MRA_RAM }, { 0xe800, 0xefff, MRA_RAM }, { 0xf000, 0xf3ff, MRA_RAM }, { 0xf800, 0xf800, input_port_0_r }, { 0xf801, 0xf801, input_port_1_r }, { 0xf802, 0xf802, input_port_2_r }, { 0xf804, 0xf804, input_port_3_r }, { 0xf805, 0xf805, input_port_4_r }, { -1 } }; static struct MemoryWriteAddress writemem[] = { { 0x0000, 0xbfff, MWA_ROM }, { 0xc000, 0xcfff, MWA_RAM }, { 0xe000, 0xe3ff, tsamurai_fg_videoram_w, &videoram }, { 0xe400, 0xe43f, tsamurai_fg_colorram_w, &colorram }, // nogi { 0xe440, 0xe7ff, MWA_RAM }, { 0xe800, 0xefff, tsamurai_bg_videoram_w, &tsamurai_videoram }, { 0xf000, 0xf3ff, MWA_RAM, &spriteram }, { 0xf400, 0xf400, MWA_NOP }, { 0xf401, 0xf401, sound_command1_w }, { 0xf402, 0xf402, sound_command2_w }, { 0xf801, 0xf801, tsamurai_bgcolor_w }, { 0xf802, 0xf802, tsamurai_scrolly_w }, { 0xf803, 0xf803, tsamurai_scrollx_w }, { 0xfc00, 0xfc00, flip_screen_w }, { 0xfc01, 0xfc01, nmi_enable_w }, { 0xfc02, 0xfc02, tsamurai_textbank_w }, { 0xfc03, 0xfc04, coin_counter_w }, { -1 } }; static struct IOReadPort z80_readport[] = { { -1 } }; static struct IOWritePort z80_writeport[] = { { 0x00, 0x00, AY8910_control_port_0_w }, { 0x01, 0x01, AY8910_write_port_0_w }, { -1 } }; /*******************************************************************************/ static READ_HANDLER( sound_command1_r ) { return sound_command1; } static WRITE_HANDLER( sound_out1_w ) { DAC_data_w(0,data); } static struct MemoryReadAddress readmem_sound1[] = { { 0x0000, 0x3fff, MRA_ROM }, { 0x6000, 0x6000, sound_command1_r }, { 0x7f00, 0x7fff, MRA_RAM }, { -1 } }; static struct MemoryWriteAddress writemem_sound1[] = { { 0x0000, 0x3fff, MWA_ROM }, { 0x6001, 0x6001, MWA_NOP }, /* ? */ { 0x6002, 0x6002, sound_out1_w }, { 0x7f00, 0x7fff, MWA_RAM }, { -1 } }; /*******************************************************************************/ static READ_HANDLER( sound_command2_r ){ return sound_command2; } static WRITE_HANDLER( sound_out2_w ){ DAC_data_w(1,data); } static struct MemoryReadAddress readmem_sound2[] = { { 0x0000, 0x3fff, MRA_ROM }, { 0x6000, 0x6000, sound_command2_r }, { 0x7f00, 0x7fff, MRA_RAM }, { -1 } }; static struct MemoryWriteAddress writemem_sound2[] = { { 0x0000, 0x3fff, MWA_ROM }, { 0x6001, 0x6001, MWA_NOP }, /* ? */ { 0x6002, 0x6002, sound_out2_w }, { 0x7f00, 0x7fff, MWA_RAM }, { -1 } }; /*******************************************************************************/ INPUT_PORTS_START( tsamurai ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START /* DSW1 */ PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x07, DEF_STR( 6C_1C ) ) PORT_DIPSETTING( 0x06, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x05, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coin_B ) ) PORT_DIPSETTING( 0x38, DEF_STR( 6C_1C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x28, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x18, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x40, 0x00, "Freeze" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) ) PORT_START /* DSW2 */ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x01, "5" ) PORT_DIPSETTING( 0x02, "7" ) PORT_BITX(0, 0x03, IPT_DIPSWITCH_SETTING | IPF_CHEAT, "254", IP_KEY_NONE, IP_JOY_NONE ) PORT_DIPNAME( 0x0c, 0x0c, "DSW2 Unknown 1" ) PORT_DIPSETTING( 0x00, "00" ) PORT_DIPSETTING( 0x04, "30" ) PORT_DIPSETTING( 0x08, "50" ) PORT_DIPSETTING( 0x0c, "70" ) PORT_DIPNAME( 0x30, 0x30, "DSW2 Unknown 2" ) PORT_DIPSETTING( 0x00, "0x00" ) PORT_DIPSETTING( 0x10, "0x01" ) PORT_DIPSETTING( 0x20, "0x02" ) PORT_DIPSETTING( 0x30, "0x03" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, "DSW2 Unknown 3" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( nunchaku ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START /* DSW1 */ PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x07, DEF_STR( 6C_1C ) ) PORT_DIPSETTING( 0x06, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x05, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coin_B ) ) PORT_DIPSETTING( 0x38, DEF_STR( 6C_1C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x28, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x18, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x40, 0x00, "Freeze" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) ) PORT_START /* DSW2 */ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x01, "5" ) PORT_DIPSETTING( 0x02, "7" ) PORT_BITX(0, 0x03, IPT_DIPSWITCH_SETTING | IPF_CHEAT, "255", IP_KEY_NONE, IP_JOY_NONE ) PORT_DIPNAME( 0x0c, 0x0c, "DSW2 Unknown 1" ) PORT_DIPSETTING( 0x00, "00" ) PORT_DIPSETTING( 0x04, "30" ) PORT_DIPSETTING( 0x08, "50" ) PORT_DIPSETTING( 0x0c, "70" ) PORT_DIPNAME( 0x30, 0x30, "DSW2 Unknown 2" ) PORT_DIPSETTING( 0x00, "0x00" ) PORT_DIPSETTING( 0x10, "0x01" ) PORT_DIPSETTING( 0x20, "0x02" ) PORT_DIPSETTING( 0x30, "0x03" ) PORT_DIPNAME( 0x40, 0x40, "DSW2 Unknown 3" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, "DSW2 Unknown 4" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( yamagchi ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START /* DSW1 */ PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x07, DEF_STR( 6C_1C ) ) PORT_DIPSETTING( 0x06, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x05, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coin_B ) ) PORT_DIPSETTING( 0x38, DEF_STR( 6C_1C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x28, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x18, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x40, 0x00, "Freeze" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) ) PORT_START /* DSW2 */ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x01, "5" ) PORT_DIPSETTING( 0x02, "7" ) PORT_BITX(0, 0x03, IPT_DIPSWITCH_SETTING | IPF_CHEAT, "255", IP_KEY_NONE, IP_JOY_NONE ) PORT_DIPNAME( 0x0c, 0x0c, "DSW2 Unknown 1" ) PORT_DIPSETTING( 0x00, "00" ) PORT_DIPSETTING( 0x04, "30" ) PORT_DIPSETTING( 0x08, "50" ) PORT_DIPSETTING( 0x0c, "70" ) PORT_DIPNAME( 0x10, 0x10, "Language" ) PORT_DIPSETTING( 0x10, "English" ) PORT_DIPSETTING( 0x00, "Japanese" ) PORT_DIPNAME( 0x20, 0x20, "DSW2 Unknown 2" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, "DSW2 Unknown 3" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END static struct GfxLayout char_layout = { 8,8, 0x200, 3, { 2*0x1000*8, 1*0x1000*8, 0*0x1000*8 }, { 0,1,2,3, 4,5,6,7 }, { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8 }, 8*8 }; static struct GfxLayout sprite_layout = { 32,32, 0x80, 3, { 2*0x4000*8, 1*0x4000*8, 0*0x4000*8 }, { 0,1,2,3,4,5,6,7, 64+0,64+1,64+2,64+3,64+4,64+5,64+6,64+7, 128+0,128+1,128+2,128+3,128+4,128+5,128+6,128+7, 64*3+0,64*3+1,64*3+2,64*3+3,64*3+4,64*3+5,64*3+6,64*3+7 }, { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8, 1*256+0*8,1*256+1*8,1*256+2*8,1*256+3*8,1*256+4*8,1*256+5*8,1*256+6*8,1*256+7*8, 2*256+0*8,2*256+1*8,2*256+2*8,2*256+3*8,2*256+4*8,2*256+5*8,2*256+6*8,2*256+7*8, 3*256+0*8,3*256+1*8,3*256+2*8,3*256+3*8,3*256+4*8,3*256+5*8,3*256+6*8,3*256+7*8 }, 4*256 }; static struct GfxLayout tile_layout = { 8,8, 0x400, 3, { 2*0x2000*8, 1*0x2000*8, 0*0x2000*8 }, { 0,1,2,3,4,5,6,7 }, { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8 }, 8*8 }; static struct GfxDecodeInfo gfxdecodeinfo[] = { { REGION_GFX1, 0, &tile_layout, 0, 32 }, { REGION_GFX2, 0, &char_layout, 0, 32 }, { REGION_GFX3, 0, &sprite_layout, 0, 32 }, { -1 } }; static struct MachineDriver machine_driver_tsamurai = { { { CPU_Z80, 4000000, readmem,writemem,z80_readport, z80_writeport, samurai_interrupt,1, }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, readmem_sound1,writemem_sound1,0,0, ignore_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, readmem_sound2,writemem_sound2,0,0, ignore_interrupt,1 } }, 60, DEFAULT_REAL_60HZ_VBLANK_DURATION, 1, /* CPU slices */ 0, /* init machine */ /* video hardware */ 32*8, 32*8, { 0, 255, 8, 255-8 }, gfxdecodeinfo, 256,256, tsamurai_convert_color_prom, VIDEO_TYPE_RASTER, 0, tsamurai_vh_start, 0, tsamurai_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface }, { SOUND_DAC, &dac_interface } } }; ROM_START( tsamurai ) ROM_REGION( 0x10000, REGION_CPU1 ) /* Z80 code - main CPU */ ROM_LOAD( "01.3r", 0x0000, 0x4000, 0xd09c8609 ) ROM_LOAD( "02.3t", 0x4000, 0x4000, 0xd0f2221c ) ROM_LOAD( "03.3v", 0x8000, 0x4000, 0xeee8b0c9 ) ROM_REGION( 0x10000 , REGION_CPU2 ) /* Z80 code - sample player#1 */ ROM_LOAD( "14.4e", 0x0000, 0x2000, 0x220e9c04 ) ROM_LOAD( "a35-15.4c", 0x2000, 0x2000, 0x1e0d1e33 ) ROM_REGION( 0x10000, REGION_CPU3 ) /* Z80 code - sample player#2 */ ROM_LOAD( "13.4j", 0x0000, 0x2000, 0x73feb0e2 ) ROM_REGION( 0x06000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a35-04.10a", 0x00000, 0x2000, 0xb97ce9b1 ) // tiles ROM_LOAD( "a35-05.10b", 0x02000, 0x2000, 0x55a17b08 ) ROM_LOAD( "a35-06.10d", 0x04000, 0x2000, 0xf5ee6f8f ) ROM_REGION( 0x03000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a35-10.11n", 0x00000, 0x1000, 0x0b5a0c45 ) // characters ROM_LOAD( "a35-11.11q", 0x01000, 0x1000, 0x93346d75 ) ROM_LOAD( "a35-12.11r", 0x02000, 0x1000, 0xf4c69d8a ) ROM_REGION( 0x0c000, REGION_GFX3 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a35-07.12h", 0x00000, 0x4000, 0x38fc349f ) // sprites ROM_LOAD( "a35-08.12j", 0x04000, 0x4000, 0xa07d6dc3 ) ROM_LOAD( "a35-09.12k", 0x08000, 0x4000, 0xc0784a0e ) ROM_REGION( 0x0300, REGION_PROMS ) ROM_LOAD( "a35-16.2j", 0x0000, 0x0100, 0x72d8b332 ) ROM_LOAD( "a35-17.2l", 0x0100, 0x0100, 0x9bf1829e ) ROM_LOAD( "a35-18.2m", 0x0200, 0x0100, 0x918e4732 ) ROM_END ROM_START( tsamura2 ) ROM_REGION( 0x10000, REGION_CPU1 ) /* Z80 code - main CPU */ ROM_LOAD( "a35-01.3r", 0x0000, 0x4000, 0x282d96ad ) ROM_LOAD( "a35-02.3t", 0x4000, 0x4000, 0xe3fa0cfa ) ROM_LOAD( "a35-03.3v", 0x8000, 0x4000, 0x2fff1e0a ) ROM_REGION( 0x10000 , REGION_CPU2 ) /* Z80 code - sample player#1 */ ROM_LOAD( "a35-14.4e", 0x0000, 0x2000, 0xf10aee3b ) ROM_LOAD( "a35-15.4c", 0x2000, 0x2000, 0x1e0d1e33 ) ROM_REGION( 0x10000, REGION_CPU3 ) /* Z80 code - sample player#2 */ ROM_LOAD( "a35-13.4j", 0x0000, 0x2000, 0x3828f4d2 ) ROM_REGION( 0x06000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a35-04.10a", 0x00000, 0x2000, 0xb97ce9b1 ) // tiles ROM_LOAD( "a35-05.10b", 0x02000, 0x2000, 0x55a17b08 ) ROM_LOAD( "a35-06.10d", 0x04000, 0x2000, 0xf5ee6f8f ) ROM_REGION( 0x03000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a35-10.11n", 0x00000, 0x1000, 0x0b5a0c45 ) // characters ROM_LOAD( "a35-11.11q", 0x01000, 0x1000, 0x93346d75 ) ROM_LOAD( "a35-12.11r", 0x02000, 0x1000, 0xf4c69d8a ) ROM_REGION( 0x0c000, REGION_GFX3 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a35-07.12h", 0x00000, 0x4000, 0x38fc349f ) // sprites ROM_LOAD( "a35-08.12j", 0x04000, 0x4000, 0xa07d6dc3 ) ROM_LOAD( "a35-09.12k", 0x08000, 0x4000, 0xc0784a0e ) ROM_REGION( 0x0300, REGION_PROMS ) ROM_LOAD( "a35-16.2j", 0x0000, 0x0100, 0x72d8b332 ) ROM_LOAD( "a35-17.2l", 0x0100, 0x0100, 0x9bf1829e ) ROM_LOAD( "a35-18.2m", 0x0200, 0x0100, 0x918e4732 ) ROM_END ROM_START( nunchaku ) ROM_REGION( 0x10000, REGION_CPU1 ) /* Z80 code - main CPU */ ROM_LOAD( "nunchack.p1", 0x0000, 0x4000, 0x4385aca6 ) ROM_LOAD( "nunchack.p2", 0x4000, 0x4000, 0xf9beb72c ) ROM_LOAD( "nunchack.p3", 0x8000, 0x4000, 0xcde5d674 ) ROM_REGION( 0x10000 , REGION_CPU2 ) /* Z80 code - sample player */ ROM_LOAD( "nunchack.m3", 0x0000, 0x2000, 0x9036c945 ) ROM_LOAD( "nunchack.m4", 0x2000, 0x2000, 0xe7206724 ) ROM_REGION( 0x10000, REGION_CPU3 ) /* Z80 code - sample player */ ROM_LOAD( "nunchack.m1", 0x0000, 0x2000, 0xb53d73f6 ) ROM_LOAD( "nunchack.m2", 0x2000, 0x2000, 0xf37d7c49 ) ROM_REGION( 0x06000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "nunchack.b1", 0x00000, 0x2000, 0x48c88fea ) // tiles ROM_LOAD( "nunchack.b2", 0x02000, 0x2000, 0xeec818e4 ) ROM_LOAD( "nunchack.b3", 0x04000, 0x2000, 0x5f16473f ) ROM_REGION( 0x03000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "nunchack.v1", 0x00000, 0x1000, 0x358a3714 ) // characters ROM_LOAD( "nunchack.v2", 0x01000, 0x1000, 0x54c18d8e ) ROM_LOAD( "nunchack.v3", 0x02000, 0x1000, 0xf7ac203a ) ROM_REGION( 0x0c000, REGION_GFX3 | REGIONFLAG_DISPOSE ) ROM_LOAD( "nunchack.c1", 0x00000, 0x4000, 0x797cbc8a ) // sprites ROM_LOAD( "nunchack.c2", 0x04000, 0x4000, 0x701a0cc3 ) ROM_LOAD( "nunchack.c3", 0x08000, 0x4000, 0xffb841fc ) ROM_REGION( 0x0300, REGION_PROMS ) ROM_LOAD( "nunchack.016", 0x000, 0x100, 0xa7b077d4 ) ROM_LOAD( "nunchack.017", 0x100, 0x100, 0x1c04c087 ) ROM_LOAD( "nunchack.018", 0x200, 0x100, 0xf5ce3c45 ) ROM_END ROM_START( yamagchi ) ROM_REGION( 0x10000, REGION_CPU1 ) /* Z80 code - main CPU */ ROM_LOAD( "a38-01.3s", 0x0000, 0x4000, 0x1a6c8498 ) ROM_LOAD( "a38-02.3t", 0x4000, 0x4000, 0xfa66b396 ) ROM_LOAD( "a38-03.3v", 0x8000, 0x4000, 0x6a4239cf ) ROM_REGION( 0x10000 , REGION_CPU2 ) /* Z80 code - sample player */ ROM_LOAD( "a38-14.4e", 0x0000, 0x2000, 0x5a758992 ) ROM_REGION( 0x10000, REGION_CPU3 ) /* Z80 code - sample player */ ROM_LOAD( "a38-13.4j", 0x0000, 0x2000, 0xa26445bb ) ROM_REGION( 0x06000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a38-04.10a", 0x00000, 0x2000, 0x6bc69d4d ) // tiles ROM_LOAD( "a38-05.10b", 0x02000, 0x2000, 0x047fb315 ) ROM_LOAD( "a38-06.10d", 0x04000, 0x2000, 0xa636afb2 ) ROM_REGION( 0x03000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a38-10.11n", 0x00000, 0x1000, 0x51ab4671 ) // characters ROM_LOAD( "a38-11.11p", 0x01000, 0x1000, 0x27890169 ) ROM_LOAD( "a38-12.11r", 0x02000, 0x1000, 0xc98d5cf2 ) ROM_REGION( 0x0c000, REGION_GFX3 | REGIONFLAG_DISPOSE ) ROM_LOAD( "a38-07.12h", 0x00000, 0x4000, 0xa3a521b6 ) // sprites ROM_LOAD( "a38-08.12j", 0x04000, 0x4000, 0x553afc66 ) ROM_LOAD( "a38-09.12l", 0x08000, 0x4000, 0x574156ae ) ROM_REGION( 0x0300, REGION_PROMS ) ROM_LOAD( "mb7114e.2k", 0x000, 0x100, 0xe7648110 ) ROM_LOAD( "mb7114e.2l", 0x100, 0x100, 0x7b874ee6 ) ROM_LOAD( "mb7114e.2m", 0x200, 0x100, 0x938d0fce ) ROM_END GAME( 1985, tsamurai, 0, tsamurai, tsamurai, 0, ROT90, "Taito", "Samurai Nihon-ichi (set 1)" ) GAME( 1985, tsamura2, tsamurai, tsamurai, tsamurai, 0, ROT90, "Taito", "Samurai Nihon-ichi (set 2)" ) GAMEX(1985, nunchaku, 0, tsamurai, nunchaku, 0, ROT90, "Taito", "Nunchackun", GAME_WRONG_COLORS ) GAMEX(1985, yamagchi, 0, tsamurai, yamagchi, 0, ROT90, "Taito", "Go Go Mr. Yamaguchi / Yuke Yuke Yamaguchi-kun", GAME_IMPERFECT_COLORS )
33.198872
143
0.692795
b9981c0ed1b6c8364e94884e454182f9ab6b219a
2,780
h
C
libzwaveip/zconnection-internal.h
anta/libzwaveip
69f0b07d0fab69c3a92dbb46a7a91eddff1ca5b4
[ "Apache-2.0" ]
79
2016-09-16T22:04:30.000Z
2021-06-29T23:44:55.000Z
libzwaveip/zconnection-internal.h
anta/libzwaveip
69f0b07d0fab69c3a92dbb46a7a91eddff1ca5b4
[ "Apache-2.0" ]
41
2016-09-21T09:50:21.000Z
2019-10-28T08:34:57.000Z
libzwaveip/zconnection-internal.h
anta/libzwaveip
69f0b07d0fab69c3a92dbb46a7a91eddff1ca5b4
[ "Apache-2.0" ]
33
2016-09-21T05:02:04.000Z
2021-09-21T10:43:40.000Z
/* * Copyright 2016 Sigma Designs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * zconneciton-internal.h * * Created on: Aug 22, 2016 * Author: aes */ #ifndef ZCONNECITON_INTERNAL_H_ #define ZCONNECITON_INTERNAL_H_ #include "zconnection.h" #ifdef WIN32 #include <Ws2tcpip.h> #else #include <netinet/in.h> #endif #include <openssl/ssl.h> #define MAXPSK 64 /** * Object holding the state between a Z/IP client and a Z/IP service. */ struct zconnection { enum { STATE_IDLE, STATE_TRANSMISSION_IN_PROGRESS, } state; uint8_t seq; uint8_t local_endpoint; /// Local endpoint of the frame being sent or /// received uint8_t remote_endpoint; /// Remote endpoint of the frame being sent or /// received uint8_t encapsulation1; /// Encapsulation format of the frame being sent or /// received uint8_t encapsulation2; /// Encapsulation format of the frame being sent or /// received uint32_t expected_delay; /// Expected delay of the frame which has just been /// sent. transfer_func_t send; transfer_func_t recv; transmit_done_func_t transmit_done; void* info; void* user_context; uint16_t timeout; pthread_mutex_t mutex; pthread_cond_t send_done_cond; pthread_mutex_t send_done_mutex; struct ima_data ima; }; struct pass_info { union { struct sockaddr_storage ss; struct sockaddr_in6 s6; struct sockaddr_in s4; } local_addr, remote_addr; SSL *ssl; int is_client; int is_running; struct zconnection connection; int fd; char psk[MAXPSK]; int psk_len; #if WIN32 WSADATA wsaData; DWORD tid; #else pthread_t tid; pthread_cond_t handshake_cond; pthread_mutex_t handshake_mutex; #endif }; /** * Entry point for all packages into the client module */ void zconnection_recv_raw(struct zconnection* connection, const uint8_t* data, uint16_t datalen); /** * MUST be called every 100ms */ void zconnection_timer_100ms(struct zconnection* connection); /** * Send keepalive to remote */ void zconnection_send_keepalive(struct zconnection* connection); #endif /* ZCONNECITON_INTERNAL_H_ */
23.965517
79
0.691007
9a09b8867a031cd574e1aa0672867e8cf0c29904
3,011
c
C
compilers/official-network-plugins/src/main/resources/templates/PosixTimerPlugin.c
brice-morin/ThingML
5f800da71075e40b9ddf08e8ef5ac37d984cd140
[ "Apache-2.0" ]
53
2017-06-13T07:31:21.000Z
2022-02-20T06:52:25.000Z
compilers/official-network-plugins/src/main/resources/templates/PosixTimerPlugin.c
CaoE/ThingML
9c06202d5437328e149d1d40a4cc6191f8a85e07
[ "Apache-2.0" ]
139
2017-06-16T10:06:16.000Z
2021-07-29T15:49:54.000Z
compilers/official-network-plugins/src/main/resources/templates/PosixTimerPlugin.c
CaoE/ThingML
9c06202d5437328e149d1d40a4cc6191f8a85e07
[ "Apache-2.0" ]
30
2017-06-14T20:54:12.000Z
2022-03-31T08:28:35.000Z
#include "Timer.h" #include <time.h> #include <unistd.h> #include <pthread.h> uint32_t Timer_timeouts[NB_SOFT_TIMERS]; uint8_t Timer_wraps[NB_SOFT_TIMERS]; uint32_t Timer_prev; pthread_mutex_t Timer_mut; uint32_t Timer_millis() { struct timespec current; int res; uint32_t millis; res = clock_gettime(CLOCK_REALTIME, &current); if (res != 0) { perror("[ERROR]: Could not get current time : "); return 0; } else { millis = current.tv_sec * 1000; millis += current.tv_nsec / 1000000; return millis; } } void Timer_setup(struct Timer_Instance *_instance) { pthread_mutex_init(&Timer_mut, NULL); uint8_t i; for (i = 0; i < NB_SOFT_TIMERS; i++) { Timer_timeouts[i] = 0; Timer_wraps[i] = 0; } Timer_prev = Timer_millis(); } void Timer_enqueue_timeout(uint8_t id, uint16_t listener_id) { /*ENQUEUERS*/ } void Timer_loop(struct Timer_Instance *_instance) { while (1) { pthread_mutex_lock(&Timer_mut); uint32_t current = Timer_millis(); uint8_t i; for (i = 0; i < NB_SOFT_TIMERS; i++) { if (Timer_timeouts[i] > 0) { if (current >= Timer_prev) { // Normal time progression if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) { Timer_enqueue_timeout(i, _instance->listener_id); Timer_timeouts[i] = 0; Timer_wraps[i] = 0; } } else { // A wraparound has occurred if (Timer_wraps[i] == 0) { Timer_enqueue_timeout(i, _instance->listener_id); Timer_timeouts[i] = 0; } else { Timer_wraps[i] = 0; if (current > Timer_timeouts[i]) { Timer_enqueue_timeout(i, _instance->listener_id); Timer_timeouts[i] = 0; } } } } } Timer_prev = current; pthread_mutex_unlock(&Timer_mut); // Wait about a millisecond for the next check usleep(1000); } } void Timer_timer_start(uint8_t id, uint32_t delay) { if (id < NB_SOFT_TIMERS) { uint32_t current = Timer_millis(); uint32_t timeout = current + delay; if (timeout == 0) timeout = 1; pthread_mutex_lock(&Timer_mut); Timer_timeouts[id] = timeout; Timer_wraps[id] = (timeout > current) ? 0 : 1; pthread_mutex_unlock(&Timer_mut); } } void Timer_timer_cancel(uint8_t id) { if (id < NB_SOFT_TIMERS) { pthread_mutex_lock(&Timer_mut); Timer_timeouts[id] = 0; Timer_wraps[id] = 0; pthread_mutex_unlock(&Timer_mut); } } // Message forwarders /*FORWARDERS*/
27.372727
78
0.525739
787b8f77fd9be8ffdf796800f5aa7113e5ccc1d3
160
c
C
Exercise_5_05_p_107/strNCpy.c
hamiltonjr/TheCProgLang
d43e000aaee8e180adaeee542a1809ac0326cf71
[ "MIT" ]
null
null
null
Exercise_5_05_p_107/strNCpy.c
hamiltonjr/TheCProgLang
d43e000aaee8e180adaeee542a1809ac0326cf71
[ "MIT" ]
null
null
null
Exercise_5_05_p_107/strNCpy.c
hamiltonjr/TheCProgLang
d43e000aaee8e180adaeee542a1809ac0326cf71
[ "MIT" ]
null
null
null
/* * This function copies string t to s. */ void strNCpy(char *s, const char *t, int n) { for ( ; (*s = *t) && (--n > 0); s++, t++); *(++s) = '\0'; }
17.777778
46
0.43125
cd63122a60642a7286e0c1e5c4a46ecc1b6d0554
1,116
c
C
libft/src/ft_memchr.c
hamza-ezzahiry/RT
f08a99f5aaee8122149b6532a8c4f9b1a2f08481
[ "MIT" ]
null
null
null
libft/src/ft_memchr.c
hamza-ezzahiry/RT
f08a99f5aaee8122149b6532a8c4f9b1a2f08481
[ "MIT" ]
null
null
null
libft/src/ft_memchr.c
hamza-ezzahiry/RT
f08a99f5aaee8122149b6532a8c4f9b1a2f08481
[ "MIT" ]
2
2020-11-16T00:52:55.000Z
2021-03-06T13:28:02.000Z
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memchr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: anabaoui <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/10 13:40:32 by anabaoui #+# #+# */ /* Updated: 2018/10/20 17:36:02 by anabaoui ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void *ft_memchr(const void *s, int c, size_t n) { char *ptrs; ptrs = (char *)s; while (n--) { if ((unsigned char)*ptrs == (unsigned char)c) { return (ptrs); } ptrs++; } return (NULL); }
37.2
80
0.196237
780d3791fadd592cfabc238ce6444157b0a9e24a
1,685
h
C
hdi/service/include/battery_config.h
openharmony-gitee-mirror/powermgr_battery_manager
e8e1c9d1a6a22a494427a2d4b97511d49e6ca13b
[ "Apache-2.0" ]
null
null
null
hdi/service/include/battery_config.h
openharmony-gitee-mirror/powermgr_battery_manager
e8e1c9d1a6a22a494427a2d4b97511d49e6ca13b
[ "Apache-2.0" ]
null
null
null
hdi/service/include/battery_config.h
openharmony-gitee-mirror/powermgr_battery_manager
e8e1c9d1a6a22a494427a2d4b97511d49e6ca13b
[ "Apache-2.0" ]
2
2021-09-13T11:17:09.000Z
2022-01-20T16:27:55.000Z
/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef BATTERY_CONFIG_H #define BATTERY_CONFIG_H #include <string> #include <vector> #include <fstream> #include <json/json.h> namespace OHOS { namespace HDI { namespace Battery { namespace V1_0 { class BatteryConfig { public: struct LedConf { int capacityBegin; int capacityEnd; int color; int brightness; }; struct TempConf { int lower; int upper; }; int32_t Init(); std::vector<LedConf> GetLedConf(); BatteryConfig::TempConf GetTempConf(); int GetCapacityConf(); private: enum JsonConfIndex { INDEX_ZERO = 0, INDEX_ONE, INDEX_TWO, INDEX_THREE, }; int32_t ParseLedConf(Json::Value &root); int32_t ParseTempConf(Json::Value &root); int32_t ParseCapacityConf(Json::Value &root); int32_t ParseConfig(const std::string filename); std::vector<BatteryConfig::LedConf> ledConf_; struct TempConf tempConf_; int capacityConf_ = -1; }; } // namespace V1_0 } // namespace Battery } // namespace HDI } // namespace OHOS #endif
24.779412
75
0.681306
935652d95581c0d48726780f0746de40c0bfd745
844
h
C
src/platformer/object/object.h
marstau/shinsango
d9468787ae8e18fa478f936770d88e9bf93c11c0
[ "BSD-3-Clause" ]
1
2021-06-16T15:25:47.000Z
2021-06-16T15:25:47.000Z
src/platformer/object/object.h
marstau/shinsango
d9468787ae8e18fa478f936770d88e9bf93c11c0
[ "BSD-3-Clause" ]
null
null
null
src/platformer/object/object.h
marstau/shinsango
d9468787ae8e18fa478f936770d88e9bf93c11c0
[ "BSD-3-Clause" ]
null
null
null
#ifndef platformer_object_h #define platformer_object_h #include <vector> class Token; /*! Platformers object class */ namespace Platformer{ class Object{ public: Object(); virtual ~Object(); virtual void act(); inline virtual void attachCamera(int id){ this->attachedCamera = id; this->followed = true; } inline virtual void detachCamera(){ this->followed = false; } inline virtual bool isFollowed(){ return this->followed; } protected: /*! Camera Info */ bool followed; int attachedCamera; /*! Object Info */ int x; int y; int width; int height; int life; bool invincible; }; } #endif
18.347826
49
0.514218
9357222efba14a4a93f2d1d9b4e035a98d988ccb
288
h
C
dev/hsed/hsed/comutil.h
dolphilia/machsp
0acb5cd792fb0e1a98d86748b6273ab8e16523aa
[ "MIT" ]
6
2018-12-21T10:58:31.000Z
2022-01-13T19:26:24.000Z
dev/hsed/hsed/comutil.h
dolphilia/machsp
0acb5cd792fb0e1a98d86748b6273ab8e16523aa
[ "MIT" ]
null
null
null
dev/hsed/hsed/comutil.h
dolphilia/machsp
0acb5cd792fb0e1a98d86748b6273ab8e16523aa
[ "MIT" ]
null
null
null
// // comutil.cpp header // #ifndef __comutil_h #define __comutil_h typedef struct _COM_GUID { int Data1; // 4バイト short Data2; // 2バイト short Data3; // 2バイト char Data4[8]; // 1バイト×8 } COM_GUID; int ConvertIID( COM_GUID *guid, char *name ); #endif
16
45
0.600694
1a3c498c08591fa0262e4e894c590f1f90c0e389
3,988
h
C
training/dtrain/pairsampling.h
kho/cdec
d88186af251ecae60974b20395ce75807bfdda35
[ "BSD-3-Clause-LBNL", "Apache-2.0" ]
114
2015-01-11T05:41:03.000Z
2021-08-31T03:47:12.000Z
training/dtrain/pairsampling.h
kho/cdec
d88186af251ecae60974b20395ce75807bfdda35
[ "BSD-3-Clause-LBNL", "Apache-2.0" ]
29
2015-01-09T01:00:09.000Z
2019-09-25T06:04:02.000Z
training/dtrain/pairsampling.h
kho/cdec
d88186af251ecae60974b20395ce75807bfdda35
[ "BSD-3-Clause-LBNL", "Apache-2.0" ]
50
2015-02-13T13:48:39.000Z
2019-08-07T09:45:11.000Z
#ifndef _DTRAIN_PAIRSAMPLING_H_ #define _DTRAIN_PAIRSAMPLING_H_ namespace dtrain { bool accept_pair(score_t a, score_t b, score_t threshold) { if (fabs(a - b) < threshold) return false; return true; } bool cmp_hyp_by_score_d(ScoredHyp a, ScoredHyp b) { return a.score > b.score; } inline void all_pairs(vector<ScoredHyp>* s, vector<pair<ScoredHyp,ScoredHyp> >& training, score_t threshold, unsigned max, bool misranked_only, float _unused=1) { sort(s->begin(), s->end(), cmp_hyp_by_score_d); unsigned sz = s->size(); bool b = false; unsigned count = 0; for (unsigned i = 0; i < sz-1; i++) { for (unsigned j = i+1; j < sz; j++) { if (misranked_only && !((*s)[i].model <= (*s)[j].model)) continue; if (threshold > 0) { if (accept_pair((*s)[i].score, (*s)[j].score, threshold)) training.push_back(make_pair((*s)[i], (*s)[j])); } else { if ((*s)[i].score != (*s)[j].score) training.push_back(make_pair((*s)[i], (*s)[j])); } if (++count == max) { b = true; break; } } if (b) break; } } /* * multipartite ranking * sort (descending) by bleu * compare top X to middle Y and low X * cmp middle Y to low X */ inline void partXYX(vector<ScoredHyp>* s, vector<pair<ScoredHyp,ScoredHyp> >& training, score_t threshold, unsigned max, bool misranked_only, float hi_lo) { unsigned sz = s->size(); if (sz < 2) return; sort(s->begin(), s->end(), cmp_hyp_by_score_d); unsigned sep = round(sz*hi_lo); unsigned sep_hi = sep; if (sz > 4) while (sep_hi < sz && (*s)[sep_hi-1].score == (*s)[sep_hi].score) ++sep_hi; else sep_hi = 1; bool b = false; unsigned count = 0; for (unsigned i = 0; i < sep_hi; i++) { for (unsigned j = sep_hi; j < sz; j++) { if (misranked_only && !((*s)[i].model <= (*s)[j].model)) continue; if (threshold > 0) { if (accept_pair((*s)[i].score, (*s)[j].score, threshold)) training.push_back(make_pair((*s)[i], (*s)[j])); } else { if ((*s)[i].score != (*s)[j].score) training.push_back(make_pair((*s)[i], (*s)[j])); } if (++count == max) { b = true; break; } } if (b) break; } unsigned sep_lo = sz-sep; while (sep_lo > 0 && (*s)[sep_lo-1].score == (*s)[sep_lo].score) --sep_lo; for (unsigned i = sep_hi; i < sz-sep_lo; i++) { for (unsigned j = sz-sep_lo; j < sz; j++) { if (misranked_only && !((*s)[i].model <= (*s)[j].model)) continue; if (threshold > 0) { if (accept_pair((*s)[i].score, (*s)[j].score, threshold)) training.push_back(make_pair((*s)[i], (*s)[j])); } else { if ((*s)[i].score != (*s)[j].score) training.push_back(make_pair((*s)[i], (*s)[j])); } if (++count == max) return; } } } /* * pair sampling as in * 'Tuning as Ranking' (Hopkins & May, 2011) * count = 5000 * threshold = 5% BLEU (0.05 for param 3) * cut = top 50 */ bool _PRO_cmp_pair_by_diff_d(pair<ScoredHyp,ScoredHyp> a, pair<ScoredHyp,ScoredHyp> b) { return (fabs(a.first.score - a.second.score)) > (fabs(b.first.score - b.second.score)); } inline void PROsampling(vector<ScoredHyp>* s, vector<pair<ScoredHyp,ScoredHyp> >& training, score_t threshold, unsigned max, bool _unused=false, float _also_unused=0) { sort(s->begin(), s->end(), cmp_hyp_by_score_d); unsigned max_count = 5000, count = 0, sz = s->size(); bool b = false; for (unsigned i = 0; i < sz-1; i++) { for (unsigned j = i+1; j < sz; j++) { if (accept_pair((*s)[i].score, (*s)[j].score, threshold)) { training.push_back(make_pair((*s)[i], (*s)[j])); if (++count == max_count) { b = true; break; } } } if (b) break; } if (training.size() > 50) { sort(training.begin(), training.end(), _PRO_cmp_pair_by_diff_d); training.erase(training.begin()+50, training.end()); } return; } } // namespace #endif
28.084507
154
0.567202
9e1ef03bcb2185485a3d6deef89f089305ea50c3
12,794
h
C
Source/ComputationNetworkLib/DeprecatedNodes.h
KeyanAndrewLi/CNTK
4b9f8739c72068d70279f91b4b59923b2ae1fc3a
[ "RSA-MD" ]
null
null
null
Source/ComputationNetworkLib/DeprecatedNodes.h
KeyanAndrewLi/CNTK
4b9f8739c72068d70279f91b4b59923b2ae1fc3a
[ "RSA-MD" ]
null
null
null
Source/ComputationNetworkLib/DeprecatedNodes.h
KeyanAndrewLi/CNTK
4b9f8739c72068d70279f91b4b59923b2ae1fc3a
[ "RSA-MD" ]
null
null
null
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.md file in the project root for full license information. // #pragma once #include "Basics.h" #include "ComputationNode.h" #include "Matrix.h" namespace Microsoft { namespace MSR { namespace CNTK { // ----------------------------------------------------------------------- // SumColumnElements (input) // Sums up all elements in each sample (column) of the input. Every sample // will be reduced to a scalar. This is equivalent to multiplying with a row of ones. // This is deprecated, in favor of ReduceElements(). // ----------------------------------------------------------------------- template <class ElemType> class SumColumnElementsNode : public ComputationNode<ElemType>, public NumInputs<1> { typedef ComputationNode<ElemType> Base; UsingComputationNodeMembersBoilerplate; static const std::wstring TypeName() { return L"SumColumnElements"; } public: DeclareConstructorFromConfigWithNumInputs(SumColumnElementsNode); SumColumnElementsNode(DEVICEID_TYPE deviceId, const wstring& name) : Base(deviceId, name) { } virtual void /*ComputationNode::*/ ForwardProp(const FrameRange& fr) override { auto sliceInputValue = InputRef(0).ValueFor(fr); auto sliceOutputValue = ValueFor(fr); // row vector Matrix<ElemType>::VectorSum(sliceInputValue, sliceOutputValue, true); } virtual void /*ComputationNode::*/ BackpropTo(const size_t /*inputIndex*/, const FrameRange& fr) override { auto sliceInputGrad = InputRef(0).GradientFor(fr); auto sliceOutputGrad = GradientFor(fr); sliceInputGrad += sliceOutputGrad; // here the assumption is that sliceOutputGrad is a row vector } virtual bool OutputUsedInComputingInputNodesGradients() const override { return false; } virtual bool InputUsedInComputingInputNodesGradients(size_t /*childIndex*/) const override { return false; } virtual void /*ComputationNodeBase::*/ Validate(bool isFinalValidationPass) override { Base::Validate(isFinalValidationPass); InferMBLayoutFromInputsForStandardCase(isFinalValidationPass); SetDims(Environment().IsV2Library() ? TensorShape() : TensorShape(1), Input(0)->HasMBLayout()); // each column is reduced to a scalar } }; template class SumColumnElementsNode<float>; template class SumColumnElementsNode<double>; // ----------------------------------------------------------------------- // (deprecated) PerDimMeanVarNormalizationNode (feature, mean, invStdDev) // Computes // output = (feature - mean) .* invStdDev // where mean and invStdDev are meant to be single elements while features // is minibatch data. // Deprecated since it can be trivially expressed in BrainScript. // ----------------------------------------------------------------------- template <class ElemType> class PerDimMeanVarNormalizationNode : public ComputationNode<ElemType>, public NumInputs<3> { typedef ComputationNode<ElemType> Base; UsingComputationNodeMembersBoilerplate; static const std::wstring TypeName() { return L"PerDimMeanVarNormalization"; } public: DeclareConstructorFromConfigWithNumInputs(PerDimMeanVarNormalizationNode); PerDimMeanVarNormalizationNode(DEVICEID_TYPE deviceId, const wstring& name) : Base(deviceId, name) { } virtual void /*ComputationNode::*/ BackpropTo(const size_t /*inputIndex*/, const FrameRange&) override { InvalidArgument("PerDimMeanVarNormalizationNode should only be called in the evaluation stage. Is any of its descendents a learnable parameter that requires gradient?"); } virtual void /*ComputationNode::*/ ForwardProp(const FrameRange& fr) override { size_t rank = DetermineElementwiseTensorRank(); auto output = ValueTensorFor(rank, fr); auto input = InputRef(0).ValueTensorFor(rank, fr); auto mean = Input(1)->ValueTensorFor(rank, fr.AllowBroadcast()); auto invStdDev = Input(2)->ValueTensorFor(rank, fr.AllowBroadcast()); output.AssignDifferenceOf(input, mean); // output = input - mean output.AssignElementwiseProductOf(output, invStdDev); // output *= invStdDev } virtual void /*ComputationNodeBase::*/ Validate(bool isFinalValidationPass) override { Base::Validate(isFinalValidationPass); InferMBLayoutFromInputsForStandardCase(isFinalValidationPass); Input(1)->ValidateInferInputDimsFrom(InputRef(0).GetSampleLayout()); Input(2)->ValidateInferInputDimsFrom(InputRef(0).GetSampleLayout()); #if 1 // support for legacy models when the mean and variance vectors were stored as column vectors (N,1) // This code will copy the shape of Input(0) (source) to Input(1) and Input(2) (target) if: // 1. The source is a 3-tensor with shape 1x1xM // 2. The target is a vector (i.e., a 2-tensor with shape Nx1) // 3. Both targets have the same number of elements // 4. The number of elements in the target (N) is the same as the number of elements in the source (M) // Note: This is somewhat ugly [Jasha Droppo]. auto dimsA = Input(0)->GetSampleLayout().GetDims(); auto dimsB = Input(1)->GetSampleLayout().GetDims(); auto dimsC = Input(2)->GetSampleLayout().GetDims(); if ( // Test condition 1. (dimsA.size() == 3 && dimsA[0] == 1 && dimsA[1] == 1) && // Test condition 2. (dimsB.size() == 2 && dimsB[1] == 1) && (dimsC.size() == 2 && dimsC[1] == 1) && // Test condition 3. and condition 4. (dimsB[0] == dimsC[0] && dimsB[0] == dimsA[2]) ) { // for error messages string dimsBstring = string(Input(1)->GetSampleLayout()); string dimsCstring = string(Input(2)->GetSampleLayout()); // reshape Input(1) Input(1)->SetDims(TensorShape(dimsA), false); fprintf(stderr, "\n%ls %ls operation: For legacy compatibility, the sample layout of second input (%ls %ls operation) was patched to [%s] (from [%s])\n", NodeName().c_str(), OperationName().c_str(), Input(1)->NodeName().c_str(), Input(1)->OperationName().c_str(), string(Input(1)->GetSampleLayout()).c_str(), dimsBstring.c_str()); // reshape Input(2) Input(2)->SetDims(TensorShape(dimsA), false); fprintf(stderr, "\n%ls %ls operation: For legacy compatibility, the sample layout of third input (%ls %ls operation) was patched to [%s] (from [%s])\n", NodeName().c_str(), OperationName().c_str(), Input(2)->NodeName().c_str(), Input(2)->OperationName().c_str(), string(Input(2)->GetSampleLayout()).c_str(), dimsCstring.c_str()); } #endif if (isFinalValidationPass) { if (!Input(0)->GetSampleLayout().IsElementwiseCompatibleWith(Input(1)->GetSampleLayout()) || !Input(0)->GetSampleLayout().IsElementwiseCompatibleWith(Input(2)->GetSampleLayout())) InvalidArgument("PerDimMeanVarNormalizationNode: All inputs should have same sample layout."); } SetDims(Input(0)); } }; template class PerDimMeanVarNormalizationNode<float>; template class PerDimMeanVarNormalizationNode<double>; // ----------------------------------------------------------------------- // DiagTimesNode (vector representing the diagonal of a square matrix, data) // Deprecated because can be implemented with ElementTimes. // ----------------------------------------------------------------------- template <class ElemType> class DiagTimesNode : public ComputationNode<ElemType>, public NumInputs<2> { typedef ComputationNode<ElemType> Base; UsingComputationNodeMembersBoilerplate; static const std::wstring TypeName() { return L"DiagTimes"; } public: DeclareConstructorFromConfigWithNumInputs(DiagTimesNode); DiagTimesNode(DEVICEID_TYPE deviceId, const wstring& name) : Base(deviceId, name) { } virtual void /*ComputationNode::*/ BackpropTo(const size_t inputIndex, const FrameRange& fr) override { if (inputIndex == 0) // left derivative { Matrix<ElemType> sliceOutputGrad = MaskedGradientFor(fr); // use Masked- version since this is reducing over frames Matrix<ElemType> sliceInput1Value = Input(1)->MaskedValueFor(fr); m_innerproduct->AssignInnerProductOf(sliceOutputGrad, sliceInput1Value, false); InputRef(0).GradientAsMatrix() += *m_innerproduct; } else // right derivative { Matrix<ElemType> sliceOutputGrad = GradientFor(fr); Matrix<ElemType> sliceInput1Grad = Input(1)->GradientFor(fr); m_rightGradient->SetValue(sliceOutputGrad); m_rightGradient->ColumnElementMultiplyWith(InputRef(0).ValueAsMatrix()); sliceInput1Grad += *m_rightGradient; } } virtual bool OutputUsedInComputingInputNodesGradients() const override { // The DiagTimesNode does not require its output value for computing // the gradients of its input nodes return false; } virtual void /*ComputationNode::*/ ForwardProp(const FrameRange& fr) override { Matrix<ElemType> sliceInput1Value = Input(1)->ValueFor(fr); Matrix<ElemType> sliceOutputValue = ValueFor(fr); sliceOutputValue.AssignValuesOf(sliceInput1Value); sliceOutputValue.ColumnElementMultiplyWith(InputRef(0).ValueAsMatrix()); } virtual void /*ComputationNodeBase::*/ Validate(bool isFinalValidationPass) override { Base::Validate(isFinalValidationPass); InferMBLayoutFromInputsForStandardCase(isFinalValidationPass); size_t rows0 = Input(0)->GetAsMatrixNumRows(); size_t rows1 = Input(1)->HasMBLayout() ? Input(1)->GetSampleMatrixNumRows() : Input(1)->GetAsMatrixNumRows(); // if dimension not specified we assume two operands' dimensions should match Input(0)->ValidateInferInputDimsFrom(TensorShape(rows1)); if (Input(1)->HasMBLayout()) { // infer rows1 as rows0 Input(1)->ValidateInferInputDimsFrom(TensorShape(rows0)); SetDims(TensorShape(rows0), true); } else // multiplying two straight matrices { size_t cols1 = Input(1)->GetAsMatrixNumCols(); // infer rows1 as rows0 Input(1)->ValidateInferInputDimsFrom(TensorShape(rows0, cols1)); SetDims(TensorShape(rows0, cols1), false); } // update after inference rows0 = Input(0)->GetAsMatrixNumRows(); rows1 = Input(1)->HasMBLayout() ? Input(1)->GetSampleMatrixNumRows() : Input(1)->GetAsMatrixNumRows(); if (isFinalValidationPass && rows0 != rows1) InvalidArgument("The inner matrix dimension in the %ls %ls operation does not match (%d vs. %d).", NodeName().c_str(), OperationName().c_str(), (int) rows1, (int) rows0); size_t cols0 = Input(0)->GetAsMatrixNumCols(); if (isFinalValidationPass && cols0 != 1) InvalidArgument("The first matrix should be a column vector representing the diagonal of a square matrix in the DiagTimes operation."); SetDims(Input(1)); } virtual void CopyTo(ComputationNodeBasePtr nodeP, const std::wstring& newName, const CopyNodeFlags flags) const override { Base::CopyTo(nodeP, newName, flags); if (flags & CopyNodeFlags::copyNodeValue) { auto node = dynamic_pointer_cast<DiagTimesNode<ElemType>>(nodeP); node->m_innerproduct->SetValue(*m_innerproduct); node->m_rightGradient->SetValue(*m_rightGradient); } } // request matrices that are needed for gradient computation virtual void RequestMatricesBeforeBackprop(MatrixPool& matrixPool) { Base::RequestMatricesBeforeBackprop(matrixPool); RequestMatrixFromPool(m_innerproduct, matrixPool); RequestMatrixFromPool(m_rightGradient, matrixPool); } // release gradient and temp matrices that no longer needed after all the children's gradients are computed. virtual void ReleaseMatricesAfterBackprop(MatrixPool& matrixPool) { Base::ReleaseMatricesAfterBackprop(matrixPool); ReleaseMatrixToPool(m_innerproduct, matrixPool); ReleaseMatrixToPool(m_rightGradient, matrixPool); } private: shared_ptr<Matrix<ElemType>> m_innerproduct; shared_ptr<Matrix<ElemType>> m_rightGradient; }; template class DiagTimesNode<float>; template class DiagTimesNode<double>; }}}
43.517007
192
0.654995
9e9aebb40aaa112b19fd129eca2bc84b2fbcd084
1,707
h
C
include/qqee_clib/utf8_gbk_windows.h
xjboss/NeteaseCacheConveter
5df89ab3fc19467921ce4781a621a98b40f2947e
[ "Apache-2.0" ]
null
null
null
include/qqee_clib/utf8_gbk_windows.h
xjboss/NeteaseCacheConveter
5df89ab3fc19467921ce4781a621a98b40f2947e
[ "Apache-2.0" ]
null
null
null
include/qqee_clib/utf8_gbk_windows.h
xjboss/NeteaseCacheConveter
5df89ab3fc19467921ce4781a621a98b40f2947e
[ "Apache-2.0" ]
null
null
null
#ifndef MM_UTF8_GBK_WINDOWS_H #define MM_UTF8_GBK_WINDOWS_H #ifdef __cplusplus extern "C"{ #endif /** * utf8转gbk * @param in_utf8 输入utf字节 * @param out_gbk 输出gbk字节 * @param out_gbk_len 缓冲区长度 * @return 返回实际输出字节长度 */ int utf8_gbk(char*in_utf8,char*out_gbk,unsigned out_gbk_len); /** * gbk转utf8 * @param in_gbk 输入gbk字节 * @param out_utf8 输出utf8字节 * @param out_utf8_len 缓冲区长度 * @return 返回实际输出字节长度 */ int gbk_utf8(char*in_gbk,char*out_utf8,unsigned out_utf8_len); //------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include <locale.h> #include <tchar.h> //int __stdcall MultiByteToWideChar(int,int,LPCSTR,int,LPWSTR,int); //int __stdcall WideCharToMultiByte(int,int,LPCWSTR,int,LPSTR,int,LPCSTR,int); int utf8_gbk(char*in_utf8,char*out_gbk,unsigned out_gbk_len){ //utf8==>unicode unsigned len=strlen(in_utf8);//wcslen len=MultiByteToWideChar(65001, 0, in_utf8, len*2, 0, 0); char*out_unicode= (char*)malloc(len*2); len=MultiByteToWideChar(65001, 0, in_utf8, len, (LPWSTR)out_unicode, len*2); //unicode==>gbk _tsetlocale(LC_ALL,_T("")); len=wcstombs(out_gbk,(wchar_t*)out_unicode,out_gbk_len); free(out_unicode); return len; } int gbk_utf8(char*in_gbk,char*out_utf8,unsigned out_utf8_len){ //gbk==>unicode0 unsigned len=strlen(in_gbk);//wcslen char*wcstr=(char*)malloc(len*2); len=mbstowcs((wchar_t*)wcstr,in_gbk,len*2); //unicode==>utf8 len=WideCharToMultiByte(65001,0,(LPCWSTR)wcstr,len*2,0,0,0,0); len=WideCharToMultiByte(65001,0,(LPCWSTR)wcstr,len*2,out_utf8,out_utf8_len,0,0); free(wcstr); return strlen(out_utf8); } #ifdef __cplusplus } #endif #endif
27.983607
81
0.707674
b12cdb893478e906a7e9d3bc3600aec45f28fd26
15,524
h
C
halfnetwork/HalfNetwork/ACE_wrappers/ace/Registry.h
cjwcjswo/com2us_cppNetStudy_work
3aab26cfd2e9bf1544fa41a0f2694d81167b2584
[ "MIT" ]
25
2019-05-20T08:07:39.000Z
2021-08-17T11:25:02.000Z
halfnetwork/HalfNetwork/ACE_wrappers/ace/Registry.h
cjwcjswo/com2us_cppNetStudy_work
3aab26cfd2e9bf1544fa41a0f2694d81167b2584
[ "MIT" ]
null
null
null
halfnetwork/HalfNetwork/ACE_wrappers/ace/Registry.h
cjwcjswo/com2us_cppNetStudy_work
3aab26cfd2e9bf1544fa41a0f2694d81167b2584
[ "MIT" ]
17
2019-07-07T12:20:16.000Z
2022-01-11T08:27:44.000Z
// -*- C++ -*- //============================================================================= /** * @file Registry.h * * $Id: Registry.h 85110 2009-04-20 09:18:43Z msmit $ * * @author Irfan Pyarali (irfan@cs.wustl.edu) */ //============================================================================= #ifndef ACE_REGISTRY_H #define ACE_REGISTRY_H #include /**/ "ace/pre.h" #include /**/ "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) // This only works on registry-capable Win32 platforms. #include "ace/Containers.h" #include "ace/SString.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** * @class ACE_Registry * * @brief A Name Server implementation * * The registry interface is inspired by the interface * specified in the CORBA Naming Service Specification. * The implementation is done through Win32 <Reg*> functions. * Other than providing an OO wrapper for the Win32 <Reg*> * functions, ACE_Registry provides an abstraction for iteration * over the elements of the Registry. */ class ACE_Export ACE_Registry { public: /// International string struct ACE_Export Name_Component { ACE_TString id_; ACE_TString kind_; bool operator== (const Name_Component &rhs) const; bool operator!= (const Name_Component &rhs) const; // Comparison }; // The <id_> field is used, // but the <kind_> field is currently ignored /// A Name is an ordered collections of components (ids) typedef ACE_Unbounded_Set<Name_Component> Name; /// Separator for components in a name static const ACE_TCHAR STRING_SEPARATOR[]; /// Convert a @a name to a @c string static ACE_TString make_string (const Name &name); /// Convert a @a string to a @c name static Name make_name (const ACE_TString &string); /// There are two types of bindings enum Binding_Type {INVALID, OBJECT, CONTEXT}; struct ACE_Export Binding { /// Empty (default) constructor Binding (void); /// Constructor /// (Name version) Binding (const Name &binding_name, Binding_Type binding_type); /// Constructor /// (String version) Binding (const ACE_TString &binding_name, Binding_Type binding_type); bool operator== (const Binding &rhs) const; bool operator!= (const Binding &rhs) const; // Comparison /// Name accessor /// (Name version) void name (Name &name); /// Set Name (String version) void name (ACE_TString &name); /// Get Name (String version) ACE_TString name (void); /// Type accessor Binding_Type type (void); private: /// A binding has a name ACE_TString name_; /// .... and a type Binding_Type type_; }; /// A list of bindings typedef ACE_Unbounded_Set<Binding> Binding_List; // Forward declaration of iterator class Binding_Iterator; /** * @class Object * * @brief An object representation * * In CORBA, all objects inherit from (CORBA::Object). * For the registry, this is used as a wrapper for an * instance of a built-in data type. * Think about an object as being similar to a file * in a file system. */ class ACE_Export Object { public: /// Default constructor Object (void *data = 0, u_long size = 0, u_long type = REG_NONE); /// Set data void data (void *data); /// Get data void *data (void) const; /// Set size void size (u_long size); /// Get size u_long size (void) const; /// Set type void type (u_long type); /// Get type u_long type (void) const; private: /// Pointer to data void *data_; /// Size of the data u_long size_; /// Type of data u_long type_; }; /** * @class Naming_Context * * @brief An context representation * * Think about a context as being similar to a directory * in a file system. */ class ACE_Export Naming_Context { public: /// Friend factory friend class ACE_Predefined_Naming_Contexts; enum { /// Max sizes of names /// (Not too sure about this value) MAX_OBJECT_NAME_SIZE = BUFSIZ, /// Max size of context name MAX_CONTEXT_NAME_SIZE = MAXPATHLEN + 1 }; /// Empty constructor: keys will be NULL Naming_Context (void); /// Constructor: key_ will be set to @a key Naming_Context (const HKEY &key); /// Destructor will call <Naming_Context::close>. ~Naming_Context (void); // The following interfaces are for objects /** * Insert @a object with @a name into @c this context. * This will fail if @a name already exists * (Name version) */ int bind_new (const Name &name, const Object &object); /** * Insert @a object with @a name into @c this context * This will fail if @a name already exists * (String version) */ int bind_new (const ACE_TString &name, const Object &object); /** * Insert or update @a object with @a name into @c this context * This will not fail if @a name already exists * (Name version) */ int bind (const Name &name, const Object &object); /** * Insert or update <object> with @a name into @c this context * This will not fail if @a name already exists * (String version) */ int bind (const ACE_TString &name, const Object &object); /// Update <object> with @a name in @c this context /// (Name version) int rebind (const Name &name, const Object &object); /// Update <object> with @a name in @c this context int rebind (const ACE_TString &name, const Object &object); /// Find <object> with @a name in @c this context /// (Name version) int resolve (const Name &name, Object &object); /// Find <object> with @a name in @c this context int resolve (const ACE_TString &name, Object &object); /// Delete object with @a name in @c this context /// (Name version) int unbind (const Name &name); /// Delete object with @a name in @c this context int unbind (const ACE_TString &name); // The following interfaces are for Naming Context /// Create new @c naming_context int new_context (Naming_Context &naming_context); /** * Insert <naming_context> with @a name relative to @c this context * This will fail if @a name already exists * (Name version) */ int bind_new_context (const Name &name, Naming_Context &naming_context, u_long persistence = REG_OPTION_NON_VOLATILE, u_long security_access = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes = 0); /// Insert <naming_context> with @a name relative to @c this context /// This will fail if @a name already exists int bind_new_context (const ACE_TString &name, Naming_Context &naming_context, u_long persistence = REG_OPTION_NON_VOLATILE, u_long security_access = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes = 0); /** * Insert or update <naming_context> with @a name relative to @c this context * This will not fail if @a name already exists * (Name version) */ int bind_context (const Name &name, /* const */ Naming_Context &naming_context, u_long persistence = REG_OPTION_NON_VOLATILE, u_long security_access = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes = 0); /// Insert or update <naming_context> with @a name relative to @c this context /// This will not fail if @a name already exists int bind_context (const ACE_TString &name, /* const */ Naming_Context &naming_context, u_long persistence = REG_OPTION_NON_VOLATILE, u_long security_access = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes = 0); /// Rename <naming_context> to @a name /// (Name version) int rebind_context (const Name &name, /* const */ Naming_Context &naming_context); /// Rename <naming_context> to @a name int rebind_context (const ACE_TString &name, /* const */ Naming_Context &naming_context); /// Find <naming_context> with @a name in @c this context /// (Name version) int resolve_context (const Name &name, Naming_Context &naming_context, u_long security_access = KEY_ALL_ACCESS); /// Find <naming_context> with @a name in @c this context int resolve_context (const ACE_TString &name, Naming_Context &naming_context, u_long security_access = KEY_ALL_ACCESS); /// Remove naming_context with @a name from @c this context /// (Name version) int unbind_context (const Name &name); /// Remove naming_context with @a name from @c this context int unbind_context (const ACE_TString &name); /// Same as <unbind_context> with @c this as naming_context int destroy (void); /** * listing function: iterator creator * This is useful when there are many objects and contexts * in @c this context and you only want to look at a few entries * at a time */ int list (u_long how_many, Binding_List &list, Binding_Iterator &iterator); /// listing function: iterator creator /// This gives back a listing of all entries in @c this context. int list (Binding_List &list); // Some other necessary functions which are // not part of the CORBA interface /// Sync content of context to disk int flush (void); /// Close the handle of the context /// @note <close> does not call <flush> int close (void); // Accessors /// Get key HKEY key (void); // void parent (HKEY parent); /// Get parent HKEY parent (void); /// Get name /// (Name version) void name (Name &name); /// Set name (String version) void name (ACE_TString &name); /// Get name (String version) ACE_TString name (void); protected: /// Set key void key (HKEY key); /// Set parent void parent (HKEY parent); /// Set name /// (Name version) void name (const Name &name); /// Set name /// (String version) void name (const ACE_TString &name); private: /// Disallow copy constructors Naming_Context (const Naming_Context &rhs); /// Disallow assignment const Naming_Context &operator= (const Naming_Context &rhs); /// Key for self HKEY key_; /// Key for parent HKEY parent_key_; /// Name of self ACE_TString name_; }; /** * @class Binding_Iterator * * @brief An iterator * * Useful when iteratorating over a few entries at a time */ class ACE_Export Binding_Iterator { public: /// Friend factory friend class Naming_Context; /// Default constructor Binding_Iterator (void); /// Next entry int next_one (Binding &binding); /// Next <how_many> entries int next_n (u_long how_many, Binding_List &list); /// Cleanup int destroy (void); /// Reset the internal state of the iterator void reset (void); /// Get naming_context that the iterator is iterating over Naming_Context &naming_context (void); private: /// Set naming_context that the iterator is iterating over void naming_context (Naming_Context& naming_context); /// Reference to context Naming_Context *naming_context_; public: // This should really be private // But the compiler is broken /** * @class Iteration_State * * Base class for state */ class ACE_Export Iteration_State { public: /// Constructor Iteration_State (void); /// Destructor virtual ~Iteration_State (void); /// Set the iterator reference. void iterator (Binding_Iterator *iterator); /// Next <how_many> entries virtual int next_n (u_long how_many, Binding_List &list) = 0; /// Reset state void reset (void); protected: /// Pointer to parent iterator Binding_Iterator *parent_; u_long index_; }; private: class ACE_Export Object_Iteration : public Iteration_State { /// Next <how_many> entries int next_n (u_long how_many, Binding_List &list); }; class ACE_Export Context_Iteration : public Iteration_State { public: /// Next @a how_many entries int next_n (u_long how_many, Binding_List &list); }; class ACE_Export Iteration_Complete : public Iteration_State { public: /// Next @a how_many entries int next_n (u_long how_many, Binding_List &list); }; /// Friend states friend class Iteration_State; friend class Object_Iteration; friend class Context_Iteration; friend class Iteration_Complete; /// Instances of all states Object_Iteration object_iteration_; Context_Iteration context_iteration_; Iteration_Complete iteration_complete_; /// Pointer to current state Iteration_State *current_enumeration_; /// Set current_enumeration void current_enumeration (Iteration_State& current_enumeration); /// Get current_enumeration Iteration_State &current_enumeration (void); }; }; /** * @class ACE_Predefined_Naming_Contexts * * @brief A factory for predefined registries, which exist by default * on Win32 platforms * * This factory can connect to both local and remote * predefined registries. */ class ACE_Export ACE_Predefined_Naming_Contexts { public: /** * Factory method for connecting to predefined registries. This * method works for both remote and local machines. However, for * remote machines, HKEY_CLASSES_ROOT and HKEY_CURRENT_USER types * are not allowed */ static int connect (ACE_Registry::Naming_Context &naming_context, HKEY predefined = HKEY_LOCAL_MACHINE, const ACE_TCHAR *machine_name = 0); private: /// Check if @a machine_name is the local host static int is_local_host (const ACE_TCHAR *machine_name); }; ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ #include /**/ "ace/post.h" #endif /* ACE_REGISTRY_H */
27.573712
83
0.597011
7f3bcf5a2c6c7dc0019eda32ff22ca72ded3b887
593
h
C
week2/smarthome/iot_config.h
kriskleva/smarthome
d0abba6b350819b054ac315d00b688f118c90c6e
[ "MIT" ]
1
2018-11-01T03:12:27.000Z
2018-11-01T03:12:27.000Z
week2/smarthome/iot_config.h
kriskleva/smarthome
d0abba6b350819b054ac315d00b688f118c90c6e
[ "MIT" ]
null
null
null
week2/smarthome/iot_config.h
kriskleva/smarthome
d0abba6b350819b054ac315d00b688f118c90c6e
[ "MIT" ]
null
null
null
// This file contains your configuration used to connect to Cloud IoT Core // WIFI const char* ssid = "OBPwifi"; const char* password = "OBP123456"; // Cloud iot details. const char* project_id = "openbench-aiy-platform"; const char* location = "us-central1"; const char* registry_id = "obp-device-registry"; const char* device_id = "obp-device-2"; const char* private_key_str = "12:b4:9d:73:40:3a:e1:ad:f7:d1:59:65:82:09:8a:" "6f:36:f3:c7:36:4e:0b:a1:40:74:25:bc:40:df:76:" "52:07"; const char* fingerprint = "7C:D4:99:11:FE:FC:0D:78:C0:A9:C1:18:52:1D:3F:0B:8B:38:C9:90";
29.65
74
0.681282
7fe2c46c5691f16d8903d7d8b3500490044b1ef3
673
h
C
commander/hints.h
alamb/aal_commander
98904febdd1da0e17cbdc1f15669197e74d997de
[ "BSD-2-Clause", "MIT" ]
null
null
null
commander/hints.h
alamb/aal_commander
98904febdd1da0e17cbdc1f15669197e74d997de
[ "BSD-2-Clause", "MIT" ]
null
null
null
commander/hints.h
alamb/aal_commander
98904febdd1da0e17cbdc1f15669197e74d997de
[ "BSD-2-Clause", "MIT" ]
null
null
null
#pragma once #include <sstream> #include <string> #include <vector> class Parsed_line; class Hints { public: Hints(); // create the expected hints from a set of possibilities Hints(const Parsed_line &line, const std::vector<std::string> &possibilities); static const int COLOR_MAGENTA; static const int COLOR_RED; static const int COLOR_GREEN; // access int color() const { return color_; } bool bold() const { return bold_; } const std::string &hint_text() const { return hint_text_; } private: int color_ = COLOR_MAGENTA; std::string hint_text_; bool bold_ = false; };
21.709677
86
0.637444
3d04b8de56da450e66a44b6c3f34221a902f91de
2,234
h
C
AlphaOmega/qSlicerAlphaOmegaModule.h
jamesobutler/SlicerNetstim
f13c8eb8996f9cd04375cf3ec845c919b12b87ae
[ "BSD-3-Clause" ]
9
2021-04-19T15:29:19.000Z
2022-01-18T11:53:46.000Z
AlphaOmega/qSlicerAlphaOmegaModule.h
jamesobutler/SlicerNetstim
f13c8eb8996f9cd04375cf3ec845c919b12b87ae
[ "BSD-3-Clause" ]
5
2021-07-01T21:44:19.000Z
2022-02-07T08:14:33.000Z
AlphaOmega/qSlicerAlphaOmegaModule.h
jamesobutler/SlicerNetstim
f13c8eb8996f9cd04375cf3ec845c919b12b87ae
[ "BSD-3-Clause" ]
9
2021-06-30T20:04:09.000Z
2022-02-06T17:43:11.000Z
/*============================================================================== Program: 3D Slicer Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved. See COPYRIGHT.txt or http://www.slicer.org/copyright/copyright.txt for details. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef __qSlicerAlphaOmegaModule_h #define __qSlicerAlphaOmegaModule_h // SlicerQt includes #include "qSlicerLoadableModule.h" #include "qSlicerAlphaOmegaModuleExport.h" class qSlicerAlphaOmegaModulePrivate; /// \ingroup Slicer_QtModules_ExtensionTemplate class Q_SLICER_QTMODULES_ALPHAOMEGA_EXPORT qSlicerAlphaOmegaModule : public qSlicerLoadableModule { Q_OBJECT Q_PLUGIN_METADATA(IID "org.slicer.modules.loadable.qSlicerLoadableModule/1.0"); Q_INTERFACES(qSlicerLoadableModule); public: typedef qSlicerLoadableModule Superclass; explicit qSlicerAlphaOmegaModule(QObject *parent=0); virtual ~qSlicerAlphaOmegaModule(); qSlicerGetTitleMacro(QTMODULE_TITLE); virtual QString helpText()const; virtual QString acknowledgementText()const; virtual QStringList contributors()const; virtual QIcon icon()const; virtual QStringList categories()const; virtual QStringList dependencies() const; /// Specify editable node types virtual QStringList associatedNodeTypes() const override; protected: /// Initialize the module. Register the volumes reader/writer virtual void setup(); /// Create and return the widget representation associated to this module virtual qSlicerAbstractModuleRepresentation * createWidgetRepresentation(); /// Create and return the logic associated to this module virtual vtkMRMLAbstractLogic* createLogic(); protected: QScopedPointer<qSlicerAlphaOmegaModulePrivate> d_ptr; private: Q_DECLARE_PRIVATE(qSlicerAlphaOmegaModule); Q_DISABLE_COPY(qSlicerAlphaOmegaModule); }; #endif
28.641026
81
0.744852
d22c4c55c40689c23b7d275fbb76af17c0b23efa
3,963
c
C
release/src-rt-6.x.4708/linux/linux-2.6.36/block/blk-ioc.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
21
2021-01-22T06:47:38.000Z
2022-03-20T14:24:29.000Z
release/src-rt-6.x.4708/linux/linux-2.6.36/block/blk-ioc.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
1
2018-08-21T03:43:09.000Z
2018-08-21T03:43:09.000Z
release/src-rt-6.x.4708/linux/linux-2.6.36/block/blk-ioc.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
12
2021-01-22T14:59:28.000Z
2022-02-22T04:03:31.000Z
/* * Functions related to io context handling */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/bio.h> #include <linux/blkdev.h> #include <linux/bootmem.h> /* for max_pfn/max_low_pfn */ #include <linux/slab.h> #include "blk.h" /* * For io context allocations */ static struct kmem_cache *iocontext_cachep; static void cfq_dtor(struct io_context *ioc) { if (!hlist_empty(&ioc->cic_list)) { struct cfq_io_context *cic; cic = list_entry(ioc->cic_list.first, struct cfq_io_context, cic_list); cic->dtor(ioc); } } /* * IO Context helper functions. put_io_context() returns 1 if there are no * more users of this io context, 0 otherwise. */ int put_io_context(struct io_context *ioc) { if (ioc == NULL) return 1; BUG_ON(atomic_long_read(&ioc->refcount) == 0); if (atomic_long_dec_and_test(&ioc->refcount)) { rcu_read_lock(); cfq_dtor(ioc); rcu_read_unlock(); kmem_cache_free(iocontext_cachep, ioc); return 1; } return 0; } EXPORT_SYMBOL(put_io_context); static void cfq_exit(struct io_context *ioc) { rcu_read_lock(); if (!hlist_empty(&ioc->cic_list)) { struct cfq_io_context *cic; cic = list_entry(ioc->cic_list.first, struct cfq_io_context, cic_list); cic->exit(ioc); } rcu_read_unlock(); } /* Called by the exitting task */ void exit_io_context(struct task_struct *task) { struct io_context *ioc; task_lock(task); ioc = task->io_context; task->io_context = NULL; task_unlock(task); if (atomic_dec_and_test(&ioc->nr_tasks)) { cfq_exit(ioc); } put_io_context(ioc); } struct io_context *alloc_io_context(gfp_t gfp_flags, int node) { struct io_context *ret; ret = kmem_cache_alloc_node(iocontext_cachep, gfp_flags, node); if (ret) { atomic_long_set(&ret->refcount, 1); atomic_set(&ret->nr_tasks, 1); spin_lock_init(&ret->lock); ret->ioprio_changed = 0; ret->ioprio = 0; ret->last_waited = 0; /* doesn't matter... */ ret->nr_batch_requests = 0; /* because this is 0 */ INIT_RADIX_TREE(&ret->radix_root, GFP_ATOMIC | __GFP_HIGH); INIT_HLIST_HEAD(&ret->cic_list); ret->ioc_data = NULL; } return ret; } /* * If the current task has no IO context then create one and initialise it. * Otherwise, return its existing IO context. * * This returned IO context doesn't have a specifically elevated refcount, * but since the current task itself holds a reference, the context can be * used in general code, so long as it stays within `current` context. */ struct io_context *current_io_context(gfp_t gfp_flags, int node) { struct task_struct *tsk = current; struct io_context *ret; ret = tsk->io_context; if (likely(ret)) return ret; ret = alloc_io_context(gfp_flags, node); if (ret) { /* make sure set_task_ioprio() sees the settings above */ smp_wmb(); tsk->io_context = ret; } return ret; } /* * If the current task has no IO context then create one and initialise it. * If it does have a context, take a ref on it. * * This is always called in the context of the task which submitted the I/O. */ struct io_context *get_io_context(gfp_t gfp_flags, int node) { struct io_context *ret = NULL; /* * Check for unlikely race with exiting task. ioc ref count is * zero when ioc is being detached. */ do { ret = current_io_context(gfp_flags, node); if (unlikely(!ret)) break; } while (!atomic_long_inc_not_zero(&ret->refcount)); return ret; } EXPORT_SYMBOL(get_io_context); void copy_io_context(struct io_context **pdst, struct io_context **psrc) { struct io_context *src = *psrc; struct io_context *dst = *pdst; if (src) { BUG_ON(atomic_long_read(&src->refcount) == 0); atomic_long_inc(&src->refcount); put_io_context(dst); *pdst = src; } } EXPORT_SYMBOL(copy_io_context); static int __init blk_ioc_init(void) { iocontext_cachep = kmem_cache_create("blkdev_ioc", sizeof(struct io_context), 0, SLAB_PANIC, NULL); return 0; } subsys_initcall(blk_ioc_init);
22.389831
76
0.709563
3223715363e62a26883b5c6deb18b7aa14052c3e
2,269
c
C
cmake_targets/lte_build_oai/build/CMakeFiles/RRC_Rel14/BandClassPriorityHRPD.c
kikikos/openairinterface5g
54d541c22cdfcb774774089291c93e4e79294a1d
[ "Apache-2.0" ]
null
null
null
cmake_targets/lte_build_oai/build/CMakeFiles/RRC_Rel14/BandClassPriorityHRPD.c
kikikos/openairinterface5g
54d541c22cdfcb774774089291c93e4e79294a1d
[ "Apache-2.0" ]
null
null
null
cmake_targets/lte_build_oai/build/CMakeFiles/RRC_Rel14/BandClassPriorityHRPD.c
kikikos/openairinterface5g
54d541c22cdfcb774774089291c93e4e79294a1d
[ "Apache-2.0" ]
1
2020-02-10T14:17:39.000Z
2020-02-10T14:17:39.000Z
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "EUTRA-RRC-Definitions" * found in "/home/user/openairinterface5g/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.7.0.asn1" * `asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example -D /home/user/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/RRC_Rel14` */ #include "BandClassPriorityHRPD.h" asn_TYPE_member_t asn_MBR_BandClassPriorityHRPD_1[] = { { ATF_NOFLAGS, 0, offsetof(struct BandClassPriorityHRPD, bandClass), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_BandclassCDMA2000, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "bandClass" }, { ATF_NOFLAGS, 0, offsetof(struct BandClassPriorityHRPD, cellReselectionPriority), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_CellReselectionPriority, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "cellReselectionPriority" }, }; static const ber_tlv_tag_t asn_DEF_BandClassPriorityHRPD_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_BandClassPriorityHRPD_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* bandClass */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* cellReselectionPriority */ }; asn_SEQUENCE_specifics_t asn_SPC_BandClassPriorityHRPD_specs_1 = { sizeof(struct BandClassPriorityHRPD), offsetof(struct BandClassPriorityHRPD, _asn_ctx), asn_MAP_BandClassPriorityHRPD_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* First extension addition */ }; asn_TYPE_descriptor_t asn_DEF_BandClassPriorityHRPD = { "BandClassPriorityHRPD", "BandClassPriorityHRPD", &asn_OP_SEQUENCE, asn_DEF_BandClassPriorityHRPD_tags_1, sizeof(asn_DEF_BandClassPriorityHRPD_tags_1) /sizeof(asn_DEF_BandClassPriorityHRPD_tags_1[0]), /* 1 */ asn_DEF_BandClassPriorityHRPD_tags_1, /* Same as above */ sizeof(asn_DEF_BandClassPriorityHRPD_tags_1) /sizeof(asn_DEF_BandClassPriorityHRPD_tags_1[0]), /* 1 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_BandClassPriorityHRPD_1, 2, /* Elements count */ &asn_SPC_BandClassPriorityHRPD_specs_1 /* Additional specs */ };
37.196721
162
0.739974
9a94d762eed99fa895812ec33cf32abbe94036a0
8,310
h
C
src/mongo/db/operation_context.h
hptabster/mongo
62ad51641684c6c8a9b502897f04228bc7fa7758
[ "Apache-2.0" ]
null
null
null
src/mongo/db/operation_context.h
hptabster/mongo
62ad51641684c6c8a9b502897f04228bc7fa7758
[ "Apache-2.0" ]
null
null
null
src/mongo/db/operation_context.h
hptabster/mongo
62ad51641684c6c8a9b502897f04228bc7fa7758
[ "Apache-2.0" ]
null
null
null
/** * Copyright (C) 2014 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #pragma once #include "mongo/base/disallow_copying.h" #include "mongo/base/status.h" #include "mongo/db/storage/recovery_unit.h" #include "mongo/db/concurrency/locker.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/write_concern_options.h" #include "mongo/util/decorable.h" namespace mongo { class Client; class CurOp; class ProgressMeter; class StringData; /** * This class encompasses the state required by an operation. * * TODO(HK): clarify what this means. There's one OperationContext for one user operation... * but is this true for getmore? Also what about things like fsyncunlock / internal * users / etc.? * * On construction, an OperationContext associates itself with the current client, and only on * destruction it deassociates itself. At any time a client can be associated with at most one * OperationContext. */ class OperationContext : public Decorable<OperationContext> { MONGO_DISALLOW_COPYING(OperationContext); public: virtual ~OperationContext() { } /** * Interface for durability. Caller DOES NOT own pointer. */ virtual RecoveryUnit* recoveryUnit() const = 0; /** * Returns the RecoveryUnit (same return value as recoveryUnit()) but the caller takes * ownership of the returned RecoveryUnit, and the OperationContext instance relinquishes * ownership. Sets the RecoveryUnit to NULL. * * Used to transfer ownership of storage engine state from OperationContext * to ClientCursor for getMore-able queries. * * Note that we don't allow the top-level locks to be stored across getMore. * We rely on active cursors being killed when collections or databases are dropped, * or when collection metadata changes. */ virtual RecoveryUnit* releaseRecoveryUnit() = 0; virtual void setRecoveryUnit(RecoveryUnit* unit) = 0; /** * Interface for locking. Caller DOES NOT own pointer. */ virtual Locker* lockState() const = 0; // --- operation level info? --- /** * If the thread is not interrupted, returns Status::OK(), otherwise returns the cause * for the interruption. The throw variant returns a user assertion corresponding to the * interruption status. */ virtual void checkForInterrupt() const = 0; virtual Status checkForInterruptNoAssert() const = 0; /** * Delegates to CurOp, but is included here to break dependencies. * Caller does not own the pointer. */ virtual ProgressMeter* setMessage(const char* msg, const std::string& name = "Progress", unsigned long long progressMeterTotal = 0, int secondsBetween = 3) = 0; /** * Delegates to CurOp, but is included here to break dependencies. * * TODO: We return a string because of hopefully transient CurOp thread-unsafe insanity. */ virtual std::string getNS() const = 0; /** * Returns the client under which this context runs. */ virtual Client* getClient() const = 0; /** * Returns CurOp. Caller does not own pointer */ virtual CurOp* getCurOp() const = 0; virtual uint64_t getRemainingMaxTimeMicros() const = 0; /** * Returns the operation ID associated with this operation. * WARNING: Due to SERVER-14995, this OpID is not guaranteed to stay the same for the * lifetime of this OperationContext. */ virtual unsigned int getOpID() const = 0; /** * @return true if this instance is primary for this namespace */ virtual bool isPrimaryFor( StringData ns ) = 0; /** * Returns WriteConcernOptions of the current operation */ const WriteConcernOptions& getWriteConcern() const { return _writeConcern; } void setWriteConcern(const WriteConcernOptions& writeConcern) { _writeConcern = writeConcern; } /** * Set whether or not operations should generate oplog entries. */ virtual void setReplicatedWrites(bool writesAreReplicated = true) = 0; /** * Returns true if operations should generate oplog entries. */ virtual bool writesAreReplicated() const = 0; protected: OperationContext() { } private: WriteConcernOptions _writeConcern; }; class WriteUnitOfWork { MONGO_DISALLOW_COPYING(WriteUnitOfWork); public: WriteUnitOfWork(OperationContext* txn) : _txn(txn), _ended(false) { _txn->lockState()->beginWriteUnitOfWork(); _txn->recoveryUnit()->beginUnitOfWork(_txn); } ~WriteUnitOfWork() { _txn->recoveryUnit()->endUnitOfWork(); if (!_ended) { _txn->lockState()->endWriteUnitOfWork(); } } void commit() { invariant(!_ended); _txn->recoveryUnit()->commitUnitOfWork(); _txn->lockState()->endWriteUnitOfWork(); _ended = true; } private: OperationContext* const _txn; bool _ended; }; /** * RAII-style class to mark the scope of a transaction. ScopedTransactions may be nested. * An outermost ScopedTransaction calls commitAndRestart() on destruction, so that the storage * engine can release resources, such as snapshots or locks, that it may have acquired during * the transaction. Note that any writes are committed in nested WriteUnitOfWork scopes, * so write conflicts cannot happen on completing a ScopedTransaction. * * TODO: The ScopedTransaction should hold the global lock */ class ScopedTransaction { MONGO_DISALLOW_COPYING(ScopedTransaction); public: /** * The mode for the transaction indicates whether the transaction will write (MODE_IX) or * only read (MODE_IS), or needs to run without other writers (MODE_S) or any other * operations (MODE_X) on the server. */ ScopedTransaction(OperationContext* txn, LockMode mode) : _txn(txn) { } ~ScopedTransaction() { if (!_txn->lockState()->isLocked()) { _txn->recoveryUnit()->commitAndRestart(); } } private: OperationContext* _txn; }; } // namespace mongo
36.130435
98
0.629122
c5acc6124d0dab437750041dec541df01c7f73b5
459
h
C
EasyJoke/EasyJoke/Classes/Other/UIBarButtonItem+XMGExtension/UIBarButtonItem+SMARTExtension.h
GoodgoodstudyDaydayups/EasyJoke
036c722b73aaddd0a72092fab8cbbf98ead1dc19
[ "MIT" ]
1
2015-12-01T15:11:44.000Z
2015-12-01T15:11:44.000Z
EasyJoke/EasyJoke/Classes/Other/UIBarButtonItem+XMGExtension/UIBarButtonItem+SMARTExtension.h
GoodgoodstudyDaydayups/EasyJoke
036c722b73aaddd0a72092fab8cbbf98ead1dc19
[ "MIT" ]
null
null
null
EasyJoke/EasyJoke/Classes/Other/UIBarButtonItem+XMGExtension/UIBarButtonItem+SMARTExtension.h
GoodgoodstudyDaydayups/EasyJoke
036c722b73aaddd0a72092fab8cbbf98ead1dc19
[ "MIT" ]
1
2016-04-01T23:46:01.000Z
2016-04-01T23:46:01.000Z
// // UIBarButtonItem+SMARTExtension.h // 3期-百思不得姐 // // Created by xiaomage on 15/9/1. // Copyright (c) 2015年 SMART. All rights reserved. // #import <UIKit/UIKit.h> @interface UIBarButtonItem (SMARTExtension) + (instancetype)itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action; + (UIButton*)barButtonWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action; @end
30.6
119
0.745098
65a0eea5e52cbfb8365c09fc1b906aa7477d8a28
90
c
C
0x1C-binary_trees/124-sorted_array_to_avl.c
johncoleman83/bootcampschool-low_level_programming
fbe8798f6c27ff62c1781fadb297f220955db234
[ "MIT" ]
4
2017-02-09T19:17:21.000Z
2018-01-17T11:53:54.000Z
0x1C-binary_trees/124-sorted_array_to_avl.c
johncoleman83/bootcampschool-low_level_programming
fbe8798f6c27ff62c1781fadb297f220955db234
[ "MIT" ]
null
null
null
0x1C-binary_trees/124-sorted_array_to_avl.c
johncoleman83/bootcampschool-low_level_programming
fbe8798f6c27ff62c1781fadb297f220955db234
[ "MIT" ]
6
2017-03-24T04:08:42.000Z
2020-06-28T17:10:40.000Z
#include "binary_trees.h" /** * */ avl_t *sorted_array_to_avl(int *array, size_t size);
15
52
0.688889
d68c750f2cf41537ec0d5aa86b483a5e4c561664
15,510
c
C
lotterytest.c
wkim97/xv6
9e5ae2276ba412a117901324d6d62316f01a5dc5
[ "MIT-0" ]
null
null
null
lotterytest.c
wkim97/xv6
9e5ae2276ba412a117901324d6d62316f01a5dc5
[ "MIT-0" ]
null
null
null
lotterytest.c
wkim97/xv6
9e5ae2276ba412a117901324d6d62316f01a5dc5
[ "MIT-0" ]
null
null
null
#include "types.h" #include "mmu.h" #include "param.h" #include "proc.h" #include "user.h" #define MAX_CHILDREN 32 typedef void (*function_type)(void); struct test_case { const char *name; int total_tests; int errors; int num_children; int tickets[MAX_CHILDREN]; int expect_ticks_unscaled[MAX_CHILDREN]; int actual_ticks[MAX_CHILDREN]; int total_actual_ticks; function_type functions[MAX_CHILDREN]; }; void yield_forever(); void run_forever(); void iowait_forever(); void exit_fast(); struct test_case tests[] = { { .name = "one process", .num_children = 1, .tickets[0] = 1000, .expect_ticks_unscaled[0] = 1, .functions[0] = yield_forever }, { .name = "two processes, unequal ratio", .num_children = 2, .tickets[0] = 1000, .tickets[1] = 2000, .expect_ticks_unscaled[0] = 1, .expect_ticks_unscaled[1] = 2, .functions[0] = yield_forever, .functions[1] = yield_forever, }, { .name = "two processes, equal", .num_children = 2, .tickets[0] = 1000, .tickets[1] = 1000, .expect_ticks_unscaled[0] = 1, .expect_ticks_unscaled[1] = 1, .functions[0] = yield_forever, .functions[1] = yield_forever, }, { .name = "three processes, unequal", .num_children = 3, .tickets[0] = 500, .tickets[1] = 1000, .tickets[2] = 1750, .expect_ticks_unscaled[0] = 50, .expect_ticks_unscaled[1] = 100, .expect_ticks_unscaled[2] = 175, .functions[0] = yield_forever, .functions[1] = yield_forever, .functions[2] = yield_forever, }, { .name = "three processes, but one io-wait", .num_children = 3, .tickets[0] = 500, .tickets[1] = 1000, .tickets[2] = 1750, .expect_ticks_unscaled[0] = 50, .expect_ticks_unscaled[1] = 100, .expect_ticks_unscaled[2] = 0, .functions[0] = yield_forever, .functions[1] = yield_forever, .functions[2] = iowait_forever, }, { .name = "three processes, but one exits", .num_children = 3, .tickets[0] = 500, .tickets[1] = 1000, .tickets[2] = 1750, .expect_ticks_unscaled[0] = 50, .expect_ticks_unscaled[1] = 100, .expect_ticks_unscaled[2] = 0, .functions[0] = yield_forever, .functions[1] = yield_forever, .functions[2] = exit_fast, }, { .name = "seven procceses", .num_children = 7, .tickets[0] = 50, .tickets[1] = 60, .tickets[2] = 70, .tickets[3] = 80, .tickets[4] = 90, .tickets[5] = 100, .tickets[6] = 110, .expect_ticks_unscaled[0] = 50, .expect_ticks_unscaled[1] = 60, .expect_ticks_unscaled[2] = 70, .expect_ticks_unscaled[3] = 80, .expect_ticks_unscaled[4] = 90, .expect_ticks_unscaled[5] = 100, .expect_ticks_unscaled[6] = 110, .functions[0] = yield_forever, .functions[1] = yield_forever, .functions[2] = yield_forever, .functions[3] = yield_forever, .functions[4] = yield_forever, .functions[5] = yield_forever, .functions[6] = yield_forever, }, { .name = "two processes, not all yielding", .num_children = 2, .tickets[0] = 50, .tickets[1] = 200, .expect_ticks_unscaled[0] = 50, .expect_ticks_unscaled[1] = 200, .functions[0] = yield_forever, .functions[1] = run_forever, }, { .name = 0, } }; #define LARGE_TICKET_COUNT 100000 #define NOT_AS_LARGE_TICKET_COUNT 10000 #define MAX_YIELDS_FOR_SETUP 100 #define WARMUP_TIME 5 #define SLEEP_TIME 50 __attribute__((noreturn)) void yield_forever() { while (1) { yield(); } } __attribute__((noreturn)) void run_forever() { while (1) { __asm__(""); } } __attribute__((noreturn)) void iowait_forever() { int fds[2]; pipe(fds); while (1) { char temp[1]; read(fds[0], temp, 0); } } __attribute__((noreturn)) void exit_fast() { exit(); } int spawn(int tickets, function_type function) { int pid = fork(); if (pid == 0) { setticket(tickets); yield(); (*function)(); exit(); } else if (pid != -1) { return pid; } else { printf(2, "error in fork\n"); return -1; } } int find_index_of_pid(int *list, int list_size, int pid) { for (int i = 0; i < list_size; ++i) { if (list[i] == pid) return i; } return -1; } void wait_for_ticket_counts(int num_children, int *pids, int *tickets) { /* temporarily lower our share to give other processes more of a chance to run * their setticket() call */ setticket(NOT_AS_LARGE_TICKET_COUNT); for (int yield_count = 0; yield_count < MAX_YIELDS_FOR_SETUP; ++yield_count) { yield(); int done = 1; struct processes_info info; getprocessinfo(&info); for (int i = 0; i < num_children; ++i) { int index = find_index_of_pid(info.pids, info.num_processes, pids[i]); if (info.tickets[index] != tickets[i]) done = 0; } if (done) break; } setticket(LARGE_TICKET_COUNT); } void check(struct test_case* test, int passed_p, const char *description) { test->total_tests++; if (!passed_p) { test->errors++; printf(1, "*** TEST FAILURE: for scenario '%s': %s\n", test->name, description); } } void execute_and_get_info( struct test_case* test, int *pids, struct processes_info *before, struct processes_info *after) { setticket(LARGE_TICKET_COUNT); for (int i = 0; i < test->num_children; ++i) { pids[i] = spawn(test->tickets[i], test->functions[i]); } wait_for_ticket_counts(test->num_children, pids, test->tickets); before->num_processes = after->num_processes = -1; sleep(WARMUP_TIME); getprocessinfo(before); sleep(SLEEP_TIME); getprocessinfo(after); for (int i = 0; i < test->num_children; ++i) { kill(pids[i]); } for (int i = 0; i < test->num_children; ++i) { wait(); } } void count_ticks( struct test_case *test, int *pids, struct processes_info *before, struct processes_info *after) { test->total_actual_ticks = 0; for (int i = 0; i < test->num_children; ++i) { int before_index = find_index_of_pid(before->pids, before->num_processes, pids[i]); int after_index = find_index_of_pid(after->pids, after->num_processes, pids[i]); check(test, before_index >= 0 && after_index >= 0, "subprocess's pid appeared in getprocessinfo output"); if (before_index >= 0 && after_index >= 0) { check(test, test->tickets[i] == before->tickets[before_index] && test->tickets[i] == after->tickets[after_index], "subprocess assigned correct number of tickets"); test->actual_ticks[i] = after->ticks[after_index] - before->ticks[before_index]; test->total_actual_ticks += test->actual_ticks[i]; } else { test->actual_ticks[i] = -99999; // obviously bogus count that will fail checks later } } } void dump_test_timings(struct test_case *test) { printf(1, "-----------------------------------------\n"); printf(1, "%s expected ticks ratios and observations\n", test->name); printf(1, "#\texpect\tobserve\t(description)\n"); for (int i = 0; i < test->num_children; ++i) { const char *assigned_function = "(unknown)"; if (test->functions[i] == yield_forever) { assigned_function = "yield_forever"; } else if (test->functions[i] == run_forever) { assigned_function = "run_forever"; } else if (test->functions[i] == iowait_forever) { assigned_function = "iowait_forever"; } else if (test->functions[i] == exit_fast) { assigned_function = "exit_fast"; } printf(1, "%d\t%d\t%d\t(assigned %d tickets; running %s)\n", i, test->expect_ticks_unscaled[i], test->actual_ticks[i], test->tickets[i], assigned_function); } printf(1, "\nNOTE: the 'expect' values above represent the expected\n" " ratio of ticks between the processes. So, to compare\n" " them to the observations by hand, multiply each expected\n" " value by (sum of observed)/(sum of expected)\n"); printf(1, "-----------------------------------------\n"); } /* The comapre_ticks() code tries to do a Chi-squared test. Since we can't use floating point in xv6, calculations are done in fixed point. */ #define FIXED_POINT_BASE (1<<10) #define FIXED_POINT_COUNT 10 /* chi-squared thresholds for a p-value of 0.001, for 1, 2, ..., 10 degrees of freedom */ const long long chi_squared_thresholds[] = { FIXED_POINT_BASE / 100 * 1083, FIXED_POINT_BASE / 100 * 1382, FIXED_POINT_BASE / 100 * 1627, FIXED_POINT_BASE / 100 * 1847, FIXED_POINT_BASE / 100 * 2052, FIXED_POINT_BASE / 100 * 2246, FIXED_POINT_BASE / 100 * 2432, FIXED_POINT_BASE / 100 * 2612, FIXED_POINT_BASE / 100 * 2788, FIXED_POINT_BASE / 100 * 2959, }; int compare_ticks_chi_squared(struct test_case *test) { if (test->num_children < 2) { return 1; } long long expect_ticks_total = 0; for (int i = 0; i < test->num_children; ++i) { expect_ticks_total += test->expect_ticks_unscaled[i]; } /* compute the expected number of ticks for each child given the total number (in fixed point, so the rounding isn't so extreme. then, use this to compute the chi-squared test statistic: sum( (observed - expected)^2 / expected ) then compare this to our table of thresholds on the chi-squared distribution for the appropriate degree of freedom as a special case, we simply ignore columns for which we expect 0 items, except that other columns are computed based on the portion of the actual total number of ticks. a better solution would be to use a statistical test that can handle this case, like Fisher's exact test. */ long long delta = 0; int skipped = 0; for (int i = 0; i < test->num_children; ++i) { long long scaled_expected = (test->expect_ticks_unscaled[i] << FIXED_POINT_COUNT) / expect_ticks_total * test->total_actual_ticks; #ifdef DEBUG printf(1, "scaled %d to %d for ratio %d:%d\n", test->expect_ticks_unscaled[i], (int)(scaled_expected >> FIXED_POINT_COUNT), (int) expect_ticks_total, test->total_actual_ticks); #endif if (scaled_expected == 0) { ++skipped; continue; } long long cur_delta = scaled_expected - (test->actual_ticks[i] << FIXED_POINT_COUNT); #ifdef DEBUG printf(1, "raw delta is is %x/%x\n", (int) cur_delta, (int) (cur_delta >> 32)); printf(1, "raw delta rounded is is %x\n", (int) (cur_delta >> FIXED_POINT_COUNT)); #endif cur_delta *= cur_delta; #ifdef DEBUG if (cur_delta <= 0LL) { printf(1, "delta is negative???\n"); } #endif // cur_delta >>= FIXED_POINT_COUNT; // skipped because cancelled out by future shift back #ifdef DEBUG printf(1, "delta before division [raw] %x/%x\n", (int) cur_delta, (int) (cur_delta >> 32)); printf(1, "delta before division [rounded] %d\n", (int) (cur_delta >> FIXED_POINT_COUNT)); #endif if (scaled_expected > 0) { // cur_delta <<= FIXED_POINT_COUNT; cur_delta = cur_delta / scaled_expected; } else { /* a huge number to make sure statistical test fails */ cur_delta = FIXED_POINT_BASE * 100000LL; } #ifdef DEBUG printf(1, "cur_delta = %x/%x\n", (int) cur_delta, (int) (cur_delta >> 32)); #endif delta += cur_delta; } #ifdef DEBUG printf(1, "%s test statistic %d (rounded)\n", test->name, (int) ((delta + FIXED_POINT_BASE / 2) >> FIXED_POINT_COUNT)); #endif int degrees_of_freedom = test->num_children - 1 - skipped; long long expected_value = chi_squared_thresholds[degrees_of_freedom - 1]; int passed_threshold = delta < expected_value; check(test, passed_threshold, "distribution of ticks run passed chi-squared test " "for being same as expected"); if (!passed_threshold) { dump_test_timings(test); } check(test, test->total_actual_ticks > 10, "experiment ran for a non-trivial number of ticks"); return passed_threshold; } /* rather than doing a proper statistical test, make sure the results are within +/-20% +/- 10. (The extra +/- 10 is to handle cases where things run for a small number of ticks.) This hopefully will detect cases where a biased random number generator is in use but otherwise the implementation is generally okay. */ void compare_ticks_naive(struct test_case *test) { if (test->num_children < 2) { return; } int expect_ticks_total = 0; for (int i = 0; i < test->num_children; ++i) { expect_ticks_total += test->expect_ticks_unscaled[i]; } int failed_any = 0; for (int i = 0; i < test->num_children; ++i) { long long scaled_expected = ((long long) test->expect_ticks_unscaled[i] * test->total_actual_ticks) / expect_ticks_total; int max_expected = scaled_expected * 11 / 10 + 10; int min_expected = scaled_expected * 9 / 10 - 10; int in_range = (test->actual_ticks[i] >= min_expected && test->actual_ticks[i] <= max_expected); if (!in_range) { failed_any = 1; } } check(test, !failed_any, "tick counts within +/- 10% or +/- 10 of expected"); if (!failed_any) { printf(1, "*** %s failed chi-squared test, but was w/in 10% of expected\n", test->name); printf(1, "*** a likely cause is bias in random number generation\n"); } } void run_test_case(struct test_case* test) { int pids[MAX_CHILDREN]; test->total_tests = test->errors = 0; struct processes_info before, after; execute_and_get_info(test, pids, &before, &after); check(test, before.num_processes < NPROC && after.num_processes < NPROC && before.num_processes > test->num_children && after.num_processes > test->num_children, "getprocessinfo returned a reasonable number of processes"); count_ticks(test, pids, &before, &after); if (!compare_ticks_chi_squared(test)) { compare_ticks_naive(test); } printf(1, "%s: passed %d of %d\n", test->name, test->total_tests - test->errors, test->total_tests); } int main(int argc, char *argv[]) { int total_tests = 0; int passed_tests = 0; for (int i = 0; tests[i].name; ++i) { struct test_case *test = &tests[i]; run_test_case(test); total_tests += test->total_tests; passed_tests += test->total_tests - test->errors; } printf(1, "overall: passed %d of %d\n", passed_tests, total_tests); exit(); }
33.141026
129
0.593359
ca2968273842a6a22625427bf0c245f1d0f26e8d
6,032
h
C
Marlin/cardreader.h
guiEmotiv/nanodlp-mk
332209ebe8579b6e39b93e3cb429a97251dbb493
[ "MIT" ]
null
null
null
Marlin/cardreader.h
guiEmotiv/nanodlp-mk
332209ebe8579b6e39b93e3cb429a97251dbb493
[ "MIT" ]
null
null
null
Marlin/cardreader.h
guiEmotiv/nanodlp-mk
332209ebe8579b6e39b93e3cb429a97251dbb493
[ "MIT" ]
null
null
null
/** * Marlin 3D Printer Firmware * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef CARDREADER_H #define CARDREADER_H #include "MarlinConfig.h" #if ENABLED(SDSUPPORT) #define MAX_DIR_DEPTH 10 // Maximum folder depth #include "SdFile.h" #include "types.h" #include "enum.h" class CardReader { public: CardReader(); void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset void checkautostart(bool x); void openFile(char* name, bool read, bool push_current=false); void openLogFile(char* name); void removeFile(char* name); void closefile(bool store_location=false); void release(); void openAndPrintFile(const char *name); void startFileprint(); void stopSDPrint(); void getStatus(); void printingHasFinished(); #if ENABLED(LONG_FILENAME_HOST_SUPPORT) void printLongPath(char *path); #endif void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); void getAbsFilename(char *t); void ls(); void chdir(const char *relpath); void updir(); void setroot(); #if ENABLED(SDCARD_SORT_ALPHA) void presort(); void getfilename_sorted(const uint16_t nr); #if ENABLED(SDSORT_GCODE) FORCE_INLINE void setSortOn(bool b) { sort_alpha = b; presort(); } FORCE_INLINE void setSortFolders(int i) { sort_folders = i; presort(); } //FORCE_INLINE void setSortReverse(bool b) { sort_reverse = b; } #endif #endif FORCE_INLINE void pauseSDPrint() { sdprinting = false; } FORCE_INLINE bool isFileOpen() { return file.isOpen(); } FORCE_INLINE bool eof() { return sdpos >= filesize; } FORCE_INLINE int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); } FORCE_INLINE void setIndex(long index) { sdpos = index; file.seekSet(index); } FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; } FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; } public: bool saving, logging, sdprinting, cardOK, filenameIsDir; char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH]; int autostart_index; private: SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH]; uint8_t workDirDepth; // Sort files and folders alphabetically. #if ENABLED(SDCARD_SORT_ALPHA) uint16_t sort_count; // Count of sorted items in the current directory #if ENABLED(SDSORT_GCODE) bool sort_alpha; // Flag to enable / disable the feature int sort_folders; // Flag to enable / disable folder sorting //bool sort_reverse; // Flag to enable / disable reverse sorting #endif // By default the sort index is static #if ENABLED(SDSORT_DYNAMIC_RAM) uint8_t *sort_order; #else uint8_t sort_order[SDSORT_LIMIT]; #endif // Cache filenames to speed up SD menus. #if ENABLED(SDSORT_USES_RAM) // If using dynamic ram for names, allocate on the heap. #if ENABLED(SDSORT_CACHE_NAMES) #if ENABLED(SDSORT_DYNAMIC_RAM) char **sortshort, **sortnames; #else char sortshort[SDSORT_LIMIT][FILENAME_LENGTH]; char sortnames[SDSORT_LIMIT][FILENAME_LENGTH]; #endif #elif DISABLED(SDSORT_USES_STACK) char sortnames[SDSORT_LIMIT][FILENAME_LENGTH]; #endif // Folder sorting uses an isDir array when caching items. #if HAS_FOLDER_SORTING #if ENABLED(SDSORT_DYNAMIC_RAM) uint8_t *isDir; #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK) uint8_t isDir[(SDSORT_LIMIT+7)>>3]; #endif #endif #endif // SDSORT_USES_RAM #endif // SDCARD_SORT_ALPHA Sd2Card card; SdVolume volume; SdFile file; #define SD_PROCEDURE_DEPTH 1 #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1) uint8_t file_subcall_ctr; uint32_t filespos[SD_PROCEDURE_DEPTH]; char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH]; uint32_t filesize; uint32_t sdpos; millis_t next_autostart_ms; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. LsAction lsAction; //stored for recursion. uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; void lsDive(const char *prepend, SdFile parent, const char * const match=NULL); #if ENABLED(SDCARD_SORT_ALPHA) void flush_presort(); #endif }; extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if PIN_EXISTS(SD_DETECT) #if ENABLED(SD_DETECT_INVERTED) #define IS_SD_INSERTED (READ(SD_DETECT_PIN) != 0) #else #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == 0) #endif #else //No card detect line? Assume the card is inserted. #define IS_SD_INSERTED true #endif #else #define IS_SD_PRINTING (false) #endif // SDSUPPORT #endif // __CARDREADER_H
31.915344
160
0.71618
a9ba5818c0999def1a199d24e765189d100a973a
786
h
C
PrivateFrameworks/ConsoleKit/CSKMenuItemRepresentation.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/ConsoleKit/CSKMenuItemRepresentation.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/ConsoleKit/CSKMenuItemRepresentation.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" @class NSMenuItem, NSString; @interface CSKMenuItemRepresentation : NSObject { NSString *_property; NSMenuItem *_parentMenuItem; NSString *_groupIdentifier; id _value; } @property(retain, nonatomic) id value; // @synthesize value=_value; @property(retain, nonatomic) NSString *groupIdentifier; // @synthesize groupIdentifier=_groupIdentifier; @property(nonatomic) __weak NSMenuItem *parentMenuItem; // @synthesize parentMenuItem=_parentMenuItem; @property(readonly, nonatomic) NSString *property; // @synthesize property=_property; - (void).cxx_destruct; - (id)initWithProperty:(id)arg1; - (id)init; @end
27.103448
104
0.737913
aa1c3809e3f073492b1c6b9144318b1db6faed43
220
h
C
Algoritmica Grafurilor App/SFML Tutorial/Random.h
TFphoenix/graph-theory-algorithms
c0004a24cbb5fd951cbb916260c227552151bc16
[ "Apache-2.0" ]
1
2021-02-07T11:15:19.000Z
2021-02-07T11:15:19.000Z
Luxembourg/Luxembourg/Random.h
TFphoenix/graph-theory-algorithms
c0004a24cbb5fd951cbb916260c227552151bc16
[ "Apache-2.0" ]
null
null
null
Luxembourg/Luxembourg/Random.h
TFphoenix/graph-theory-algorithms
c0004a24cbb5fd951cbb916260c227552151bc16
[ "Apache-2.0" ]
null
null
null
#pragma once #include <random> class Random { public: Random(); int generate(int minim, int maxim); float generate(float minim, float maxim); private: std::random_device randomDevice; std::mt19937 m_MTwister; };
13.75
42
0.731818
aa8ce5247cd71b3842603309275eb82682b3c2a7
2,500
c
C
tests/test_contexts.c
martaiborra/c-blosc2
861ba79f31393dec0a0782ca11cf32cebb6f6610
[ "BSD-3-Clause" ]
null
null
null
tests/test_contexts.c
martaiborra/c-blosc2
861ba79f31393dec0a0782ca11cf32cebb6f6610
[ "BSD-3-Clause" ]
null
null
null
tests/test_contexts.c
martaiborra/c-blosc2
861ba79f31393dec0a0782ca11cf32cebb6f6610
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (C) 2020 The Blosc Developers http://blosc.org License: BSD (see LICENSE.txt) */ #include <stdio.h> #include "test_common.h" #define SIZE 500 * 1000 #define NTHREADS 2 int main(void) { static int32_t data[SIZE]; static int32_t data_out[SIZE]; static int32_t data_dest[SIZE]; int32_t data_subset[5]; int32_t data_subset_ref[5] = {5, 6, 7, 8, 9}; int32_t isize = SIZE * sizeof(int32_t), osize = SIZE * sizeof(int32_t); int dsize = SIZE * sizeof(int32_t), csize; int i, ret; blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS; blosc2_dparams dparams = BLOSC2_DPARAMS_DEFAULTS; blosc2_context *cctx, *dctx; /* Initialize dataset */ for (i = 0; i < SIZE; i++) { data[i] = i; } printf("Blosc version info: %s (%s)\n", BLOSC_VERSION_STRING, BLOSC_VERSION_DATE); install_blosc_callback_test(); /* optionally install callback test */ /* Create a context for compression */ cparams.typesize = sizeof(int32_t); cparams.compcode = BLOSC_BLOSCLZ; cparams.filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_SHUFFLE; cparams.clevel = 5; cparams.nthreads = NTHREADS; cctx = blosc2_create_cctx(cparams); /* Compress with clevel=5 and shuffle active */ csize = blosc2_compress_ctx(cctx, data, isize, data_out, osize); blosc2_free_ctx(cctx); if (csize == 0) { printf("Buffer is uncompressible. Giving up.\n"); return EXIT_FAILURE; } if (csize < 0) { printf("Compression error. Error code: %d\n", csize); return EXIT_FAILURE; } /* Create a context for decompression */ dparams.nthreads = NTHREADS; dctx = blosc2_create_dctx(dparams); ret = blosc2_getitem_ctx(dctx, data_out, csize, 5, 5, data_subset, sizeof(data_subset)); if (ret < 0) { printf("Error in blosc2_getitem_ctx(). Giving up.\n"); blosc2_free_ctx(dctx); return EXIT_FAILURE; } for (i = 0; i < 5; i++) { if (data_subset[i] != data_subset_ref[i]) { printf("blosc2_getitem_ctx() fetched data differs from original!\n"); blosc2_free_ctx(dctx); return EXIT_FAILURE; } } /* Decompress */ dsize = blosc2_decompress_ctx(dctx, data_out, csize, data_dest, (size_t)dsize); blosc2_free_ctx(dctx); if (dsize < 0) { printf("Decompression error. Error code: %d\n", dsize); return EXIT_FAILURE; } for (i = 0; i < SIZE; i++) { if (data[i] != data_dest[i]) { printf("Decompressed data differs from original!\n"); return EXIT_FAILURE; } } return EXIT_SUCCESS; }
26.595745
90
0.6664
80345c1ea253adb573e93d0e6910d99f27942157
12,898
c
C
Software/Analysis/src/filters.c
AmberXiong/Mic4Test_KC705
0a66a7305934f9d9da5c725a04e1e1ddcc4763c1
[ "MIT" ]
2
2018-01-17T08:44:39.000Z
2020-12-14T11:30:45.000Z
Software/Analysis/src/filters.c
AmberXiong/Mic4Test_KC705
0a66a7305934f9d9da5c725a04e1e1ddcc4763c1
[ "MIT" ]
null
null
null
Software/Analysis/src/filters.c
AmberXiong/Mic4Test_KC705
0a66a7305934f9d9da5c725a04e1e1ddcc4763c1
[ "MIT" ]
2
2018-01-17T08:46:04.000Z
2020-12-14T11:30:47.000Z
#include <string.h> #include <sys/types.h> #include <stdint.h> #include <math.h> #include <gsl/gsl_linalg.h> #include <gsl/gsl_wavelet.h> #include <fftw3.h> #include "common.h" #include "utils.h" #include "filters.h" filters_t *filters_init(ANALYSIS_WAVEFORM_BASE_TYPE *inWav, size_t n) { filters_t *fHdl; fHdl = (filters_t*)malloc(sizeof(filters_t)); fHdl->wavLen = n; fHdl->respLen = 0; fHdl->malloced = 0; fHdl->fftUsed = 0; fHdl->fftwNThreads = FFTW_NTHREADS_DEFAULT; fHdl->fftwFlags = FFTW_FLAGS_DEFAULT; if(inWav == NULL) { fHdl->inWav = (ANALYSIS_WAVEFORM_BASE_TYPE*) calloc(fHdl->wavLen, sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); fHdl->malloced = 1; } else { fHdl->inWav = inWav; } fHdl->outWav = (ANALYSIS_WAVEFORM_BASE_TYPE*) calloc(fHdl->wavLen, sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); fHdl->waveletWav = (WAVELET_BASE_TYPE*) calloc(fHdl->wavLen, sizeof(WAVELET_BASE_TYPE)); fHdl->gslDWT = gsl_wavelet_alloc(gsl_wavelet_daubechies_centered, 10); fHdl->gslDWTWork = gsl_wavelet_workspace_alloc(fHdl->wavLen); return fHdl; } /* for convolution */ filters_t *filters_init_for_convolution(ANALYSIS_WAVEFORM_BASE_TYPE *inWav, size_t n, size_t np) { filters_t *fHdl; if((np > 0) && (np % 2 == 0)) { error_printf("%s(): np = %zd is not odd!\n", __FUNCTION__, np); return NULL; } fHdl = filters_init(inWav, n); fHdl->respLen = np; fHdl->fftUsed = 1; fHdl->respWav = (ANALYSIS_WAVEFORM_BASE_TYPE*) calloc(fHdl->respLen, sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); if(np > 0) { fHdl->fftLen = (fHdl->wavLen + fHdl->respLen+1); /* zero padding */ if(fHdl->fftLen % 2) fHdl->fftLen++; /* ensure fHdl->fftLen is even */ } else { fHdl->fftLen = fHdl->wavLen; /* for spectrum calculation */ } if(fHdl->fftwNThreads > 0) { if(FFTW(init_threads)() == 0) { error_printf("fftw_init_threads error!\n"); } FFTW(plan_with_nthreads)(fHdl->fftwNThreads); } fHdl->fftwWork = (FFT_BASE_TYPE*) FFTW(malloc)(sizeof(FFT_BASE_TYPE) * fHdl->fftLen); fHdl->fftwWork1 = (FFT_BASE_TYPE*) FFTW(malloc)(sizeof(FFT_BASE_TYPE) * fHdl->fftLen); fHdl->fftwWin = (FFT_BASE_TYPE*) FFTW(malloc)(sizeof(FFT_BASE_TYPE) * fHdl->fftLen); filters_hanning_window(fHdl); /* Hanning window as the default */ fHdl->dt = 1.0; fHdl->fftwPlan = FFTW(plan_r2r_1d)(fHdl->fftLen, fHdl->fftwWork, fHdl->fftwWork, FFTW_R2HC, fHdl->fftwFlags); fHdl->fftwPlan1 = FFTW(plan_r2r_1d)(fHdl->fftLen, fHdl->fftwWork1, fHdl->fftwWork1, FFTW_R2HC, fHdl->fftwFlags); fHdl->fftwPlan2 = FFTW(plan_r2r_1d)(fHdl->fftLen, fHdl->fftwWork, fHdl->fftwWork, FFTW_HC2R, fHdl->fftwFlags); return fHdl; } int filters_close(filters_t *fHdl) { if(fHdl->malloced) { if(fHdl->inWav) free(fHdl->inWav); } if(fHdl->outWav) free(fHdl->outWav); if(fHdl->fftUsed) { if(fHdl->respWav) free(fHdl->respWav); FFTW(destroy_plan)(fHdl->fftwPlan); FFTW(destroy_plan)(fHdl->fftwPlan1); FFTW(destroy_plan)(fHdl->fftwPlan2); FFTW(free)(fHdl->fftwWork); FFTW(free)(fHdl->fftwWork1); FFTW(free)(fHdl->fftwWin); if(fHdl->fftwNThreads > 0) { FFTW(cleanup_threads)(); FFTW(cleanup)(); } } gsl_wavelet_free(fHdl->gslDWT); gsl_wavelet_workspace_free(fHdl->gslDWTWork); if(fHdl->waveletWav) free(fHdl->waveletWav); return 0; } /* Filters should directly write into fHdl->respWav the real space * response waveform in wrapped around order */ int filters_SavitzkyGolay(filters_t *fHdl, int m, int ld) /* m: order of polynomial, np: number of points, ld: degree of derivative*/ { int np; ANALYSIS_WAVEFORM_BASE_TYPE *c; int ipj, imj, mm, j, k, nl, nr; double fac, sum; gsl_permutation * p; gsl_vector *b; gsl_matrix *a; np = fHdl->respLen; if(np<1 || np<m-1 || np%2==0 || ld>m || np!=fHdl->respLen) { error_printf("%s(): improper arguments, returning...\n", __FUNCTION__); return 1; } c = calloc(np, sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); p = gsl_permutation_alloc (m+1); b = gsl_vector_alloc(m+1); a = gsl_matrix_alloc(m+1, m+1); nl = np/2; nr = nl; for(ipj=0;ipj<=(m << 1);ipj++) { sum=(ipj ? 0.0 : 1.0); for(k=1;k<=nr;k++) sum += pow((double)(k),(double)(ipj)); for(k=1;k<=nl;k++) sum += pow((double)(-k),(double)(ipj)); mm=MIN(ipj,2*m-ipj); for(imj=-mm;imj<=mm;imj+=2) gsl_matrix_set(a,(ipj+imj)/2,(ipj-imj)/2,sum); } gsl_linalg_LU_decomp(a, p, &k); for (j=0;j<m+1;j++) gsl_vector_set(b,j,0.0); gsl_vector_set(b,ld,1.0); gsl_linalg_LU_solve (a, p, b, b); for(k = -nl;k<=nr;k++) { sum = gsl_vector_get(b,0); fac = 1.0; for (mm=1;mm<=m;mm++) sum += gsl_vector_get(b,mm)*(fac *= k); j=(np-k) % np; c[j]=sum; // c is in wraparound order, convenient for fft convolute // c[nl + k] = sum; } memcpy(fHdl->respWav, c, np * sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); /* for(j=0; j<np; j++) { fprintf(stderr, "%g\n", c[j]); } */ gsl_vector_free(b); gsl_matrix_free(a); gsl_permutation_free(p); /* for(k=nl; k<wavlen - nr; k++) { sum = 0.0; for(j=0; j<np; j++) { sum += c[j] * inwav[k+j-nl]; outwav[k] = sum; } } */ free(c); return 0; } int filters_raisedCosine(filters_t *fHdl) { ssize_t i; ANALYSIS_WAVEFORM_BASE_TYPE x; for(i=0; i<(fHdl->respLen+1)/2; i++) { /* positive side */ x = 2.0*M_PI/(ANALYSIS_WAVEFORM_BASE_TYPE)(fHdl->respLen-1)*(ANALYSIS_WAVEFORM_BASE_TYPE)i; fHdl->respWav[i] = (1.0 + cos(x))/(ANALYSIS_WAVEFORM_BASE_TYPE)fHdl->respLen; } for(i=-((fHdl->respLen-1)/2); i<0; i++) { /* negative side */ /* i=-(fHdl->respLen-1)/2 cast to wrong value */ x = 2.0*M_PI/(ANALYSIS_WAVEFORM_BASE_TYPE)(fHdl->respLen-1)*(ANALYSIS_WAVEFORM_BASE_TYPE)i; fHdl->respWav[fHdl->respLen+i] = (1.0 + cos(x))/(ANALYSIS_WAVEFORM_BASE_TYPE)fHdl->respLen; } return 0; } int filters_convolute(filters_t *fHdl) { size_t i; ANALYSIS_WAVEFORM_BASE_TYPE re, im; for(i=0; i<fHdl->wavLen; i++) { fHdl->fftwWork[i] = fHdl->inWav[i]; } for(i=fHdl->wavLen; i<fHdl->fftLen; i++) { fHdl->fftwWork[i] = 0.0; } // fill in with respwav in wrap-around order fHdl->fftwWork1[0] = fHdl->respWav[0]; for(i=1; i<(fHdl->respLen+1)/2; i++) { fHdl->fftwWork1[i] = fHdl->respWav[i]; fHdl->fftwWork1[fHdl->fftLen-i] = fHdl->respWav[fHdl->respLen-i]; } for(i=(fHdl->respLen+1)/2; i<(fHdl->fftLen-(fHdl->respLen+1)/2); i++) { fHdl->fftwWork1[i] = 0.0; } // do fft FFTW(execute)(fHdl->fftwPlan); FFTW(execute)(fHdl->fftwPlan1); // multiply in complex fourier space, half-complex format fHdl->fftwWork[0] = fHdl->fftwWork[0] * fHdl->fftwWork1[0] / (ANALYSIS_WAVEFORM_BASE_TYPE)fHdl->fftLen; for(i=1; i<fHdl->fftLen/2; i++) { re = fHdl->fftwWork[i] * fHdl->fftwWork1[i] - fHdl->fftwWork[fHdl->fftLen-i] * fHdl->fftwWork1[fHdl->fftLen-i]; im = fHdl->fftwWork[i] * fHdl->fftwWork1[fHdl->fftLen-i] + fHdl->fftwWork[fHdl->fftLen-i] * fHdl->fftwWork1[i]; fHdl->fftwWork[i] = re / (ANALYSIS_WAVEFORM_BASE_TYPE)fHdl->fftLen; fHdl->fftwWork[fHdl->fftLen-i] = im / (ANALYSIS_WAVEFORM_BASE_TYPE)fHdl->fftLen; } fHdl->fftwWork[fHdl->fftLen/2] = fHdl->fftwWork[fHdl->fftLen/2] * fHdl->fftwWork1[fHdl->fftLen/2] / (ANALYSIS_WAVEFORM_BASE_TYPE)fHdl->fftLen; // ifft FFTW(execute)(fHdl->fftwPlan2); // copy the output to outwav memcpy(fHdl->outWav, fHdl->fftwWork, fHdl->wavLen * sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); return 0; } int filters_hanning_window(filters_t *fHdl) { size_t i; fHdl->fftwS1 = 0.0; fHdl->fftwS2 = 0.0; for(i=0; i<fHdl->fftLen; i++) { fHdl->fftwWin[i] = 0.5 * (1.0 - cos(2*M_PI*i/(double)fHdl->fftLen)); fHdl->fftwS1 += fHdl->fftwWin[i]; fHdl->fftwS2 += fHdl->fftwWin[i] * fHdl->fftwWin[i]; } return 0; } int filters_fft_spectrum(filters_t *fHdl) { size_t i; for(i=0; i<fHdl->fftLen; i++) { fHdl->fftwWork[i] = fHdl->inWav[i] * fHdl->fftwWin[i]; } FFTW(execute)(fHdl->fftwPlan); /* Compute linearized power spectrum into fftwWork1, in [V] for example, normalized. * Total length should be (int)(n/2)+1 */ fHdl->fftwWork1[0] = fHdl->fftwWork[0] / fHdl->fftwS1; for(i=1; i<(fHdl->fftLen+1)/2; i++) { fHdl->fftwWork1[i] = hypot(fHdl->fftwWork[i], fHdl->fftwWork[fHdl->fftLen - i]) * sqrt(2.0) / fHdl->fftwS1; } if(fHdl->fftLen % 2 == 0) { /* even number */ fHdl->fftwWork1[fHdl->fftLen/2] = fHdl->fftwWork[fHdl->fftLen/2] / fHdl->fftwS1; } /* For spectra density, normalization should be * sqrt(2.0 * dt / fftwS2) */ for(i=0; i<=fHdl->fftLen/2; i++) { fHdl->fftwWork[i] = fHdl->fftwWork1[i] * fHdl->fftwS1 * sqrt(fHdl->dt / fHdl->fftwS2); } return 0; } int filters_DWT(filters_t *fHdl) /* discrete wavelet transform */ { gsl_wavelet_transform_forward(fHdl->gslDWT, fHdl->waveletWav, 1, fHdl->wavLen, fHdl->gslDWTWork); return 0; } int filters_median(filters_t *fHdl, size_t n) /* median filter with moving window size n */ { size_t i, mid=n/2; for(i=0; i<mid;i++) /* overhang at the beginning */ fHdl->outWav[i] = quickselect(fHdl->inWav, mid+i+1, (mid+i+1)/2); for(i=0; i<fHdl->wavLen-1 - mid; i++) fHdl->outWav[mid+i] = quickselect(fHdl->inWav + i, n, n/2); for(i=0; i<mid; i++) /* overhang at the end */ fHdl->outWav[fHdl->wavLen-1 - i] = quickselect(fHdl->inWav + fHdl->wavLen - (mid-i+1), mid-i+1, (mid-i+1)/2); return 0; } int filters_trapezoidal(filters_t *fHdl, size_t k, size_t l, double M) { double s, pp; ssize_t i, j, jk, jl, jkl; double vj, vjk, vjl, vjkl, dkl; s = 0.0; pp = 0.0; for(i=0; i<fHdl->wavLen; i++) { j=i; jk = j-k; jl = j-l; jkl = j-k-l; vj = j>=0 ? fHdl->inWav[j] : fHdl->inWav[0]; vjk = jk>=0 ? fHdl->inWav[jk] : fHdl->inWav[0]; vjl = jl>=0 ? fHdl->inWav[jl] : fHdl->inWav[0]; vjkl = jkl>=0 ? fHdl->inWav[jkl] : fHdl->inWav[0]; dkl = vj - vjk - vjl + vjkl; pp = pp + dkl; if(M>=0.0) { s = s + pp + dkl * M; } else { /* infinit decay time, so the input is a step function */ s = s + dkl; } fHdl->outWav[i] = s / (fabs(M) * (double)k); } return 0; } #ifdef FILTERS_DEBUG_ENABLEMAIN int main(int argc, char **argv) { #define PLEN 1503 ANALYSIS_WAVEFORM_BASE_TYPE pulse[PLEN] = {0.0}; size_t i; filters_t *fHdl; i = 2; pulse[i++]=0.0; pulse[i++]=1.0; pulse[i++]=10.0; pulse[i++]=8.0; pulse[i++]=6.0; pulse[i++]=4.0; pulse[i++]=2.0; pulse[i++]=1.0; pulse[i++]=0.5; pulse[i++]=0.2; i = 100; pulse[i--]=0.0; pulse[i--]=1.0; pulse[i--]=10.0; pulse[i--]=8.0; pulse[i--]=6.0; pulse[i--]=4.0; pulse[i--]=2.0; pulse[i--]=1.0; pulse[i--]=0.5; pulse[i--]=0.2; fHdl = filters_init(pulse, PLEN); filters_median(fHdl, 11); for(i=0; i<fHdl->wavLen; i++) { printf("%g %g\n", fHdl->inWav[i], fHdl->outWav[i]); } printf("\n\n"); #if 0 for(i=0; i<PLEN; i++) { pulse[i] += 10.0 * cos(2.0 * M_PI/3.0 * i); } fHdl = filters_init_for_convolution(pulse, PLEN, 0); filters_fft_spectrum(fHdl); for(i=0; i<fHdl->fftLen; i++) { printf("%g %g\n", fHdl->fftwWork[i], fHdl->fftwWork1[i]); } printf("\n\n"); #endif #if 0 fHdl = filters_init_for_convolution(NULL, PLEN, 31); memcpy(fHdl->inWav, pulse, PLEN * sizeof(ANALYSIS_WAVEFORM_BASE_TYPE)); filters_raisedCosine(fHdl); filters_convolute(fHdl); for(i=0; i<fHdl->fftLen/*PLEN*/; i++) { // printf("%g %g\n", pulse[i], fHdl->outWav[i]); printf("%g %g\n", fHdl->fftwWork[i], fHdl->fftwWork1[i]); } printf("\n\n"); filters_SavitzkyGolay(fHdl, 5, 0); filters_convolute(fHdl); for(i=0; i<fHdl->fftLen/*PLEN*/; i++) { // printf("%g %g\n", pulse[i], fHdl->outWav[i]); printf("%g %g\n", fHdl->fftwWork[i], fHdl->fftwWork1[i]); } #endif filters_close(fHdl); return EXIT_SUCCESS; } #endif
31.768473
101
0.57319
bd26b52fc8adb30e00f7d7dbf158151f410b0bf2
2,073
h
C
Source/Dynamics/ParticleSystem/MeshCollision.h
weikm/sandcarSimulation2
fe499d0a3289c0ac1acce69c7dc78d8ce1b2708a
[ "Apache-2.0" ]
null
null
null
Source/Dynamics/ParticleSystem/MeshCollision.h
weikm/sandcarSimulation2
fe499d0a3289c0ac1acce69c7dc78d8ce1b2708a
[ "Apache-2.0" ]
null
null
null
Source/Dynamics/ParticleSystem/MeshCollision.h
weikm/sandcarSimulation2
fe499d0a3289c0ac1acce69c7dc78d8ce1b2708a
[ "Apache-2.0" ]
null
null
null
#pragma once #include "Core/Array/Array.h" #include "Framework/Framework/CollisionModel.h" #include "Framework/Framework/ModuleTopology.h" #include "Framework/Framework/Node.h" #include "Framework/Framework/FieldArray.h" namespace PhysIKA { template <typename> class CollidablePoints; template <typename> class NeighborQuery; template <typename> class NeighborList; template <typename> class GridHash; template <typename TDataType> class PointSet; template <typename TDataType> class TriangleSet; template <typename TDataType> class MeshCollision : public CollisionModel { DECLARE_CLASS_1(MeshCollision, TDataType) public: typedef typename TDataType::Real Real; typedef typename TDataType::Coord Coord; typedef typename TopologyModule::Triangle Triangle; MeshCollision(); virtual ~MeshCollision(); bool isSupport(std::shared_ptr<CollidableObject> obj) override; void addCollidableObject(std::shared_ptr<CollidableObject> obj) override; bool initializeImpl() override; void doCollision() override; DeviceArrayField<Coord> m_position; DeviceArrayField<Coord> m_velocity; DeviceArrayField<Real> m_triangle_vertex_mass; DeviceArrayField<Coord> m_triangle_vertex; DeviceArrayField<Coord> m_triangle_vertex_old; DeviceArrayField<Triangle> m_triangle_index; DeviceArrayField<int> m_flip; NeighborField<int> m_neighborhood_tri; DeviceArrayField<Coord> m_velocity_mod; protected: DeviceArray<int> m_objId; DeviceArray<Real> weights; DeviceArray<Coord> init_pos; DeviceArray<Coord> posBuf; DeviceArray<Coord> m_position_previous; DeviceArray<Coord> m_triangle_vertex_previous; std::shared_ptr<NeighborQuery<TDataType>> m_nbrQuery; std::shared_ptr<NeighborList<int>> m_nList; std::vector<std::shared_ptr<CollidablePoints<TDataType>>> m_collidableObjects; }; #ifdef PRECISION_FLOAT template class MeshCollision<DataType3f>; #else template class MeshCollision<DataType3d>; #endif } // namespace PhysIKA
27.276316
82
0.760733
2328dc52cd535618f4ed269455ce453c1095a1b5
714
h
C
src/camera/include/CameraData.h
robots-inspired/visual_odometry
8690830d2a86d51030b2cf10ffc11ca161718b50
[ "MIT" ]
null
null
null
src/camera/include/CameraData.h
robots-inspired/visual_odometry
8690830d2a86d51030b2cf10ffc11ca161718b50
[ "MIT" ]
null
null
null
src/camera/include/CameraData.h
robots-inspired/visual_odometry
8690830d2a86d51030b2cf10ffc11ca161718b50
[ "MIT" ]
null
null
null
#pragma once #include <src/camera/include/CameraModel.h> namespace my_robot { class CameraData { public: CameraData() { }; CameraData(const cv::Mat& image, const cv::Mat& depth, const CameraModel& cameraModel) : _image(image), _depth(depth), _cameraModel(cameraModel) { } const cv::Mat& getImage() const { return _image; } const cv::Mat& getDepth() const { return _depth; } const CameraModel& getCameraModel() const { return _cameraModel; } bool isValid() const { return _cameraModel.isCalibrated(); } private: cv::Mat _image; cv::Mat _depth; CameraModel _cameraModel; }; }
22.3125
91
0.596639
6c8a5d58f5ab32c4b3a0bbab134b69322e5424e8
3,823
c
C
test/test_sem.c
kimushu/tinythreads
000ac8739f5ae8ef19a7f9cc28cf1ad6404c23a4
[ "MIT" ]
7
2018-03-21T18:35:23.000Z
2022-01-29T16:59:12.000Z
test/test_sem.c
kimushu/tinythreads
000ac8739f5ae8ef19a7f9cc28cf1ad6404c23a4
[ "MIT" ]
5
2016-12-09T15:26:02.000Z
2020-10-06T00:14:59.000Z
test/test_sem.c
kimushu/tinythreads
000ac8739f5ae8ef19a7f9cc28cf1ad6404c23a4
[ "MIT" ]
3
2020-05-20T00:44:28.000Z
2021-10-09T02:54:05.000Z
#include <tthread.h> #include <errno.h> #include <stdint.h> #include <string.h> #include "unity.h" static volatile int test_worker_pass = 0; static void *wait_worker(sem_t *sem) { test_worker_pass = 1; TEST_ASSERT_EQUAL_MESSAGE( 0, sem_wait(sem), "sem_wait() on sub thread should succeed immediately"); test_worker_pass = 2; errno = 0; TEST_ASSERT_EQUAL_MESSAGE(-1, sem_trywait(sem), "sem_trywait() on sub thread should fail"); TEST_ASSERT_EQUAL_MESSAGE(EAGAIN, errno, "errno should be set to EAGAIN"); test_worker_pass = 3; TEST_ASSERT_EQUAL_MESSAGE(0, sem_wait(sem), "sem_wait() on sub thread should succeed"); test_worker_pass = 4; return NULL; } static void test_sem_init_getvalue(void) { sem_t sem; errno = 0; TEST_ASSERT_EQUAL_MESSAGE(-1, sem_init(&sem, 1, 1), "sem_init() should fail (w/pshared == 1)"); TEST_ASSERT_EQUAL_MESSAGE(ENOSYS, errno, "errno should be set to ENOSYS"); errno = 0; TEST_ASSERT_EQUAL_MESSAGE(-1, sem_init(&sem, 0, SEM_VALUE_MAX + 1), "sem_init() should fail (w/too large value)"); TEST_ASSERT_EQUAL_MESSAGE(EINVAL, errno, "errno should be set to ENOSYS"); memset(&sem, 0x55, sizeof(sem)); TEST_ASSERT_EQUAL_MESSAGE(0, sem_init(&sem, 0, 123), "sem_init() should succeed"); int value = 0; TEST_ASSERT_EQUAL_MESSAGE(0, sem_getvalue(&sem, &value), "sem_getvalue() should succeed"); TEST_ASSERT_EQUAL_MESSAGE(123, value, "initial value should be set correctly"); } static void test_sem_wait_trywait_post(void) { sem_t sem; memset(&sem, 0x55, sizeof(sem)); TEST_ASSERT_EQUAL_MESSAGE(0, sem_init(&sem, 0, 1), "sem_init() should succeed"); test_worker_pass = 0; pthread_attr_t attr; memset(&attr, 0x55, sizeof(attr)); TEST_ASSERT_EQUAL_MESSAGE(0, pthread_attr_init(&attr), "pthread_attr_init() should succeed"); struct sched_param param; memset(&param, 0, sizeof(param)); param.sched_priority = 11; TEST_ASSERT_EQUAL_MESSAGE(0, pthread_attr_setschedparam(&attr, &param), "pthread_attr_setschedparam() should succeed"); pthread_t tid; memset(&tid, 0x55, sizeof(tid)); TEST_ASSERT_EQUAL_MESSAGE( 0, pthread_create(&tid, &attr, (void *(*)(void *))wait_worker, &sem), "pthread_create() should succeed"); TEST_ASSERT_EQUAL_MESSAGE(3, test_worker_pass, "sub thread should be waiting with 2nd sem_wait()"); sem_post(&sem); TEST_ASSERT_EQUAL_MESSAGE(4, test_worker_pass, "sub thread should be finished"); TEST_ASSERT_EQUAL_MESSAGE(0, pthread_join(tid, NULL), "pthread_join() should succeed"); } static void test_sem_post_overflow(void) { sem_t sem; memset(&sem, 0x55, sizeof(sem)); TEST_ASSERT_EQUAL_MESSAGE(0, sem_init(&sem, 0, SEM_VALUE_MAX), "sem_init() should succeed"); errno = 0; TEST_ASSERT_EQUAL_MESSAGE(-1, sem_post(&sem), "sem_destroy() should fail"); TEST_ASSERT_EQUAL_MESSAGE(EOVERFLOW, errno, "errno should be set to EOVERFLOW"); } static void test_sem_destroy(void) { sem_t sem; memset(&sem, 0x55, sizeof(sem)); TEST_ASSERT_EQUAL_MESSAGE(0, sem_init(&sem, 0, 123), "sem_init() should succeed"); TEST_ASSERT_EQUAL_MESSAGE(0, sem_destroy(&sem), "sem_destroy() should succeed"); } void test_sem(void) { UnitySetTestFile(__FILE__); RUN_TEST(test_sem_init_getvalue); RUN_TEST(test_sem_wait_trywait_post); RUN_TEST(test_sem_post_overflow); RUN_TEST(test_sem_destroy); }
31.858333
80
0.642166
1e8a68df90b9b121179556b7371d8ce2e20324b2
127
h
C
private/inet/mshtml/external/inc/msls/plnobj.h
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
windows/richedit/lsinc/plnobj.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
windows/richedit/lsinc/plnobj.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2019-01-16T01:01:23.000Z
2022-02-20T15:54:27.000Z
#ifndef PLNOBJ_DEFINED #define PLNOBJ_DEFINED struct lnobj; typedef struct lnobj* PLNOBJ; #endif /* PLNOBJ_DEFINED */
15.875
30
0.740157
e7b345ba634b20beb7ade07253a1c6744759ad0f
252
h
C
HomeworkPatterns/Models/EnglishMan.h
WytenCode/HomeworkPatterns
e04eaf7d8466f1117be496fad897fb7f8ccd2b66
[ "MIT" ]
null
null
null
HomeworkPatterns/Models/EnglishMan.h
WytenCode/HomeworkPatterns
e04eaf7d8466f1117be496fad897fb7f8ccd2b66
[ "MIT" ]
null
null
null
HomeworkPatterns/Models/EnglishMan.h
WytenCode/HomeworkPatterns
e04eaf7d8466f1117be496fad897fb7f8ccd2b66
[ "MIT" ]
null
null
null
// // EnglishMan.h // HomeworkPatterns // // Created by Владимир on 08/05/2019. // Copyright © 2019 Владимир. All rights reserved. // #import <Foundation/Foundation.h> #import "StreetMan.h" @interface EnglishMan : NSObject <StreetPerson> @end
14.823529
51
0.702381
9b1968b2bdb50987844628c89d42cd3577c2d5e7
39,579
c
C
draw/draw.c
multigcs/multigcs
bd37e2a81411474c6adc5a51bfaef64656920fa3
[ "libpng-2.0" ]
25
2015-03-30T20:19:23.000Z
2021-12-10T06:18:10.000Z
draw/draw.c
multigcs/multigcs
bd37e2a81411474c6adc5a51bfaef64656920fa3
[ "libpng-2.0" ]
null
null
null
draw/draw.c
multigcs/multigcs
bd37e2a81411474c6adc5a51bfaef64656920fa3
[ "libpng-2.0" ]
16
2015-01-02T22:43:29.000Z
2020-04-22T08:44:36.000Z
#include <all.h> #if SDL_BYTEORDER == SDL_BIG_ENDIAN Uint32 rmask = 0xff000000; Uint32 gmask = 0x00ff0000; Uint32 bmask = 0x0000ff00; Uint32 amask = 0x000000ff; #else Uint32 rmask = 0x000000ff; Uint32 gmask = 0x0000ff00; Uint32 bmask = 0x00ff0000; Uint32 amask = 0xff000000; #endif SrtmCache AltCache[MAX_ALTCACHE]; const GLfloat DEG2RAD = PI / 180.0; uint8_t screen_select(char *name, float x, float y, int8_t button, float data, uint8_t action); #ifndef GL_BGRA #define GL_BGRA 0x80E1 #define GL_RGBA 0x1908 #define GL_BGR 0x80E0 #define GL_RGB 0x1907 #endif void draw_scrollbar(ESContext *esContext, uint16_t page, uint16_t page_max, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t)) { #ifdef CONSOLE_ONLY return; #endif if (page_max > 0) { draw_box_f3(esContext, 1.3, -0.77, 0.002, 1.35, 0.77, 0.002, 255, 255, 255, 128); set_button("down", setup.view_mode, 1.3, -0.77, 1.35, -0.67, callback, -1.0, 0); set_button("down2", setup.view_mode, 1.3, -0.77, 1.35, 0.0, callback, -1.0, 0); draw_box_f3(esContext, 1.3, -0.77, 0.002, 1.35, -0.67, 0.002, 255, 255, 255, 128); draw_box_f3(esContext, 1.3, -0.77, 0.002, 1.35, -0.67, 0.002, 255, 255, 255, 128); draw_rect_f3(esContext, 1.3, -0.77, 0.002, 1.35, -0.67, 0.002, 255, 255, 255, 128); set_button("up", setup.view_mode, 1.3, 0.67, 1.35, 0.77, callback, 1.0, 0); set_button("up2", setup.view_mode, 1.3, 0.0, 1.35, 0.77, callback, 1.0, 0); if (page < 0) { page = 0; } if (page > page_max) { page = page_max; } draw_box_f3(esContext, 1.3, 0.67, 0.002, 1.35, 0.77, 0.002, 255, 255, 255, 128); draw_box_f3(esContext, 1.3, 0.77, 0.002, 1.35, 0.67, 0.002, 255, 255, 255, 128); draw_rect_f3(esContext, 1.3, 0.77, 0.002, 1.35, 0.67, 0.002, 255, 255, 255, 128); draw_box_f3(esContext, 1.3 - 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max) - 0.02, 0.002, 1.35 + 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max), 0.002, 255, 255, 255, 200); draw_rect_f3(esContext, 1.3 - 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max) - 0.02, 0.002, 1.35 + 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max), 0.002, 100, 100, 100, 128); } } void draw_title(ESContext *esContext, char *text) { #ifdef CONSOLE_ONLY return; #endif draw_text_f3(esContext, 0.0 - strlen(text) * 0.06 * 0.6 / 2.0 - 0.012, -0.95, 0.02, 0.06, 0.06, FONT_GREEN, text); // draw_text_button(esContext, "screen_select", setup.view_mode, text, FONT_WHITE, -1.1, -0.95, 0.003, 0.06, ALIGN_LEFT, ALIGN_TOP, screen_select, -1.0); } uint8_t draw_button(ESContext *esContext, char *name, uint8_t view_mode, char *text, char *font, float x1, float y1, float z1, float x2, float y2, float z2, float fh, uint8_t align_x, uint8_t align_y, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t), float data) { #ifdef CONSOLE_ONLY return 0; #endif uint16_t n = 0; draw_rect_f3(esContext, x1, y1, z1, x2, y2, z1, 128, 128, 128, 32); draw_box_f3c2(esContext, x1, y1, z1, x2, y1 + (y2 - y1) / 3 * 2, z1, 128, 128, 128, 64, 128, 128, 128, 128); draw_box_f3c2(esContext, x1, y1 + (y2 - y1) / 3 * 2, z1, x2, y2, z1, 128, 128, 128, 128, 128, 128, 128, 64); float tx = x1; float ty = y1; if (align_x == ALIGN_CENTER) { tx = x1 + (x2 - x1) / 2 - (strlen(text) * fh * 0.6) / 2; } else if (align_x == ALIGN_RIGHT) { tx = x2 - fh / 4 - (strlen(text) * fh * 0.6); } else if (align_x == ALIGN_LEFT) { tx = x1 + fh / 4; } if (align_y == ALIGN_CENTER) { ty = y1 + (y2 - y1) / 2 - fh / 2; } else if (align_y == ALIGN_TOP) { ty = y1 + fh / 4; } else if (align_y == ALIGN_BOTTOM) { ty = y2 - fh / 4 - fh; } // draw_text_f3(esContext, x1, y1 + (y2 - y1) / 2 - fh / 2, z1, fh, fh, font, text); draw_text_f3(esContext, tx, ty, z1, fh, fh, font, text); if (gui_ov_lock == 1) { return 0; } for (n = 0; n < MAX_BUTTONS; n++) { if (strcmp(Buttons[n].name, name) == 0) { Buttons[n].view_mode = setup.view_mode; Buttons[n].x1 = x1; Buttons[n].y1 = y1; Buttons[n].x2 = x2; Buttons[n].y2 = y2; Buttons[n].data = data; Buttons[n].callback = callback; Buttons[n].type = 0; return 0; } else if (Buttons[n].name[0] == 0) { strncpy(Buttons[n].name, name, 99); Buttons[n].view_mode = setup.view_mode; Buttons[n].x1 = x1; Buttons[n].y1 = y1; Buttons[n].x2 = x2; Buttons[n].y2 = y2; Buttons[n].data = data; Buttons[n].callback = callback; Buttons[n].type = 0; return 1; } } return 2; } uint8_t draw_text_button(ESContext *esContext, char *name, uint8_t view_mode, char *text, char *font, float x, float y, float z, float h, uint8_t align_x, uint8_t align_y, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t), float data) { #ifdef CONSOLE_ONLY return 0; #endif uint16_t n = 0; float x1 = x - strlen(text) * h * 0.6 / 2.0 - 0.012; float y1 = y; float x2 = x + strlen(text) * h * 0.6 / 2.0 + 0.012; float y2 = y + h; float z1 = z; if (align_x == ALIGN_CENTER) { x1 = x - strlen(text) * h * 0.6 / 2.0 - 0.012; x2 = x + strlen(text) * h * 0.6 / 2.0 + 0.012; } else if (align_x == ALIGN_RIGHT) { x1 = x - strlen(text) * h * 0.6 - 0.012; x2 = x; } else if (align_x == ALIGN_LEFT) { x1 = x; x2 = x + strlen(text) * h * 0.6 + 0.02; } if (align_y == ALIGN_CENTER) { y1 = y - h / 2; y2 = y + h / 2; } draw_text_f3(esContext, x1, y1, z1, h, h, font, text); if (callback == NULL) { return 0; } // draw_rect_f3(esContext, x1 - 0.01, y1 - 0.01, z1, x2 + 0.01, y2 + 0.01, z1, 255, 255, 255, 64); if (gui_ov_lock == 1) { return 0; } for (n = 0; n < MAX_BUTTONS; n++) { if (strcmp(Buttons[n].name, name) == 0) { Buttons[n].view_mode = setup.view_mode; Buttons[n].x1 = x1 - 0.01; Buttons[n].y1 = y1 - 0.01; Buttons[n].x2 = x2 + 0.01; Buttons[n].y2 = y2 + 0.01; Buttons[n].data = data; Buttons[n].callback = callback; Buttons[n].type = 0; return 0; } else if (Buttons[n].name[0] == 0) { strncpy(Buttons[n].name, name, 99); Buttons[n].view_mode = setup.view_mode; Buttons[n].x1 = x1 - 0.01; Buttons[n].y1 = y1 - 0.01; Buttons[n].x2 = x2 + 0.01; Buttons[n].y2 = y2 + 0.01; Buttons[n].data = data; Buttons[n].callback = callback; Buttons[n].type = 0; return 1; } } return 2; } uint8_t draw_text_align(ESContext *esContext, char *text, char *font, float x, float y, float z, float h, uint8_t align_x, uint8_t align_y) { #ifdef CONSOLE_ONLY return 0; #endif float x1 = x - strlen(text) * h * 0.6 / 2.0 - 0.012; float y1 = y; float z1 = z; if (align_x == ALIGN_CENTER) { x1 = x - strlen(text) * h * 0.6 / 2.0 - 0.012; } else if (align_x == ALIGN_RIGHT) { x1 = x - strlen(text) * h * 0.6 - 0.012; } else if (align_x == ALIGN_LEFT) { x1 = x; } if (align_y == ALIGN_CENTER) { y1 = y - h / 2; } draw_text_f3(esContext, x1, y1, z1, h, h, font, text); return 0; } uint8_t draw_image_button(ESContext *esContext, char *name, uint8_t view_mode, char *image, float x, float y, float z, float w, float h, uint8_t align_x, uint8_t align_y, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t), float data) { #ifdef CONSOLE_ONLY return 0; #endif char text[1024]; char font[1024]; strncpy(text, "img", 1023); strncpy(font, FONT_GREEN, 1023); uint16_t n = 0; float x1 = x - w / 2.0; float y1 = y; float x2 = x + w / 2.0; float y2 = y + h; if (align_x == ALIGN_CENTER) { x1 = x - w / 2.0; x2 = x + w / 2.0; } else if (align_x == ALIGN_RIGHT) { x1 = x - w; x2 = x; } else if (align_x == ALIGN_LEFT) { x1 = x; x2 = x + w; } if (align_y == ALIGN_CENTER) { y1 = y - h / 2; y2 = y + h / 2; } draw_image_f3(esContext, x1, y1, x2, y2, 0.0, image); // draw_rect_f3(esContext, x1 - 0.01, y1 - 0.01, z1, x2 + 0.01, y2 + 0.01, z1, 255, 0, 0, 255); if (gui_ov_lock == 1) { return 0; } for (n = 0; n < MAX_BUTTONS; n++) { if (strcmp(Buttons[n].name, name) == 0) { Buttons[n].view_mode = setup.view_mode; Buttons[n].x1 = x1 - 0.01; Buttons[n].y1 = y1 - 0.01; Buttons[n].x2 = x2 + 0.01; Buttons[n].y2 = y2 + 0.01; Buttons[n].data = data; Buttons[n].callback = callback; Buttons[n].type = 0; return 0; } else if (Buttons[n].name[0] == 0) { strncpy(Buttons[n].name, name, 100); Buttons[n].view_mode = setup.view_mode; Buttons[n].x1 = x1 - 0.01; Buttons[n].y1 = y1 - 0.01; Buttons[n].x2 = x2 + 0.01; Buttons[n].y2 = y2 + 0.01; Buttons[n].data = data; Buttons[n].callback = callback; Buttons[n].type = 0; return 1; } } return 2; } int next_power_of_two(int n) { double logbase2 = log((double) n) / log(2.0); return (int)(pow(2, ceil(logbase2)) + 0.5); } SDL_Surface *convert_to_power_of_two(SDL_Surface *surface) { int width = next_power_of_two(surface->w); int height = next_power_of_two(surface->h); SDL_Surface *pot_surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); SDL_Rect dstrect; dstrect.x = (pot_surface->w - surface->w) / 2; dstrect.y = (pot_surface->h - surface->h) / 2; dstrect.w = surface->w; dstrect.h = surface->w; SDL_BlitSurface(surface, NULL, pot_surface, &dstrect); return pot_surface; } int imagefile_exists(char *fileName) { struct stat buf; int i = stat(fileName, &buf); if (i == 0) { return 1; } return 0; } int loadImage(const char *filename) { #ifndef ANDROID if (strstr(filename, ".png\0") > 0) { return loadPNG(filename); } #else if (strncmp(filename, "./", 2) == 0) { filename += 2; } #endif #ifdef RPI_NO_X char tmp_file[1024]; sprintf(tmp_file, "%s.png", filename); if (imagefile_exists(tmp_file) == 0) { char tmp_cmd[2048]; sprintf(tmp_cmd, "convert \"%s\" \"%s\"", filename, tmp_file); system(tmp_cmd); } return loadPNG(tmp_file); #endif SDL_Surface *imageSurface1 = IMG_Load(filename); if (! imageSurface1) { SDL_Log("Error: loading image: %s\n", filename); return 0; } SDL_Surface *imageSurface = convert_to_power_of_two(imageSurface1); SDL_FreeSurface(imageSurface1); GLuint texture; GLenum texture_format; GLint nOfColors; nOfColors = imageSurface->format->BytesPerPixel; if (nOfColors == 4) { if (imageSurface->format->Rmask == 0x000000ff) { texture_format = GL_RGBA; } else { texture_format = GL_BGRA; } } else if (nOfColors == 3) { if (imageSurface->format->Rmask == 0x000000ff) { texture_format = GL_RGB; } else { texture_format = GL_BGR; } } else { SDL_Log("warning: the image is not truecolor.. this will probably break\n"); return 0; } glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #ifndef ANDROID #ifdef SDLGL glTexImage2D(GL_TEXTURE_2D, 0, nOfColors, imageSurface->w, imageSurface->h, 0, texture_format, GL_UNSIGNED_BYTE, imageSurface->pixels); #else glTexImage2D(GL_TEXTURE_2D, 0, texture_format, imageSurface->w, imageSurface->h, 0, texture_format, GL_UNSIGNED_BYTE, imageSurface->pixels); #endif #else glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, imageSurface->w, imageSurface->h, 0, texture_format, GL_UNSIGNED_BYTE, imageSurface->pixels); #endif SDL_FreeSurface(imageSurface); imageSurface = NULL; return texture; } int loadPNG(const char *filename) { GLuint texture; png_structp png_ptr = NULL; png_infop info_ptr = NULL; png_bytep *row_pointers = NULL; int bitDepth, colourType; FILE *pngFile = fopen(filename, "rb"); if (!pngFile) { return 0; } png_byte sig[8]; fread(&sig, 8, sizeof(png_byte), pngFile); rewind(pngFile); if (!png_check_sig(sig, 8)) { //SDL_Log("png sig failure\n"); return 0; } png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { //SDL_Log("png ptr not created\n"); return 0; } if (setjmp(png_jmpbuf(png_ptr))) { //SDL_Log("set jmp failed\n"); return 0; } info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { //SDL_Log("cant get png info ptr\n"); return 0; } png_init_io(png_ptr, pngFile); png_read_info(png_ptr, info_ptr); bitDepth = png_get_bit_depth(png_ptr, info_ptr); colourType = png_get_color_type(png_ptr, info_ptr); if (colourType == PNG_COLOR_TYPE_PALETTE) { png_set_palette_to_rgb(png_ptr); } if (colourType == PNG_COLOR_TYPE_GRAY && bitDepth < 8) //png_set_gray_1_2_4_to_8(png_ptr); { png_set_expand_gray_1_2_4_to_8(png_ptr); // thanks to Jesse Jaara for bug fix for newer libpng... } if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(png_ptr); } if (bitDepth == 16) { png_set_strip_16(png_ptr); } else if (bitDepth < 8) { png_set_packing(png_ptr); } png_read_update_info(png_ptr, info_ptr); png_uint_32 width, height; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bitDepth, &colourType, NULL, NULL, NULL); int components; // = GetTextureInfo(colourType); switch (colourType) { case PNG_COLOR_TYPE_GRAY: components = 1; break; case PNG_COLOR_TYPE_GRAY_ALPHA: components = 2; break; case PNG_COLOR_TYPE_RGB: components = 3; break; case PNG_COLOR_TYPE_RGB_ALPHA: components = 4; break; default: components = -1; } if (components == -1) { if (png_ptr) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); } //SDL_Log("%s broken?\n", filename); return 0; } GLubyte *pixels = (GLubyte *) malloc(sizeof(GLubyte) * (width * height * components)); row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * height); int i = 0; for (i = 0; i < height; ++i) { row_pointers[i] = (png_bytep)(pixels + (i * width * components)); } png_read_image(png_ptr, row_pointers); png_read_end(png_ptr, NULL); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GLuint glcolours; (components == 4) ? (glcolours = GL_RGBA) : (0); (components == 3) ? (glcolours = GL_RGB) : (0); (components == 2) ? (glcolours = GL_LUMINANCE_ALPHA) : (0); (components == 1) ? (glcolours = GL_LUMINANCE) : (0); //SDL_Log("%s has %i colour components\n",filename,components); //glTexImage2D(GL_TEXTURE_2D, 0, components, width, height, 0, glcolours, GL_UNSIGNED_BYTE, pixels); glTexImage2D(GL_TEXTURE_2D, 0, glcolours, width, height, 0, glcolours, GL_UNSIGNED_BYTE, pixels); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(pngFile); free(row_pointers); free(pixels); return texture; } void draw_image_uncache(char *file) { #ifdef CONSOLE_ONLY return; #endif int16_t n = 0; int16_t tex_num = -1; for (n = 0; n < MAX_TEXCACHE; n++) { if (strcmp(TexCache[n].name, file) == 0) { tex_num = n; SDL_Log("remove image %s from cache %i (%i)\n", TexCache[tex_num].name, tex_num, TexCache[tex_num].atime); glDeleteTextures(1, &TexCache[tex_num].texture); TexCache[tex_num].name[0] = 0; TexCache[tex_num].texture = -1; break; } } } void draw_line_f(ESContext *esContext, float x1, float y1, float x2, float y2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_line_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a); } void draw_line(ESContext *esContext, int16_t px1, int16_t py1, int16_t px2, int16_t py2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif GLfloat x1 = (float)px1 / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; GLfloat y1 = (float)py1 / (float)esContext->height * 2.0 - 1.0; GLfloat x2 = (float)px2 / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; GLfloat y2 = (float)py2 / (float)esContext->height * 2.0 - 1.0; draw_line_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a); } void draw_circle_f(ESContext *esContext, float x1, float y1, float radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_circle_f3(esContext, x1, y1, 0.0, radius, r, g, b, a); } void draw_circle(ESContext *esContext, int16_t x, int16_t y, int16_t radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif GLfloat x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; GLfloat y1 = (float)y / (float)esContext->height * 2.0 - 1.0; GLfloat radius1 = (float)radius / (float)esContext->width * 2.0 * aspect; y1 = y1 * -1; draw_circle_f3(esContext, x1, y1, 0.0, radius1, r, g, b, a); } void draw_circleFilled_f(ESContext *esContext, float x1, float y1, float radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_circleFilled_f3(esContext, x1, y1, 0.0, radius, r, g, b, a); } void draw_circleFilled(ESContext *esContext, int16_t x, int16_t y, int16_t radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif GLfloat x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; GLfloat y1 = (float)y / (float)esContext->height * 2.0 - 1.0; GLfloat radius1 = (float)radius / (float)esContext->width * 2.0 * aspect; y1 = y1 * -1; draw_circleFilled_f3(esContext, x1, y1, 0.0, radius1, r, g, b, a); } void draw_rect_f(ESContext *esContext, float x1, float y1, float x2, float y2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_rect_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a); } void draw_box_f(ESContext *esContext, float x1, float y1, float x2, float y2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_box_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a); } void draw_rect(ESContext *esContext, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif float x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; float y1 = (float)y / (float)esContext->height * 2.0 - 1.0; float x2 = x1 + (float)w / (float)esContext->width * 2.0 * aspect; float y2 = y1 + (float)h / (float)esContext->height * 2.0; draw_rect_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a); } void draw_box(ESContext *esContext, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif float x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; float y1 = (float)y / (float)esContext->height * 2.0 - 1.0; float x2 = x1 + (float)w / (float)esContext->width * 2.0 * aspect; float y2 = y1 + (float)h / (float)esContext->height * 2.0; draw_box_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a); } void draw_tria_f(ESContext *esContext, float x1, float y1, float x2, float y2, float x3, float y3, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_tria_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, x3, y3, 0.0, r, g, b, a); } void draw_triaFilled_f(ESContext *esContext, float x1, float y1, float x2, float y2, float x3, float y3, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif draw_triaFilled_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, x3, y3, 0.0, r, g, b, a); } void draw_circleFilled_f3_part_end(ESContext *esContext, float x1, float y1, float z1, float radius, float radius_inner, float start, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { #ifdef CONSOLE_ONLY return; #endif y1 = y1 * -1; x1 = x1 - cos(start * DEG2RAD) * (radius_inner + (radius - radius_inner) / 2.0); y1 = y1 + sin(start * DEG2RAD) * (radius_inner + (radius - radius_inner) / 2.0); if (start > 180.0) { draw_circleFilled_f3_part(esContext, x1, -y1, 0.0, (radius - radius_inner) / 2.0, 0.0, 0.0, 360.0, r, g, b, a); } else { draw_circleFilled_f3_part(esContext, x1, -y1, 0.0, (radius - radius_inner) / 2.0, 0.0, 180.0, 360.0, r, g, b, a); } } void draw_circleMeter_f3(ESContext *esContext, float x, float y, float z, float radius, float start1, float start2, float start3, float start4, float value, char *text, char *text2, uint8_t type) { #ifdef CONSOLE_ONLY return; #endif float th = radius / 3.5; float width = radius / 15.0; if (type == 2) { width = 0.015; } float offset1 = start1; float offset2 = start4; start2 = (offset2 - offset1) * start2 / 100.0 + offset1; start3 = (offset2 - offset1) * start3 / 100.0 + offset1; value = (offset2 - offset1) * value / 100.0 + offset1; if (type == 2) { if (setup.contrast == 1) { // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset1, 255, 255, 255, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, offset1, start2, 255, 255, 255, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start2, start3, 255, 255, 0, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start3, offset2, 255, 0, 0, 255); // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset2, 255, 0, 0, 255); draw_circleFilled_f3_part(esContext, x, y, z, 0.0, radius - width, offset1, value, 100, 100, 255, 255); draw_circlePointer_f3(esContext, x, y, z + 0.0001, radius - width, radius / 20.0, value, 255, 255, 255, 255); } else { // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset1, 227, 227, 227, 200); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, offset1, start2, 227, 227, 227, 200); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start2, start3, 255, 255, 0, 200); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start3, offset2, 255, 0, 0, 200); // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset2, 255, 0, 0, 200); draw_circleFilled_f3_part(esContext, x, y, z, 0.0, radius - width, offset1, value, 100, 100, 255, 127); draw_circlePointer_f3(esContext, x, y, z + 0.0001, radius - width, radius / 20.0, value, 255, 255, 255, 255); } } else { if (setup.contrast == 1) { // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset1, 127, 127, 127, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, offset1, start2, 127, 127, 127, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start2, start3, 200, 200, 200, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start3, offset2, 255, 255, 255, 255); // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset2, 10, 200, 10, 255); draw_circlePointer_f3(esContext, x, y, z + 0.0001, radius - width, radius / 20.0, value, 255, 255, 255, 255); } else { // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset1, 200, 10, 10, 255); if (type == 3) { draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, offset1, start2, 10, 220, 10, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start2, start3, 220, 220, 10, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start3, offset2, 220, 10, 10, 255); } else { draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, offset1, start2, 220, 10, 10, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start2, start3, 220, 220, 10, 255); draw_circleFilled_f3_part(esContext, x, y, z, radius, radius - width, start3, offset2, 10, 220, 10, 255); } // draw_circleFilled_f3_part_end(esContext, x, y, z, radius, radius - width, offset2, 10, 200, 10, 255); draw_circlePointer_f3(esContext, x, y, z + 0.0001, radius - width, radius / 20.0, value, 255, 255, 255, 255); } } if (strlen(text) > 0 || strlen(text2) > 0) { if (type == 1) { draw_text_f3(esContext, x + radius - width - strlen(text) * th * 0.6, y + (radius - width) / 2.0, z + 0.001, th, th, FONT_WHITE, text); draw_text_f3(esContext, x + radius - width - strlen(text2) * th * 0.6, y + th + (radius - width) / 2.0, z + 0.001, th, th, FONT_WHITE, text2); } else if (type == 2) { draw_box_f3(esContext, x - radius / 5 * 3, y - th / 2.0, z + 0.0011, x + radius / 5 * 3, y + th * 3.0 / 2.0, z + 0.0011, 0, 0, 0, 127); draw_rect_f3(esContext, x - radius / 5 * 3, y - th / 2.0, z + 0.0015, x + radius / 5 * 3, y + th * 3.0 / 2.0, z + 0.0015, 255, 255, 255, 255); draw_text_f3(esContext, x - strlen(text) * th * 0.6 / 2.0, y - th / 2.0, z + 0.0015, th, th, FONT_WHITE, text); draw_text_f3(esContext, x - strlen(text2) * th * 0.6 / 2.0, y + th / 2.0, z + 0.0015, th, th, FONT_WHITE, text2); } else { draw_text_f3(esContext, x - strlen(text) * th * 0.6 / 2, y + th / 2.0, z + 0.001, th, th, FONT_WHITE, text); draw_text_f3(esContext, x - strlen(text2) * th * 0.6 / 2, y + th / 2.0 + th, z + 0.001, th, th, FONT_WHITE, text2); } } } void draw_image_f(ESContext *esContext, float x1, float y1, float x2, float y2, char *file) { #ifdef CONSOLE_ONLY return; #endif draw_image_f3(esContext, x1, y1, x2, y2, 0.0, file); } void draw_image(ESContext *esContext, int16_t x, int16_t y, int16_t w, int16_t h, char *file) { #ifdef CONSOLE_ONLY return; #endif float x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; float y1 = (float)y / (float)esContext->height * 2.0 - 1.0; float x2 = x1 + (float)w / (float)esContext->width * 2.0 * aspect; float y2 = y1 + (float)h / (float)esContext->height * 2.0; draw_image_f3(esContext, x1, y1, x2, y2, 0.0, file); } #ifdef SDLGL uint32_t getpixel(SDL_Surface *surface, int x, int y) { int bpp = surface->format->BytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; switch (bpp) { case 1: return *p; case 2: return *(Uint16 *)p; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { return p[0] << 16 | p[1] << 8 | p[2]; } else { return p[0] | p[1] << 8 | p[2] << 16; } case 4: return *(Uint32 *)p; default: return 0; /* shouldn't happen, but avoids warnings */ } } #endif int16_t get_altitude(float lat, float lon) { char file[100]; int8_t n = 0; int8_t alt_num = -1; int8_t old_num = -1; uint32_t atime_min = time(0); int16_t px = 0; int16_t py = 0; int16_t lat_m = (int)lat; int16_t lon_m = (int)lon; int8_t flag = 0; char LON[128]; char LAT[128]; if (lat_m < 0) { sprintf(LAT, "S%02i", lat_m * -1 + 1); } else { sprintf(LAT, "N%02i", lat_m); } if (lon_m < 0) { sprintf(LON, "W%03i", lon_m * -1 + 1); } else { sprintf(LON, "E%03i", lon_m); } sprintf(file, "%s/MAPS/%s%s.hgt", get_datadirectory(), LAT, LON); for (n = 0; n < 8; n++) { if (strcmp(AltCache[n].name, file) == 0) { alt_num = n; } else if (AltCache[n].atime < atime_min) { old_num = n; atime_min = AltCache[n].atime; } } if (alt_num == -1) { for (n = 0; n < MAX_ALTCACHE; n++) { if (AltCache[n].name[0] == 0) { alt_num = n; break; } } if (old_num == -1) { old_num = 0; } if (alt_num == -1) { alt_num = old_num; SDL_Log("remove srtm %s from cache %i (%i)\n", AltCache[alt_num].name, old_num, AltCache[alt_num].atime); // Delete; AltCache[alt_num].name[0] = 0; } if (alt_num != -1) { // SDL_Log("loading srtm %s in to alt-cache %i %i\n", file, alt_num, AltCache[alt_num].atime); FILE *fr; fr = fopen(file, "rb"); if (fr != 0) { strncpy(AltCache[alt_num].name, file, 1023); AltCache[alt_num].atime = time(0); for (py = 0; py < 1201; py++) { for (px = 0; px < 1201; px++) { uint8_t val1 = 0; uint8_t val2 = 0; int16_t val = 0; fread(&val1, 1, 1, fr); fread(&val2, 1, 1, fr); val = (val1 << 8) + val2; if (lat_m < 0) { if (lon_m < 0) { AltCache[alt_num].data[py][1200 - px] = val; } else { AltCache[alt_num].data[py][px] = val; } } else { if (lon_m < 0) { AltCache[alt_num].data[1200 - py][1200 - px] = val; } else { AltCache[alt_num].data[1200 - py][px] = val; } } } } fclose(fr); } else { flag = 1; } } } if (flag == 0) { AltCache[alt_num].atime = time(0); // SDL_Log("# using Alt-Cache: %s\n", AltCache[alt_num].name); // geting all field-points float fy = 0.0; float fx = 0.0; int16_t y1 = 0; int16_t x1 = 0; int16_t y2 = 0; int16_t x2 = 0; if (lat_m < 0) { lat_m *= -1; lat *= -1.0; } if (lon_m < 0) { lon_m *= -1; lon *= -1.0; } y1 = (int)((lat - (float)lat_m) * 1201.0); y2 = y1 + 1; fy = ((lat - (float)lat_m) * 1201.0); x1 = (int)((lon - (float)lon_m) * 1201.0); x2 = x1 + 1; fx = ((lon - (float)lon_m) * 1201.0); #ifndef SDLGL return AltCache[alt_num].data[y1][x1]; #else // geting alt-values of field-points int16_t vx1a = AltCache[alt_num].data[y1][x1]; int16_t vx2a = AltCache[alt_num].data[y1][x2]; int16_t vx1b = AltCache[alt_num].data[y2][x1]; int16_t vx2b = AltCache[alt_num].data[y2][x2]; if (vx1a == -32768) { uint16_t tn = 0; for (tn = 0; tn < 10; tn++) { vx1a = AltCache[alt_num].data[y1 + tn][x1 + tn]; if (vx1a != -32768) { break; } vx1a = AltCache[alt_num].data[y1 - tn][x1 - tn]; if (vx1a != -32768) { break; } } } if (vx2a == -32768) { uint16_t tn = 0; for (tn = 0; tn < 10; tn++) { vx2a = AltCache[alt_num].data[y1 + tn][x2 + tn]; if (vx2a != -32768) { break; } vx2a = AltCache[alt_num].data[y1 - tn][x2 - tn]; if (vx2a != -32768) { break; } } } if (vx1b == -32768) { uint16_t tn = 0; for (tn = 0; tn < 10; tn++) { vx1b = AltCache[alt_num].data[y2 + tn][x1 + tn]; if (vx1b != -32768) { break; } vx1b = AltCache[alt_num].data[y2 - tn][x1 - tn]; if (vx1b != -32768) { break; } } } if (vx2b == -32768) { uint16_t tn = 0; for (tn = 0; tn < 10; tn++) { vx2b = AltCache[alt_num].data[y2 + tn][x2 + tn]; if (vx2b != -32768) { break; } vx2b = AltCache[alt_num].data[y2 - tn][x2 - tn]; if (vx2b != -32768) { break; } } } // geting alt-values of avarages (x1,y1->x2,y1 and x1,y2->x2,y2) int16_t vxa = (float)(vx2a - vx1a) * (fx - (float)x1) + (float)vx1a; int16_t vxb = (float)(vx2b - vx1b) * (fx - (float)x1) + (float)vx1b; // geting alt-values avarages (xy1->xy2) int16_t alt = (vxb - vxa) * (fy - (float)y1) + vxa; return alt; #endif } return 0; } void draw_pointer(ESContext *esContext, int16_t x, int16_t y, int16_t w, int16_t h, char *file) { #ifdef CONSOLE_ONLY return; #endif float x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; float y1 = (float)y / (float)esContext->height * 2.0 - 1.0; float x2 = x1 + (float)w / (float)esContext->width * 2.0 * aspect; float y2 = y1 + (float)h / (float)esContext->height * 2.0; draw_image_f3(esContext, x1, y1, x2, y2, 0.0035, file); } void draw_text_f3(ESContext *esContext, float x1, float y1, float z1, float w, float h, char *file, char *text) { #ifdef CONSOLE_ONLY return; #endif draw_text_f3_fast(esContext, x1, y1, z1, w, h, file, text); } void draw_text_f(ESContext *esContext, float x1, float y1, float w, float h, char *file, char *text) { #ifdef CONSOLE_ONLY return; #endif draw_text_f3(esContext, x1, y1, 0.003, w, h, file, text); } void draw_text(ESContext *esContext, int16_t x, int16_t y, int16_t w, int16_t h, char *file, char *text) { #ifdef CONSOLE_ONLY return; #endif float x1 = (float)x / (float)esContext->width * 2.0 * aspect - 1.0 * aspect; float y1 = (float)y / (float)esContext->height * 2.0 - 1.0; float fw = (float)w / 200; float fh = (float)h / 200; draw_text_f3(esContext, x1, y1, 0.0, fw, fh, file, text); } void draw_pulldown(ESContext *esContext, float x1, float y1, float w, float z, char *name, EntryList *list, uint8_t open, uint8_t select, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t)) { #ifdef CONSOLE_ONLY return; #endif uint8_t n = 0; float x2 = x1 + w; float h = 0.07; float y2 = y1 + h; char tmp_str[1024]; #ifdef SDLGL #ifndef ANDROID draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55); draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255); #else draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55); draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255); #endif #endif if (open == 1) { // y1 -= select * h; // y2 -= select * h; while (list[n].name != NULL) { if (n == select) { draw_box_f3(esContext, x1 + 0.01, y1 + n * h, z, x2 - 0.01, y2 + n * h, z + 0.05, 200, 200, 200, 200); } else { draw_box_f3(esContext, x1 + 0.01, y1 + n * h, z, x2 - 0.01, y2 + n * h, z + 0.05, 255, 255, 255, 200); } draw_text_f3(esContext, x1 + 0.001 + 0.005, y1 + n * h + 0.005, z + 0.1, h - 0.01, h - 0.01, FONT_GREEN, list[n].name); sprintf(tmp_str, "%s_%i", name, n); set_button(tmp_str, setup.view_mode, x1 + 0.01, y1 + n * h, x2 + 0.01, y2 + n * h, callback, (float)(n + 1), 0); n++; } gui_ov_lock = 1; } else { draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.01, z, x2 - 0.02, y1 + h / 2 - 0.01, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.01, z, x2 - h / 2, y1 + h / 2 + 0.01, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 + 0.01, z, x2 - 0.02, y1 + h / 2 - 0.01, z, 255, 255, 255, 255); draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, list[select].name); sprintf(tmp_str, "%s", name); set_button(tmp_str, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0); } } void draw_spinbox(ESContext *esContext, float x1, float y1, float w, float z, char *name, char *format, float value, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t)) { #ifdef CONSOLE_ONLY return; #endif float x2 = x1 + w; float h = 0.07; float y2 = y1 + h; char tmp_str[1024]; sprintf(tmp_str, format, value); #ifdef SDLGL #ifndef ANDROID draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55); draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255); #else draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55); draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255); #endif #endif draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 + 0.005, z, x2 - 0.02, y1 + h / 2 + 0.005, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 + 0.005, z, x2 - h / 2, y1 + h / 2 + 0.02, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 + 0.02, z, x2 - 0.02, y1 + h / 2 + 0.005, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.005, z, x2 - 0.02, y1 + h / 2 - 0.005, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.005, z, x2 - h / 2, y1 + h / 2 - 0.02, z, 255, 255, 255, 255); draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 - 0.02, z, x2 - 0.02, y1 + h / 2 - 0.005, z, 255, 255, 255, 255); draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, tmp_str); set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0); } void draw_textbox(ESContext *esContext, float x1, float y1, float w, float z, char *name, char *text, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t)) { #ifdef CONSOLE_ONLY return; #endif float x2 = x1 + w; float h = 0.07; float y2 = y1 + h; #ifdef SDLGL #ifndef ANDROID draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55); draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255); #else draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55); draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255); #endif #endif draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, text); set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0); } void draw_checkbox(ESContext *esContext, float x1, float y1, float z, char *name, uint8_t check, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t)) { #ifdef CONSOLE_ONLY return; #endif float w = 0.07; float h = 0.07; float x2 = x1 + w; float y2 = y1 + h; #ifdef SDLGL #ifndef ANDROID draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55); draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255); #else draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55); draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255); #endif #endif if (check == 1) { draw_line_f3(esContext, x1 + 0.02, y1 + 0.02, z, x2 - 0.02, y2 - 0.02, z, 255, 255, 255, 255); draw_line_f3(esContext, x1 + 0.02, y2 - 0.02, z, x2 - 0.02, y1 + 0.02, z, 255, 255, 255, 255); } set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0); } void draw_window(ESContext *esContext, float x1, float y1, float x2, float y2, float z, char *name, char *title, EntryList *list, uint8_t select, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t)) { #ifdef CONSOLE_ONLY return; #endif uint8_t n = 0; uint8_t m = 0; float tw = 0.6; float step = 0.4; char tmp_str[1024]; while (list[m].name != NULL) { m++; } #ifdef SDLGL #ifndef ANDROID draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, 0.04, 55, 55, 255, 100); draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, 0.04, 255, 255, 255, 255); #else draw_box_f3(esContext, x1, y1, z, x2, y2, z, 55, 55, 255, 100); draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255); #endif #endif draw_line_f3(esContext, x1, y1 + 0.08, z, x1 + tw, y1 + 0.08, z, 255, 255, 255, 255); draw_line_f3(esContext, x1 + tw, y1 + 0.08, z, x1 + tw + 0.1, y1, z, 255, 255, 255, 255); draw_text_f3(esContext, x1 + 0.05, y1 + 0.01, z + 0.001, 0.07, 0.07, FONT_PINK, title); while (list[n].name != NULL) { sprintf(tmp_str, "%s%i", name, n); if (n == select) { draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x1 + tw + step * n + step, y1 + 0.08, z, 255, 255, 255, 100); } else { draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x1 + tw + step * n + step, y1 + 0.08, z, 255, 255, 255, 255); } draw_line_f3(esContext, x1 + tw + step * n + step, y1 + 0.08, z, x1 + tw + step * n + step + 0.1, y1, z, 255, 255, 255, 255); draw_text_f3(esContext, x1 + tw + step * n + 0.07, y1 + 0.02, z + 0.001, 0.06, 0.06, FONT_WHITE, list[n].name); set_button(tmp_str, setup.view_mode, x1 + tw + step * n, y1, x1 + tw + step * n + step, y1 + 0.08, callback, (float)n, 0); n++; } draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x2, y1 + 0.08, z, 255, 255, 255, 255); } void draw_buttonbox(ESContext *esContext, char *name, uint8_t view_mode, char *text, float x1, float y1, float w, float z, uint8_t (*callback)(char *, float, float, int8_t, float, uint8_t), float data) { #ifdef CONSOLE_ONLY return; #endif float x2 = x1 + w; float h = 0.07; float y2 = y1 + h; #ifdef SDLGL #ifndef ANDROID draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55); draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255); #else draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55); draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255); #endif #endif draw_text_f3(esContext, x1 + w / 2 - (h - 0.01) * 0.6 * strlen(text) / 2.0 - (h - 0.01) * 0.6 / 3.0, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, text); set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0); }
35.8181
200
0.629804
bb78a712e85a902cdad33cad1a279b265ac1ea8f
267
h
C
c++/updates.h
Notgnoshi/joystick
4b4e57f059c4604c0a48cfb295142a417cdd9cf5
[ "MIT" ]
8
2017-04-22T06:55:46.000Z
2020-06-07T20:21:56.000Z
c++/updates.h
Notgnoshi/joystick
4b4e57f059c4604c0a48cfb295142a417cdd9cf5
[ "MIT" ]
null
null
null
c++/updates.h
Notgnoshi/joystick
4b4e57f059c4604c0a48cfb295142a417cdd9cf5
[ "MIT" ]
3
2017-12-02T16:09:59.000Z
2021-12-14T23:02:49.000Z
#pragma once #include "joy.h" #include <iostream> #include <climits> void update_buttons(Joystick* joy); void update_axes(Joystick* joy); short bound_short(int num); short map(long x, long in_min, long in_max, long out_min, long out_max); short short_map(long x);
20.538462
72
0.752809
159a182fe2f391fd0ace4701a7c94172e40aa2c7
4,641
h
C
DataCollector/mozilla/xulrunner-sdk/include/mozilla/dom/BrowserElementDictionariesBinding.h
andrasigneczi/TravelOptimiser
b08805f97f0823fd28975a36db67193386aceb22
[ "Apache-2.0" ]
1
2016-04-20T08:35:44.000Z
2016-04-20T08:35:44.000Z
DataCollector/mozilla/xulrunner-sdk/include/mozilla/dom/BrowserElementDictionariesBinding.h
andrasigneczi/TravelOptimiser
b08805f97f0823fd28975a36db67193386aceb22
[ "Apache-2.0" ]
null
null
null
DataCollector/mozilla/xulrunner-sdk/include/mozilla/dom/BrowserElementDictionariesBinding.h
andrasigneczi/TravelOptimiser
b08805f97f0823fd28975a36db67193386aceb22
[ "Apache-2.0" ]
null
null
null
/* THIS FILE IS AUTOGENERATED FROM BrowserElementDictionaries.webidl BY Codegen.py - DO NOT EDIT */ #ifndef mozilla_dom_BrowserElementDictionariesBinding_h #define mozilla_dom_BrowserElementDictionariesBinding_h #include "js/RootingAPI.h" #include "jspubtd.h" #include "mozilla/ErrorResult.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/Nullable.h" #include "nsINode.h" class nsINode; namespace mozilla { namespace dom { struct AsyncScrollEventDetailAtoms; struct DOMWindowResizeEventDetailAtoms; struct NativePropertyHooks; struct OpenWindowEventDetailAtoms; class ProtoAndIfaceCache; } // namespace dom } // namespace mozilla namespace mozilla { namespace dom { struct AsyncScrollEventDetail : public DictionaryBase { float mHeight; float mLeft; float mScrollHeight; float mScrollWidth; float mTop; float mWidth; AsyncScrollEventDetail(); explicit inline AsyncScrollEventDetail(const FastDictionaryInitializer& ) { // Do nothing here; this is used by our "Fast" subclass } explicit inline AsyncScrollEventDetail(const AsyncScrollEventDetail& aOther) { *this = aOther; } bool Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); bool Init(const nsAString& aJSON); bool ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; bool ToJSON(nsAString& aJSON) const; void TraceDictionary(JSTracer* trc); void operator=(const AsyncScrollEventDetail& aOther); private: static bool InitIds(JSContext* cx, AsyncScrollEventDetailAtoms* atomsCache); }; namespace binding_detail { struct FastAsyncScrollEventDetail : public AsyncScrollEventDetail { inline FastAsyncScrollEventDetail() : AsyncScrollEventDetail(FastDictionaryInitializer()) { // Doesn't matter what int we pass to the parent constructor } }; } // namespace binding_detail struct DOMWindowResizeEventDetail : public DictionaryBase { int32_t mHeight; int32_t mWidth; DOMWindowResizeEventDetail(); explicit inline DOMWindowResizeEventDetail(const FastDictionaryInitializer& ) { // Do nothing here; this is used by our "Fast" subclass } explicit inline DOMWindowResizeEventDetail(const DOMWindowResizeEventDetail& aOther) { *this = aOther; } bool Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); bool Init(const nsAString& aJSON); bool ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; bool ToJSON(nsAString& aJSON) const; void TraceDictionary(JSTracer* trc); void operator=(const DOMWindowResizeEventDetail& aOther); private: static bool InitIds(JSContext* cx, DOMWindowResizeEventDetailAtoms* atomsCache); }; namespace binding_detail { struct FastDOMWindowResizeEventDetail : public DOMWindowResizeEventDetail { inline FastDOMWindowResizeEventDetail() : DOMWindowResizeEventDetail(FastDictionaryInitializer()) { // Doesn't matter what int we pass to the parent constructor } }; } // namespace binding_detail struct OpenWindowEventDetail : public DictionaryBase { nsString mFeatures; nsRefPtr<nsINode> mFrameElement; nsString mName; nsString mUrl; OpenWindowEventDetail(); explicit inline OpenWindowEventDetail(const FastDictionaryInitializer& ) { // Do nothing here; this is used by our "Fast" subclass } explicit inline OpenWindowEventDetail(const OpenWindowEventDetail& aOther) { *this = aOther; } bool Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); bool Init(const nsAString& aJSON); bool ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; bool ToJSON(nsAString& aJSON) const; void TraceDictionary(JSTracer* trc); void operator=(const OpenWindowEventDetail& aOther); private: static bool InitIds(JSContext* cx, OpenWindowEventDetailAtoms* atomsCache); }; namespace binding_detail { struct FastOpenWindowEventDetail : public OpenWindowEventDetail { inline FastOpenWindowEventDetail() : OpenWindowEventDetail(FastDictionaryInitializer()) { // Doesn't matter what int we pass to the parent constructor } }; } // namespace binding_detail } // namespace dom } // namespace mozilla #endif // mozilla_dom_BrowserElementDictionariesBinding_h
23.678571
120
0.729584
e9f173ec5db7a2797de76cd6f70d94b7d2dd14fc
1,067
c
C
ultrasonic.c
bglebrun/CENG447FinalLab
b23d26f701d4bc89414669cf9391e54839a35a84
[ "WTFPL" ]
null
null
null
ultrasonic.c
bglebrun/CENG447FinalLab
b23d26f701d4bc89414669cf9391e54839a35a84
[ "WTFPL" ]
null
null
null
ultrasonic.c
bglebrun/CENG447FinalLab
b23d26f701d4bc89414669cf9391e54839a35a84
[ "WTFPL" ]
null
null
null
#include "ultrasonic.h" /****************************************************************************** * * Ultrasonic sensor functions * * * Sets the pins for ultrasonic sensor, * then will setup the necessary timer 1 * to properly time the sensor */ void initUltrasonic() { // Trig on A5 setBit(DDRC, US_TRIG); // Echo on A4 clearBit(DDRC, US_ECHO); clearBit(PORTC, US_TRIG); clearBit(PORTC, US_ECHO); initTimer1(); } unsigned int readUltrasonic() { // Trigger the sensor triggerUltrasonic(); // Spin while we either timeout or wait while (!TimerOverflow && !responseAvailable) { }; unsigned int i = TIM16_ReadTCNT1(); // 64 us per count in i unsigned int result = ((i * 64) / 58); return result; } // Triggers ultrasonic sensor, then waits 60 ms void triggerUltrasonic() { TimerOverflow = false; setBit(PORTC, US_TRIG); _delay_us(10); clearBit(PORTC, US_TRIG); // reset counter 1 // TIM16_WriteTCNT1(0); // Delay while pulse is sent _delay_ms(60); }
20.519231
79
0.593252
1880770eb35660ff478b647f779e688cd26cb41b
1,392
h
C
elbridge/graph.h
pjrule/elbridge
d889d17fc5b762a7fbaf516861b2a325aff63e6d
[ "MIT" ]
2
2018-07-20T20:17:40.000Z
2019-03-03T01:01:30.000Z
elbridge/graph.h
pjrule/elbridge
d889d17fc5b762a7fbaf516861b2a325aff63e6d
[ "MIT" ]
2
2019-03-02T22:11:58.000Z
2019-07-14T03:46:53.000Z
elbridge/graph.h
pjrule/elbridge
d889d17fc5b762a7fbaf516861b2a325aff63e6d
[ "MIT" ]
null
null
null
#ifndef GRAPH_H #define GRAPH_H #include <unordered_set> #include <unordered_map> #include <vector> namespace graph { class VTD { int id; int district; public: VTD(int id); void add_neighbor(VTD* vtd); bool is_neighbor(int id); int get_id(); int get_district(); void set_district(int _district); std::vector<VTD*> neighbors; }; class Graph { std::unordered_map<int, VTD> vtds; std::vector<int> curr_vtds; std::vector<int> prev_vtds; int curr_district; int ws_left; void next_district(); public: Graph(); void add(int id, std::vector<int> neighbors); bool shared_border(std::vector<int> unallocated, bool prev); bool contiguous(std::vector<int> unallocated); std::vector<int> validate(std::vector<int> unallocated); std::vector<int> border_vtds(std::vector<int> unallocated); std::vector<int> unallocated_on_border(int district); void allocate(std::vector<int> unallocated, bool next); void reset_district(); void print_neighbors(int id); void print_curr_district(); }; } #endif
31.636364
85
0.533046
767953f433279b16e049caa770360d387f80db27
4,744
h
C
thirdparty/qscintilla/Qt4Qt5/Qsci/qscilexercmake.h
Victor-Y-Fadeev/qreal
2c7f14d5eb24753d4a7c038e13a3fa3026adce18
[ "Apache-2.0" ]
6
2017-07-03T13:55:35.000Z
2018-11-28T03:39:51.000Z
thirdparty/qscintilla/Qt4Qt5/Qsci/qscilexercmake.h
Victor-Y-Fadeev/qreal
2c7f14d5eb24753d4a7c038e13a3fa3026adce18
[ "Apache-2.0" ]
27
2017-06-29T09:36:37.000Z
2017-11-25T14:50:04.000Z
thirdparty/qscintilla/Qt4Qt5/Qsci/qscilexercmake.h
Victor-Y-Fadeev/qreal
2c7f14d5eb24753d4a7c038e13a3fa3026adce18
[ "Apache-2.0" ]
null
null
null
// This defines the interface to the QsciLexerCMake class. // // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com> // // This file is part of QScintilla. // // 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 QSCILEXERCMAKE_H #define QSCILEXERCMAKE_H #include <QObject> #include <Qsci/qsciglobal.h> #include <Qsci/qscilexer.h> //! \brief The QsciLexerCMake class encapsulates the Scintilla CMake lexer. class QSCINTILLA_EXPORT QsciLexerCMake : public QsciLexer { Q_OBJECT public: //! This enum defines the meanings of the different styles used by the //! CMake lexer. enum { //! The default. Default = 0, //! A comment. Comment = 1, //! A string. String = 2, //! A left quoted string. StringLeftQuote = 3, //! A right quoted string. StringRightQuote = 4, //! A function. (Defined by keyword set number 1.) Function = 5, //! A variable. (Defined by keyword set number 2.) Variable = 6, //! A label. Label = 7, //! A keyword defined in keyword set number 3. The class must be //! sub-classed and re-implement keywords() to make use of this style. KeywordSet3 = 8, //! A WHILE block. BlockWhile = 9, //! A FOREACH block. BlockForeach = 10, //! An IF block. BlockIf = 11, //! A MACRO block. BlockMacro = 12, //! A variable within a string. StringVariable = 13, //! A number. Number = 14 }; //! Construct a QsciLexerCMake with parent \a parent. \a parent is //! typically the QsciScintilla instance. QsciLexerCMake(QObject *parent = 0); //! Destroys the QsciLexerCMake instance. virtual ~QsciLexerCMake(); //! Returns the name of the language. const char *language() const; //! Returns the name of the lexer. Some lexers support a number of //! languages. const char *lexer() const; //! Returns the foreground colour of the text for style number \a style. //! //! \sa defaultPaper() QColor defaultColor(int style) const; //! Returns the font for style number \a style. QFont defaultFont(int style) const; //! Returns the background colour of the text for style number \a style. //! //! \sa defaultColor() QColor defaultPaper(int style) const; //! Returns the set of keywords for the keyword set \a set recognised //! by the lexer as a space separated string. const char *keywords(int set) const; //! Returns the descriptive name for style number \a style. If the //! style is invalid for this language then an empty QString is returned. //! This is intended to be used in user preference dialogs. QString description(int style) const; //! Causes all properties to be refreshed by emitting the propertyChanged() //! signal as required. void refreshProperties(); //! Returns true if ELSE blocks can be folded. //! //! \sa setFoldAtElse() bool foldAtElse() const; public slots: //! If \a fold is true then ELSE blocks can be folded. The default is //! false. //! //! \sa foldAtElse() virtual void setFoldAtElse(bool fold); protected: //! The lexer's properties are read from the settings \a qs. \a prefix //! (which has a trailing '/') should be used as a prefix to the key of //! each setting. true is returned if there is no error. //! bool readProperties(QSettings &qs,const QString &prefix); //! The lexer's properties are written to the settings \a qs. //! \a prefix (which has a trailing '/') should be used as a prefix to //! the key of each setting. true is returned if there is no error. //! bool writeProperties(QSettings &qs,const QString &prefix) const; private: void setAtElseProp(); bool fold_atelse; QsciLexerCMake(const QsciLexerCMake &); QsciLexerCMake &operator=(const QsciLexerCMake &); }; #endif
29.465839
79
0.651981
b7134e846d9ab9a8bdd8694fa527e6064ac0ab56
7,527
h
C
src/ftagtable_impl.h
glennhickey/context
e7cdb988e2bb6eed5be78567ae7b88378eda9411
[ "MIT-0" ]
1
2018-04-22T22:16:47.000Z
2018-04-22T22:16:47.000Z
src/ftagtable_impl.h
glennhickey/context
e7cdb988e2bb6eed5be78567ae7b88378eda9411
[ "MIT-0" ]
null
null
null
src/ftagtable_impl.h
glennhickey/context
e7cdb988e2bb6eed5be78567ae7b88378eda9411
[ "MIT-0" ]
null
null
null
//Copyright (C) 2010 by Glenn Hickey // //Released under the MIT license, see LICENSE.txt #include <cassert> #include <iostream> #include <cmath> template<typename T, typename U> inline FTAGTable<T, U>::FTAGTable() : _tab1(NULL), _tab2(NULL), _tab3(NULL), _lenA(0), _lenB(0), _winA(0), _winB(0), _tm(NULL) { initMaps(); } template<typename T, typename U> inline FTAGTable<T, U>::~FTAGTable() { delete [] _tab1; delete [] _tab2; delete [] _tab3; } template<typename T, typename U> inline void FTAGTable<T, U>::setTransitionModel(const TransitionModel* tm) { _tm = tm; } template<typename T, typename U> inline void FTAGTable<T, U>::resize(size_t lenA, size_t lenB, size_t winA, size_t winB) { if (lenA != _lenA || lenB != _lenB || winA != _winA || winB != _winB) { _lenA = lenA; _lenB = lenB; _winA = winA; _winB = winB; _c1[2] = FTAGStates::IPStatesSize; _c1[1] = _lenB * FTAGStates::IPStatesSize; _c1[0] = _lenA * _lenB * FTAGStates::IPStatesSize; _c2[4] = FTAGStates::IJKPStatesSize; _c2[3] = _winA * FTAGStates::IJKPStatesSize; _c2[2] = _winA * _winA * FTAGStates::IJKPStatesSize; _c2[1] = _lenB * _winA * _winA * FTAGStates::IJKPStatesSize; _c2[0] = _lenA * _lenB * _winA * _winA * FTAGStates::IJKPStatesSize; _c3[4] = FTAGStates::IPQRStatesSize; _c3[3] = _winB * FTAGStates::IPQRStatesSize; _c3[2] = _winB * _winB * FTAGStates::IPQRStatesSize; _c3[1] = _lenB * _winB * _winB * FTAGStates::IPQRStatesSize; _c3[0] = _lenA * _lenB * _winB * _winB * FTAGStates::IPQRStatesSize; try{ // table 1 delete [] _tab1; _tab1 = new T[_c1[0]]; // table 2 delete [] _tab2; _tab2 = new T[_c2[0]]; // table 3 delete [] _tab3; _tab3 = new T[_c3[0]]; } catch (...) { std::cerr << "ALLOCATION FAIL of \n" << "T1 : " << (sizeof(T) * _c1[0]) / (1 << 20)+1 << " MB\n" << "T2 : " << (sizeof(T) * _c2[0]) / (1 << 20) << " MB\n" << "T3 : " << (sizeof(T) * _c3[0]) / (1 << 20) << " MB\n" << std::endl; exit(1); } } } template<typename T, typename U> inline void FTAGTable<T, U>::reset(T val) { size_t i; // table 1 for (i = 0; i < _c1[0]; ++i) { _tab1[i] = val; } // table 2 for (i = 0; i < _c2[0]; ++i) { _tab2[i] = val; } // table 3 for (i = 0; i < _c3[0]; ++i) { _tab3[i] = val; } } // table 1 template<typename T, typename U> inline T FTAGTable<T, U>::get1(size_t i, size_t p, State s) const { assert(_map1[s] < FTAGStates::IPStatesSize); return _tab1[i * _c1[1] + p * _c1[2] + _map1[s]]; } template<typename T, typename U> inline void FTAGTable<T, U>::set1(size_t i, size_t p, State s, T val) { assert(_map1[s] < FTAGStates::IPStatesSize); assert(!isnan(val) && !isinf(val)); _tab1[i * _c1[1] + p * _c1[2] + _map1[s]] = val; } // table 2 template<typename T, typename U> inline T FTAGTable<T, U>::get2(size_t i, size_t j, size_t k, size_t p, State s) const { assert(_map2[s] < FTAGStates::IJKPStatesSize); j -= i + 1; k -= i + 1; assert(j < _winA && k < _winA); return _tab2[i * _c2[1] + p * _c2[2] + j * _c2[3] + k * _c2[4] + _map2[s]]; } template<typename T, typename U> inline void FTAGTable<T, U>::set2(size_t i, size_t j, size_t k, size_t p, State s, T val) { assert(_map2[s] < FTAGStates::IJKPStatesSize); assert(!isnan(val) && !isinf(val)); j -= i + 1; k -= i + 1; assert(j < _winA && k < _winA); _tab2[i * _c2[1] + p * _c2[2] + j * _c2[3] + k * _c2[4] + _map2[s]] = val; } // table 3 template<typename T, typename U> inline T FTAGTable<T, U>::get3(size_t i, size_t p, size_t q, size_t r, State s) const { assert(_map3[s] < FTAGStates::IPQRStatesSize); q -= p + 1; r -= p + 1; assert(q < _winB && r < _winB); return _tab3[i * _c3[1] + p * _c3[2] + q * _c3[3] + r * _c3[4] + _map3[s]]; } template<typename T, typename U> inline void FTAGTable<T, U>::set3(size_t i, size_t p, size_t q, size_t r, State s, T val) { assert(_map3[s] < FTAGStates::IPQRStatesSize); assert(!isnan(val) && !isinf(val)); q -= p + 1; r -= p + 1; assert(q < _winB && r < _winB); _tab3[i * _c3[1] + p * _c3[2] + q * _c3[3] + r * _c3[4] + _map3[s]] = val; } template<typename T, typename U> inline T FTAGTable<T, U>::all1f(size_t i, size_t p, State to, const State states[], size_t statesSize) const { T all = U::seed(); for (size_t s = 0; s < statesSize; ++s) { U::acc(all, get1(i, p, states[s]) * _tm->prTrans(states[s], to), FTAGTableStructs::Trace(states[s], i, p)); } return all; } template<typename T, typename U> inline T FTAGTable<T, U>::all2f(size_t i, size_t j, size_t k, size_t p, State to, const State states[], size_t statesSize) const { T all = U::seed(); for (size_t s = 0; s < statesSize; ++s) { U::acc(all, get2(i, j, k, p, states[s]) * _tm->prTrans(states[s], to), FTAGTableStructs::Trace(states[s], i, j, k, p)); } return all; } template<typename T, typename U> inline T FTAGTable<T, U>::all3f(size_t i, size_t p, size_t q, size_t r, State to, const State states[], size_t statesSize) const { T all = U::seed(); for (size_t s = 0; s < statesSize; ++s) { U::acc(all, get3(i, p, q, r, states[s]) * _tm->prTrans(states[s], to), FTAGTableStructs::Trace(states[s], i, p, q, r)); } return all; } template<typename T, typename U> inline T FTAGTable<T, U>::all1fFrom2(size_t i, size_t p, const State states[], size_t statesSize) const { T all = U::seed(); size_t u = i > _winA ? i - _winA : 0; for (; u < i; ++u) { for (size_t s = 0; s < statesSize; ++s) { U::acc(all, get2(u, u+1, i, p, states[s]) * _tm->prTrans(states[s], FTAGStates::S_Close), FTAGTableStructs::Trace(states[s], u, u+1, i, p)); } } return all; } template<typename T, typename U> inline T FTAGTable<T, U>::all1fFrom3(size_t i, size_t p, const State states[], size_t statesSize) const { T all = U::seed(); size_t v = p > _winB ? p - _winB : 0; for (; v < p; ++v) { for (size_t s = 0; s < statesSize; ++s) { U::acc(all, get3(i, v, v+1, p, states[s]) * _tm->prTrans(states[s], FTAGStates::S_Close), FTAGTableStructs::Trace(states[s], i, v, v+1, p)); } } return all; } template<typename T, typename U> inline void FTAGTable<T, U>::initMaps() { size_t i; for (i = 0; i < FTAGStates::S_Max; ++i) { _map1[i] = FTAGStates::S_Max; _map2[i] = FTAGStates::S_Max; _map3[i] = FTAGStates::S_Max; } for (i = 0; i < FTAGStates::IPStatesSize; ++i) { _map1[FTAGStates::IPStates[i]] = i; } for (i = 0; i < FTAGStates::IJKPStatesSize; ++i) { _map2[FTAGStates::IJKPStates[i]] = i; } for (i = 0; i < FTAGStates::IPQRStatesSize; ++i) { _map3[FTAGStates::IPQRStates[i]] = i; } }
25.777397
78
0.529826
f4eb5992eead994020171df684f4851d49eb7e0d
1,774
c
C
MainSource/File8.c
righthalfplane/SdrGult
f6a082939d7922c08cef1f53104a84841be80910
[ "MIT" ]
null
null
null
MainSource/File8.c
righthalfplane/SdrGult
f6a082939d7922c08cef1f53104a84841be80910
[ "MIT" ]
null
null
null
MainSource/File8.c
righthalfplane/SdrGult
f6a082939d7922c08cef1f53104a84841be80910
[ "MIT" ]
null
null
null
#include "File8.h" #include "Utilities.h" extern int cFree(char *data); extern int mstrncpy(char *out,char *in,long n); INT8_64 FileSeeks8,FileReads8,FileWrite8,FileReadBytes8; FILE8 *fopen8(char *name,char *mode) { FILE8 *file; FILE *open; if(!name || !mode)return NULL; open=fopen(name,mode); if(!open)return NULL; file=(FILE8 *)cMalloc(sizeof(FILE8),6476); if(!file){ if(open)fclose(open); return NULL; } zerol((char *)file,sizeof(FILE8)); file->file=open; mstrncpy(file->name,name,sizeof(file->name)); mstrncpy(file->mode,mode,sizeof(file->mode)); file->convertRead=1; file->convertWrite=1; return file; } int fclose8(FILE8 *file) { if(!file)return 1; if(file->file)fclose(file->file); file->file=NULL; cFree((char *)file); return 0; } INT8_64 ftell8(FILE8 *file) { if(!file)return -1; if(!file->file)return -1; return (INT8_64)ftello(file->file); } int fseek8(FILE8 *file,INT8_64 offset,int from) { if(!file)return -1; if(!file->file)return -1; ++FileSeeks8; return fseeko(file->file,offset,from); } int fput8(FILE8 *file,char *data,INT8_64 lengthin) { size_t length; if(!data)return -1; if(!file)return -1; if(!file->file)return -1; length=(long)lengthin; ++FileWrite8; if(fwrite((char *)data,1,length,file->file) != length){ return -1; } return (int)length; } int fget8(FILE8 *file,char *data,INT8_64 size,INT8_64 lengthin) { size_t length,ret; if(!data)return -1; if(!file)return -1; if(!file->file)return -1; length=(size_t)lengthin; ++FileReads8; FileReadBytes8 += length; ret=fread((char *)data,size,length,file->file); if(ret != length){ return -1; } // float *in=(float *)data; // printf("%g %lld %lld\n",*in,size,lengthin); return (int)length; }
18.102041
63
0.660654
63b395789c5d9fcbdcd523f4d2e604705762dda6
596
h
C
particles/Random.h
peppincsoda/particles-demo
a293ac779ce88440cc10a8c1cd0bcdb12ef94e9a
[ "MIT" ]
null
null
null
particles/Random.h
peppincsoda/particles-demo
a293ac779ce88440cc10a8c1cd0bcdb12ef94e9a
[ "MIT" ]
null
null
null
particles/Random.h
peppincsoda/particles-demo
a293ac779ce88440cc10a8c1cd0bcdb12ef94e9a
[ "MIT" ]
null
null
null
#ifndef RANDOM_H #define RANDOM_H #include <cstdint> namespace particles { // Source: http://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use inline static uint32_t next_random(uint32_t& seed) { seed = seed * 1664525U + 1013904223U; return seed; } // 0 <= _ <= 1 inline static double next_random_01(uint32_t& seed) { return static_cast<double>(next_random(seed)) / UINT32_MAX; } // -1 <= _ <= 1 inline static double next_random_11(uint32_t& seed) { return 2.0 * next_random_01(seed) - 1.0; } } #endif // RANDOM_H
19.866667
96
0.677852
494a7327e863c47f438fad2d3e88ce1d088291ff
635
h
C
include/orz/mem/need.h
ViewFaceCore/OpenRoleZoo
19cef3cdc5238374cedcf7068dc7a6ad8448c21b
[ "BSD-2-Clause" ]
null
null
null
include/orz/mem/need.h
ViewFaceCore/OpenRoleZoo
19cef3cdc5238374cedcf7068dc7a6ad8448c21b
[ "BSD-2-Clause" ]
null
null
null
include/orz/mem/need.h
ViewFaceCore/OpenRoleZoo
19cef3cdc5238374cedcf7068dc7a6ad8448c21b
[ "BSD-2-Clause" ]
null
null
null
// // Created by Lby on 2017/10/9. // #ifndef ORZ_MEM_NEED_H #define ORZ_MEM_NEED_H #include "orz/tools/void_bind.h" namespace orz { class need { public: template<typename FUNC> need(FUNC func) { task = void_bind(func); } template<typename FUNC, typename... Args> need(FUNC func, Args &&... args) { task = void_bind(func, std::forward<Args>(args)...); } ~need() { task(); } private: need(const need &that) = delete; need &operator=(const need &that) = delete; VoidOperator task; }; } #endif //ORZ_NEED_H
17.162162
64
0.549606
49584049bd39e5c4a2b63a79ab92a81eb549f130
5,781
h
C
include/nop/structure.h
carloscm/libnop
9d56beb16fd1f9ae21ec53ca26da372369352bd2
[ "Apache-2.0" ]
null
null
null
include/nop/structure.h
carloscm/libnop
9d56beb16fd1f9ae21ec53ca26da372369352bd2
[ "Apache-2.0" ]
null
null
null
include/nop/structure.h
carloscm/libnop
9d56beb16fd1f9ae21ec53ca26da372369352bd2
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2017 The Native Object Protocols Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef LIBNOP_INCLUDE_NOP_STRUCTURE_H_ #define LIBNOP_INCLUDE_NOP_STRUCTURE_H_ #include <nop/base/macros.h> #include <nop/types/detail/member_pointer.h> namespace nop { // // User-defined structures are structs or classes that have been annotated so // that the serialization engine understands how to read and write them. // Annotation is performed by invoking one of the following three macros: // * NOP_STRUCTURE in the body of the struct, class, or template. // * NOP_EXTERNAL_STRUCTURE at namespace scope matching the type. // * NOP_EXTERNAL_TEMPLATE at namespace scope matching the template. // // Example: // // struct User { // std::string name; // std::uint8_t age; // // enum class Gender { // Other, // Female, // Male, // }; // nop::Optional<Gender> gender; // // NOP_STRUCTURE(User, name, age, gender); // }; // // Defines the set of members belonging to a type that should be // serialized/deserialized. This macro must be invoked once within the // struct/class definition, preferrably in the private section for classes with // private data. #define NOP_STRUCTURE(type, ... /*members*/) \ template <typename, typename> \ friend struct ::nop::Encoding; \ template <typename, typename> \ friend struct ::nop::HasInternalMemberList; \ template <typename, typename> \ friend struct ::nop::MemberListTraits; \ using NOP__MEMBERS = ::nop::MemberList<_NOP_MEMBER_LIST(type, __VA_ARGS__)> // Defines the set of members belonging to a type that should be // serialized/deserialized without changing the type itself. This is useful for // making external library types with public data serializable. #define NOP_EXTERNAL_STRUCTURE(type, ... /*members*/) \ template <typename> \ struct NOP__MEMBER_TRAITS; \ template <> \ struct NOP__MEMBER_TRAITS<type> { \ using MemberList = ::nop::MemberList<_NOP_MEMBER_LIST(type, __VA_ARGS__)>; \ }; \ inline NOP__MEMBER_TRAITS<type> NOP__GetExternalMemberTraits \ NOP_GNU_USED (type*) { \ return {}; \ } // Similar to NOP_EXTERNAL_STRUCTURE but for template types. #define NOP_EXTERNAL_TEMPLATE(type, ... /*members*/) \ template <typename> \ struct NOP__MEMBER_TRAITS; \ template <typename... Ts> \ struct NOP__MEMBER_TRAITS<type<Ts...>> { \ using MemberList = \ ::nop::MemberList<_NOP_MEMBER_LIST(type<Ts...>, __VA_ARGS__)>; \ }; \ template <typename... Ts> \ inline NOP__MEMBER_TRAITS<type<Ts...>> NOP__GetExternalMemberTraits \ NOP_GNU_USED(type<Ts...>*) { \ return {}; \ } // // Utility macros used by the macros above. // // Generates a pair of template arguments (member pointer type and value) to be // passed to MemberPointer<MemberPointerType, MemberPointerValue, ...> from the // given type name and member name. #define _NOP_MEMBER_POINTER(type, member) decltype(&type::member), &type::member // Generates a MemberPointer type definition, given a type name and a variable // number of member names. The first member name is handled here, while the // remaining member names are passed to _NOP_MEMBER_POINTER_NEXT for recursive // expansion. #define _NOP_MEMBER_POINTER_FIRST(type, ...) \ ::nop::MemberPointer<_NOP_MEMBER_POINTER(type, _NOP_FIRST_ARG(__VA_ARGS__)) \ _NOP_MEMBER_POINTER_NEXT( \ type, _NOP_REST_ARG(__VA_ARGS__))> // Recursively handles the remaining member names in the template argument list // for MemberPointer. #define _NOP_MEMBER_POINTER_NEXT(type, ...) \ _NOP_IF_ELSE(_NOP_HAS_ARGS(__VA_ARGS__)) \ (, _NOP_MEMBER_POINTER(type, _NOP_FIRST_ARG(__VA_ARGS__)) \ _NOP_DEFER2(__NOP_MEMBER_POINTER_NEXT)()( \ type, _NOP_REST_ARG(__VA_ARGS__)))(/*done*/) // Indirection to enable recursive macro expansion of _NOP_MEMBER_POINTER_NEXT. #define __NOP_MEMBER_POINTER_NEXT() _NOP_MEMBER_POINTER_NEXT // Defines a list of MemberPointer types given a type and list of member names. #define _NOP_MEMBER_LIST(type, ...) \ NOP_MAP_ARGS(_NOP_MEMBER_POINTER_FIRST, (type), __VA_ARGS__) } // namespace nop #endif // LIBNOP_INCLUDE_NOP_STRUCTURE_H_
44.813953
80
0.593669
5bbec84a4278c4afc289f3792a831a302fa4d943
274
h
C
src/tan_time.h
tansrv/tanshipper
7096266ea59522058f153fc751a16f8f9a959e53
[ "BSD-2-Clause" ]
null
null
null
src/tan_time.h
tansrv/tanshipper
7096266ea59522058f153fc751a16f8f9a959e53
[ "BSD-2-Clause" ]
null
null
null
src/tan_time.h
tansrv/tanshipper
7096266ea59522058f153fc751a16f8f9a959e53
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (C) tanserver.org * Copyright (C) Chen Daye * * Feedback: tanserver@outlook.com */ #ifndef TAN_TIME_H #define TAN_TIME_H #include "tan_core.h" void tan_localtime(struct tm *tm); #define tan_msleep(ms) usleep(ms * 1000) #endif /* TAN_TIME_H */
11.913043
41
0.682482
c0bb31d1f73bdaa353d6f7cd000c481c71fe94b2
2,043
h
C
src/abaeterno/hw_model/cpu.h
paolofrb/cotson
1289b58ecc5d8279bc1124495ca0042f9586af11
[ "MIT" ]
null
null
null
src/abaeterno/hw_model/cpu.h
paolofrb/cotson
1289b58ecc5d8279bc1124495ca0042f9586af11
[ "MIT" ]
null
null
null
src/abaeterno/hw_model/cpu.h
paolofrb/cotson
1289b58ecc5d8279bc1124495ca0042f9586af11
[ "MIT" ]
null
null
null
// (C) Copyright 2006-2009 Hewlett-Packard Development Company, L.P. // // 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. // // $Id$ #ifndef CPU_H #define CPU_H #include "cpu_timer.h" #include "lua_helpers.h" #include "libmetric.h" #include "cotson.h" #include "states.h" class TokenQueue; class CpuTokenParser; class Predictor; class Cpu : public metric, public SimpleStateObserver { public: Cpu(TokenQueue*,uint64_t,const std::string&); ~Cpu(); // lua hook void timer(luabind::object); void instruction_cache(Memory::lua&); void data_cache(Memory::lua&); void instruction_tlb(Memory::lua&); void data_tlb(Memory::lua&); void inject(InjectState); void tag(uint32_t,const Cotson::Inject::info_tag&); bool execute(uint32_t); double cpi() const; // void cpi(double); inline uint64_t id() const { return devid; } inline const std::string& name() const { return devname; } inline CpuTimer* cpu_timer() const { return timing.get(); } protected: const uint64_t devid; const std::string devname; void beginSimulation(); void beginFunctional(); void beginSimpleWarming(); void beginFullWarming(); private: std::map<std::string,difference> stats; void do_compute_metrics(); void reset_sample(); void set_sample(); void setIPC(); boost::scoped_ptr<CpuTokenParser> parser; boost::scoped_ptr<CpuTimer> timing; boost::scoped_ptr<Predictor> predictor; std::vector<uint64_t> hb; difference cycles; difference instructions; difference idlecount; difference sample_instructions; difference sample_cycles; difference sample_idle; double cpi_; bool init; }; #endif
22.955056
77
0.742535