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
6ed0ce835950b5d6f56d1266fbd55c8ad2323e1c
1,432
h
C
code/engine/xrGame/CarLights.h
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
58
2016-11-20T19:14:35.000Z
2021-12-27T21:03:35.000Z
code/engine/xrGame/CarLights.h
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
59
2016-09-10T10:44:20.000Z
2018-09-03T19:07:30.000Z
code/engine/xrGame/CarLights.h
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
39
2017-02-05T13:35:37.000Z
2022-03-14T11:00:12.000Z
#ifndef CAR_LIGHTS_H #define CAR_LIGHTS_H #pragma once #include "../xrEngine/Render.h" class CCarLights; class CCar; struct SCarLight { ref_light light_render; ref_glow glow_render; u16 bone_id; CCarLights* m_holder; SCarLight(); ~SCarLight(); void Switch(); void TurnOn(); void TurnOff(); bool isOn(); void Init(CCarLights* holder); void Update(); void ParseDefinitions(LPCSTR section); }; using LIGHTS_STORAGE = xr_vector<SCarLight*>; class CCarLights { public: void ParseDefinitions(); void Init(CCar* pcar); void Update(); CCar* PCar() { return m_pcar; } void SwitchHeadLights(); void TurnOnHeadLights(); void TurnOffHeadLights(); bool IsLight(u16 bone_id); bool findLight(u16 bone_id, SCarLight*& light); CCarLights(); ~CCarLights(); protected: struct SFindLightPredicate { const SCarLight* m_light; SFindLightPredicate(const SCarLight* light) : m_light(light) {} bool operator()(const SCarLight* light) const { return light->bone_id == m_light->bone_id; } }; LIGHTS_STORAGE m_lights; CCar* m_pcar; /* Ivector2 m_head_near_lights ; Ivector2 m_head_far_lights ; Ivector2 m_left_turns ; Ivector2 m_stops ; Ivector2 m_gabarites ; Ivector2 m_door_gabarites ; */ private: }; #endif
23.096774
100
0.634078
31ea8b60f7385410c44a4d22e2759f8ab7171226
922
c
C
src/builtin/echo.c
Michelkusy/42sh
74625648c1538aecd5b5a36e3de25d1e1d3d09c4
[ "Apache-2.0" ]
null
null
null
src/builtin/echo.c
Michelkusy/42sh
74625648c1538aecd5b5a36e3de25d1e1d3d09c4
[ "Apache-2.0" ]
null
null
null
src/builtin/echo.c
Michelkusy/42sh
74625648c1538aecd5b5a36e3de25d1e1d3d09c4
[ "Apache-2.0" ]
null
null
null
/* ** EPITECH PROJECT, 2019 ** echo.c ** File description: ** echo */ #include "42sh.h" void echo_disp(char *str) { int len = my_strlen(str); if ((str[0] == '"' || str[0] == '\'') && (str[len - 1] == '"' || str[len - 1] == '\'')) { str[len - 1] = '\0'; str++; } my_printf("%s", str); } void echo_sup(int ret, char **str, int i, general_t *gen) { if (i != 1) my_printf(" "); if (str[i][0] == '$') { check_local_var(gen, str[i]); } else if (my_strcompare("$?", str[i])) { my_printf("%d", ret); } else echo_disp(str[i]); return; } int echo_fun(general_t *general, function_t *tmp) { if (my_strcompare("echo", tmp->str[0])) { for (int i = 1; tmp->str[i]; i++) echo_sup(general->ret, tmp->str, i, general); my_printf("\n"); general->ret = 0; return (1); } return (0); }
19.617021
57
0.467462
5a23497a8e2c2fe2b276b7defae3b82bb0335ca1
679
c
C
src/kpsglib/HOMODEC.c
DanIverson/OpenVnmrJ
0db324603dbd8f618a6a9526b9477a999c5a4cc3
[ "Apache-2.0" ]
32
2016-06-17T05:04:26.000Z
2022-03-28T17:54:44.000Z
src/kpsglib/HOMODEC.c
DanIverson/OpenVnmrJ
0db324603dbd8f618a6a9526b9477a999c5a4cc3
[ "Apache-2.0" ]
128
2016-07-13T17:09:02.000Z
2022-03-28T17:53:52.000Z
src/kpsglib/HOMODEC.c
DanIverson/OpenVnmrJ
0db324603dbd8f618a6a9526b9477a999c5a4cc3
[ "Apache-2.0" ]
102
2016-01-23T15:27:16.000Z
2022-03-20T05:41:54.000Z
// Copyright (C) 2015 University of Oregon // You may distribute under the terms of either the GNU General Public // License or the Apache License, as specified in the LICENSE file. // For more information, see the LICENSE file. /* */ /* HOMODEC - standard two-pulse sequence for homonuclear decoupling Forces the value of dmm and homo parameters */ #include <standard.h> void pulsesequence() { char homo[MAXSTR]; strcpy(dmm, "ccc"); strcpy(homo, "y"); /* equilibrium period */ status(A); hsdelay(d1); /* --- tau delay --- */ status(B); pulse(p1, zero); hsdelay(d2); /* --- observe period --- */ status(C); pulse(pw,oph); }
19.4
70
0.639175
6e798d7abdb1677a89a858f812e94bec38182fa8
275
h
C
CenCheckbox/AppDelegate.h
ZHANGneuro/CenCheckbox
6524f21ab152bd36ccd554c4af0c7aa03dc8f826
[ "MIT" ]
3
2017-06-14T06:08:31.000Z
2019-07-08T07:10:21.000Z
CenCheckbox/AppDelegate.h
ZHANGneuro/CenCheckbox
6524f21ab152bd36ccd554c4af0c7aa03dc8f826
[ "MIT" ]
null
null
null
CenCheckbox/AppDelegate.h
ZHANGneuro/CenCheckbox
6524f21ab152bd36ccd554c4af0c7aa03dc8f826
[ "MIT" ]
null
null
null
// // AppDelegate.h // XiaoCen_Checkbox // // Created by boo on 03/06/2017. // Copyright © 2017 boo. All rights reserved. // #import <Cocoa/Cocoa.h> #import "CenCheckBox.h" @interface AppDelegate : NSObject <NSApplicationDelegate> @property NSWindow *window; @end
13.75
57
0.698182
f5be554f09f73e193f1ffbb9978e8d8aefa1ebfa
6,853
h
C
avr/src/dev/si4432.h
robs8899/ambient-sensors
514c23de8aa9fc672da27854e5d339a1ed4fb1e7
[ "MIT" ]
2
2019-10-16T19:40:37.000Z
2020-08-13T13:07:38.000Z
avr/src/dev/si4432.h
robs8899/ambient-sensors
514c23de8aa9fc672da27854e5d339a1ed4fb1e7
[ "MIT" ]
null
null
null
avr/src/dev/si4432.h
robs8899/ambient-sensors
514c23de8aa9fc672da27854e5d339a1ed4fb1e7
[ "MIT" ]
null
null
null
#define SI4432_NSEL_PIN 0 // NSEL port pin number for spi_cs() / spi_ds(): 0=PB2, 1=PB1 #define SI4432_FIXP_SIZE 58 // fixed packet size (58); #define SI4432_REG_DEV_TYPE 0x00 // Device Type Code #define SI4432_REG_DEV_VERSION 0x01 // Version Code #define SI4432_REG_DEV_STATUS 0x02 // Device Status #define SI4432_REG_STATUS_1 0x03 // Interrupt/Status 1 // bits for SI4432_REG_STATUS_1 #define SI4432_STATUS_1_IFFERR 0x80 // FIFO Underflow/Overflow Error #define SI4432_STATUS_1_ITXFFAFULL 0x40 // TX FIFO Almost Full #define SI4432_STATUS_1_IXTFFAEM 0x20 // TX FIFO Almost Empty #define SI4432_STATUS_1_IRXFFAFULL 0x10 // RX FIFO Almost Full #define SI4432_STATUS_1_IEXT 0x08 // External Interrupt #define SI4432_STATUS_1_IPKSENT 0x04 // Packet Sent Interrupt #define SI4432_STATUS_1_IPKVALID 0x02 // Valid Packet Received #define SI4432_STATUS_1_ICRERROR 0x01 // CRC Error #define SI4432_STATUS_1_IGNORE 0x00 // ignore all Status 1 flags in ezr_poll() #define SI4432_REG_STATUS_2 0x04 // Interrupt/Status 2 // bits for SI4432_REG_STATUS_2 #define SI4432_STATUS_2_ISWDET 0x80 // Sync Word Detected #define SI4432_STATUS_2_IPREAVAL 0x40 // Valid Preamble Detected #define SI4432_STATUS_2_IPREAINVAL 0x20 // Invalid Preamble Detected #define SI4432_STATUS_2_IRSSI 0x10 // RSSI level exceeds threshold #define SI4432_STATUS_2_IWUT 0x08 // Wake-Up-Time expiration #define SI4432_STATUS_2_ILBD 0x04 // Low Battery Detect #define SI4432_STATUS_2_ICHIPRDY 0x02 // Chip Ready (XTAL) #define SI4432_STATUS_2_IPOR 0x01 // Power-on-Reset (POR) #define SI4432_STATUS_2_IGNORE 0x00 // ignore all Status 2 flags in ezr_poll() #define SI4432_REG_INT_1 0x05 // Interrupt Enable 1 // bits for SI4432_REG_INT_1 #define SI4432_INT_1_ENFFERR 0x80 // Enable FIFO Underflow/Overflow #define SI4432_INT_1_ENTXFFAFULL 0x40 // Enable TX FIFO Almost Full #define SI4432_INT_1_ENTXFFAEM 0x20 // Enable TX FIFO Almost Empty #define SI4432_INT_1_ENRXFFAFULL 0x10 // Enable RX FIFO Almost Full #define SI4432_INT_1_ENEXT 0x08 // Enable External Interrupt #define SI4432_INT_1_ENPKSENT 0x04 // Enable Packet Sent #define SI4432_INT_1_ENPKVALID 0x02 // Enable Valid Packet Received #define SI4432_INT_1_ENCRCERROR 0x01 // Enable CRC Error #define SI4432_REG_INT_2 0x06 // Interrupt Enable 2 // bits for SI4432_REG_INT_2 #define SI4432_INT_2_ENSWDET 0x80 // Enable Sync Word Detected #define SI4432_INT_2_ENPREAVAL 0x40 // Enable Valid Preamble Detected #define SI4432_INT_2_ENPREAINVAL 0x20 // Enable Invalid Preamble Detected #define SI4432_INT_2_ENRSSI 0x10 // Enable RSSI Threshold for CCA #define SI4432_INT_2_ENWUT 0x08 // Enable Wake-Up Timer #define SI4432_INT_2_ENLBD 0x04 // Enable Low Battery Detect #define SI4432_INT_2_ENCHIPRDY 0x02 // Enable Chip Ready (XTAL) #define SI4432_INT_2_ENPOR 0x01 // Enable POR #define SI4432_REG_OPMODE_CTRL_1 0x07 // Operating Mode and Function Control Register 1 // bits for SI4432_REG_OPMODE_CTRL1 #define SI4432_OPMODE_CTRL_1_SWRES 0x80 // Software Register Reset Bit #define SI4432_OPMODE_CTRL_1_ENLBD 0x40 // Enable Low Battery Detect #define SI4432_OPMODE_CTRL_1_ENWT 0x20 // Enable Wake-Up-Timer #define SI4432_OPMODE_CTRL_1_X32KSEL 0x10 // 32,768 kHz Crystal Oscillator Select #define SI4432_OPMODE_CTRL_1_TXON 0x08 // TX on in Manual Transmit Mode #define SI4432_OPMODE_CTRL_1_RXON 0x04 // RX on in Manual Receiver Mode #define SI4432_OPMODE_CTRL_1_PLLON 0x02 // TUNE Mode (PLL is ON) #define SI4432_OPMODE_CTRL_1_XTON 0x01 // READY Mode (Xtal is ON) #define SI4432_REG_OPMODE_CTRL_2 0x08 // Operating Mode and Function Control Register 2 // bits for SI4432_REG_OPMODE_CTRL_2 #define SI4432_OPMODE_CTRL_2_RXMPK 0x10 // RX Multi Packet #define SI4432_OPMODE_CTRL_2_AUTOTX 0x08 // Automatic Transmission #define SI4432_OPMODE_CTRL_2_ENLDM 0x04 // Enable Low Duty Cycle Mode #define SI4432_OPMODE_CTRL_2_FFCLRRX 0x02 // RX FIFO Reset/Clear #define SI4432_OPMODE_CTRL_2_FFCLRTX 0x01 // TX FIFO Reset/Clear #define SI4432_REG_RSSI_VALUE 0x26 // Received Signal Strength Indicator #define SI4432_REG_RSSI_CCI 0x27 // RSSI Threshold for Clear Channel Indicator #define SI4432_REG_ANT_DIV_1 0x28 // Antenna Diversity 1 #define SI4432_REG_ANT_DIV_2 0x29 // Antenna Diversity 2 #define SI4432_REG_AFC_LIMITER 0x2A // AFC Limiter #define SI4432_REG_AFC_CORRECT 0x2B // AFC Correction (MSBs) #define SI4432_REG_OOK_COUNTER_1 0x2C // OOK Counter Value 1 #define SI4432_REG_OOK_COUNTER_2 0x2D // OOK Counter Value 2 #define SI4432_REG_SLICER_PEAK_HLDR 0x2E // Slicer Peak Holder #define SI4432_REG_DATA_ACCESS_CTRL 0x30 // Data Access Control #define SI4432_AFC_LSB 0x0C // AFC correction bits [7:6] in REG_OOK_COUNTER_1 #define SI4432_REG_AGC_OVERRIDE 0x69 // AGC Control Register #define SI4432_AGC_LNA_GAIN_BIT 0x10 // LAN Gain: 0=5dB / 1=25 dB #define SI4432_AGC_PGA_GAIN_MSK 0x0F // PGA Gain mask: 3dB steps #define SI4432_REG_MDMODE_CTRL_1 0x70 // Modulation Mode Control 1 #define SI4432_REG_MDMODE_CTRL_2 0x71 // Modulation Mode Control 2 // values for Modulation source: dtmod[5:4] #define SI4432_MDMODE_CTRL_2_GPIO 0x00 // Direct Mode via the GPIO pin #define SI4432_MDMODE_CTRL_2_SDI 0x10 // Direct Mode via the SDI pin #define SI4432_MDMODE_CTRL_2_FIFO 0x20 // FIFO Mode #define SI4432_MDMODE_CTRL_2_PN9 0x30 // PN9 (internally generated) // values for Modulation Type: modtyp[1:0] #define SI4432_MDMODE_CTRL_2_CARRIER 0x00 // Unmodulated carrier #define SI4432_MDMODE_CTRL_2_OOK 0x01 // OOK #define SI4432_MDMODE_CTRL_2_FSK 0x02 // FSK #define SI4432_MDMODE_CTRL_2_GFSK 0x03 // GFSK #define SI4432_REG_FIFO 0x7F // FIFO read/write access /* register/value pair of the init sequence */ typedef struct EZR_REG_VAL { uint8_t reg; uint8_t val; } ezr_reg_val; void ezr_init(int port, int nirq, int sdn); void ezr_startup(); void ezr_shutdown(); void ezr_configure(); uint8_t ezr_get(uint8_t reg); uint8_t ezr_set(uint8_t reg, uint8_t val); void ezr_rx(void *data, int len); void ezr_tx(void *data, int len); int ezr_poll(uint8_t s1, uint8_t s2, int max);
50.021898
107
0.7102
91b52caa3d299e54718c89690771fdcb7d2ac625
1,030
c
C
test/programs/simple/problem-type.c
GnKonkort/cpachecker
d79a358c2d89ca4b5d58b36859efcf8c320a737b
[ "Apache-2.0" ]
16
2015-01-19T15:52:14.000Z
2015-11-30T14:12:31.000Z
test/programs/simple/problem-type.c
teodorov/cpachecker
16e37b76c5b9e3d203992c6c7bf96b64da6fbae1
[ "Apache-2.0" ]
5
2022-02-15T03:55:13.000Z
2022-02-28T03:59:20.000Z
test/programs/simple/problem-type.c
teodorov/cpachecker
16e37b76c5b9e3d203992c6c7bf96b64da6fbae1
[ "Apache-2.0" ]
18
2015-02-17T19:22:41.000Z
2015-11-24T09:12:39.000Z
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 // This file demonstrates a bug in Eclipse CDT at least up to 8.1.2 // With the next line the problem does not occur. //struct request_queue; struct gendisk { struct request_queue *queue; }; typedef struct request_queue request_queue_t; typedef void (request_fn_proc) (request_queue_t *q); struct request_queue { request_fn_proc *request_fn; }; struct ddv_genhd { struct gendisk *gd; }; int main() { struct ddv_genhd genhd_registered; struct gendisk *gd = genhd_registered.gd; // Without the following line the problem does not occur. struct request_queue *queue = gd->queue; struct request_queue q; // The expression type of the "q.request_fn" IASTFieldReference is a ProblemType. request_fn_proc *request_fn = q.request_fn; return 0; }
23.409091
85
0.729126
e5b946fc257032bc3915775bffcf9a182197dcb1
2,605
h
C
Archived/v1/WCDistractionFreeXcodePlugin/Headers/PlugIns/IDESpriteKitParticleEditor/CDStructures.h
wokalski/Distraction-Free-Xcode-plugin
54ab4b9d9825e8370855b7985d6ff39d64c19f25
[ "MIT" ]
25
2016-03-03T07:43:56.000Z
2021-09-05T08:47:40.000Z
Archived/v1/WCDistractionFreeXcodePlugin/Headers/PlugIns/IDESpriteKitParticleEditor/CDStructures.h
wokalski/Distraction-Free-Xcode-plugin
54ab4b9d9825e8370855b7985d6ff39d64c19f25
[ "MIT" ]
8
2016-02-23T18:40:20.000Z
2016-08-18T13:21:05.000Z
Archived/v1/WCDistractionFreeXcodePlugin/Headers/PlugIns/IDESpriteKitParticleEditor/CDStructures.h
wokalski/Distraction-Free-Xcode-plugin
54ab4b9d9825e8370855b7985d6ff39d64c19f25
[ "MIT" ]
4
2016-02-24T13:24:27.000Z
2016-06-28T12:50:36.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // @class SKNode; #pragma mark Blocks typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown #pragma mark Named Structures struct CGPath; struct CGPoint { double x; double y; }; struct CGRect { struct CGPoint _field1; struct CGSize _field2; }; struct CGSize { double width; double height; }; struct FSEventStreamContext { long long version; void *info; CDUnknownFunctionPointerType retain; CDUnknownFunctionPointerType release; CDUnknownFunctionPointerType copyDescription; }; struct NodeMovePair; struct PolyEditor { struct CGPath *_path; _Bool _dirty; struct CGPoint _continuityButtonPos; struct CGPoint _lockButtonPos; unsigned long long _editIndex; int _editPart; _Bool _filled; _Bool _closed; _Bool _smoothPath; struct vector<PolyEditor::Vertex, std::__1::allocator<PolyEditor::Vertex>> _verts; SKNode *_offsetNode; struct CGPoint _lastOffsetPosition; struct Vertex _firstVert; }; struct SnapResult { _Bool _field1; _Bool _field2; float _field3; float _field4; }; struct Vertex { struct CGPoint point; struct CGPoint tangentIn; struct CGPoint tangentOut; int tangency; }; struct _NSRange { unsigned long long _field1; unsigned long long _field2; }; struct vector<NodeMovePair, std::__1::allocator<NodeMovePair>> { struct NodeMovePair *__begin_; struct NodeMovePair *__end_; struct __compressed_pair<NodeMovePair *, std::__1::allocator<NodeMovePair>> { struct NodeMovePair *__first_; } __end_cap_; }; struct vector<PolyEditor::Vertex, std::__1::allocator<PolyEditor::Vertex>> { struct Vertex *__begin_; struct Vertex *__end_; struct __compressed_pair<PolyEditor::Vertex *, std::__1::allocator<PolyEditor::Vertex>> { struct Vertex *__first_; } __end_cap_; }; #pragma mark Typedef'd Structures typedef struct { struct CGPoint _field1; struct CGPoint _field2; struct CGPoint _field3; struct CGPoint _field4; struct CGPoint _field5; struct CGPoint _field6; struct CGPoint _field7; struct CGPoint _field8; struct CGPoint _field9; struct CGPoint _field10; struct CGPoint _field11; double _field12; struct CGPoint _field13; struct CGSize _field14; struct CGPoint _field15; struct CGPoint _field16; struct CGPoint _field17; struct CGPoint _field18; } CDStruct_76845b71;
22.456897
93
0.710173
9182817731e56049ff17de0c506d86a8738c26e9
491
h
C
src/iLinX/Obsolete/LightsPageViewController.h
arpandesai/ilinx
eb3b7d1c2303b45fa615bb699228a6f95e8352c5
[ "Apache-2.0" ]
null
null
null
src/iLinX/Obsolete/LightsPageViewController.h
arpandesai/ilinx
eb3b7d1c2303b45fa615bb699228a6f95e8352c5
[ "Apache-2.0" ]
null
null
null
src/iLinX/Obsolete/LightsPageViewController.h
arpandesai/ilinx
eb3b7d1c2303b45fa615bb699228a6f95e8352c5
[ "Apache-2.0" ]
2
2018-02-19T07:55:09.000Z
2018-10-22T06:34:26.000Z
// // LightsPageViewController.h // iLinX // // Created by mcf on 29/01/2009. // Copyright 2009 Micropraxis Ltd. All rights reserved. // #import <UIKit/UIKit.h> #import "NLServiceGeneric.h" @interface LightsPageViewController : UIViewController <NLServiceGenericDelegate> { @private NLServiceGeneric *_lightsService; NSUInteger _offset; NSUInteger _count; } - (id) initWithService: (NLServiceGeneric *) lightsService offset: (NSUInteger) offset count: (NSUInteger) count; @end
21.347826
113
0.753564
bcc4a8dca8cda743a2696dedcc81c5187493b304
454
h
C
code/key/key.h
374565452/RTT-BeepPlayer
f86a1f270c4a5c49e1a490554e28d59dd62b3a60
[ "Apache-2.0" ]
24
2018-11-26T09:56:24.000Z
2021-12-15T03:20:52.000Z
code/key/key.h
374565452/RTT-BeepPlayer
f86a1f270c4a5c49e1a490554e28d59dd62b3a60
[ "Apache-2.0" ]
1
2018-12-04T03:48:43.000Z
2018-12-04T03:48:43.000Z
code/key/key.h
Guozhanxin/RTT-BeepPlayer
f86a1f270c4a5c49e1a490554e28d59dd62b3a60
[ "Apache-2.0" ]
15
2018-12-04T02:53:53.000Z
2021-04-01T06:19:39.000Z
/* * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-10-17 flybreak the first version */ #ifndef BEEP_KEY_H #define BEEP_KEY_H #include "multi_button.h" #include "player.h" #define KEY_PLAY_PIN 2 #define KEY_LAST_PIN 1 #define KEY_NEXT_PIN 3 #define KEY_PRESS_LEVEL 0 int key_init(void); //按键初始化 #endif
18.16
53
0.651982
34993a6067e0925f889b60bd702b2c78682e389f
1,598
h
C
System/Library/PrivateFrameworks/SpringBoard.framework/SBDeckToFullScreenSwitcherModifier.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/SpringBoard.framework/SBDeckToFullScreenSwitcherModifier.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/SpringBoard.framework/SBDeckToFullScreenSwitcherModifier.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:45:05 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/SpringBoard.framework/SpringBoard * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <SpringBoard/SpringBoard-Structs.h> #import <SpringBoard/SBTransitionSwitcherModifier.h> @class SBAppLayout, SBSwitcherModifier; @interface SBDeckToFullScreenSwitcherModifier : SBTransitionSwitcherModifier { long long _direction; SBAppLayout* _fullScreenAppLayout; SBSwitcherModifier* _deckModifier; BOOL _wantsMinificationFilter; } -(long long)homeScreenBackdropBlurType; -(id)transitionWillBegin; -(id)_layoutSettings; -(double)opacityForIndex:(unsigned long long)arg1 ; -(BOOL)isWallpaperRequiredForSwitcher; -(BOOL)isHomeScreenContentRequired; -(BOOL)isSwitcherWindowVisible; -(id)handleMainTransitionEvent:(id)arg1 ; -(BOOL)isSwitcherWindowUserInteractionEnabled; -(id)topMostLayoutElements; -(long long)wallpaperStyle; -(id)appLayoutsToCacheSnapshots; -(UIRectCornerRadii)cardCornerRadiiForIndex:(unsigned long long)arg1 ; -(id)animationAttributesForLayoutElement:(id)arg1 ; -(id)_appLayoutToScrollToDuringTransition; -(id)initWithTransitionID:(id)arg1 direction:(long long)arg2 fullScreenAppLayout:(id)arg3 deckModifier:(id)arg4 ; -(BOOL)shouldRasterizeLiveContentUntilDelay:(inout double*)arg1 ; -(id)appLayoutToScrollToBeforeTransitioning; -(id)visibleAppLayouts; -(id)liveContentRasterizationAttributesForAppLayout:(id)arg1 ; @end
36.318182
113
0.822904
425421aa589a1cf43aeb432ab88546390ba50b86
3,375
h
C
moos-ivp/ivp/src/lib_ipfview/QuadSet.h
EasternEdgeRobotics/2018
24df2fe56fa6d172ba3c34c1a97f249dbd796787
[ "MIT" ]
null
null
null
moos-ivp/ivp/src/lib_ipfview/QuadSet.h
EasternEdgeRobotics/2018
24df2fe56fa6d172ba3c34c1a97f249dbd796787
[ "MIT" ]
null
null
null
moos-ivp/ivp/src/lib_ipfview/QuadSet.h
EasternEdgeRobotics/2018
24df2fe56fa6d172ba3c34c1a97f249dbd796787
[ "MIT" ]
null
null
null
/*****************************************************************/ /* NAME: Michael Benjamin */ /* ORGN: Dept of Mechanical Eng / CSAIL, MIT Cambridge MA */ /* FILE: QuadSet.h */ /* DATE: July 4th 2006 */ /* */ /* This file is part of MOOS-IvP */ /* */ /* MOOS-IvP 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. */ /* */ /* MOOS-IvP 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 MOOS-IvP. If not, see */ /* <http://www.gnu.org/licenses/>. */ /*****************************************************************/ #ifndef QUAD_SET_HEADER #define QUAD_SET_HEADER #include <vector> #include <string> #include "Quad3D.h" #include "IvPFunction.h" #include "IvPDomain.h" #include "FColorMap.h" class QuadSet { public: QuadSet(); ~QuadSet() {} // Building the QuadSet void addQuad3D(Quad3D quad) {m_quads.push_back(quad);} void setIvPDomain(IvPDomain domain) {m_ivp_domain = domain;} void resetMinMaxVals(); void markDense(bool v) {m_dense=v;} // Modifying the QuadSet void applyColorMap(const FColorMap&); void applyColorMap(const FColorMap&, double low, double hgh); void addQuadSet(const QuadSet&); void normalize(double, double); void interpolate(double xdelta); void applyColorIntensity(double); void applyScale(double); void applyBase(double); void applyTranslation(double x, double y); void applyTranslation(); void applyPolar(double, int); // Geting QuadSet Information unsigned int size() const {return(m_quads.size());} Quad3D getQuad(unsigned int) const; IvPDomain getDomain() const {return(m_ivp_domain);} double getMaxVal() const {return(m_maxpt_val);} double getMinVal() const {return(m_minpt_val);} bool isDense() const {return(m_dense);} double getMaxPoint(std::string) const; unsigned int getMaxPointQIX(std::string) const; void print() const; protected: std::vector<Quad3D> m_quads; IvPDomain m_ivp_domain; bool m_dense; // Cache Min/Max values. These are evaluated once all the Quads // have been calculated and added. double m_maxpt_val; // Max utilty all quad vertices double m_minpt_val; unsigned int m_max_x_qix; // Index in ivp_domain of max x value unsigned int m_max_y_qix; }; #endif
37.921348
70
0.539259
5517303de4e0c22a304fbcc0464a0e7f1d132145
6,835
c
C
sra_clicker/sra_clicker.c
rphii/sra_clicker
a32e5cfce5b02f01f1982a0be92900d41b3ca9f7
[ "MIT" ]
3
2021-02-14T14:59:37.000Z
2021-02-16T15:56:03.000Z
sra_clicker/sra_clicker.c
rphii/sra_clicker
a32e5cfce5b02f01f1982a0be92900d41b3ca9f7
[ "MIT" ]
null
null
null
sra_clicker/sra_clicker.c
rphii/sra_clicker
a32e5cfce5b02f01f1982a0be92900d41b3ca9f7
[ "MIT" ]
null
null
null
#include "sra_clicker.h" /*LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { // thanks to //https://stackoverflow.com/questions/22975916/global-keyboard-hook-with-wh-keyboard-ll-and-keybd-event-windows BOOL fEatKeystroke = FALSE; switch (wParam) { case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: { PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT)lParam; if((fEatKeystroke = (p->vkCode == VK_F8))) { } // if ((fEatKeystroke = (p->vkCode == 0x41))) //redirect a to b { printf("Hello a\n"); if ( (wParam == WM_KEYDOWN) || (wParam == WM_SYSKEYDOWN) ) // Keydown { keybd_event('B', 0, 0, 0); } else if ( (wParam == WM_KEYUP) || (wParam == WM_SYSKEYUP) ) // Keyup { keybd_event('B', 0, KEYEVENTF_KEYUP, 0); } break; // break; } default: break; } return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam, lParam)); }*/ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) //int main(void) { //ShowWindow(FindWindowA("ConsoleWindowClass", NULL), 0); // hide console // Install the low-level keyboard & mouse hooks //HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, 0, 0); // create mouse and initialize it sra_mouse_t mouse; sra_mouse_setup(&mouse); // create locate and initialize it sra_locate_t locate; sra_locate_setup(&locate); //if(locate.restrict_window(&locate, "Notepad++ : a free (GNU) source code editor (32 Bit)")) // for(;;) // { if(locate.restrict_window(&locate, L"Task-Manager")) { // printf("ok1\n"); if(locate.refresh(&locate)) { // printf("ok2\n"); if(locate.save_bmp(&locate, L"image.bmp")) { printf("ok3\n"); } //printf("."); } } // } // Keep this app running until we're told to stop /*MSG Message; for(;;) { BOOL MessageResult = GetMessage(&Message, 0, 0, 0); if(MessageResult > 0) { TranslateMessage(&Message); DispatchMessage(&Message); } else { break; } }*/ /*locate.restrict_window(&locate, "Bluestacks"); locate.refresh(&locate); locate.save_bmp(&locate, "image.bmp"); for(;;) { }*/ /*locate.refresh(&locate); // TODO add this thing to locate.c/h, but add it good for(;;) { HWND handle = FindWindow(NULL, L"Rechner"); //HWND handle = FindWindowA(NULL, "Rechner"); RECT rect; if(GetWindowRect(handle, &rect)) { if(handle == GetForegroundWindow()) { printf("%4d/%4d;%4d/%4d\n", rect.left, rect.top, rect.right, rect.bottom); } else { printf("window not active\n"); } } else { printf("window not found\n"); } }*/ //for(int i = 0; i < 999999999; i++) {}; //mouse.clickl_xy(&mouse, 1000, 1000); for(;;); /*for(;;) { for(int i = 0; i < 999999999; i++) {}; mouse.pressl(&mouse); for(int i = 0; i < 999999999; i++) {}; mouse.releasel(&mouse); }*/ /* bool found = false; locate.restrict_window(&locate, L"OneNote für Windows 10"); for(int i = 0; i < 10000; i++) //for(;;) { //for(int i = 0; i < 999999; i++) {}; locate.refresh(&locate); //found = locate.locate_color_rgb(&locate, 191, 226, 255); // bright blue //found = locate.locate_color_rgb(&locate, 108, 131, 224); // desaturated blue found = locate.locate_color(&locate, 0xff6c83e0); // desaturated blue if(found) { //printf("1"); //mouse.move_xy(&mouse, locate.x, locate.y); //mouse.pressl(&mouse); mouse.clickl_xy(&mouse, locate.x, locate.y); } locate.refresh(&locate); //found = locate.locate_color_rgb(&locate, 130, 169, 252); // darker blue found = locate.locate_color(&locate, 0xff82a9fc); // darker blue if(found) { //printf("2"); //mouse.move_xy(&mouse, locate.x, locate.y); //mouse.pressl(&mouse); mouse.clickl_xy(&mouse, locate.x, locate.y); } locate.refresh(&locate); found = locate.locate_color(&locate, 0xffb8dbff); // bright blue if(found) { //printf("3"); mouse.clickl_xy(&mouse, locate.x, locate.y); } locate.refresh(&locate); found = locate.locate_color(&locate, 0xff758ce9); // bright blue if(found) { //printf("4"); mouse.clickl_xy(&mouse, locate.x, locate.y); } //locate.get_color_rgb_xy(&locate, p.x, p.y); //uint32_t col = locate.get_color_xy(&locate, p.x, p.y); //printf("%d/%d:%d,%d,%d|%x\n", p.x, p.y, locate.r, locate.g, locate.b, col); //printf("%d/%d:%x\n", p.x, p.y, col); } */ /* for(;;) { for(int i = 0; i < 999999999; i++) {}; mouse.clickl_xy(&mouse, 60000, 60000); }*/ /* int interval = 99999; int delta = 1; int direction = 0; int changedirection = 1; int sum = 0; for(;;) { sum += delta; if(sum > changedirection) { direction = (direction + 1) % 4; sum = 0; } switch(direction) { case 0: mouse.move_xy(&mouse, delta, delta); break; case 1: mouse.move_xy(&mouse, -delta, delta); break; case 2: mouse.move_xy(&mouse, -delta, -delta); break; case 3: mouse.move_xy(&mouse, delta, -delta); break; default: break; } for(int i = 0; i < interval; i++) {}; } */ //UnhookWindowsHookEx(hhkLowLevelKybd); sra_mouse_free(&mouse); return 0; }
26.492248
115
0.468764
ab511d5b65a449a567698a787b73036d21f7c414
8,600
c
C
release/src-rt/linux/linux-2.6/arch/powerpc/platforms/cell/cbe_cpufreq.c
ghsecuritylab/tomato_egg
50473a46347f4631eb4878a0f47955cc64c87293
[ "FSFAP" ]
278
2015-11-03T03:01:20.000Z
2022-01-20T18:21:05.000Z
release/src-rt/linux/linux-2.6/arch/powerpc/platforms/cell/cbe_cpufreq.c
ghsecuritylab/tomato_egg
50473a46347f4631eb4878a0f47955cc64c87293
[ "FSFAP" ]
374
2015-11-03T12:37:22.000Z
2021-12-17T14:18:08.000Z
release/src-rt/linux/linux-2.6/arch/powerpc/platforms/cell/cbe_cpufreq.c
ghsecuritylab/tomato_egg
50473a46347f4631eb4878a0f47955cc64c87293
[ "FSFAP" ]
96
2015-11-22T07:47:26.000Z
2022-01-20T19:52:19.000Z
/* * cpufreq driver for the cell processor * * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 * * Author: Christian Krafft <krafft@de.ibm.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/cpufreq.h> #include <linux/timer.h> #include <asm/hw_irq.h> #include <asm/io.h> #include <asm/machdep.h> #include <asm/processor.h> #include <asm/prom.h> #include <asm/time.h> #include <asm/pmi.h> #include <asm/of_platform.h> #include "cbe_regs.h" static DEFINE_MUTEX(cbe_switch_mutex); /* the CBE supports an 8 step frequency scaling */ static struct cpufreq_frequency_table cbe_freqs[] = { {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {8, 0}, {10, 0}, {0, CPUFREQ_TABLE_END}, }; /* to write to MIC register */ static u64 MIC_Slow_Fast_Timer_table[] = { [0 ... 7] = 0x007fc00000000000ull, }; /* more values for the MIC */ static u64 MIC_Slow_Next_Timer_table[] = { 0x0000240000000000ull, 0x0000268000000000ull, 0x000029C000000000ull, 0x00002D0000000000ull, 0x0000300000000000ull, 0x0000334000000000ull, 0x000039C000000000ull, 0x00003FC000000000ull, }; static unsigned int pmi_frequency_limit = 0; /* * hardware specific functions */ static struct of_device *pmi_dev; #ifdef CONFIG_PPC_PMI static int set_pmode_pmi(int cpu, unsigned int pmode) { int ret; pmi_message_t pmi_msg; #ifdef DEBUG u64 time; #endif pmi_msg.type = PMI_TYPE_FREQ_CHANGE; pmi_msg.data1 = cbe_cpu_to_node(cpu); pmi_msg.data2 = pmode; #ifdef DEBUG time = (u64) get_cycles(); #endif pmi_send_message(pmi_dev, pmi_msg); ret = pmi_msg.data2; pr_debug("PMI returned slow mode %d\n", ret); #ifdef DEBUG time = (u64) get_cycles() - time; /* actual cycles (not cpu cycles!) */ time = 1000000000 * time / CLOCK_TICK_RATE; /* time in ns (10^-9) */ pr_debug("had to wait %lu ns for a transition\n", time); #endif return ret; } #endif static int get_pmode(int cpu) { int ret; struct cbe_pmd_regs __iomem *pmd_regs; pmd_regs = cbe_get_cpu_pmd_regs(cpu); ret = in_be64(&pmd_regs->pmsr) & 0x07; return ret; } static int set_pmode_reg(int cpu, unsigned int pmode) { struct cbe_pmd_regs __iomem *pmd_regs; struct cbe_mic_tm_regs __iomem *mic_tm_regs; u64 flags; u64 value; local_irq_save(flags); mic_tm_regs = cbe_get_cpu_mic_tm_regs(cpu); pmd_regs = cbe_get_cpu_pmd_regs(cpu); pr_debug("pm register is mapped at %p\n", &pmd_regs->pmcr); pr_debug("mic register is mapped at %p\n", &mic_tm_regs->slow_fast_timer_0); out_be64(&mic_tm_regs->slow_fast_timer_0, MIC_Slow_Fast_Timer_table[pmode]); out_be64(&mic_tm_regs->slow_fast_timer_1, MIC_Slow_Fast_Timer_table[pmode]); out_be64(&mic_tm_regs->slow_next_timer_0, MIC_Slow_Next_Timer_table[pmode]); out_be64(&mic_tm_regs->slow_next_timer_1, MIC_Slow_Next_Timer_table[pmode]); value = in_be64(&pmd_regs->pmcr); /* set bits to zero */ value &= 0xFFFFFFFFFFFFFFF8ull; /* set bits to next pmode */ value |= pmode; out_be64(&pmd_regs->pmcr, value); /* wait until new pmode appears in status register */ value = in_be64(&pmd_regs->pmsr) & 0x07; while(value != pmode) { cpu_relax(); value = in_be64(&pmd_regs->pmsr) & 0x07; } local_irq_restore(flags); return 0; } static int set_pmode(int cpu, unsigned int slow_mode) { #ifdef CONFIG_PPC_PMI if (pmi_dev) return set_pmode_pmi(cpu, slow_mode); else #endif return set_pmode_reg(cpu, slow_mode); } static void cbe_cpufreq_handle_pmi(struct of_device *dev, pmi_message_t pmi_msg) { u8 cpu; u8 cbe_pmode_new; BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE); cpu = cbe_node_to_cpu(pmi_msg.data1); cbe_pmode_new = pmi_msg.data2; pmi_frequency_limit = cbe_freqs[cbe_pmode_new].frequency; pr_debug("cbe_handle_pmi: max freq=%d\n", pmi_frequency_limit); } static int pmi_notifier(struct notifier_block *nb, unsigned long event, void *data) { struct cpufreq_policy *policy = data; if (event != CPUFREQ_INCOMPATIBLE) return 0; cpufreq_verify_within_limits(policy, 0, pmi_frequency_limit); return 0; } static struct notifier_block pmi_notifier_block = { .notifier_call = pmi_notifier, }; static struct pmi_handler cbe_pmi_handler = { .type = PMI_TYPE_FREQ_CHANGE, .handle_pmi_message = cbe_cpufreq_handle_pmi, }; /* * cpufreq functions */ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) { const u32 *max_freqp; u32 max_freq; int i, cur_pmode; struct device_node *cpu; cpu = of_get_cpu_node(policy->cpu, NULL); if (!cpu) return -ENODEV; pr_debug("init cpufreq on CPU %d\n", policy->cpu); max_freqp = of_get_property(cpu, "clock-frequency", NULL); if (!max_freqp) return -EINVAL; /* we need the freq in kHz */ max_freq = *max_freqp / 1000; pr_debug("max clock-frequency is at %u kHz\n", max_freq); pr_debug("initializing frequency table\n"); /* initialize frequency table */ for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index; pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); } policy->governor = CPUFREQ_DEFAULT_GOVERNOR; /* if DEBUG is enabled set_pmode() measures the correct latency of a transition */ policy->cpuinfo.transition_latency = 25000; cur_pmode = get_pmode(policy->cpu); pr_debug("current pmode is at %d\n",cur_pmode); policy->cur = cbe_freqs[cur_pmode].frequency; #ifdef CONFIG_SMP policy->cpus = cpu_sibling_map[policy->cpu]; #endif cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu); if (pmi_dev) { /* frequency might get limited later, initialize limit with max_freq */ pmi_frequency_limit = max_freq; cpufreq_register_notifier(&pmi_notifier_block, CPUFREQ_POLICY_NOTIFIER); } /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */ return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs); } static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy) { if (pmi_dev) cpufreq_unregister_notifier(&pmi_notifier_block, CPUFREQ_POLICY_NOTIFIER); cpufreq_frequency_table_put_attr(policy->cpu); return 0; } static int cbe_cpufreq_verify(struct cpufreq_policy *policy) { return cpufreq_frequency_table_verify(policy, cbe_freqs); } static int cbe_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { int rc; struct cpufreq_freqs freqs; int cbe_pmode_new; cpufreq_frequency_table_target(policy, cbe_freqs, target_freq, relation, &cbe_pmode_new); freqs.old = policy->cur; freqs.new = cbe_freqs[cbe_pmode_new].frequency; freqs.cpu = policy->cpu; mutex_lock(&cbe_switch_mutex); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", policy->cpu, cbe_freqs[cbe_pmode_new].frequency, cbe_freqs[cbe_pmode_new].index); rc = set_pmode(policy->cpu, cbe_pmode_new); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); mutex_unlock(&cbe_switch_mutex); return rc; } static struct cpufreq_driver cbe_cpufreq_driver = { .verify = cbe_cpufreq_verify, .target = cbe_cpufreq_target, .init = cbe_cpufreq_cpu_init, .exit = cbe_cpufreq_cpu_exit, .name = "cbe-cpufreq", .owner = THIS_MODULE, .flags = CPUFREQ_CONST_LOOPS, }; /* * module init and destoy */ static int __init cbe_cpufreq_init(void) { #ifdef CONFIG_PPC_PMI struct device_node *np; #endif if (!machine_is(cell)) return -ENODEV; #ifdef CONFIG_PPC_PMI np = of_find_node_by_type(NULL, "ibm,pmi"); pmi_dev = of_find_device_by_node(np); if (pmi_dev) pmi_register_handler(pmi_dev, &cbe_pmi_handler); #endif return cpufreq_register_driver(&cbe_cpufreq_driver); } static void __exit cbe_cpufreq_exit(void) { #ifdef CONFIG_PPC_PMI if (pmi_dev) pmi_unregister_handler(pmi_dev, &cbe_pmi_handler); #endif cpufreq_unregister_driver(&cbe_cpufreq_driver); } module_init(cbe_cpufreq_init); module_exit(cbe_cpufreq_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
23.955432
86
0.742326
e2f6df3e82a1b266be5a3719ea79f138a9dc3490
2,961
h
C
src/config/keymap.h
kittipong-y/bmk-sdk
c36c032747f84ed792415ad5d4fa223b6f71991e
[ "MIT" ]
6
2018-12-25T04:33:02.000Z
2020-06-02T08:54:55.000Z
src/config/keymap.h
casktura/bmk-sdk
c36c032747f84ed792415ad5d4fa223b6f71991e
[ "MIT" ]
null
null
null
src/config/keymap.h
casktura/bmk-sdk
c36c032747f84ed792415ad5d4fa223b6f71991e
[ "MIT" ]
3
2019-01-20T16:38:53.000Z
2019-09-19T03:53:57.000Z
#ifndef _KEYMAP_H_ #define _KEYMAP_H_ #include <stdint.h> #include "../keycodes.h" #include "keyboard.h" const uint32_t KEYMAP[][MATRIX_COL_NUM * MATRIX_ROW_NUM * 2] = { [_BS] = { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_ESC, XXXXXXX, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_WNLK, XXXXXXX, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, XXXXXXX, KC_DEL, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT, KC_ESC, KC_L4, KC_LGUI, KC_LALT, KC_L1, KC_SPC, XXXXXXX, XXXXXXX, KC_RSFT, KC_L2, KC_RALT, KC_RGUI, KC_DEL, XXXXXXX }, [_L1] = { KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, XXXXXXX, XXXXXXX, KC_CIRC, KC_AMPR, KC_ASTR, KC_MINS, KC_EQL, KC_PIPE, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, XXXXXXX, XXXXXXX, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, _______, _______, _______, KC_LCBR, KC_LBRC, KC_LPRN, _______, _______, KC_RPRN, KC_RBRC, KC_RCBR, KC_UNDS, KC_PLUS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_L3, _______, _______, _______, _______ }, [_L2] = { KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, _______, KC_PGUP, KC_PGDN, KC_HOME, KC_END, KC_INS , KC_DEL, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_PSCR, KC_PAUS, _______, _______, _______, _______, _______, _______, _______, _______, KC_PRWD, KC_NXWD, _______, _______, _______, KC_SLCK, _______, _______, _______, _______, KC_L3, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, [_L3] = { _______, _______, _______, _______, _______, _______, _______, _______, KC_PAST, KC_P7, KC_P8, KC_P9, KC_PMNS, KC_NLCK, KC_CAPS, _______, _______, _______, _______, _______, _______, _______, KC_PSLS, KC_P4, KC_P5, KC_P6, KC_PPLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P0, KC_P1, KC_P2, KC_P3, KC_PDOT, KC_PENT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, [_L4] = { KC_VOLU, KC_BRIU, _______, _______, KC_DVCN, KC_DVC1, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_BRID, _______, _______, _______, KC_DVC2, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, _______, _______, KC_DVC3, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ } }; #endif
68.860465
133
0.651469
9f7d8a6bbf0b8d6e6c83e505c759851b09dd2d97
13,457
h
C
libtensor/gen_block_tensor/impl/gen_bto_contract2_clst_builder_impl.h
maxscheurer/libtensor
288ed0596b24356d187d2fa40c05b0dacd00b413
[ "BSL-1.0" ]
33
2016-02-08T06:05:17.000Z
2021-11-17T01:23:11.000Z
libtensor/gen_block_tensor/impl/gen_bto_contract2_clst_builder_impl.h
maxscheurer/libtensor
288ed0596b24356d187d2fa40c05b0dacd00b413
[ "BSL-1.0" ]
11
2020-12-04T20:26:12.000Z
2021-12-03T08:07:09.000Z
libtensor/gen_block_tensor/impl/gen_bto_contract2_clst_builder_impl.h
maxscheurer/libtensor
288ed0596b24356d187d2fa40c05b0dacd00b413
[ "BSL-1.0" ]
12
2016-05-19T18:09:38.000Z
2021-02-24T17:35:21.000Z
#ifndef LIBTENSOR_GEN_BTO_CONTRACT2_CLST_BUILDER_IMPL_H #define LIBTENSOR_GEN_BTO_CONTRACT2_CLST_BUILDER_IMPL_H #include <cstring> #include <libutil/threads/tls.h> #include <libtensor/core/abs_index.h> #include <libtensor/core/orbit.h> #include <libtensor/core/orbit_list.h> #include <libtensor/gen_block_tensor/gen_block_tensor_ctrl.h> #include "gen_bto_contract2_clst_builder.h" namespace libtensor { class gen_bto_contract2_clst_builder_buffer { private: std::vector<char> m_v; public: static std::vector<char> &get_v() { return libutil::tls<gen_bto_contract2_clst_builder_buffer>:: get_instance().get().m_v; } }; template<size_t N, size_t M, size_t K, typename Traits> const char *gen_bto_contract2_clst_builder<N, M, K, Traits>::k_clazz = "gen_bto_contract2_clst_builder<N, M, K, Traits>"; template<size_t N, size_t M, typename Traits> const char *gen_bto_contract2_clst_builder<N, M, 0, Traits>::k_clazz = "gen_bto_contract2_clst_builder<N, M, 0, Traits>"; template<size_t N, size_t M, size_t K, typename Traits> gen_bto_contract2_clst_builder<N, M, K, Traits>::gen_bto_contract2_clst_builder( const contraction2<N, M, K> &contr, const symmetry<NA, element_type> &syma, const symmetry<NB, element_type> &symb, const block_list<NA> &blka, const block_list<NB> &blkb, const dimensions<NC> &bidimsc, const index<NC> &ic) : gen_bto_contract2_clst_builder_base<N, M, K, Traits>(contr), m_syma(syma), m_symb(symb), m_blka(blka), m_blkb(blkb), m_bidimsc(bidimsc), m_ic(ic) { } template<size_t N, size_t M, typename Traits> gen_bto_contract2_clst_builder<N, M, 0, Traits>::gen_bto_contract2_clst_builder( const contraction2<N, M, 0> &contr, const symmetry<NA, element_type> &syma, const symmetry<NB, element_type> &symb, const block_list<NA> &blka, const block_list<NB> &blkb, const dimensions<NC> &bidimsc, const index<NC> &ic) : gen_bto_contract2_clst_builder_base<N, M, 0, Traits>(contr), m_syma(syma), m_symb(symb), m_blka(blka), m_blkb(blkb), m_bidimsc(bidimsc), m_ic(ic) { } template<size_t N, size_t M, size_t K, typename Traits> void gen_bto_contract2_clst_builder<N, M, K, Traits>::build_list( bool testzero) { // For a specified block in the result block tensor (C), // this algorithm makes a list of contractions of the blocks // from A and B that need to be made. // (The abbreviated version of the algorithm, which terminates // as soon as it is clear that at least one contraction is required // and therefore the block in C is non-zero.) const sequence<NA + NB + NC, size_t> &conn = get_contr().get_conn(); const dimensions<NA> &bidimsa = m_blka.get_dims(); const dimensions<NB> &bidimsb = m_blkb.get_dims(); index<K> ik1, ik2; for(size_t i = 0, j = 0; i < NA; i++) { if(conn[NC + i] > NC) { ik2[j++] = bidimsa[i] - 1; } } dimensions<K> bidimsk(index_range<K>(ik1, ik2)); size_t nk = bidimsk.get_size(); std::vector<char> &chk = gen_bto_contract2_clst_builder_buffer::get_v(); chk.resize(nk, 0); ::memset(&chk[0], 1, nk); size_t aik = 0; const char *p0 = &chk[0]; while(aik < nk) { const char *p = (const char*)::memchr(p0 + aik, 1, nk - aik); if(p == 0) break; aik = p - p0; index<NA> ia; index<NB> ib; const index<NC> &ic = m_ic; index<K> ik; abs_index<K>::get_index(aik, bidimsk, ik); sequence<K, size_t> ka(0), kb(0); // Determine ia, ib from ic, ik for(size_t i = 0, j = 0; i < NA; i++) { if(conn[NC + i] < NC) { ia[i] = ic[conn[NC + i]]; } else { ka[j] = i; kb[j] = conn[NC + i] - 2 * N - M - K; ia[ka[j]] = ib[kb[j]] = ik[j]; j++; } } for(size_t i = 0; i < NB; i++) { if(conn[2 * N + M + K + i] < N + M) { ib[i] = ic[conn[2 * N + M + K + i]]; } } size_t aia = abs_index<NA>::get_abs_index(ia, bidimsa); size_t aib = abs_index<NB>::get_abs_index(ib, bidimsb); if(!m_blka.contains(aia) || !m_blkb.contains(aib)) { chk[aik] = 0; continue; } orbit<NA, element_type> oa(m_syma, ia, false); orbit<NB, element_type> ob(m_symb, ib, false); contr_list clst; // Build the list of contractions for the current orbits A, B typename orbit<NA, element_type>::iterator ja; typename orbit<NB, element_type>::iterator jb; for(ja = oa.begin(); ja != oa.end(); ++ja) for(jb = ob.begin(); jb != ob.end(); ++jb) { index<NA> ia1; index<NB> ib1; abs_index<NA>::get_index(oa.get_abs_index(ja), bidimsa, ia1); abs_index<NB>::get_index(ob.get_abs_index(jb), bidimsb, ib1); index<NC> ic1; index<K> ika, ikb; for(size_t i = 0; i < K; i++) { ika[i] = ia1[ka[i]]; ikb[i] = ib1[kb[i]]; } if(!ika.equals(ikb)) continue; for(size_t i = 0; i < N + M; i++) { if(conn[i] >= 2 * N + M + K) { ic1[i] = ib1[conn[i] - 2 * N - M - K]; } else { ic1[i] = ia1[conn[i] - N - M]; } } if(!ic1.equals(ic)) continue; clst.push_back(contr_pair( oa.get_abs_index(ja), oa.get_acindex(), oa.get_transf(ja), ob.get_abs_index(jb), ob.get_acindex(), ob.get_transf(jb))); chk[abs_index<K>::get_abs_index(ika, bidimsk)] = 0; } coalesce(clst); bool clst_empty = clst.empty(); merge(clst); // This empties clst // In the abbreviated version of the algorithm, if the list is // not empty, there is no need to continue: the block is non-zero if(testzero && !clst_empty) break; } } template<size_t N, size_t M, size_t K, typename Traits> void gen_bto_contract2_clst_builder<N, M, K, Traits>::build_list( bool testzero, const gen_bto_contract2_block_list<N, M, K> &bl) { if(testzero == true) { build_list(true); return; } // For a specified block in the result block tensor (C), // this algorithm makes a list of contractions of the blocks // from A and B that need to be made. // (The abbreviated version of the algorithm, which terminates // as soon as it is clear that at least one contraction is required // and therefore the block in C is non-zero.) const sequence<NA + NB + NC, size_t> &conn = get_contr().get_conn(); const dimensions<NA> &bidimsa = m_blka.get_dims(); const dimensions<NB> &bidimsb = m_blkb.get_dims(); const index<NC> &ic = m_ic; sequence<N, size_t> mapai; sequence<M, size_t> mapbj; sequence<K, size_t> mapak, mapbk; index<N> ii1, ii2, ii; index<M> ij1, ij2, ij; index<K> ik1, ik2, ik; for(size_t i = 0, j = 0; i < NA; i++) { if(conn[NC + i] < NC) { mapai[j] = i; ii2[j] = bidimsa[i] - 1; ii[j] = ic[conn[NC + i]]; j++; } } for(size_t i = 0, j = 0; i < NB; i++) { if(conn[NC + NA + i] < NC) { mapbj[j] = i; ij2[j] = bidimsb[i] - 1; ij[j] = ic[conn[NC + NA + i]]; j++; } } for(size_t i = 0, k = 0; i < NA; i++) { if(conn[NC + i] >= NC + NA) { mapak[k] = i; mapbk[k] = conn[NC + i] - NC - NA; ik2[k] = bidimsa[i] - 1; k++; } } dimensions<N> dimsi(index_range<N>(ii1, ii2)); dimensions<M> dimsj(index_range<M>(ij1, ij2)); dimensions<K> dimsk(index_range<K>(ik1, ik2)); size_t aii = abs_index<N>::get_abs_index(ii, dimsi); size_t aij = abs_index<M>::get_abs_index(ij, dimsj); size_t aik = 0; const std::vector< index<2> > &bla = bl.get_blsta_2(); const std::vector< index<2> > &blb = bl.get_blstb_2(); index<2> i2; i2[0] = aik; i2[1] = aii; typename std::vector< index<2> >::const_iterator ibla_beg = std::lower_bound(bla.begin(), bla.end(), i2, gen_bto_contract2_block_list_less_2()); i2[0] = aik; i2[1] = aii + 1; typename std::vector< index<2> >::const_iterator ibla_end = std::lower_bound(ibla_beg, bla.end(), i2, gen_bto_contract2_block_list_less_2()); i2[0] = aik; i2[1] = aij; typename std::vector< index<2> >::const_iterator iblb_beg = std::lower_bound(blb.begin(), blb.end(), i2, gen_bto_contract2_block_list_less_2()); i2[0] = aik; i2[1] = aij + 1; typename std::vector< index<2> >::const_iterator iblb_end = std::lower_bound(iblb_beg, blb.end(), i2, gen_bto_contract2_block_list_less_2()); typename std::vector< index<2> >::const_iterator ibla; typename std::vector< index<2> >::const_iterator iblb; for(ibla = ibla_beg; ibla != ibla_end; ++ibla) { index<N> iii; index<K> iik; abs_index<K>::get_index(ibla->at(0), dimsk, iik); if(N>0) abs_index<N>::get_index(ibla->at(1), dimsi, iii); } for(iblb = iblb_beg; iblb != iblb_end; ++iblb) { index<M> iij; index<K> iik; abs_index<K>::get_index(iblb->at(0), dimsk, iik); if(M>0) abs_index<M>::get_index(iblb->at(1), dimsj, iij); } index<NA> ia; index<NB> ib; contr_list clst; ibla = ibla_beg; iblb = iblb_beg; while(true) { while(ibla != ibla_end && iblb != iblb_end && ibla->at(0) != iblb->at(0)) { while(ibla != ibla_end && ibla->at(0) < iblb->at(0)) ++ibla; while(ibla != ibla_end && iblb != iblb_end && iblb->at(0) < ibla->at(0)) ++iblb; } if(ibla == ibla_end || iblb == iblb_end) break; aik = ibla->at(0); abs_index<K>::get_index(aik, dimsk, ik); for(size_t i = 0; i != N; i++) ia[mapai[i]] = ii[i]; for(size_t i = 0; i != M; i++) ib[mapbj[i]] = ij[i]; for(size_t i = 0; i != K; i++) ia[mapak[i]] = ib[mapbk[i]] = ik[i]; size_t aia = abs_index<NA>::get_abs_index(ia, bidimsa); size_t aib = abs_index<NB>::get_abs_index(ib, bidimsb); orbit<NA, element_type> oa(m_syma, ia, false); orbit<NB, element_type> ob(m_symb, ib, false); clst.push_back(contr_pair( aia, oa.get_acindex(), oa.get_transf(aia), aib, ob.get_acindex(), ob.get_transf(aib))); ++ibla; ++iblb; } coalesce(clst); merge(clst); // This empties clst } template<size_t N, size_t M, typename Traits> void gen_bto_contract2_clst_builder<N, M, 0, Traits>::build_list( bool testzero) { // For a specified block in the result block tensor (C), // this algorithm makes a list of contractions of the blocks // from A and B that need to be made. // (The abbreviated version of the algorithm, which terminates // as soon as it is clear that at least one contraction is required // and therefore the block in C is non-zero.) const sequence<NA + NB + NC, size_t> &conn = get_contr().get_conn(); const dimensions<NA> &bidimsa = m_blka.get_dims(); const dimensions<NB> &bidimsb = m_blkb.get_dims(); index<N> ia; index<M> ib; const index<N + M> &ic = m_ic; // Determine ia, ib from ic for(size_t i = 0; i < N; i++) { ia[i] = ic[conn[NC + i]]; } for(size_t i = 0; i < M; i++) { ib[i] = ic[conn[NC + NA + i]]; } if(!m_blka.contains(ia) || !m_blkb.contains(ib)) return; orbit<NA, element_type> oa(m_syma, ia, false); orbit<NB, element_type> ob(m_symb, ib, false); contr_list clst; // Build the list of contractions for the current orbits A, B typename orbit<NA, element_type>::iterator ja; typename orbit<NB, element_type>::iterator jb; for(ja = oa.begin(); ja != oa.end(); ++ja) for(jb = ob.begin(); jb != ob.end(); ++jb) { index<NA> ia1; index<NB> ib1; abs_index<NA>::get_index(oa.get_abs_index(ja), bidimsa, ia1); abs_index<NB>::get_index(ob.get_abs_index(jb), bidimsb, ib1); index<NC> ic1; for(size_t i = 0; i < NC; i++) { if(conn[i] >= 2 * N + M) { ic1[i] = ib1[conn[i] - 2 * N - M]; } else { ic1[i] = ia1[conn[i] - N - M]; } } if(!ic1.equals(ic)) continue; clst.push_back(contr_pair( oa.get_abs_index(ja), oa.get_acindex(), oa.get_transf(ja), ob.get_abs_index(jb), ob.get_acindex(), ob.get_transf(jb))); } coalesce(clst); merge(clst); } template<size_t N, size_t M, size_t K, typename Traits> void gen_bto_contract2_clst_builder_base<N, M, K, Traits>::coalesce( contr_list &clst) { typedef typename Traits::template to_contract2_type<N, M, K>::clst_optimize_type coalesce_type; coalesce_type(m_contr).perform(clst); } template<size_t N, size_t M, size_t K, typename Traits> void gen_bto_contract2_clst_builder_base<N, M, K, Traits>::merge( contr_list &clst) { m_clst.splice(m_clst.end(), clst); } } // namespace libtensor #endif // LIBTENSOR_GEN_BTO_CONTRACT2_CLST_BUILDER_IMPL_H
32.742092
92
0.574199
9fa98c97db497190ccb596ac7994b23d1ac6e7ea
18
c
C
tutorials/tutorialspoint.com#c#1/functions/functions/source7.c
officialrafsan/CppDroid
5fb2cc7750fea53b1ea6ff47b5094da6e95e9224
[ "MIT" ]
null
null
null
tutorials/tutorialspoint.com#c#1/functions/functions/source7.c
officialrafsan/CppDroid
5fb2cc7750fea53b1ea6ff47b5094da6e95e9224
[ "MIT" ]
null
null
null
tutorials/tutorialspoint.com#c#1/functions/functions/source7.c
officialrafsan/CppDroid
5fb2cc7750fea53b1ea6ff47b5094da6e95e9224
[ "MIT" ]
null
null
null
Max value is : 200
18
18
0.722222
f933a2241bd2d2c6fddaad4974337cab643db8d3
121
h
C
Strategy/iwalk.h
Notidman/DesignPatterns
85f51dccde0f435b8837a6e985f16bbbe6165317
[ "MIT" ]
null
null
null
Strategy/iwalk.h
Notidman/DesignPatterns
85f51dccde0f435b8837a6e985f16bbbe6165317
[ "MIT" ]
1
2022-02-02T13:09:27.000Z
2022-02-02T13:09:27.000Z
Strategy/iwalk.h
Notidman/DesignPatterns
85f51dccde0f435b8837a6e985f16bbbe6165317
[ "MIT" ]
null
null
null
#ifndef IWALK_H #define IWALK_H class Iwalk { public: Iwalk(); virtual void walk() = 0; }; #endif // IWALK_H
9.307692
28
0.619835
b236f1d25f168dab981d43a0cb882f6f7f17d8ec
1,692
h
C
released_plugins/v3d_plugins/cellseg_gvf/src/FL_accessory.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
1
2021-12-27T19:14:03.000Z
2021-12-27T19:14:03.000Z
released_plugins/v3d_plugins/cellseg_gvf/src/FL_accessory.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
1
2016-12-03T05:33:13.000Z
2016-12-03T05:33:13.000Z
released_plugins/v3d_plugins/cellseg_gvf/src/FL_accessory.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
null
null
null
// accessory functions for get info from image matrix // F. Long // 20080510 #ifndef __FL_ACCESSORY__ #define __FL_ACCESSORY__ #include "FL_defType.h" // Convert from linear index to array coordinates. template <class T> void ind_to_sub(V3DLONG p, T in_num_dims, V3DLONG *cumprod, V3DLONG *coords) { int j; for (j = (int)in_num_dims-1; j >= 0; j--) { coords[j] = p / cumprod[j]; p = p % cumprod[j]; } } // Convert from array coordinates to zero-based linear index. template <class T> V3DLONG sub_to_ind(V3DLONG *coords, V3DLONG *cumprod, T in_num_dims) { V3DLONG index = 0; int k; for (k = 0; k < int(in_num_dims); k++) { index += coords[k] * cumprod[k]; } return index; } // Compute linear relative offset when given relative array offsets. template <class T> V3DLONG sub_to_relative_ind(V3DLONG *coords, T in_num_dims) { int N; int P; int abs_coord; V3DLONG cumprod = 1; int index = 0; int k; // Find the maximum absolute neighbor offset. N = 0; for (k = 0; k < int(in_num_dims); k++) { abs_coord = coords[k] > 0 ? coords[k] : -coords[k]; if (abs_coord > N) { N = abs_coord; } } P = 2*N + 1; // Perform sub_to_ind computation. for (k = 0; k < int(in_num_dims); k++) { index += coords[k] * cumprod; cumprod *= P; } return index; } // Count nonzero elements template <class T> V3DLONG num_nonzeros(const T *D, const V3DLONG num_elements) { int p; V3DLONG count = 0; for (p = 0; p < num_elements; p++) { if (D[p]) count++; } return count; } #endif
19.905882
95
0.585106
58df3b90bdf745feb37cea028762222a58db14f8
484
h
C
PrivateFrameworks/iWorkImport.framework/_TSUImageM.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/iWorkImport.framework/_TSUImageM.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/iWorkImport.framework/_TSUImageM.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/TSUtility.framework/TSUtility */ @interface _TSUImageM : TSUImage + (id)allocWithZone:(struct _NSZone { }*)arg1; + (id)init; + (id)initWithCGImage:(struct CGImage { }*)arg1; + (id)initWithCGImage:(struct CGImage { }*)arg1 scale:(double)arg2 orientation:(long long)arg3; + (id)initWithContentsOfFile:(id)arg1; + (id)initWithData:(id)arg1; + (id)initWithImageSourceRef:(struct CGImageSource { }*)arg1; @end
30.25
95
0.739669
2511e0875aecb794ac6d5984de5fec53f5c8659b
4,071
h
C
blinky/sam0/drivers/system/power/quick_start/qs_power.h
femtoio/femtousb-blink-example
5e166bdee500f67142d0ee83a1a169bab57fe142
[ "MIT" ]
50
2017-01-26T14:00:34.000Z
2022-01-03T01:19:59.000Z
blinky/sam0/drivers/system/power/quick_start/qs_power.h
femtoio/femtousb-blink-example
5e166bdee500f67142d0ee83a1a169bab57fe142
[ "MIT" ]
2
2017-02-23T01:51:57.000Z
2021-07-27T23:19:49.000Z
examples/sam-r21-blink/sam0/drivers/system/power/quick_start/qs_power.h
Surfndez/femto-beacon
13f82b86f33bb6cf7d107b8f77388a4a7c2d6f92
[ "MIT" ]
13
2017-02-22T22:59:12.000Z
2022-01-03T01:20:04.000Z
/** * \file * * \brief SAM Power Driver Quick Start * * Copyright (C) 2014 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * 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. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * \asf_license_stop * */ /** \page asfdoc_sam0_power_basic_use_case Quick Start Guide for Power Driver * * The supported board list: * - SAM L21 Xplained Pro * * This example demonstrates how to use the power driver. BUTTON0 is used to * wake up system from standby mode and as an external wake up * pin to wake up system from BACKUP mode. The wakeup pin level is low. * PB22/PB23 are used as GCLK0/GCLK1 output pin, oscilloscope can be used to * monitor their clock frequency. * * After POR, LED0 is ON and GCLK0/GCLK1 are running at 4MHz, after one second, * LED0 becomes OFF and system enters standby mode. BUTTON0 can be used to wake up * system. After system wake up, LED0 becomes ON and performance level switch to PL2, * GCLK0 is running at 48MHz, GCLK1 is running at 4MHz. Then LED0 toggles * two times and becomes OFF, system enters BACKUP mode. * * When PA04 is connected to low level, system wakes up from BACKUP mode, LED0 * toggles four times. GCLK0/GCLK1 are running at 4MHz. * * \section asfdoc_sam0_power_basic_use_case_setup Quick Start * * \subsection asfdoc_sam0_power_basic_use_case_prereq Prerequisites * There are no prerequisites for this use case. * * \subsection asfdoc_sam0_power_basic_use_case_setup_code Code * * Copy-paste the following setup code to your user application: * \snippet quick_start/qs_power.c setup * * \subsection asfdoc_sam0_power_basic_use_case_setup_flow Workflow * -# Switch performance level to PL2. * \snippet quick_start/qs_power.c switch_pl * * -# Configure GCLK0/GCLK1 output pin and extwakeup pin. * \snippet quick_start/qs_power.c pin_mux * * -# Config external interrupt. * \snippet quick_start/qs_power.c config_extint * * \section asfdoc_sam0_power_basic_use_case_main Use Case * * \subsection asfdoc_sam0_power_basic_use_case_main_code Code * Copy-paste the following code to your user application: * \snippet quick_start/qs_power.c setup_init * * \subsection asfdoc_sam0_power_basic_use_case_main_flow Workflow * -# Check if the RESET is caused by external wakeup pin. * \snippet quick_start/qs_power.c ext_wakeup * -# Check STANDBY mode and BACKUP mode. * \snippet quick_start/qs_power.c backup_stanby_mode */ /** * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */
41.121212
90
0.757308
0f883a70bf8a71becbc04884281938e44fd63c16
3,313
h
C
gpio/gpio-arm-timer.h
scinext/raspberry-pi-c-gpio-example
1e42ba620259a32950954b19e9ac8bd5827876f4
[ "Zlib" ]
null
null
null
gpio/gpio-arm-timer.h
scinext/raspberry-pi-c-gpio-example
1e42ba620259a32950954b19e9ac8bd5827876f4
[ "Zlib" ]
null
null
null
gpio/gpio-arm-timer.h
scinext/raspberry-pi-c-gpio-example
1e42ba620259a32950954b19e9ac8bd5827876f4
[ "Zlib" ]
null
null
null
#ifndef GPIO_ARM_TIMER_H #define GPIO_ARM_TIMER_H #include "gpio.h" //#define ARM_TIMER_DEBUG #if defined(ARM_TIMER_DEBUG) || defined(GPIO_DEBUG) #define ArmTimerDprintf printf #else #define ArmTimerDprintf #endif /* datasheet p196 */ #define ARM_TIMER_BASE ( BCM2708_PERI_BASE + 0x0000B000) //=0x7E00 B000 #define ARM_TIMER_LOAD 0x0400/sizeof(uint32_t) //Timer Load register #define ARM_TIMER_VALUE 0x0404/sizeof(uint32_t) //Timer Value register Read Only #define ARM_TIMER_C 0x0408/sizeof(uint32_t) //Control #define ARM_TIMER_IRQ 0x040C/sizeof(uint32_t) //IRQ Clear/Ack Write only #define ARM_TIMER_RAW_IRQ 0x0410/sizeof(uint32_t) //Raw IRQ Read Only #define ARM_TIMER_MASK_IRQ 0x0414/sizeof(uint32_t) //Masked IRQRead Only #define ARM_TIMER_RELOAD 0x0418/sizeof(uint32_t) //Reload #define ARM_TIMER_DIVIDER 0x041C/sizeof(uint32_t) //Pre divider #define ARM_TIMER_COUNTER 0x0420/sizeof(uint32_t) //Free running counter //Load Register //ここに値を入れると自動でカウントダウンが始まる? //Value Register //Load registerに入れられた値からスタートした現在のカウントダウンされたタイマ値が入っている? //Control register 24-31 unused, 10-15 unused, 4 unused #define ARM_TIMER_C_REGISTER_FREE_SCALER 16 //フリーカウンタのスケール?( Freq= sys_clk/scale+1 ) #define ARM_TIMER_C_FREE_SCALER_USE_BIT 8 typedef enum _ArmTimerRes{ ARM_TIMER_DEFAULT = 0, //通常の分解能のタイマ(divider=249 -> 1/(250/(249+1)) -> 1ms ARM_TIMER_HI_RES = 1 //高性能の分解能のタイマ(divider=24 -> 1/(250/(24+1)) -> 0.1ms } ArmTimerRes; #define ARM_TIMER_C_REGISTER_FREE 9 //フリーカウンタの有効 0->Disable 1->Enable #define ARM_TIMER_C_REGISTER_HALT 8 //debug halted modeの時の動き 0->keep 1->halt #define ARM_TIMER_C_REGISTER_ACTIVE 7 //タイマの有効 0->Disable 1->Enable #define ARM_TIMER_C_REGISTER_MODE 6 //not use, runningモードの設定だが常にフリーモードらしい #define ARM_TIMER_C_REGISTER_INT 5 //タイマー割り込みの有効 0->Disable 1->Enable #define ARM_TIMER_C_REGISTER_SCALE 3 //pre-scale #define ARM_TIMER_C_SCALE_USE_BIT 2 typedef enum _ArmTimerScale{ ARM_TIMER_SCALE_NO=0x00, //bin 0000 no pre scale ARM_TIMER_SCALE_16=0x01, //bin 0001 clock / 16 ARM_TIMER_SCALE_256=0x02, //bin 0010 clock / 256 ARM_TIMER_SCALE_1_2=0x03, //bin 0011 clock / 1(SP804ではない機能) } ArmTimerScale; #define ARM_TIMER_C_REGISTER_BITS 1 //カウンタのbit数 0->16bit 1->23bit #define ARM_TIMER_C_REGISTER_WRAP 0 //not use, wrappin modeの設定常にwrapping modeらしい //Raw IRQ register 1-31 unused Read only #define ARM_TIMER_RAW_IRQ_REGISTER_PEND 0 //保留の割り込みがあるかどうか //Masked IRQ 1-31 unused Read only #define ARM_TIMER_MASK_REGISTER_IRQ 0 //割り込みラインが有効かどうか? //Timer Reload //Loadレジスタのコピー、通常ここには書き込まない?、valueレジスタのカウントが0になるとここが読み込まれる //pre-divider 10-31 unused #define ARM_TIMER_DIVIDER_REGISTER_VALUE 0 // clock = apb_clock /(pre divider+1) 0x7Dのときは126になる #define ARM_TIMER_DIVIDER_USE_BIT 9 //Free running counter 0-31 data void DelayArmTimerCounter(unsigned int delayCount); unsigned int GetArmTimer(); unsigned int ArmTimerSetFreeScale(unsigned int divider); void PrintArmTimerRegister(); void PrintArmTimerCounter(); int InitArmTimer(ArmTimerRes res); int UnInitArmTimer(); #ifdef ARM_TIMER_DEBUG void ArmTimerPrecisionTest(); #endif #endif
39.915663
101
0.742529
db73e805a9f220fa0b94fb583ddd0af4f0081190
370
h
C
ios/versioned-react-native/ABI33_0_0/Libraries/ART/ViewManagers/ABI33_0_0ARTRenderableManager.h
Jinksi/expo
9f9c25037d89f9cd7b64cba6328edc32330f669b
[ "Apache-2.0", "MIT" ]
2
2020-01-02T06:07:18.000Z
2021-09-30T11:09:41.000Z
ios/versioned-react-native/ABI33_0_0/Libraries/ART/ViewManagers/ABI33_0_0ARTRenderableManager.h
Jinksi/expo
9f9c25037d89f9cd7b64cba6328edc32330f669b
[ "Apache-2.0", "MIT" ]
19
2020-04-07T07:36:24.000Z
2022-03-26T09:32:12.000Z
ios/versioned-react-native/ABI33_0_0/Libraries/ART/ViewManagers/ABI33_0_0ARTRenderableManager.h
Jinksi/expo
9f9c25037d89f9cd7b64cba6328edc32330f669b
[ "Apache-2.0", "MIT" ]
2
2019-02-22T08:41:09.000Z
2019-02-22T08:47:56.000Z
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "ABI33_0_0ARTNodeManager.h" #import "ABI33_0_0ARTRenderable.h" @interface ABI33_0_0ARTRenderableManager : ABI33_0_0ARTNodeManager - (ABI33_0_0ARTRenderable *)node; @end
23.125
66
0.764865
c52b2686aeec8a1c60e0f6fc51597909ba634907
2,647
c
C
ft_printf/test/test.c
artacone/ft_printf
0497aeb37ab61e637b7068bfb2f7feae48bde564
[ "MIT" ]
null
null
null
ft_printf/test/test.c
artacone/ft_printf
0497aeb37ab61e637b7068bfb2f7feae48bde564
[ "MIT" ]
null
null
null
ft_printf/test/test.c
artacone/ft_printf
0497aeb37ab61e637b7068bfb2f7feae48bde564
[ "MIT" ]
null
null
null
#include "../includes/ft_printf.h" #include <stdio.h> #include <stdlib.h> int main() { // char str[] = "Hello, world!"; int n = -4221; // char c = 'A'; int *ptr = &n; // int X = 0x1234FA; int x = 0x1B; // ft_printf("%d\n", n); // ft_printf("%0#10c\n", c); // ft_printf("%s\n", str); // ft_printf("%p\n", ptr); // ft_printf("%X\n", X); // ft_printf("%%\n"); // ft_printf("%%%%%%\nThe number is: %d\nThe char is: %c\nThe message is: %s\n", n, c, str); // ft_printf("Floats: |%4.2f|%4.3f|%4.1f|%4.0f|%4f|\n", 3.141592, 3.141592, 3.141592, 3.141592, 3.141592); // // ft_printf("Characters: %c %c \n", 'a', 65); // ft_printf("Decimals: %d %ld\n", 1977, 650000L); // ft_printf("Preceding with blanks: %10d \n", 1977); // ft_printf("Preceding with zeros: %010d \n", 1977); // ft_printf("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100); // ft_printf("floats: %4.2f %+.0e \n", 3.1416, 3.1416); // ft_printf("Width trick: %*d \n", 5, 10); // ft_printf("%s \n", "A string"); // printf("printf|%-8.5d|\n", 34); // ft_printf("fprint|%-8.5d|\n", 34); // // printf("printf|%8.5d|\n", 34); // ft_printf("fprint|%8.5d|\n", 34); // PRINT(" --- Return : %d\n", PRINT("%-00000-----*i, %---0.*d, %0-0-0-0-0.*d, %-0-0-0-0-.*d, %-----.*d", a, i, a, i, a, i, a, i, a, i)); // PRINT(" --- Return : %d\n", PRINT("%-00000-----*i, %---0.*d, %0-0-0-0-0.*d, %-0-0-0-0-.*d, %-----.*d", a, j, a, j, a, j, a, j, a, j)); // PRINT(" --- Return : %d\n", PRINT("%-00000-----*i, %---0.*d, %0-0-0-0-0.*d, %-0-0-0-0-.*d, %-----.*d", a, l, a, l, a, l, a, l, a, l)); // printf("%#"); // printf("\n"); // ft_printf("fprint|%#"); // printf("\n"); // // printf("printf|% *.5i|\n", 4, 42); // ft_printf("fprint|% *.5i|\n", 4, 42); // printf("printf|%0-00000-----*i|\n", 12, 8); // ft_printf("fprint|%0-00000-----*i|\n", 12, 8); // printf("printf|%05i|\n", -54); // ft_printf("fprint|%05i|\n", -54); // // printf("printf|%0*i|\n", -7, -54); // ft_printf("fprint|%0*i|\n", -7, -54); // // printf("printf|%0*i|\n", -7, 54); // ft_printf("fprint|%0*i|\n", -7, 54); // // printf("printf|%.*s|\n", 0, "hello"); // ft_printf("fprint|%.*s|\n", 0, "hello"); // printf("printf|%.1f|\n", 3.85); // ft_printf("fprint|%.1f|\n", 3.85); // printf("printf|%.1f|\n", -3.95); // ft_printf("fprint|%.1f|\n", -3.95); // printf("printf|%.3f|\n", -3.9995); // ft_printf("fprint|%.3f|\n", -3.9995); printf("-->|%-12p|<--\n", ptr); ft_printf("-->|%-12p|<--\n", ptr); printf("-->|%#-2x|<--\n", x); ft_printf("-->|%#-2x|<--\n", x); printf("-->|%2d|<--\n", 123); ft_printf("-->|%#-2x|<--\n", x); printf("-->|%#04x|<--\n", x); ft_printf("-->|%#04x|<--\n", x); return (0); }
32.679012
137
0.490744
41211534079fa02129d572f0364e8d4a65fc5d88
2,872
h
C
src/braft/cli_service.h
MozartWang/braft
32c3080b002217205158701b91b129656f04b4e3
[ "Apache-2.0" ]
1,844
2017-09-20T06:35:49.000Z
2019-12-09T12:30:42.000Z
src/braft/cli_service.h
MozartWang/braft
32c3080b002217205158701b91b129656f04b4e3
[ "Apache-2.0" ]
146
2019-12-11T06:48:10.000Z
2022-03-14T04:08:42.000Z
src/braft/cli_service.h
MozartWang/braft
32c3080b002217205158701b91b129656f04b4e3
[ "Apache-2.0" ]
440
2017-09-20T16:49:40.000Z
2019-12-09T08:42:03.000Z
// Copyright (c) 2018 Baidu.com, 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. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) #ifndef BRAFT_CLI_SERVICE_H #define BRAFT_CLI_SERVICE_H #include <butil/status.h> #include "braft/cli.pb.h" // CliService #include "braft/node.h" // NodeImpl namespace braft { class CliServiceImpl : public CliService { public: void add_peer(::google::protobuf::RpcController* controller, const ::braft::AddPeerRequest* request, ::braft::AddPeerResponse* response, ::google::protobuf::Closure* done); void remove_peer(::google::protobuf::RpcController* controller, const ::braft::RemovePeerRequest* request, ::braft::RemovePeerResponse* response, ::google::protobuf::Closure* done); void reset_peer(::google::protobuf::RpcController* controller, const ::braft::ResetPeerRequest* request, ::braft::ResetPeerResponse* response, ::google::protobuf::Closure* done); void snapshot(::google::protobuf::RpcController* controller, const ::braft::SnapshotRequest* request, ::braft::SnapshotResponse* response, ::google::protobuf::Closure* done); void get_leader(::google::protobuf::RpcController* controller, const ::braft::GetLeaderRequest* request, ::braft::GetLeaderResponse* response, ::google::protobuf::Closure* done); void change_peers(::google::protobuf::RpcController* controller, const ::braft::ChangePeersRequest* request, ::braft::ChangePeersResponse* response, ::google::protobuf::Closure* done); void transfer_leader(::google::protobuf::RpcController* controller, const ::braft::TransferLeaderRequest* request, ::braft::TransferLeaderResponse* response, ::google::protobuf::Closure* done); private: butil::Status get_node(scoped_refptr<NodeImpl>* node, const GroupId& group_id, const std::string& peer_id); }; } #endif //BRAFT_CLI_SERVICE_H
44.184615
75
0.618733
3bad05fff5d86dcf0e141b599d093f84ac5239f6
703
c
C
src/test/kc/function-pointer-return-3.c
jbrandwood/kickc
d4b68806f84f8650d51b0e3ef254e40f38b0ffad
[ "MIT" ]
2
2022-03-01T02:21:14.000Z
2022-03-01T04:33:35.000Z
src/test/kc/function-pointer-return-3.c
jbrandwood/kickc
d4b68806f84f8650d51b0e3ef254e40f38b0ffad
[ "MIT" ]
null
null
null
src/test/kc/function-pointer-return-3.c
jbrandwood/kickc
d4b68806f84f8650d51b0e3ef254e40f38b0ffad
[ "MIT" ]
null
null
null
// Calling a function pointer with return value // Calling a function pointer inside a struct without * struct Task { char param; void (*handler)(char); }; char * const RASTER = (char*)0xd012; char * const BORDER = (char*)0xd020; char * const BACKGROUND = (char*)0xd021; void set_border(char col) { *BORDER = col; } void set_bg(char col) { *BACKGROUND = col; } void run(struct Task* task) { task->handler(task->param); } struct Task tasks[] = { { 0, &set_border }, { 0, &set_bg }, { 1, &set_border }, { 2, &set_bg } }; void main() { for(;;) { for(char i=0; i < sizeof(tasks)/sizeof(struct Task); i++) { run(tasks+i); } } }
17.575
67
0.57468
22e5678dc12db2ce72c096dd86922432252a0d85
2,550
h
C
Source/KernelRunner/KernelRunner.h
Fillo7/KTT
a0c252efb75a8366450e2df589f0ae641f015312
[ "MIT" ]
32
2017-09-12T23:52:52.000Z
2020-12-09T07:13:24.000Z
Source/KernelRunner/KernelRunner.h
Fillo7/KTT
a0c252efb75a8366450e2df589f0ae641f015312
[ "MIT" ]
23
2017-05-11T14:38:45.000Z
2021-02-03T13:45:14.000Z
Source/KernelRunner/KernelRunner.h
Fillo7/KTT
a0c252efb75a8366450e2df589f0ae641f015312
[ "MIT" ]
5
2017-11-06T12:40:05.000Z
2020-06-16T13:11:24.000Z
#pragma once #include <memory> #include <Api/Configuration/KernelConfiguration.h> #include <Api/Output/BufferOutputDescriptor.h> #include <Api/Output/KernelResult.h> #include <Api/ExceptionReason.h> #include <ComputeEngine/ComputeEngine.h> #include <Kernel/Kernel.h> #include <KernelArgument/KernelArgumentManager.h> #include <KernelRunner/ComputeLayer.h> #include <KernelRunner/KernelRunMode.h> #include <KernelRunner/ResultValidator.h> #include <KttTypes.h> namespace ktt { class KernelRunner { public: explicit KernelRunner(ComputeEngine& engine, KernelArgumentManager& argumentManager); KernelResult RunKernel(const Kernel& kernel, const KernelConfiguration& configuration, const KernelRunMode mode, const std::vector<BufferOutputDescriptor>& output, const bool manageBuffers = true); void SetupBuffers(const Kernel& kernel); void CleanupBuffers(const Kernel& kernel); void DownloadBuffers(const std::vector<BufferOutputDescriptor>& output); void SetReadOnlyArgumentCache(const bool flag); void SetProfiling(const bool flag); bool IsProfilingActive() const; void SetValidationMethod(const ValidationMethod method, const double toleranceThreshold); void SetValidationMode(const ValidationMode mode); void SetValidationRange(const ArgumentId id, const size_t range); void SetValueComparator(const ArgumentId id, ValueComparator comparator); void SetReferenceComputation(const ArgumentId id, ReferenceComputation computation); void SetReferenceKernel(const ArgumentId id, const Kernel& kernel, const KernelConfiguration& configuration); void ClearReferenceResult(const Kernel& kernel); void RemoveKernelData(const KernelId id); void RemoveValidationData(const ArgumentId id); private: std::unique_ptr<ComputeLayer> m_ComputeLayer; std::unique_ptr<ResultValidator> m_Validator; ComputeEngine& m_Engine; KernelArgumentManager& m_ArgumentManager; bool m_ReadOnlyCacheFlag; bool m_ProfilingFlag; KernelLauncher GetKernelLauncher(const Kernel& kernel); KernelResult RunKernelInternal(const Kernel& kernel, const KernelConfiguration& configuration, KernelLauncher launcher, const std::vector<BufferOutputDescriptor>& output); Nanoseconds RunLauncher(KernelLauncher launcher); void PrepareValidationData(const ArgumentId id); void ValidateResult(const Kernel& kernel, KernelResult& result, const KernelRunMode mode); static ResultStatus GetStatusFromException(const ExceptionReason reason); }; } // namespace ktt
39.84375
123
0.792157
f1e022188058f854f83baca646027a1451ce0228
3,943
h
C
lib/am335x_sdk/ti/csl/soc/k2g/src/cslr_soc.h
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
2
2021-12-27T10:19:01.000Z
2022-03-15T07:09:06.000Z
lib/am335x_sdk/ti/csl/soc/k2g/src/cslr_soc.h
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
null
null
null
lib/am335x_sdk/ti/csl/soc/k2g/src/cslr_soc.h
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
null
null
null
/* * Auto-generated CSL section */ /* * * Copyright (C) 2011 - 2018 Texas Instruments Incorporated - http://www.ti.com/ * * * 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 Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* * Auto-generated CSL section * PSC Configuration V0.6 */ #include <ti/csl/cslr.h> #include <ti/csl/tistdtypes.h> #include <ti/csl/soc/k2g/src/cslr_soc_baseaddress.h> #include <ti/csl/soc/k2g/src/cslr_interrupt.h> #ifndef CSLR_SOC_DEVICE_H #define CSLR_SOC_DEVICE_H #ifdef __cplusplus extern "C" { #endif /* * Auto-generated CSL section */ #define CSL_PSC_PD_ALWAYSON 0 #define CSL_PSC_PD_DEBUG 1 #define CSL_PSC_PD_NSS 2 #define CSL_PSC_PD_SA 3 #define CSL_PSC_PD_TERANET 4 #define CSL_PSC_PD_SYS_COMP 5 #define CSL_PSC_PD_SR 6 #define CSL_PSC_PD_MSMC 7 #define CSL_PSC_PD_C66X_COREPAC_0 8 #define CSL_PSC_PD_ARM 9 #define CSL_PSC_PD_ASRC 10 #define CSL_PSC_PD_ICSS 11 #define CSL_PSC_PD_DSS 12 #define CSL_PSC_PD_PCIE 13 #define CSL_PSC_PD_USB 14 #define CSL_PSC_PD_DDR3 15 #define CSL_PSC_PD_SPARE0 16 #define CSL_PSC_PD_SPARE1 17 /* * Auto-generated CSL section */ #define CSL_PSC_LPSC_ALWAYSON 0 #define CSL_PSC_LPSC_PMMC 1 #define CSL_PSC_LPSC_DEBUG 2 #define CSL_PSC_LPSC_NSS 3 #define CSL_PSC_LPSC_SA 4 #define CSL_PSC_LPSC_TERANET 5 #define CSL_PSC_LPSC_SYS_COMP 6 #define CSL_PSC_LPSC_QSPI 7 #define CSL_PSC_LPSC_MMC 8 #define CSL_PSC_LPSC_GPMC 9 #define CSL_PSC_LPSC_MLB 11 #define CSL_PSC_LPSC_EHRPWM 12 #define CSL_PSC_LPSC_EQEP 13 #define CSL_PSC_LPSC_ECAP 14 #define CSL_PSC_LPSC_MCASP 15 #define CSL_PSC_LPSC_SR 16 #define CSL_PSC_LPSC_MSMC 17 #define CSL_PSC_LPSC_C66X_COREPAC_0 18 #define CSL_PSC_LPSC_ARM 19 #define CSL_PSC_LPSC_ASRC 20 #define CSL_PSC_LPSC_ICSS 21 #define CSL_PSC_LPSC_DSS 23 #define CSL_PSC_LPSC_PCIE 24 #define CSL_PSC_LPSC_USB_0 25 #define CSL_PSC_LPSC_USB_1 26 #define CSL_PSC_LPSC_DDR3 27 #define CSL_PSC_LPSC_SPARE0_LPSC0 28 #define CSL_PSC_LPSC_SPARE0_LPSC1 29 #define CSL_PSC_LPSC_SPARE1_LPSC0 30 #define CSL_PSC_LPSC_SPARE1_LPSC1 31 #ifndef CSL_MODIFICATION #define SOC_UART0_BASE (CSL_UART_0_REGS) #define SOC_DSP_L1P_BASE (CSL_C66X_COREPAC_LOCAL_L1P_SRAM_REGS) #define SOC_DSP_L1D_BASE (CSL_C66X_COREPAC_LOCAL_L1D_SRAM_REGS) #define SOC_DSP_L2_BASE (CSL_C66X_COREPAC_LOCAL_L2_SRAM_REGS) #define SOC_DSP_ICFG_BASE (CSL_C66X_COREPAC_REG_BASE_ADDRESS_REGS - 0x800000U) #endif #ifdef __cplusplus } #endif #endif /* CSLR_SOC_H_ */
32.319672
91
0.783667
47cca64da67a14f77a596318fc71557caad17f40
6,004
c
C
util.c
uhm0311/arcus-memcached
debf41c797e0591f1a2e56e6c1611fe18d928d55
[ "Apache-2.0", "BSD-3-Clause" ]
67
2015-03-25T05:21:04.000Z
2022-01-02T14:38:16.000Z
util.c
uhm0311/arcus-memcached
debf41c797e0591f1a2e56e6c1611fe18d928d55
[ "Apache-2.0", "BSD-3-Clause" ]
411
2015-02-24T12:36:17.000Z
2022-03-27T11:14:40.000Z
util.c
uhm0311/arcus-memcached
debf41c797e0591f1a2e56e6c1611fe18d928d55
[ "Apache-2.0", "BSD-3-Clause" ]
82
2015-01-23T13:49:19.000Z
2022-03-11T05:01:22.000Z
/* * arcus-memcached - Arcus memory cache server * Copyright 2010-2014 NAVER Corp. * Copyright 2015 JaM2in 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. */ #include "config.h" #include <stdio.h> #include <assert.h> #include <ctype.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> #include <memcached/util.h> bool safe_strtoull(const char *str, uint64_t *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; unsigned long long ull = strtoull(str, &endptr, 10); if (errno == ERANGE) return false; if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { if ((long long) ull < 0) { /* only check for negative signs in the uncommon case when * the unsigned number is so big that it's negative as a * signed number. */ if (strchr(str, '-') != NULL) { return false; } } *out = ull; return true; } return false; } bool safe_strtoll(const char *str, int64_t *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; long long ll = strtoll(str, &endptr, 10); if (errno == ERANGE) return false; if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = ll; return true; } return false; } bool safe_strtoul(const char *str, uint32_t *out) { char *endptr = NULL; unsigned long l = 0; assert(out); assert(str); *out = 0; errno = 0; l = strtoul(str, &endptr, 10); if (errno == ERANGE) { return false; } if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { if ((long) l < 0) { /* only check for negative signs in the uncommon case when * the unsigned number is so big that it's negative as a * signed number. */ if (strchr(str, '-') != NULL) { return false; } } *out = l; return true; } return false; } bool safe_strtol(const char *str, int32_t *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; long l = strtol(str, &endptr, 10); if (errno == ERANGE) return false; if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = l; return true; } return false; } bool safe_strtof(const char *str, float *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; float l = strtof(str, &endptr); if (errno == ERANGE) return false; if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = l; return true; } return false; } bool safe_strtohexa(const char *str, unsigned char *bin, const int size) { assert(bin != NULL); int slen = strlen(str); char ch1, ch2; if (slen <= 0 || slen > (2*size) || (slen%2) != 0) { return false; } for (int i=0; i < (slen/2); i++) { ch1 = str[2*i]; ch2 = str[2*i+1]; if (ch1 >= '0' && ch1 <= '9') bin[i] = (ch1 - '0'); else if (ch1 >= 'A' && ch1 <= 'F') bin[i] = (ch1 - 'A' + 10); else if (ch1 >= 'a' && ch1 <= 'f') bin[i] = (ch1 - 'a' + 10); else return false; if (ch2 >= '0' && ch2 <= '9') bin[i] = (bin[i] << 4) + (ch2 - '0'); else if (ch2 >= 'A' && ch2 <= 'F') bin[i] = (bin[i] << 4) + (ch2 - 'A' + 10); else if (ch2 >= 'a' && ch2 <= 'f') bin[i] = (bin[i] << 4) + (ch2 - 'a' + 10); else return false; } return true; } void safe_hexatostr(const unsigned char *bin, const int size, char *str) { assert(str != NULL); for (int i=0; i < size; i++) { str[(i*2) ] = (bin[i] & 0xF0) >> 4; str[(i*2)+1] = (bin[i] & 0x0F); if (str[(i*2) ] < 10) str[(i*2) ] += ('0'); else str[(i*2) ] += ('A' - 10); if (str[(i*2)+1] < 10) str[(i*2)+1] += ('0'); else str[(i*2)+1] += ('A' - 10); } str[size*2] = '\0'; } /* prefix name check */ static inline bool mc_isnamechar(int c) { return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (c == '_') || (c == '-') || (c == '+') || (c == '.')); } static inline bool mc_ishyphon(int c) { return (c == '-'); } bool mc_isvalidname(const char *str, int len) { bool valid; if (mc_ishyphon(str[0])) { return false; } valid = true; for (int i = 0; i < len; i++) { if (!mc_isnamechar(str[i])) { valid = false; break; } } return valid; } void vperror(const char *fmt, ...) { int old_errno = errno; char buf[1024]; va_list ap; va_start(ap, fmt); if (vsnprintf(buf, sizeof(buf), fmt, ap) == -1) { buf[sizeof(buf) - 1] = '\0'; } va_end(ap); errno = old_errno; perror(buf); } #ifndef HAVE_HTONLL static uint64_t mc_swap64(uint64_t in) { #ifndef WORDS_BIGENDIAN /* Little endian, flip the bytes around until someone makes a faster/better * way to do this. */ int64_t rv = 0; int i = 0; for(i = 0; i<8; i++) { rv = (rv << 8) | (in & 0xff); in >>= 8; } return rv; #else /* big-endian machines don't need byte swapping */ return in; #endif } uint64_t mc_ntohll(uint64_t val) { return mc_swap64(val); } uint64_t mc_htonll(uint64_t val) { return mc_swap64(val); } #endif
26.104348
85
0.511992
dfa0164b47fb4fa08070a82a1131f56b0c943d0d
2,413
c
C
emusrc/goombacolor/src/gbcgamedetect.c
hitsmaxft/SimpleLight
633ad61a51de6f3ad67fa772f0925f5b14b4b2c1
[ "Apache-2.0" ]
79
2019-09-16T19:41:38.000Z
2022-03-24T12:32:45.000Z
emusrc/goombacolor/src/gbcgamedetect.c
hitsmaxft/SimpleLight
633ad61a51de6f3ad67fa772f0925f5b14b4b2c1
[ "Apache-2.0" ]
15
2019-11-09T13:01:25.000Z
2021-07-21T23:33:36.000Z
emusrc/goombacolor/src/gbcgamedetect.c
hitsmaxft/SimpleLight
633ad61a51de6f3ad67fa772f0925f5b14b4b2c1
[ "Apache-2.0" ]
21
2019-11-08T01:06:14.000Z
2022-02-08T14:17:45.000Z
#include "includes.h" #ifndef ARRSIZE #define ARRSIZE(xxxx) (sizeof((xxxx))/sizeof((xxxx)[0])) #endif const u8 gameHashTable[] = { 0x71, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x15, 0x00, 0xDB, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x16, 0x00, 0x35, 0x00, 0x67, 0x00, 0x75, 0x00, 0x92, 0x00, 0x99, 0x00, 0xB7, 0x00, 0x00, 0x00, 0x28, 0x41, 0xA5, 0x41, 0xE8, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x00, 0x61, 0x45, 0x00, 0x00, 0xD3, 0x52, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x9C, 0x00, 0x00, 0x00, 0xB3, 0x55, 0x00, 0x00, 0x34, 0x00, 0x66, 0x45, 0xF4, 0x20, 0x00, 0x00, 0x3D, 0x00, 0x6A, 0x49, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x46, 0x45, 0x00, 0x00, 0x0D, 0x45, 0x00, 0x00, 0xBF, 0x20, 0x00, 0x00, 0x28, 0x46, 0x4B, 0x00, 0x90, 0x00, 0x9A, 0x00, 0xBD, 0x00, 0x00, 0x00, 0x39, 0x00, 0x43, 0x00, 0x97, 0x00, 0x00, 0x00, 0xA5, 0x52, 0x00, 0x00, 0x18, 0x49, 0x3F, 0x00, 0x66, 0x4C, 0xC6, 0x20, 0x00, 0x00, 0x95, 0x00, 0xB3, 0x52, 0x00, 0x00, 0x3E, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x0D, 0x52, 0x69, 0x00, 0xF2, 0x00, 0x00, 0x00, 0x59, 0x00, 0xC6, 0x41, 0x00, 0x00, 0x86, 0x00, 0xA8, 0x00, 0x00, 0x00, 0xBF, 0x43, 0xCE, 0x00, 0xD1, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x27, 0x42, 0x49, 0x00, 0x5C, 0x00, 0xB3, 0x42, 0x00, 0x00, 0xC9, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x00, 0x00, 0x18, 0x4B, 0x6A, 0x4B, 0x6B, 0x00, 0x00, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x17, 0x00, 0x27, 0x4E, 0x61, 0x41, 0x8B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x29, 0x00, 0x52, 0x00, 0x5D, 0x00, 0x68, 0x00, 0x6D, 0x00, 0xF6, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xA2, 0x00, 0xF7, 0x00, 0x00, 0x00, 0x46, 0x52, 0x00, 0x00, 0xD3, 0x49, 0x00, 0x00, 0xF4, 0x2D }; static const int FIRST_GBC_PALETTE = 49; int GetGbcPaletteNumber(u8 *rom) { // Always "Grayscale" return 1; #if 0 int entryCount = ARRSIZE(gameHashTable); int nameSum = 0; for (int i = 0; i < 16; i++) { nameSum += rom[0x0134 + i]; } int fourthLetter = rom[0x0134 + 3]; nameSum &= 0xFF; int gameNumber = 0; for (int i = 0; i < entryCount; i+=2) { int hash = gameHashTable[i]; int disambig = gameHashTable[i+1]; if (hash == 0) { gameNumber++; } else if (hash == nameSum) { if (disambig == 0 || disambig == fourthLetter) { return gameNumber + FIRST_GBC_PALETTE; } } } return 0; #endif }
13.185792
56
0.6523
2aed549d43d845451fefe34bf7398fb6cf84178b
219
h
C
Examples/GMObjCDemo/GMAppDelegate.h
muzipiao/GmObjC
732ace23ff52cdce85c23ab5ce64f98f7217f5b8
[ "MIT" ]
243
2019-08-02T13:33:44.000Z
2022-03-31T00:53:05.000Z
Examples/GMObjCDemo/GMAppDelegate.h
Blasphel/GMObjC
d629f2a684670dfb72bc209e9d20729a647180a9
[ "MIT" ]
63
2019-08-15T06:35:20.000Z
2022-03-24T05:40:14.000Z
Examples/GMObjCDemo/GMAppDelegate.h
Blasphel/GMObjC
d629f2a684670dfb72bc209e9d20729a647180a9
[ "MIT" ]
50
2019-10-08T06:44:08.000Z
2022-03-15T09:02:11.000Z
// // AppDelegate.h // GMObjC // // Created by lifei on 2021/9/27. // #import <UIKit/UIKit.h> @interface GMAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow * window; @end
13.6875
62
0.694064
f1c6e03812e2dfff668d216262fc3d212974791b
850
h
C
System/Library/PrivateFrameworks/Translation.framework/_LTSpeechTranslationDelegate.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/Translation.framework/_LTSpeechTranslationDelegate.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/Translation.framework/_LTSpeechTranslationDelegate.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:42:11 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/Translation.framework/Translation * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @protocol _LTSpeechTranslationDelegate <NSObject> @optional -(void)cancel; -(void)speechRecognitionResult:(id)arg1; -(void)translatorDidTranslate:(id)arg1; -(void)translationDidFinishWithError:(id)arg1; -(void)languageDetectionResult:(id)arg1; -(void)languageDetectionCompleted; -(void)hybridEndpointerFoundEndpoint; -(void)serverEndpointerFeatures:(id)arg1 locale:(id)arg2; -(void)paragraphTranslation:(id)arg1 result:(id)arg2 error:(id)arg3; -(void)languageInstallProgressed:(id)arg1 error:(id)arg2; @end
34
83
0.791765
0457e736f56d02445d035ec72513fc255d822b7b
195
h
C
example2/List.h
borneq/module-pch
071c08e4b02342e0a89ac504f69df13034d759d1
[ "MIT" ]
null
null
null
example2/List.h
borneq/module-pch
071c08e4b02342e0a89ac504f69df13034d759d1
[ "MIT" ]
null
null
null
example2/List.h
borneq/module-pch
071c08e4b02342e0a89ac504f69df13034d759d1
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <iostream> #include <map> #include <memory> #include <set> using namespace std; class List { vector<int> vec; public: void addToVector(int n); };
13
28
0.687179
448b7edc6c31167134a0bdbefa9fb77e315e030d
759
c
C
maker/__alloca.c
masahase0117/delegate
b03786383c709323289879f7dfe2fae71a25e813
[ "BSD-3-Clause" ]
1
2021-12-15T14:37:55.000Z
2021-12-15T14:37:55.000Z
maker/__alloca.c
gfen934/delegate
b03786383c709323289879f7dfe2fae71a25e813
[ "BSD-3-Clause" ]
1
2022-01-11T14:53:47.000Z
2022-01-11T14:53:47.000Z
maker/__alloca.c
gfen934/delegate
b03786383c709323289879f7dfe2fae71a25e813
[ "BSD-3-Clause" ]
3
2020-12-15T03:04:37.000Z
2021-12-23T06:40:35.000Z
#include <stdio.h> #include <stdlib.h> #include "yalloca.h" #include "ystring.h" int alloca_call(AllocaArg *ap) { char *buff; int size; int rcode; void *bp; buff = (char*)alloca(ap->s_size * ap->s_unit); if( buff == NULL ){ porting_dbg("#### FATAL: alloca_call() failed (no more stack)"); exit(-1); } bp = addStrBuffer(ap->s_level,buff,ap->s_size*ap->s_unit); markStackBase(bp); if( ap->s_trace ){ size = ap->s_sp0 - buff; porting_dbg("%s (%4d) = %5d [%08X - %08X]", ap->s_what,ap->s_size,size,p2i((char*)&ap),p2i(ap->s_sp0)); } buff = 0; size = 0; rcode = (*ap->s_func)(ap->s_av[0],ap->s_av[1],ap->s_av[2],ap->s_av[3], ap->s_av[4],ap->s_av[5]); freeStrBuffer(ap->s_level,bp); return rcode; } int INHERENT_alloca(){ return 1; }
23
71
0.619236
28c9e522b2fa85a2f5eaec577a350297fdad718e
89
h
C
include/FreeType/PaxHeaders.20917/ftsynth.h
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
5
2015-10-11T10:22:39.000Z
2019-07-24T10:09:13.000Z
include/FreeType/PaxHeaders.20917/ftsynth.h
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
8
2016-04-24T13:07:28.000Z
2016-06-01T10:04:42.000Z
include/FreeType/PaxHeaders.20917/ftsynth.h
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
1
2016-08-28T06:47:43.000Z
2016-08-28T06:47:43.000Z
30 mtime=1378200294.538892297 29 atime=1386491102.80602479 30 ctime=1384254877.873227063
22.25
29
0.865169
139b27643fba027d267f0a25dedd2207e40f9fdb
9,508
c
C
src/rtlib/win32/io_serial.c
zai1208/fbc
02cc78513c9e9d2aeab93dd41994f7593fceff48
[ "MIT" ]
521
2015-01-13T20:42:25.000Z
2022-03-24T19:13:18.000Z
src/rtlib/win32/io_serial.c
jayrm/fbc
ae665330eefc276bc16c0831657b714ee2f592fd
[ "MIT" ]
196
2015-02-06T14:01:07.000Z
2022-03-30T18:10:33.000Z
src/rtlib/win32/io_serial.c
jayrm/fbc
ae665330eefc276bc16c0831657b714ee2f592fd
[ "MIT" ]
142
2015-02-04T03:59:44.000Z
2022-03-09T07:33:33.000Z
/* serial port access for Windows */ #include "../fb.h" #include "../io_serial_private.h" #define GET_MSEC_TIME() ((DWORD) (fb_Timer() * 1000.0)) static int fb_hSerialWaitSignal( HANDLE hDevice, DWORD dwMask, DWORD dwResult, DWORD dwTimeout ) { DWORD dwStartTime = GET_MSEC_TIME(); DWORD dwModemStatus = 0; if( !GetCommModemStatus( hDevice, &dwModemStatus ) ) return FALSE; while ( ((GET_MSEC_TIME() - dwStartTime) <= dwTimeout) && ((dwModemStatus & dwMask)!=dwResult) ) { if( !GetCommModemStatus( hDevice, &dwModemStatus ) ) return FALSE; } return ((dwModemStatus & dwMask)==dwResult); } static int fb_hSerialCheckLines( HANDLE hDevice, FB_SERIAL_OPTIONS *pOptions ) { DBG_ASSERT( pOptions!=NULL ); if( pOptions->DurationCD!=0 ) { if( !fb_hSerialWaitSignal( hDevice, MS_RLSD_ON, MS_RLSD_ON, pOptions->DurationCD ) ) return FALSE; } if( pOptions->DurationDSR!=0 ) { if( !fb_hSerialWaitSignal( hDevice, MS_DSR_ON, MS_DSR_ON, pOptions->DurationDSR ) ) return FALSE; } return TRUE; } int fb_SerialOpen( FB_FILE *handle, int iPort, FB_SERIAL_OPTIONS *options, const char *pszDevice, void **ppvHandle ) { DWORD dwDefaultTxBufferSize = 16384; DWORD dwDefaultRxBufferSize = 16384; DWORD dwDesiredAccess = 0; char *pszDev, *p; HANDLE hDevice; int res; /* The IRQ stuff is not supported on Windows ... */ if( options->IRQNumber!=0 ) return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); res = fb_ErrorSetNum( FB_RTERROR_OK ); switch( handle->access ) { case FB_FILE_ACCESS_READ: dwDesiredAccess = GENERIC_READ; break; case FB_FILE_ACCESS_WRITE: dwDesiredAccess = GENERIC_WRITE; break; case FB_FILE_ACCESS_READWRITE: case FB_FILE_ACCESS_ANY: dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; break; } /* Get device name without ":" */ pszDev = calloc(strlen( pszDevice ) + 5, 1); if( iPort == 0 ) { iPort = 1; strcpy( pszDev, "COM1:" ); } else { if( iPort > 9 ) strcpy(pszDev, "\\\\.\\"); else *pszDev = '\0'; strcat(pszDev, pszDevice); p = strchr( pszDev, ':'); if( p ) *p = '\0'; } #if 0 /* FIXME: Use default COM properties by default */ COMMCONFIG cc; if( !GetDefaultCommConfig( pszDev, &cc, &dwSizeCC ) ) { } #endif /* Open device */ hDevice = CreateFileA( pszDev, dwDesiredAccess, 0 /* dwShareMode: must be zero (exclusive access) for COM port according to MSDN */, NULL, OPEN_EXISTING, 0, NULL ); free( pszDev ); if( hDevice==INVALID_HANDLE_VALUE ) return fb_ErrorSetNum( FB_RTERROR_FILENOTFOUND ); /* Set rx/tx buffer sizes */ if( res==FB_RTERROR_OK ) { COMMPROP prop; if( !GetCommProperties( hDevice, &prop ) ) { res = fb_ErrorSetNum( FB_RTERROR_NOPRIVILEGES ); } else { if( prop.dwCurrentTxQueue ) { dwDefaultTxBufferSize = prop.dwCurrentTxQueue; } else if( prop.dwMaxTxQueue ) { dwDefaultTxBufferSize = prop.dwMaxTxQueue; } if( prop.dwCurrentRxQueue ) { dwDefaultRxBufferSize = prop.dwCurrentRxQueue; } else if( prop.dwMaxRxQueue ) { dwDefaultRxBufferSize = prop.dwMaxRxQueue; } if( options->TransmitBuffer ) dwDefaultTxBufferSize = options->TransmitBuffer; if( options->ReceiveBuffer ) dwDefaultRxBufferSize = options->ReceiveBuffer; if( !SetupComm( hDevice, dwDefaultRxBufferSize, dwDefaultTxBufferSize ) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } } } /* set timeouts */ if( res==FB_RTERROR_OK ) { COMMTIMEOUTS timeouts; if( !GetCommTimeouts( hDevice, &timeouts ) ) { res = fb_ErrorSetNum( FB_RTERROR_NOPRIVILEGES ); } else { if( options->DurationCTS!=0 ) { timeouts.ReadIntervalTimeout = options->DurationCTS; timeouts.ReadTotalTimeoutMultiplier = timeouts.ReadTotalTimeoutConstant = 0; } if( !SetCommTimeouts( hDevice, &timeouts ) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } } } /* setup generic COM port configuration */ if( res==FB_RTERROR_OK ) { DCB dcb; dcb.DCBlength = sizeof( DCB ); if( !GetCommState( hDevice, &dcb ) ) { res = fb_ErrorSetNum( FB_RTERROR_NOPRIVILEGES ); } else { dcb.BaudRate = options->uiSpeed; dcb.fBinary = !options->AddLF; /* FIXME: Windows only supports binary mode */ dcb.fParity = options->CheckParity; dcb.fOutxCtsFlow = options->DurationCTS!=0; dcb.fDtrControl = ( (options->KeepDTREnabled) ? DTR_CONTROL_ENABLE : DTR_CONTROL_DISABLE ); /* Not sure about this one ... */ dcb.fDsrSensitivity = options->DurationDSR!=0; dcb.fOutxDsrFlow = FALSE; /* No XON/XOFF */ dcb.fOutX = FALSE; dcb.fInX = FALSE; dcb.fNull = FALSE; /* Not sure about this one ... */ dcb.fRtsControl = ( ( options->SuppressRTS ) ? RTS_CONTROL_DISABLE : RTS_CONTROL_HANDSHAKE ); dcb.fAbortOnError = FALSE; dcb.ByteSize = (BYTE) options->uiDataBits; switch ( options->Parity ) { case FB_SERIAL_PARITY_NONE: dcb.Parity = NOPARITY; break; case FB_SERIAL_PARITY_EVEN: dcb.Parity = EVENPARITY; break; case FB_SERIAL_PARITY_ODD: dcb.Parity = ODDPARITY; break; case FB_SERIAL_PARITY_SPACE: dcb.Parity = SPACEPARITY; break; case FB_SERIAL_PARITY_MARK: dcb.Parity = MARKPARITY; break; } switch ( options->StopBits ) { case FB_SERIAL_STOP_BITS_1: dcb.StopBits = ONESTOPBIT; break; case FB_SERIAL_STOP_BITS_1_5: dcb.StopBits = ONE5STOPBITS; break; case FB_SERIAL_STOP_BITS_2: dcb.StopBits = TWOSTOPBITS; break; } if( !SetCommState( hDevice, &dcb ) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } else { EscapeCommFunction( hDevice, SETDTR ); } } } if( !fb_hSerialCheckLines( hDevice, options ) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } if( res!=FB_RTERROR_OK ) { CloseHandle( hDevice ); } else { W32_SERIAL_INFO *pInfo = calloc( 1, sizeof(W32_SERIAL_INFO) ); DBG_ASSERT( ppvHandle!=NULL ); *ppvHandle = pInfo; pInfo->hDevice = hDevice; pInfo->iPort = iPort; pInfo->pOptions = options; } return res; } int fb_SerialGetRemaining( FB_FILE *handle, void *pvHandle, fb_off_t *pLength ) { W32_SERIAL_INFO *pInfo = (W32_SERIAL_INFO*) pvHandle; DWORD dwErrors; COMSTAT Status; if( !ClearCommError( pInfo->hDevice, &dwErrors, &Status ) ) return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); if( pLength ) *pLength = (long) Status.cbInQue; return fb_ErrorSetNum( FB_RTERROR_OK ); } int fb_SerialWrite( FB_FILE *handle, void *pvHandle, const void *data, size_t length ) { W32_SERIAL_INFO *pInfo = (W32_SERIAL_INFO*) pvHandle; DWORD dwWriteCount; if( !fb_hSerialCheckLines( pInfo->hDevice, pInfo->pOptions ) ) { return fb_ErrorSetNum( FB_RTERROR_FILEIO ); } if( !WriteFile( pInfo->hDevice, data, length, &dwWriteCount, NULL ) ) return fb_ErrorSetNum( FB_RTERROR_FILEIO ); if( length != (size_t) dwWriteCount ) return fb_ErrorSetNum( FB_RTERROR_FILEIO ); return fb_ErrorSetNum( FB_RTERROR_OK ); } int fb_SerialRead( FB_FILE *handle, void *pvHandle, void *data, size_t *pLength ) { W32_SERIAL_INFO *pInfo = (W32_SERIAL_INFO*) pvHandle; DWORD dwReadCount; DBG_ASSERT( pLength!=NULL ); if( !fb_hSerialCheckLines( pInfo->hDevice, pInfo->pOptions ) ) { return fb_ErrorSetNum( FB_RTERROR_FILEIO ); } if( !ReadFile( pInfo->hDevice, data, *pLength, &dwReadCount, NULL ) ) return fb_ErrorSetNum( FB_RTERROR_FILEIO ); *pLength = (size_t) dwReadCount; return fb_ErrorSetNum( FB_RTERROR_OK ); } int fb_SerialClose( FB_FILE *handle, void *pvHandle ) { W32_SERIAL_INFO *pInfo = (W32_SERIAL_INFO*) pvHandle; CloseHandle( pInfo->hDevice ); free(pInfo); return fb_ErrorSetNum( FB_RTERROR_OK ); }
29.899371
105
0.561001
286fad2cc3f5719cb8c72c67993be860ef4822e3
6,924
h
C
src-qt5/Core/sysadm-client.h
yamajun/sysadm-ui-qt
e472d2ead74b3ea1774ae53ba486becc2fd0ba8c
[ "BSD-2-Clause" ]
null
null
null
src-qt5/Core/sysadm-client.h
yamajun/sysadm-ui-qt
e472d2ead74b3ea1774ae53ba486becc2fd0ba8c
[ "BSD-2-Clause" ]
null
null
null
src-qt5/Core/sysadm-client.h
yamajun/sysadm-ui-qt
e472d2ead74b3ea1774ae53ba486becc2fd0ba8c
[ "BSD-2-Clause" ]
null
null
null
//=========================================== // PC-BSD source code // Copyright (c) 2016, PC-BSD Software/iXsystems // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #ifndef _PCBSD_SYSADM_CLIENT_CLASS_H #define _PCBSD_SYSADM_CLIENT_CLASS_H #include <QJsonObject> #include <QJsonDocument> #include <QJsonValue> #include <QWebSocket> #include <QObject> #include <QSettings> #include <QSslError> #include <QHash> #include <QDebug> #include <QTimer> //NOTE: The default port will be used unless the host IP has ":<port>" appended on the end //NOTE-2: The host IP can be either a number (127.0.0.1) or a URL address-only (mysystem.net) #define WSPORTDEFAULT 12150 #define BRIDGEPORTDEFAULT 12149 //Number of automatic re-connects to try before failing out #define FAIL_MAX 10 struct message_in{ QString from_bridge_id; QString name, namesp, id; QJsonValue args; }; class bridge_data{ public: QByteArray enc_key; //current encryption key to use QString auth_tok; //current authentication token QString hostname; bridge_data(){} ~bridge_data(){} }; class sysadm_client : public QObject{ Q_OBJECT public: enum EVENT_TYPE{ DISPATCHER, LIFEPRESERVER, SYSSTATE}; sysadm_client(); ~sysadm_client(); // Overall Connection functions (start/stop) void openConnection(QString user, QString pass, QString hostIP); void openConnection(QString authkey, QString hostIP); void openConnection(QString hostIP); //uses SSL auth if possible void openConnection(); //uses last valid auth settings QString currentHost(); bool isActive(); bool isLocalHost(); //special case, checks currentHost for the localhost definitions bool needsBaseAuth(); //returns if a base user/password auth is required(always true until an SSL auth is attempted) bool isReady(); //returns true if the connection is all set and ready for inputs (auth successful, etc). bool isConnecting(); //returns true if it is currently trying to establish a connection //Bridged Connection Functions bool isBridge(); QStringList bridgeConnections(); //list the known connections through the bridge QString bridgedHostname(QString bridge_id); //Check if the sysadm server is running on the local system static bool localhostAvailable(); //If the server is installed static bool localhostRunning(); //If the local server is running // Register for Event Notifications (no notifications by default) void registerForEvents(EVENT_TYPE event, bool receive = true); //Return the current priority for the system state (0-9) int statePriority(); //Register the custom SSL Certificate with the server void registerCustomCert(); // Messages which are still pending a response QStringList pending(); //returns only the "id" for each // Fetch a message from the recent cache QJsonObject cachedRequest(QString id); QJsonValue cachedReply(QString id); private: QWebSocket *SOCKET; QString chost, cauthkey, cuser, cpass; //current host/authkey/user/pass QList<EVENT_TYPE> events; QHash<QString, QJsonObject> SENT, BACK; //small cache of sent/received messages QStringList PENDING; //ID's for sent but not received messages bool keepActive, SSLsuccess, usedSSL; int num_fail; //number of server connection failures int cPriority; bool isbridge; QHash<QString, bridge_data> BRIDGE; QTimer *connectTimer, *pingTimer; //Functions to do the initial socket setup void performAuth(QString user="", QString pass=""); //uses cauthkey if empty inputs void performAuth_bridge(QString bridge_id); //SSL only void clearAuth(); //Communication subroutines with the server void sendEventSubscription(EVENT_TYPE event, bool subscribe = true); void sendEventSubscription_bridge(QString bridge_id, EVENT_TYPE event, bool subscribe = true); void sendSocketMessage(QJsonObject msg); void sendSocketMessage(QString msg); //Simplification functions bridge_data getBridgeData(QString ID); message_in convertServerReply(QString reply); QString pubkeyMD5(QSslConfiguration cfg); QString SSL_Encode_String(QString str, QSslConfiguration cfg); QString EncodeString(QString str, QByteArray key); QString DecodeString(QString str, QByteArray key); //Queuing system for data submission to prevent crashes QStringList QUEUE; QTimer *QueueTimer; public slots: void closeConnection(); // Overloaded Communication functions // Reply from server may be obtained later from the newReply() signal void communicate(QString ID, QString namesp, QString name, QJsonValue args); void communicate(QJsonObject); void communicate(QList<QJsonObject>); //Overloaded Bridge Communication functions void communicate_bridge(QString bridge_host_id, QString ID, QString namesp, QString name, QJsonValue args); void communicate_bridge(QString bridge_host_id, QJsonObject); void communicate_bridge(QString bridge_host_id, QList<QJsonObject>); private slots: void setupSocket(); //uses chost/cport for setup void sendPing(); //Used to keep a connection active at regular intervals //Socket signal/slot connections void socketConnected(); //Signal: connected() void socketClosed(); //Signal: disconnected() void socketSslErrors(const QList<QSslError>&errlist); //Signal: sslErrors() void socketError(QAbstractSocket::SocketError err); //Signal:: error() //void socketProxyAuthRequired(const QNetworkProxy &proxy, QAuthenticator *auth); //Signal: proxyAuthenticationRequired() // - Main message output routine (tied to an internal signal - don't use manually) void forwardSocketMessage(QString); void sendFromQueue(); // - Main message input parsing void socketMessage(QString msg); //Signal: textMessageReceived() void handleMessage(const QString msg); //Run within a separate thread bool handleMessageInternally(message_in msg); signals: void clientTypeChanged(); //the bridge/server type changed void clientConnected(); //Stage 1 - host address is valid void clientAuthorized(); //Stage 2 - user is authorized to continue void clientReconnecting(); //emitted periodically while attempting to establish a connection to the server void clientDisconnected(); //Only emitted if the client could not automatically reconnect to the server void clientUnauthorized(); //Only emitted if the user needs to re-authenticate with the server void bridgeConnectionsChanged(QStringList); //list of server connections now available void bridgeAuthorized(QString); void newReply(QString ID, QString namesp, QString name, QJsonValue args); void bridgeReply(QString bridgeID, QString ID, QString namesp, QString name, QJsonValue args); void NewEvent(sysadm_client::EVENT_TYPE, QJsonValue); void bridgeEvent(QString bridgeID, sysadm_client::EVENT_TYPE, QJsonValue); void statePriorityChanged(int); void bridgeStatePriorityChanged(QString bridgeID, int); //Private signals void sendOutputMessage(QString); }; #endif
39.118644
122
0.76892
ffb034a154bffae271e9115558f3a2a790e8d66c
6,854
c
C
src/cgi/wificgi.c
ThoughtWorksIoTGurgaon/esp-highway
5610bca91423945e8bd0102089993158008dc314
[ "Apache-2.0" ]
null
null
null
src/cgi/wificgi.c
ThoughtWorksIoTGurgaon/esp-highway
5610bca91423945e8bd0102089993158008dc314
[ "Apache-2.0" ]
null
null
null
src/cgi/wificgi.c
ThoughtWorksIoTGurgaon/esp-highway
5610bca91423945e8bd0102089993158008dc314
[ "Apache-2.0" ]
null
null
null
/* Cgi/template routines for the /wifi url. */ /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Jeroen Domburg <jeroen@spritesmods.com> wrote this file. As long as you retain * this notice you can do whatever you want with this stuff. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * ---------------------------------------------------------------------------- * Heavily modified and enhanced by Thorsten von Eicken in 2015 * ---------------------------------------------------------------------------- */ #include <esp8266.h> #include "cgi.h" #include "wifi.h" #define CGIWIFI_DBG static int ICACHE_FLASH_ATTR _cgiWifiStartScan(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. jsonHeader(connData, 200); Wifi_startScan(); return HTTPD_CGI_DONE; } static int ICACHE_FLASH_ATTR _cgiWifiGetScan(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[2048]; int len; jsonHeader(connData, 200); if (Wifi_isScanInProgress()) { //We're still scanning. Tell Javascript code that. len = os_sprintf(buff, "{\n \"result\": { \n\"inProgress\": \"1\"\n }\n}\n"); httpdSend(connData, buff, len); return HTTPD_CGI_DONE; } Wifi_ApData **apData = Wifi_getScannedAP(); int numberOfAPScanned = Wifi_getNumberOfAPScanned(); len = os_sprintf(buff, "{\"result\": {\"inProgress\": \"0\", \"APs\": [\n"); for (int pos=0; pos < numberOfAPScanned; pos++) { len += os_sprintf(buff+len, "{\"essid\": \"%s\", \"rssi\": %d, \"enc\": \"%d\"}%s\n", apData[pos]->ssid, apData[pos]->rssi, apData[pos]->enc, (pos==numberOfAPScanned-1)?"":","); } len += os_sprintf(buff+len, "]}}\n"); //os_printf("Sending %d bytes: %s\n", len, buff); httpdSend(connData, buff, len); return HTTPD_CGI_DONE; } int ICACHE_FLASH_ATTR CGI_Wifi_scan(HttpdConnData *connData) { if (connData->requestType == HTTPD_METHOD_GET) { return _cgiWifiGetScan(connData); } else if (connData->requestType == HTTPD_METHOD_POST) { return _cgiWifiStartScan(connData); } else { jsonHeader(connData, 404); return HTTPD_CGI_DONE; } } // This cgi uses the routines above to connect to a specific access point with the // given ESSID using the given password. int ICACHE_FLASH_ATTR CGI_Wifi_connect(HttpdConnData *connData) { char essid[128]; char passwd[128]; if (connData->conn==NULL) return HTTPD_CGI_DONE; int el = httpdFindArg(connData->getArgs, "essid", essid, sizeof(essid)); int pl = httpdFindArg(connData->getArgs, "passwd", passwd, sizeof(passwd)); if (el > 0 && pl >= 0) { Wifi_connect(essid, passwd); jsonHeader(connData, 200); } else { jsonHeader(connData, 400); httpdSend(connData, "Cannot parse ssid or password", -1); } return HTTPD_CGI_DONE; } //This cgi changes the operating mode: STA / AP / STA+AP int ICACHE_FLASH_ATTR CGI_Wifi_setMode(HttpdConnData *connData) { int len; char buff[1024]; if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. len=httpdFindArg(connData->getArgs, "mode", buff, sizeof(buff)); if (len!=0) { Wifi_setWifiMode(buff); jsonHeader(connData, 200); } else { jsonHeader(connData, 400); } return HTTPD_CGI_DONE; } #ifdef CHANGE_TO_STA #define MODECHANGE "yes" #else #define MODECHANGE "no" #endif static char *_connStatuses[] = { "idle", "connecting", "wrong password", "AP not found", "failed", "got IP address" }; static char *_wifiMode[] = { 0, "STA", "AP", "AP+STA" }; static char *_wifiPhy[] = { 0, "11b", "11g", "11n" }; // print various Wifi information into json buffer static int ICACHE_FLASH_ATTR _printWifiInfo(char *buff) { int len; struct station_config stconf; wifi_station_get_config(&stconf); uint8_t op = wifi_get_opmode() & 0x3; char *mode = _wifiMode[op]; char *status = "unknown"; int st = wifi_station_get_connect_status(); if (st >= 0 && st < sizeof(_connStatuses)) status = _connStatuses[st]; int p = wifi_get_phy_mode(); char *phy = _wifiPhy[p&3]; sint8 rssi = wifi_station_get_rssi(); if (rssi > 0) rssi = 0; uint8 mac_addr[6]; wifi_get_macaddr(0, mac_addr); uint8_t chan = wifi_get_channel(); len = os_sprintf(buff, "\"mode\": \"%s\", \"modechange\": \"%s\", \"ssid\": \"%s\", \"status\": \"%s\", \"phy\": \"%s\", " "\"rssi\": \"%ddB\", \"mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\", \"chan\":%d", mode, MODECHANGE, (char*)stconf.ssid, status, phy, rssi, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5], chan); struct ip_info info; if (wifi_get_ip_info(0, &info)) { len += os_sprintf(buff+len, ", \"ip\": \"%d.%d.%d.%d\"", IP2STR(&info.ip.addr)); len += os_sprintf(buff+len, ", \"netmask\": \"%d.%d.%d.%d\"", IP2STR(&info.netmask.addr)); len += os_sprintf(buff+len, ", \"gateway\": \"%d.%d.%d.%d\"", IP2STR(&info.gw.addr)); len += os_sprintf(buff+len, ", \"hostname\": \"%s\"", "my-esp"); } else { len += os_sprintf(buff+len, ", \"ip\": \"-none-\""); } // len += os_sprintf(buff+len, ", \"staticip\": \"%d.%d.%d.%d\"", IP2STR(&flashConfig.staticip)); // len += os_sprintf(buff+len, ", \"dhcp\": \"%s\"", flashConfig.staticip > 0 ? "off" : "on"); return len; } // reasons for which a connection failed static char *_wifiReasons[] = { "", "unspecified", "auth_expire", "auth_leave", "assoc_expire", "assoc_toomany", "not_authed", "not_assoced", "assoc_leave", "assoc_not_authed", "disassoc_pwrcap_bad", "disassoc_supchan_bad", "ie_invalid", "mic_failure", "4way_handshake_timeout", "group_key_update_timeout", "ie_in_4way_differs", "group_cipher_invalid", "pairwise_cipher_invalid", "akmp_invalid", "unsupp_rsn_ie_version", "invalid_rsn_ie_cap", "802_1x_auth_failed", "cipher_suite_rejected", "beacon_timeout", "no_ap_found" }; static char* ICACHE_FLASH_ATTR _wifiGetReason() { uint8 wifiReason = Wifi_getDisconnectionReason(); if (wifiReason <= 24) return _wifiReasons[wifiReason]; if (wifiReason >= 200 && wifiReason <= 201) return _wifiReasons[wifiReason-200+24]; return _wifiReasons[1]; } // Cgi to return various Wifi information int ICACHE_FLASH_ATTR CGI_Wifi_info(HttpdConnData *connData) { char buff[1024]; if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. os_strcpy(buff, "{"); _printWifiInfo(buff+1); len += os_sprintf(buff+len, ", "); if (Wifi_getDisconnectionReason() != 0) { len += os_sprintf(buff+len, "\"reason\": \"%s\"", _wifiGetReason()); } os_strcat(buff, " }"); jsonHeader(connData, 200); httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; }
32.483412
103
0.639626
d8fbcb985da814cebc71880046d7d47486e0b7ae
2,776
h
C
firmware/coreboot/src/southbridge/intel/fsp_rangeley/gpio.h
fabiojna02/OpenCellular
45b6a202d6b2e2485c89955b9a6da920c4d56ddb
[ "CC-BY-4.0", "BSD-3-Clause" ]
1
2019-11-04T07:11:25.000Z
2019-11-04T07:11:25.000Z
firmware/coreboot/src/southbridge/intel/fsp_rangeley/gpio.h
fabiojna02/OpenCellular
45b6a202d6b2e2485c89955b9a6da920c4d56ddb
[ "CC-BY-4.0", "BSD-3-Clause" ]
13
2018-10-12T21:29:09.000Z
2018-10-25T20:06:51.000Z
firmware/coreboot/src/southbridge/intel/fsp_rangeley/gpio.h
fabiojna02/OpenCellular
45b6a202d6b2e2485c89955b9a6da920c4d56ddb
[ "CC-BY-4.0", "BSD-3-Clause" ]
null
null
null
/* * This file is part of the coreboot project. * * Copyright (C) 2011 The Chromium OS Authors. All rights reserved. * Copyright (C) 2013 Sage Electronic Engineering, LLC. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef INTEL_RANGELEY_GPIO_H #define INTEL_RANGELEY_GPIO_H #include <compiler.h> #define GPIO_MODE_NATIVE 0 #define GPIO_MODE_GPIO 1 #define GPIO_MODE_NONE 1 #define GPIO_DIR_OUTPUT 0 #define GPIO_DIR_INPUT 1 #define GPIO_LEVEL_LOW 0 #define GPIO_LEVEL_HIGH 1 #define GPIO_TPE_DISABLE 0 #define GPIO_TPE_ENABLE 1 #define GPIO_TNE_DISABLE 0 #define GPIO_TNE_ENABLE 1 #define GPIO_TS_DISABLE 0 #define GPIO_TS_ENABLE 1 #define GPIO_WE_DISABLE 0 #define GPIO_WE_ENABLE 1 struct soc_gpio { u32 gpio0 : 1; u32 gpio1 : 1; u32 gpio2 : 1; u32 gpio3 : 1; u32 gpio4 : 1; u32 gpio5 : 1; u32 gpio6 : 1; u32 gpio7 : 1; u32 gpio8 : 1; u32 gpio9 : 1; u32 gpio10 : 1; u32 gpio11 : 1; u32 gpio12 : 1; u32 gpio13 : 1; u32 gpio14 : 1; u32 gpio15 : 1; u32 gpio16 : 1; u32 gpio17 : 1; u32 gpio18 : 1; u32 gpio19 : 1; u32 gpio20 : 1; u32 gpio21 : 1; u32 gpio22 : 1; u32 gpio23 : 1; u32 gpio24 : 1; u32 gpio25 : 1; u32 gpio26 : 1; u32 gpio27 : 1; u32 gpio28 : 1; u32 gpio29 : 1; u32 gpio30 : 1; u32 gpio31 : 1; } __packed; struct soc_cfio { u32 pad_conf_0; u32 pad_conf_1; u32 pad_val; u32 pad_dft; } __packed; struct soc_gpio_map { /* GPIO core */ struct { const struct soc_gpio *mode; const struct soc_gpio *direction; const struct soc_gpio *level; const struct soc_gpio *tpe; const struct soc_gpio *tne; const struct soc_gpio *ts; const struct soc_cfio *cfio_init; const u32 cfio_entrynum; }core; /* GPIO SUS */ struct { const struct soc_gpio *mode; const struct soc_gpio *direction; const struct soc_gpio *level; const struct soc_gpio *tpe; const struct soc_gpio *tne; const struct soc_gpio *ts; const struct soc_gpio *we; const struct soc_cfio *cfio_init; const u32 cfio_entrynum; }sus; }; /* Configure GPIOs with mainboard provided settings */ void setup_soc_gpios(const struct soc_gpio_map *gpio); /* Get GPIO pin value */ int get_gpio(int gpio_num); /* * Get a number comprised of multiple GPIO values. gpio_num_array points to * the array of GPIO pin numbers to scan, terminated by -1. */ unsigned get_gpios(const int *gpio_num_array); #endif
21.858268
75
0.71938
4f2b58aaf045236e483b7c91471a14ecc9be1634
1,299
h
C
include/ltl/movable_any.h
qnope/Little-Type-Library
97f09319aca070226b4674371fb4ae84fbb3b482
[ "MIT" ]
62
2018-12-16T15:01:42.000Z
2022-03-06T10:15:25.000Z
include/ltl/movable_any.h
qnope/Little-Type-Library
97f09319aca070226b4674371fb4ae84fbb3b482
[ "MIT" ]
2
2020-09-26T13:49:25.000Z
2020-10-01T17:31:01.000Z
include/ltl/movable_any.h
qnope/Little-Type-Library
97f09319aca070226b4674371fb4ae84fbb3b482
[ "MIT" ]
6
2018-12-31T16:02:26.000Z
2022-02-16T17:15:42.000Z
#pragma once #include <cassert> #include <memory> #include <typeindex> #include <utility> namespace ltl { class movable_any { struct Concept { virtual const void *ptr() const noexcept = 0; virtual void *ptr() noexcept = 0; virtual ~Concept() = default; }; template <typename T> class Model : public Concept { public: Model(T &&v) : m_underlying{std::move(v)} {} void *ptr() noexcept override { return std::addressof(m_underlying); } const void *ptr() const noexcept override { return std::addressof(m_underlying); } private: T m_underlying; }; public: template <typename T> movable_any(T t) noexcept : m_typeIndex{typeid(T)}, // m_concept{std::make_shared<Model<T>>(std::move(t))} {} template <typename T> T &get() noexcept { assert(m_typeIndex == typeid(T)); return *static_cast<T *>(m_concept->ptr()); } template <typename T> const T &get() const noexcept { assert(m_typeIndex == typeid(T)); return *static_cast<const T *>(m_concept->ptr()); } std::type_index type() const noexcept { return m_typeIndex; } private: std::type_index m_typeIndex; std::shared_ptr<Concept> m_concept; }; } // namespace ltl
24.055556
90
0.61047
94c4b2c6324dcc02ff4cc020d3f05b177dce84e5
626
h
C
AtriusActionZone.framework/Headers/AtriusActionZone.h
deanandreakis/atl-demo-ios-app
0b55210736bf39529aab68fed01919d2ce5efce9
[ "MIT" ]
null
null
null
AtriusActionZone.framework/Headers/AtriusActionZone.h
deanandreakis/atl-demo-ios-app
0b55210736bf39529aab68fed01919d2ce5efce9
[ "MIT" ]
null
null
null
AtriusActionZone.framework/Headers/AtriusActionZone.h
deanandreakis/atl-demo-ios-app
0b55210736bf39529aab68fed01919d2ce5efce9
[ "MIT" ]
null
null
null
// // AtriusActionZone.h // AtriusActionZone // // Created by Satya Mukkavilli on 11/17/16. // Copyright © 2016 Acuity Brands. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for AtriusActionZone. FOUNDATION_EXPORT double ABActionZoneVersionNumber; //! Project version string for AtriusActionZone. FOUNDATION_EXPORT const unsigned char ABActionZoneVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <AtriusActionZone/PublicHeader.h> @import AtriusCore; #import "ATRActionZone.h" #import "ATRSiteActionZoneManager.h"
28.454545
141
0.784345
9ee39c8d1010cda660950bc599d23b0060a97ea2
10,036
c
C
interface.c
gromaudio/android_external_iw
65fab049d66f6fe888de228ff9c228c64d357e9b
[ "0BSD" ]
4
2015-01-22T22:21:46.000Z
2018-02-01T12:28:41.000Z
interface.c
gromaudio/android_external_iw
65fab049d66f6fe888de228ff9c228c64d357e9b
[ "0BSD" ]
null
null
null
interface.c
gromaudio/android_external_iw
65fab049d66f6fe888de228ff9c228c64d357e9b
[ "0BSD" ]
3
2015-04-12T18:50:19.000Z
2020-07-30T00:26:39.000Z
#include <net/if.h> #include <errno.h> #include <string.h> #include <stdbool.h> #include <netlink/genl/genl.h> #include <netlink/genl/family.h> #include <netlink/genl/ctrl.h> #include <netlink/msg.h> #include <netlink/attr.h> #include "nl80211.h" #include "iw.h" #define VALID_FLAGS "none: no special flags\n"\ "fcsfail: show frames with FCS errors\n"\ "control: show control frames\n"\ "otherbss: show frames from other BSSes\n"\ "cook: use cooked mode" SECTION(interface); static char *mntr_flags[NL80211_MNTR_FLAG_MAX + 1] = { "none", "fcsfail", "plcpfail", "control", "otherbss", "cook", }; static int parse_mntr_flags(int *_argc, char ***_argv, struct nl_msg *msg) { struct nl_msg *flags; int err = -ENOBUFS; enum nl80211_mntr_flags flag; int argc = *_argc; char **argv = *_argv; flags = nlmsg_alloc(); if (!flags) return -ENOMEM; while (argc) { int ok = 0; for (flag = __NL80211_MNTR_FLAG_INVALID; flag <= NL80211_MNTR_FLAG_MAX; flag++) { if (strcmp(*argv, mntr_flags[flag]) == 0) { ok = 1; /* * This shouldn't be adding "flag" if that is * zero, but due to a problem in the kernel's * nl80211 code (using NLA_NESTED policy) it * will reject an empty nested attribute but * not one that contains an invalid attribute */ NLA_PUT_FLAG(flags, flag); break; } } if (!ok) { err = -EINVAL; goto out; } argc--; argv++; } nla_put_nested(msg, NL80211_ATTR_MNTR_FLAGS, flags); err = 0; nla_put_failure: out: nlmsg_free(flags); *_argc = argc; *_argv = argv; return err; } /* for help */ #define IFACE_TYPES "Valid interface types are: managed, ibss, monitor, mesh, wds." /* return 0 if ok, internal error otherwise */ static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type, bool need_type) { char *tpstr; if (*argc < 1 + !!need_type) return 1; if (need_type && strcmp((*argv)[0], "type")) return 1; tpstr = (*argv)[!!need_type]; *argc -= 1 + !!need_type; *argv += 1 + !!need_type; if (strcmp(tpstr, "adhoc") == 0 || strcmp(tpstr, "ibss") == 0) { *type = NL80211_IFTYPE_ADHOC; return 0; } else if (strcmp(tpstr, "monitor") == 0) { *type = NL80211_IFTYPE_MONITOR; return 0; } else if (strcmp(tpstr, "master") == 0 || strcmp(tpstr, "ap") == 0) { *type = NL80211_IFTYPE_UNSPECIFIED; fprintf(stderr, "You need to run a management daemon, e.g. hostapd,\n"); fprintf(stderr, "see http://wireless.kernel.org/en/users/Documentation/hostapd\n"); fprintf(stderr, "for more information on how to do that.\n"); return 2; } else if (strcmp(tpstr, "__ap") == 0) { *type = NL80211_IFTYPE_AP; return 0; } else if (strcmp(tpstr, "__ap_vlan") == 0) { *type = NL80211_IFTYPE_AP_VLAN; return 0; } else if (strcmp(tpstr, "wds") == 0) { *type = NL80211_IFTYPE_WDS; return 0; } else if (strcmp(tpstr, "managed") == 0 || strcmp(tpstr, "mgd") == 0 || strcmp(tpstr, "station") == 0) { *type = NL80211_IFTYPE_STATION; return 0; } else if (strcmp(tpstr, "mp") == 0 || strcmp(tpstr, "mesh") == 0) { *type = NL80211_IFTYPE_MESH_POINT; return 0; } else if (strcmp(tpstr, "__p2pcl") == 0) { *type = NL80211_IFTYPE_P2P_CLIENT; return 0; } else if (strcmp(tpstr, "__p2pgo") == 0) { *type = NL80211_IFTYPE_P2P_GO; return 0; } fprintf(stderr, "invalid interface type %s\n", tpstr); return 2; } static int parse_4addr_flag(const char *value, struct nl_msg *msg) { if (strcmp(value, "on") == 0) NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, 1); else if (strcmp(value, "off") == 0) NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, 0); else return 1; return 0; nla_put_failure: return 1; } static int handle_interface_add(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { char *name; char *mesh_id = NULL; enum nl80211_iftype type; int tpset; if (argc < 1) return 1; name = argv[0]; argc--; argv++; tpset = get_if_type(&argc, &argv, &type, true); if (tpset) return tpset; if (argc) { if (strcmp(argv[0], "mesh_id") == 0) { argc--; argv++; if (!argc) return 1; mesh_id = argv[0]; argc--; argv++; } else if (strcmp(argv[0], "4addr") == 0) { argc--; argv++; if (parse_4addr_flag(argv[0], msg)) { fprintf(stderr, "4addr error\n"); return 2; } argc--; argv++; } else if (strcmp(argv[0], "flags") == 0) { argc--; argv++; if (parse_mntr_flags(&argc, &argv, msg)) { fprintf(stderr, "flags error\n"); return 2; } } else { return 1; } } if (argc) return 1; NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, name); NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, type); if (mesh_id) NLA_PUT(msg, NL80211_ATTR_MESH_ID, strlen(mesh_id), mesh_id); return 0; nla_put_failure: return -ENOBUFS; } COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]", NL80211_CMD_NEW_INTERFACE, 0, CIB_PHY, handle_interface_add, "Add a new virtual interface with the given configuration.\n" IFACE_TYPES "\n\n" "The flags are only used for monitor interfaces, valid flags are:\n" VALID_FLAGS "\n\n" "The mesh_id is used only for mesh mode."); COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]", NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL); static int handle_interface_del(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { return 0; } TOPLEVEL(del, NULL, NL80211_CMD_DEL_INTERFACE, 0, CIB_NETDEV, handle_interface_del, "Remove this virtual interface"); HIDDEN(interface, del, NULL, NL80211_CMD_DEL_INTERFACE, 0, CIB_NETDEV, handle_interface_del); static int print_iface_handler(struct nl_msg *msg, void *arg) { struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; unsigned int *wiphy = arg; const char *indent = ""; nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); if (wiphy && tb_msg[NL80211_ATTR_WIPHY]) { unsigned int thiswiphy = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]); indent = "\t"; if (*wiphy != thiswiphy) printf("phy#%d\n", thiswiphy); *wiphy = thiswiphy; } if (tb_msg[NL80211_ATTR_IFNAME]) printf("%sInterface %s\n", indent, nla_get_string(tb_msg[NL80211_ATTR_IFNAME])); if (tb_msg[NL80211_ATTR_IFINDEX]) printf("%s\tifindex %d\n", indent, nla_get_u32(tb_msg[NL80211_ATTR_IFINDEX])); if (tb_msg[NL80211_ATTR_IFTYPE]) printf("%s\ttype %s\n", indent, iftype_name(nla_get_u32(tb_msg[NL80211_ATTR_IFTYPE]))); return NL_SKIP; } static int handle_interface_info(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, NULL); return 0; } TOPLEVEL(info, NULL, NL80211_CMD_GET_INTERFACE, 0, CIB_NETDEV, handle_interface_info, "Show information for this interface."); static int handle_interface_set(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { if (!argc) return 1; NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_MONITOR); switch (parse_mntr_flags(&argc, &argv, msg)) { case 0: return 0; case -ENOMEM: fprintf(stderr, "failed to allocate flags\n"); return 2; case -EINVAL: fprintf(stderr, "unknown flag %s\n", *argv); return 2; default: return 2; } nla_put_failure: return -ENOBUFS; } COMMAND(set, monitor, "<flag>*", NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_set, "Set monitor flags. Valid flags are:\n" VALID_FLAGS); static int handle_interface_meshid(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { char *mesh_id = NULL; if (argc != 1) return 1; mesh_id = argv[0]; NLA_PUT(msg, NL80211_ATTR_MESH_ID, strlen(mesh_id), mesh_id); return 0; nla_put_failure: return -ENOBUFS; } COMMAND(set, meshid, "<meshid>", NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_meshid, NULL); static unsigned int dev_dump_wiphy; static int handle_dev_dump(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { dev_dump_wiphy = -1; nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, &dev_dump_wiphy); return 0; } TOPLEVEL(dev, NULL, NL80211_CMD_GET_INTERFACE, NLM_F_DUMP, CIB_NONE, handle_dev_dump, "List all network interfaces for wireless hardware."); static int handle_interface_type(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { enum nl80211_iftype type; int tpset; tpset = get_if_type(&argc, &argv, &type, false); if (tpset) return tpset; if (argc) return 1; NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, type); return 0; nla_put_failure: return -ENOBUFS; } COMMAND(set, type, "<type>", NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_type, "Set interface type/mode.\n" IFACE_TYPES); static int handle_interface_4addr(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { if (argc != 1) return 1; return parse_4addr_flag(argv[0], msg); } COMMAND(set, 4addr, "<on|off>", NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_4addr, "Set interface 4addr (WDS) mode."); static int handle_interface_wds_peer(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { unsigned char mac_addr[ETH_ALEN]; if (argc < 1) return 1; if (mac_addr_a2n(mac_addr, argv[0])) { fprintf(stderr, "Invalid MAC address\n"); return 2; } argc--; argv++; if (argc) return 1; NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); return 0; nla_put_failure: return -ENOBUFS; } COMMAND(set, peer, "<MAC address>", NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer, "Set interface WDS peer.");
24.067146
95
0.675767
9eeb62a9599e26a573144b661e214312bad7a140
1,122
h
C
System/Library/Frameworks/MapKit.framework/MKBlockBasedSnapshotRequester.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
1
2020-11-11T06:05:23.000Z
2020-11-11T06:05:23.000Z
System/Library/Frameworks/MapKit.framework/MKBlockBasedSnapshotRequester.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
System/Library/Frameworks/MapKit.framework/MKBlockBasedSnapshotRequester.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.5 * on Tuesday, November 10, 2020 at 10:14:12 PM Mountain Standard Time * Operating System: Version 14.2 (Build 18K57) * Image Source: /System/Library/Frameworks/MapKit.framework/MapKit * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ #import <libobjc.A.dylib/MKMapSnapshotCreatorRequester.h> @class NSString; @interface MKBlockBasedSnapshotRequester : NSObject <MKMapSnapshotCreatorRequester> { /*^block*/id handler; } @property (nonatomic,copy) id handler; @property (readonly) unsigned long long hash; @property (readonly) Class superclass; @property (copy,readonly) NSString * description; @property (copy,readonly) NSString * debugDescription; +(id)snapshotRequesterWitHandler:(/*^block*/id)arg1 ; -(void)setHandler:(id)arg1 ; -(id)handler; -(void)mapSnapshotCreator:(id)arg1 didCreateSnapshot:(id)arg2 attributionString:(id)arg3 context:(id)arg4 ; @end
37.4
130
0.673797
36868d2e33053486da29efe913ce5b172a64a696
212
h
C
src/read_src_rec_loc.h
dt-jackson/FWI
5fbb42590dec4187314eb1bd21ea8d24c207209b
[ "MIT" ]
null
null
null
src/read_src_rec_loc.h
dt-jackson/FWI
5fbb42590dec4187314eb1bd21ea8d24c207209b
[ "MIT" ]
null
null
null
src/read_src_rec_loc.h
dt-jackson/FWI
5fbb42590dec4187314eb1bd21ea8d24c207209b
[ "MIT" ]
null
null
null
#ifndef READ_SRC_REC_LOC_H #define READ_SRC_REC_LOC_H #include "read_parameters.h" #include "seis_data.h" void read_src_loc(parameters *p, seis_data *d); void read_rec_loc(parameters *p, seis_data *d); #endif
19.272727
47
0.787736
a96282781f94e0e3d24376ed5583df72eca21caf
4,967
c
C
fs/proc/meminfo.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
fs/proc/meminfo.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
fs/proc/meminfo.c
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
#include <linux/fs.h> #include <linux/hugetlb.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/mman.h> #include <linux/mmzone.h> #include <linux/proc_fs.h> #include <linux/quicklist.h> #include <linux/seq_file.h> #include <linux/swap.h> #include <linux/vmstat.h> #include <asm/atomic.h> #include <asm/page.h> #include <asm/pgtable.h> #include "internal.h" void __attribute__((weak)) arch_report_meminfo(struct seq_file *m) { } static int meminfo_proc_show(struct seq_file *m, void *v) { struct sysinfo i; unsigned long committed; unsigned long allowed; struct vmalloc_info vmi; long cached; unsigned long pages[NR_LRU_LISTS]; int lru; /* * display in kilobytes. */ #define K(x) ((x) << (PAGE_SHIFT - 10)) si_meminfo(&i); si_swapinfo(&i); committed = percpu_counter_read_positive(&vm_committed_as); allowed = ((totalram_pages - hugetlb_total_pages()) * sysctl_overcommit_ratio / 100) + total_swap_pages; cached = global_page_state(NR_FILE_PAGES) - total_swapcache_pages - i.bufferram; if (cached < 0) cached = 0; get_vmalloc_info(&vmi); for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) pages[lru] = global_page_state(NR_LRU_BASE + lru); /* * Tagged format, for easy grepping and expansion. */ seq_printf(m, "MemTotal: %8lu kB\n" "MemFree: %8lu kB\n" "Buffers: %8lu kB\n" "Cached: %8lu kB\n" "SwapCached: %8lu kB\n" "Active: %8lu kB\n" "Inactive: %8lu kB\n" "Active(anon): %8lu kB\n" "Inactive(anon): %8lu kB\n" "Active(file): %8lu kB\n" "Inactive(file): %8lu kB\n" "Unevictable: %8lu kB\n" "Mlocked: %8lu kB\n" #ifdef CONFIG_HIGHMEM "HighTotal: %8lu kB\n" "HighFree: %8lu kB\n" "LowTotal: %8lu kB\n" "LowFree: %8lu kB\n" #endif #ifndef CONFIG_MMU "MmapCopy: %8lu kB\n" #endif "SwapTotal: %8lu kB\n" "SwapFree: %8lu kB\n" "Dirty: %8lu kB\n" "Writeback: %8lu kB\n" "AnonPages: %8lu kB\n" "Mapped: %8lu kB\n" "Shmem: %8lu kB\n" "Slab: %8lu kB\n" "SReclaimable: %8lu kB\n" "SUnreclaim: %8lu kB\n" "KernelStack: %8lu kB\n" "PageTables: %8lu kB\n" #ifdef CONFIG_QUICKLIST "Quicklists: %8lu kB\n" #endif "NFS_Unstable: %8lu kB\n" "Bounce: %8lu kB\n" "WritebackTmp: %8lu kB\n" "CommitLimit: %8lu kB\n" "Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n" "VmallocUsed: %8lu kB\n" "VmallocChunk: %8lu kB\n" #ifdef CONFIG_MEMORY_FAILURE "HardwareCorrupted: %5lu kB\n" #endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE "AnonHugePages: %8lu kB\n" #endif , K(i.totalram), K(i.freeram), K(i.bufferram), K(cached), K(total_swapcache_pages), K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]), K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]), K(pages[LRU_ACTIVE_ANON]), K(pages[LRU_INACTIVE_ANON]), K(pages[LRU_ACTIVE_FILE]), K(pages[LRU_INACTIVE_FILE]), K(pages[LRU_UNEVICTABLE]), K(global_page_state(NR_MLOCK)), #ifdef CONFIG_HIGHMEM K(i.totalhigh), K(i.freehigh), K(i.totalram-i.totalhigh), K(i.freeram-i.freehigh), #endif #ifndef CONFIG_MMU K((unsigned long) atomic_long_read(&mmap_pages_allocated)), #endif K(i.totalswap), K(i.freeswap), K(global_page_state(NR_FILE_DIRTY)), K(global_page_state(NR_WRITEBACK)), #ifdef CONFIG_TRANSPARENT_HUGEPAGE K(global_page_state(NR_ANON_PAGES) + global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR), #else K(global_page_state(NR_ANON_PAGES)), #endif K(global_page_state(NR_FILE_MAPPED)), K(global_page_state(NR_SHMEM)), K(global_page_state(NR_SLAB_RECLAIMABLE) + global_page_state(NR_SLAB_UNRECLAIMABLE)), K(global_page_state(NR_SLAB_RECLAIMABLE)), K(global_page_state(NR_SLAB_UNRECLAIMABLE)), global_page_state(NR_KERNEL_STACK) * THREAD_SIZE / 1024, K(global_page_state(NR_PAGETABLE)), #ifdef CONFIG_QUICKLIST K(quicklist_total_size()), #endif K(global_page_state(NR_UNSTABLE_NFS)), K(global_page_state(NR_BOUNCE)), K(global_page_state(NR_WRITEBACK_TEMP)), K(allowed), K(committed), (unsigned long)VMALLOC_TOTAL >> 10, vmi.used >> 10, vmi.largest_chunk >> 10 #ifdef CONFIG_MEMORY_FAILURE ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10) #endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR) #endif ); hugetlb_report_meminfo(m); arch_report_meminfo(m); return 0; #undef K } static int meminfo_proc_open(struct inode *inode, struct file *file) { return single_open(file, meminfo_proc_show, NULL); } static const struct file_operations meminfo_proc_fops = { .open = meminfo_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int __init proc_meminfo_init(void) { proc_create("meminfo", 0, NULL, &meminfo_proc_fops); return 0; } module_init(proc_meminfo_init);
25.471795
68
0.688343
e70792bc697f6501598e2a72e3ef6b39b730153b
7,566
c
C
C/imageio.c
Jimmy-Hu/3dFDCT
6a363674a1aac592f0f34e1f3e033ec3a66b6e32
[ "Apache-2.0" ]
null
null
null
C/imageio.c
Jimmy-Hu/3dFDCT
6a363674a1aac592f0f34e1f3e033ec3a66b6e32
[ "Apache-2.0" ]
null
null
null
C/imageio.c
Jimmy-Hu/3dFDCT
6a363674a1aac592f0f34e1f3e033ec3a66b6e32
[ "Apache-2.0" ]
null
null
null
/* Develop by Jimmy Hu */ #include "imageio.h" RGB *raw_image_to_array(const int xsize, const int ysize, const unsigned char * const image) { RGB *output; output = malloc(sizeof *output * xsize * ysize); if(output == NULL) { printf("Memory allocation error!"); return NULL; } unsigned char FillingByte; FillingByte = bmp_filling_byte_calc(xsize); for(int y = 0; y < ysize; y++) { for(int x = 0; x < xsize; x++) { for (int color = 0; color < 3; color++) { output[y * xsize + x].channels[color] = image[3 * (y * xsize + x) + y * FillingByte + (2 - color)]; } } } return output; } //----bmp_read_x_size function---- unsigned long bmp_read_x_size(const char *filename, const bool extension) { char fname_bmp[MAX_PATH]; if(extension == false) { sprintf(fname_bmp, "%s.bmp", filename); } else { strcpy(fname_bmp,filename); } FILE *fp; fp = fopen(fname_bmp, "rb"); if (fp == NULL) { printf("Fail to read file!\n"); return -1; } unsigned char header[54]; fread(header, sizeof(unsigned char), 54, fp); unsigned long output; output = header[18] + ((unsigned long)header[19] << 8) + ((unsigned long)header[20] << 16) + ((unsigned long)header[21] << 24); fclose(fp); return output; } //---- bmp_read_y_size function ---- unsigned long bmp_read_y_size(const char * const filename, const bool extension) { char fname_bmp[MAX_PATH]; if(extension == false) { sprintf(fname_bmp, "%s.bmp", filename); } else { strcpy(fname_bmp,filename); } FILE *fp; fp = fopen(fname_bmp, "rb"); if (fp == NULL) { printf("Fail to read file!\n"); return -1; } unsigned char header[54]; fread(header, sizeof(unsigned char), 54, fp); unsigned long output; output= header[22] + ((unsigned long)header[23] << 8) + ((unsigned long)header[24] << 16) + ((unsigned long)header[25] << 24); fclose(fp); return output; } //---- bmp_file_read function ---- char bmp_read(unsigned char * const image, const int xsize, const int ysize, const char * const filename, const bool extension) { char fname_bmp[MAX_PATH]; if(extension == false) { sprintf(fname_bmp, "%s.bmp", filename); } else { strcpy(fname_bmp,filename); } unsigned char filling_bytes; filling_bytes = bmp_filling_byte_calc(xsize); FILE *fp; fp = fopen(fname_bmp, "rb"); if (fp==NULL) { printf("Fail to read file!\n"); return -1; } unsigned char header[54]; fread(header, sizeof(unsigned char), 54, fp); fread(image, sizeof(unsigned char), (size_t)(long)(xsize * 3 + filling_bytes)*ysize, fp); fclose(fp); return 0; } BMPIMAGE bmp_file_read(const char * const filename, const bool extension) { BMPIMAGE output; stpcpy(output.FILENAME, ""); output.XSIZE = 0; output.YSIZE = 0; output.IMAGE_DATA = NULL; if(filename == NULL) { printf("Path is null\n"); return output; } char fname_bmp[MAX_PATH]; if(extension == false) { sprintf(fname_bmp, "%s.bmp", filename); } else { strcpy(fname_bmp,filename); } FILE *fp; fp = fopen(fname_bmp, "rb"); if (fp == NULL) { printf("Fail to read file!\n"); return output; } stpcpy(output.FILENAME, fname_bmp); output.XSIZE = (unsigned int)bmp_read_x_size(output.FILENAME,true); output.YSIZE = (unsigned int)bmp_read_y_size(output.FILENAME,true); if( (output.XSIZE == -1) || (output.YSIZE == -1) ) { printf("Fail to fetch information of image!"); return output; } else { printf("Width of the input image: %d\n",output.XSIZE); printf("Height of the input image: %d\n",output.YSIZE); printf("Size of the input image(Byte): %d\n", (size_t)output.XSIZE * output.YSIZE * 3); output.FILLINGBYTE = bmp_filling_byte_calc(output.XSIZE); output.IMAGE_DATA = malloc(sizeof *output.IMAGE_DATA * (output.XSIZE * 3 + output.FILLINGBYTE) * output.YSIZE); if (output.IMAGE_DATA == NULL) { printf("Memory allocation error!"); return output; } else { for(int i = 0; i < ((output.XSIZE * 3 + output.FILLINGBYTE) * output.YSIZE);i++) { output.IMAGE_DATA[i] = 255; } bmp_read(output.IMAGE_DATA, output.XSIZE, output.YSIZE, output.FILENAME, true); } } return output; } //----bmp_write function---- int bmp_write(const char * const filename, const int xsize, const int ysize, const unsigned char * const image) { unsigned char FillingByte; FillingByte = bmp_filling_byte_calc(xsize); unsigned char header[54] = { 0x42, 0x4d, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned long file_size = (long)xsize * (long)ysize * 3 + 54; unsigned long width, height; char fname_bmp[MAX_PATH]; header[2] = (unsigned char)(file_size &0x000000ff); header[3] = (file_size >> 8) & 0x000000ff; header[4] = (file_size >> 16) & 0x000000ff; header[5] = (file_size >> 24) & 0x000000ff; width = xsize; header[18] = width & 0x000000ff; header[19] = (width >> 8) &0x000000ff; header[20] = (width >> 16) &0x000000ff; header[21] = (width >> 24) &0x000000ff; height = ysize; header[22] = height &0x000000ff; header[23] = (height >> 8) &0x000000ff; header[24] = (height >> 16) &0x000000ff; header[25] = (height >> 24) &0x000000ff; sprintf(fname_bmp, "%s.bmp", filename); FILE *fp; if (!(fp = fopen(fname_bmp, "wb"))) { return -1; } fwrite(header, sizeof(unsigned char), 54, fp); fwrite(image, sizeof(unsigned char), (size_t)(long)(xsize * 3 + FillingByte) * ysize, fp); fclose(fp); return 0; } unsigned char *array_to_raw_image(const int xsize, const int ysize, const RGB* const input_data) { unsigned char FillingByte; FillingByte = bmp_filling_byte_calc(xsize); unsigned char *output; output = malloc(sizeof *output * (xsize * 3 + FillingByte) * ysize); if(output == NULL) { printf("Memory allocation error!"); return NULL; } for(int y = 0;y < ysize;y++) { for(int x = 0;x < (xsize * 3 + FillingByte);x++) { output[y * (xsize * 3 + FillingByte) + x] = 0; } } for(int y = 0;y<ysize;y++) { for(int x = 0;x<xsize;x++) { for (int color = 0; color < 3; color++) { output[3 * (y * xsize + x) + y * FillingByte + (2 - color)] = input_data[y*xsize + x].channels[color]; } } } return output; } unsigned char bmp_filling_byte_calc(const unsigned int xsize) { unsigned char filling_bytes; filling_bytes = ( xsize % 4); return filling_bytes; }
29.325581
127
0.543881
aa8be7499f5936951bc8c7d9caf1d16158006c55
7,290
c
C
mpc/tests/ptest.c
gbr/slur
c3042beaf2169f2d0e53e56b5eff3a9b24a08d85
[ "MIT" ]
null
null
null
mpc/tests/ptest.c
gbr/slur
c3042beaf2169f2d0e53e56b5eff3a9b24a08d85
[ "MIT" ]
null
null
null
mpc/tests/ptest.c
gbr/slur
c3042beaf2169f2d0e53e56b5eff3a9b24a08d85
[ "MIT" ]
null
null
null
#include "ptest.h" #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <time.h> #include <unistd.h> /* Globals */ enum { MAX_NAME = 512 }; enum { MAX_ERROR = 2048 }; enum { MAX_TESTS = 2048 }; static int test_passing = 0; static int suite_passing = 0; /* Colors */ enum { BLACK = 0x0, BLUE = 0x1, GREEN = 0x2, AQUA = 0x3, RED = 0x4, PURPLE = 0x5, YELLOW = 0x6, WHITE = 0x7, GRAY = 0x8, LIGHT_BLUE = 0x9, LIGHT_GREEN = 0xA, LIGHT_AQUA = 0xB, LIGHT_RED = 0xC, LIGHT_PURPLE = 0xD, LIGHT_YELLOW = 0xE, LIGHT_WHITE = 0xF }; #ifdef _WIN32 #include <windows.h> static void pt_color(int color) { HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hCon, color); } #else static const char* colors[] = { "\x1B[0m", "\x1B[34m", "\x1B[32m", "\x1B[36m", "\x1B[31m", "\x1B[35m", "\x1B[33m", "\x1B[37m", "", "\x1B[34m", "\x1B[32m", "\x1B[36m", "\x1B[31m", "\x1B[35m", "\x1B[33m", "\x1B[37m" }; static void pt_color(int color) { printf("%s", colors[color]); } #endif /* Asserts */ static int num_asserts = 0; static int num_assert_passes = 0; static int num_assert_fails = 0; static char assert_err[MAX_ERROR]; static char assert_err_buff[MAX_ERROR]; static int assert_err_num = 0; void pt_assert_run(int result, const char* expr, const char* func, const char* file, int line) { (void) func; num_asserts++; test_passing = test_passing && result; if (result) { num_assert_passes++; } else { sprintf(assert_err_buff, " %i. Assert [ %s ] (%s:%i)\n", assert_err_num+1, expr, file, line ); strcat(assert_err, assert_err_buff); assert_err_num++; num_assert_fails++; } } static void ptest_signal(int sig) { test_passing = 0; switch( sig ) { case SIGFPE: sprintf(assert_err_buff, " %i. Division by Zero\n", assert_err_num+1); break; case SIGILL: sprintf(assert_err_buff, " %i. Illegal Instruction\n", assert_err_num+1); break; case SIGSEGV: sprintf(assert_err_buff, " %i. Segmentation Fault\n", assert_err_num+1); break; default: break; } assert_err_num++; strcat(assert_err, assert_err_buff); pt_color(WHITE); pt_color(RED); printf("Failed! \n\n%s\n", assert_err); pt_color(WHITE); printf(" | Stopping Execution.\n"); fflush(stdout); exit(0); } /* Tests */ static void pt_title_case(char* output, const char* input) { int space = 1; size_t i; strcpy(output, input); for(i = 0; i < strlen(output); i++) { if (output[i] == '_' || output[i] == ' ') { space = 1; output[i] = ' '; continue; } if (space && output[i] >= 'a' && output[i] <= 'z') { space = 0; output[i] = output[i] - 32; continue; } space = 0; } } typedef struct { void (*func)(void); char name[MAX_NAME]; char suite[MAX_NAME]; } test_t; static test_t tests[MAX_TESTS]; static int num_tests = 0; static int num_tests_passes = 0; static int num_tests_fails = 0; void pt_add_test(void (*func)(void), const char* name, const char* suite) { test_t test; if (num_tests == MAX_TESTS) { printf("ERROR: Exceeded maximum test count of %i!\n", MAX_TESTS); abort(); } if (strlen(name) >= MAX_NAME) { printf("ERROR: Test name '%s' too long (Maximum is %i characters)\n", name, MAX_NAME); abort(); } if (strlen(suite) >= MAX_NAME) { printf("ERROR: Test suite '%s' too long (Maximum is %i characters)\n", suite, MAX_NAME); abort(); } test.func = func; pt_title_case(test.name, name); pt_title_case(test.suite, suite); tests[num_tests] = test; num_tests++; } /* Suites */ static int num_suites = 0; static int num_suites_passes = 0; static int num_suites_fails = 0; void pt_add_suite(void (*func)(void)) { num_suites++; func(); } /* Running */ static clock_t start, end; static char current_suite[MAX_NAME]; int pt_run(void) { int i; double total; printf(" \n"); printf(" +-------------------------------------------+\n"); printf(" | ptest MicroTesting Magic for C |\n"); printf(" | |\n"); printf(" | http://github.com/orangeduck/ptest |\n"); printf(" | |\n"); printf(" | Daniel Holden (contact@theorangeduck.com) |\n"); printf(" +-------------------------------------------+\n"); signal(SIGFPE, ptest_signal); signal(SIGILL, ptest_signal); signal(SIGSEGV, ptest_signal); start = clock(); strcpy(current_suite, ""); for(i = 0; i < num_tests; i++) { test_t test = tests[i]; /* Check for transition to a new suite */ if (strcmp(test.suite, current_suite)) { /* Don't increment any counter for first entrance */ if (strcmp(current_suite, "")) { if (suite_passing) { num_suites_passes++; } else { num_suites_fails++; } } suite_passing = 1; strcpy(current_suite, test.suite); printf("\n\n ===== %s =====\n\n", current_suite); } /* Run Test */ test_passing = 1; strcpy(assert_err, ""); strcpy(assert_err_buff, ""); assert_err_num = 0; printf(" | %s ... ", test.name); test.func(); suite_passing = suite_passing && test_passing; if (test_passing) { num_tests_passes++; pt_color(GREEN); printf("Passed! \n"); pt_color(WHITE); } else { num_tests_fails++; pt_color(RED); printf("Failed! \n\n%s\n", assert_err); pt_color(WHITE); } } if (suite_passing) { num_suites_passes++; } else { num_suites_fails++; } end = clock(); printf(" \n"); printf(" +---------------------------------------------------+\n"); printf(" | Summary |\n"); printf(" +---------++------------+-------------+-------------+\n"); printf(" | Suites ||"); pt_color(YELLOW); printf(" Total %4d ", num_suites); pt_color(WHITE); printf("|"); pt_color(GREEN); printf(" Passed %4d ", num_suites_passes); pt_color(WHITE); printf("|"); pt_color(RED); printf(" Failed %4d ", num_suites_fails); pt_color(WHITE); printf("|\n"); printf(" | Tests ||"); pt_color(YELLOW); printf(" Total %4d ", num_tests); pt_color(WHITE); printf("|"); pt_color(GREEN); printf(" Passed %4d ", num_tests_passes); pt_color(WHITE); printf("|"); pt_color(RED); printf(" Failed %4d ", num_tests_fails); pt_color(WHITE); printf("|\n"); printf(" | Asserts ||"); pt_color(YELLOW); printf(" Total %4d ", num_asserts); pt_color(WHITE); printf("|"); pt_color(GREEN); printf(" Passed %4d ", num_assert_passes); pt_color(WHITE); printf("|"); pt_color(RED); printf(" Failed %4d ", num_assert_fails); pt_color(WHITE); printf("|\n"); printf(" +---------++------------+-------------+-------------+\n"); printf(" \n"); total = (double)(end - start) / CLOCKS_PER_SEC; printf(" Total Running Time: %0.3fs\n\n", total); if (num_suites_fails > 0) { return 1; } else { return 0; } }
22.996845
105
0.555144
10712a9eda7be7164e2dc0576583a8242ed67859
910
c
C
src/rtlib/file_seek.c
zai1208/fbc
02cc78513c9e9d2aeab93dd41994f7593fceff48
[ "MIT" ]
521
2015-01-13T20:42:25.000Z
2022-03-24T19:13:18.000Z
src/rtlib/file_seek.c
jayrm/fbc
ae665330eefc276bc16c0831657b714ee2f592fd
[ "MIT" ]
196
2015-02-06T14:01:07.000Z
2022-03-30T18:10:33.000Z
src/rtlib/file_seek.c
jayrm/fbc
ae665330eefc276bc16c0831657b714ee2f592fd
[ "MIT" ]
142
2015-02-04T03:59:44.000Z
2022-03-09T07:33:33.000Z
/* SEEK() and SEEK */ #include "fb.h" int fb_FileSeekEx( FB_FILE *handle, fb_off_t newpos ) { int res; if( !FB_HANDLE_USED(handle) ) return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); FB_LOCK(); /* clear put back buffer for every modifying non-read operation */ handle->putback_size = 0; /* convert to 0 based file i/o */ --newpos; if( handle->mode == FB_FILE_MODE_RANDOM ) newpos = newpos * handle->len; if (handle->hooks->pfnSeek!=NULL) { res = handle->hooks->pfnSeek(handle, newpos, SEEK_SET ); } else { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } FB_UNLOCK(); return res; } FBCALL int fb_FileSeek( int fnum, int newpos ) { return fb_FileSeekEx( FB_FILE_TO_HANDLE(fnum), newpos ); } FBCALL int fb_FileSeekLarge( int fnum, long long newpos ) { return fb_FileSeekEx( FB_FILE_TO_HANDLE(fnum), newpos ); }
21.666667
70
0.665934
a261e7f9aa0aafb6cfd7100de61007a98dd12c4d
2,139
h
C
include/hal/tch_usart.h
fritzprix/tachyos_app
9c4463c213b6fec4a1384b419c0e06fd30a0c0e6
[ "Apache-2.0" ]
null
null
null
include/hal/tch_usart.h
fritzprix/tachyos_app
9c4463c213b6fec4a1384b419c0e06fd30a0c0e6
[ "Apache-2.0" ]
null
null
null
include/hal/tch_usart.h
fritzprix/tachyos_app
9c4463c213b6fec4a1384b419c0e06fd30a0c0e6
[ "Apache-2.0" ]
null
null
null
/* * tch_usart.h * * Copyright (C) 2014 doowoong,lee * All rights reserved. * * This software may be modified and distributed under the terms * of the LGPL v3 license. See the LICENSE file for details. * * * Created on: 2014. 6. 15. * Author: innocentevil */ #ifndef TCH_USART_H_ #define TCH_USART_H_ #include "tch.h" #if defined(_cplusplus) extern "C"{ #endif #define tch_USART0 ((uart_t) 0) #define tch_USART1 ((uart_t) 1) #define tch_USART2 ((uart_t) 2) #define tch_USART3 ((uart_t) 3) #define tch_USART4 ((uart_t) 4) #define tch_USART5 ((uart_t) 5) #define tch_USART6 ((uart_t) 6) #define tch_USART7 ((uart_t) 7) #define USART_StopBit_1B (uint8_t) (0) #define USART_StopBit_0dot5B (uint8_t) (1) #define USART_StopBit_2B (uint8_t) (2) #define USART_StopBit_1dot5B (uint8_t) (3) #define USART_Parity_NON (uint8_t) (0 << 1 | 0 << 0) #define USART_Parity_ODD (uint8_t) (1 << 1 | 1 << 0) #define USART_Parity_EVEN (uint8_t) (1 << 1 | 0 << 0) typedef uint8_t uart_t; typedef struct tch_usart_handle_s* tch_usartHandle; typedef struct tch_usart_cfg_s tch_UartCfg; struct tch_usart_cfg_s { uint8_t StopBit; uint8_t Parity; uint32_t Buadrate; BOOL FlowCtrl; }; struct tch_usart_handle_s { tchStatus (*close)(tch_usartHandle handle); tchStatus (*put)(tch_usartHandle handle,uint8_t c); tchStatus (*get)(tch_usartHandle handle,uint8_t* rc,uint32_t timeout); tchStatus (*write)(tch_usartHandle handle,const uint8_t* bp,uint32_t sz); uint32_t (*read)(tch_usartHandle handle,uint8_t* bp, uint32_t sz,uint32_t timeout); }; typedef struct tch_lld_usart { const uint8_t count; tch_usartHandle (*const allocate)(const tch* env,uart_t port,tch_UartCfg* cfg,uint32_t timeout,tch_PwrOpt popt); }tch_lld_usart; #if defined(_cplusplus) } #endif #endif /* TCH_USART_H_ */
27.423077
113
0.619916
740239d81a074b7a0ffcdd3dbf463135381ff998
2,353
h
C
third_party/OpenImageDenoise/examples/image_io.h
tpsiaki/filament
772af1e8971e65bbff314cf696a9f32da79e3485
[ "Apache-2.0" ]
7
2020-02-28T05:45:58.000Z
2021-08-06T20:46:39.000Z
third_party/OpenImageDenoise/examples/image_io.h
tpsiaki/filament
772af1e8971e65bbff314cf696a9f32da79e3485
[ "Apache-2.0" ]
7
2019-08-23T17:54:13.000Z
2020-02-01T06:59:52.000Z
third_party/OpenImageDenoise/examples/image_io.h
tpsiaki/filament
772af1e8971e65bbff314cf696a9f32da79e3485
[ "Apache-2.0" ]
2
2019-11-21T11:06:00.000Z
2020-03-22T21:48:57.000Z
// ======================================================================== // // Copyright 2009-2019 Intel Corporation // // // // Licensed under the Apache License, Version 2.0 (the "License"); // // you may not use this file except in compliance with the License. // // You may obtain a copy of the License at // // // // http://www.apache.org/licenses/LICENSE-2.0 // // // // Unless required by applicable law or agreed to in writing, software // // distributed under the License is distributed on an "AS IS" BASIS, // // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // // limitations under the License. // // ======================================================================== // #pragma once #include <string> #include <vector> #include <array> namespace oidn { class ImageBuffer { private: std::vector<float> data; int width; int height; int channels; public: ImageBuffer() : width(0), height(0), channels(0) {} ImageBuffer(int width, int height, int channels) : data(width * height * channels), width(width), height(height), channels(channels) {} operator bool() const { return data.data() != nullptr; } const float& operator [](size_t i) const { return data[i]; } float& operator [](size_t i) { return data[i]; } int getWidth() const { return width; } int getHeight() const { return height; } std::array<int, 2> getSize() const { return {width, height}; } int getChannels() const { return channels; } const float* getData() const { return data.data(); } float* getData() { return data.data(); } int getDataSize() { return int(data.size()); } }; ImageBuffer loadImage(const std::string& filename); void saveImage(const std::string& filename, const ImageBuffer& image); } // namespace oidn
35.119403
78
0.493838
4e23a099c829f29426fe7eaacbee14588f486ea6
802
h
C
logdevice/lib/verifier/DataSourceWriter.h
SimonKinds/LogDevice
fc9ac2fccb6faa3292b2b0a610a9eb77fd445824
[ "BSD-3-Clause" ]
1
2018-10-17T06:49:04.000Z
2018-10-17T06:49:04.000Z
logdevice/lib/verifier/DataSourceWriter.h
msdgwzhy6/LogDevice
bc2491b7dfcd129e25490c7d5321d3d701f53ac4
[ "BSD-3-Clause" ]
null
null
null
logdevice/lib/verifier/DataSourceWriter.h
msdgwzhy6/LogDevice
bc2491b7dfcd129e25490c7d5321d3d701f53ac4
[ "BSD-3-Clause" ]
null
null
null
/** * Copyright (c) 2018-present, Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <map> #include "logdevice/include/Record.h" #include "logdevice/include/Client.h" namespace facebook { namespace logdevice { // Interface for data handling (appending and reading). class DataSourceWriter { public: // The destructor must be virtual in order to work correctly. virtual ~DataSourceWriter(){}; virtual int append(logid_t logid, std::string payload, append_callback_t cb, AppendAttributes attrs = AppendAttributes()) = 0; }; }} // namespace facebook::logdevice
28.642857
72
0.685786
0855968e0469d9c86dba163655450e565517194a
4,138
h
C
include/priocpp/logger.h
littlemole/prio
b4b1aa33f8770f80d85d92973a932560e8522ad6
[ "MIT" ]
null
null
null
include/priocpp/logger.h
littlemole/prio
b4b1aa33f8770f80d85d92973a932560e8522ad6
[ "MIT" ]
null
null
null
include/priocpp/logger.h
littlemole/prio
b4b1aa33f8770f80d85d92973a932560e8522ad6
[ "MIT" ]
null
null
null
#ifndef MOL_PROMISE_LIBEVENT_PipedProcess_LOGGER_DEF_GUARD_DEFINE_ #define MOL_PROMISE_LIBEVENT_PipedProcess_LOGGER_DEF_GUARD_DEFINE_ /** * \file logger.h */ #ifndef _WIN32 #include "priocpp/pipe.h" namespace prio { #define LOG_LEVEL_FATAL 0 #define LOG_LEVEL_ERROR 1 #define LOG_LEVEL_WARN 2 #define LOG_LEVEL_INFO 3 #define LOG_LEVEL_DEBUG 4 #ifndef DEBUG_LEVEL #define DEBUG_LEVEL 2 #endif #if DEBUG_LEVEL > 3 #define LOG_DEBUG(...) LOG_LEVEL_DEBUG, __func__, __LINE__, __FILE__, __VA_ARGS__ #else #define LOG_DEBUG( ...) #endif #if DEBUG_LEVEL > 2 #define LOG_INFO( ...) LOG_LEVEL_INFO, __func__, __LINE__, __FILE__, __VA_ARGS__ #else #define LOG_INFO( ...) #endif #if DEBUG_LEVEL > 1 #define LOG_WARN( ...) LOG_LEVEL_WARN, __func__, __LINE__, __FILE__, __VA_ARGS__ #else #define LOG_WARN(...) #endif #if DEBUG_LEVEL > 0 #define LOG_ERROR( ...) LOG_LEVEL_ERROR, __func__, __LINE__, __FILE__, __VA_ARGS__ #else #define LOG_ERROR( ...) #endif #define LOG_FATAL(...) LOG_LEVEL_FATAL, __func__, __LINE__, __FILE__, __VA_ARGS__ class LogConfig { public: std::vector<std::function<void(std::string)>> appender; }; inline std::string now() { std::time_t now = std::time(nullptr); std::tm* t = std::gmtime(&now); std::stringstream oss; // std::locale mylocale("de_DE.utf8"); // oss.imbue(mylocale); oss << std::put_time(t, "%Y-%m-%dT%H:%M:%S"); return oss.str(); } inline void log_printf(std::ostream& oss, const char* s ) { while(*s) { if(*s == '"') { oss << "\\\""; s++; continue; } if(*s == '\n') { oss << "\\n"; s++; continue; } if(*s=='%' && *++s != '%') { throw std::runtime_error("invalid format: missing args"); } oss << *s++; } } template<class T, class ... Args> void log_printf(std::ostream& oss, const char* s, T t, Args ... args) { while(*s) { if(*s == '"') { oss << "\\\""; s++; continue; } if(*s == '\n') { oss << "\\n"; s++; continue; } if(*s=='%' && *++s != '%') { oss << t; return log_printf(oss,s,args...); } oss << *s++; } throw std::runtime_error("invalid format: extra args"); } class Logging { public: Logging(std::shared_ptr<LogConfig> c) : pipe_(Pipe::create()), config_(c) { pipe_->asyncLineReader(config_->appender); } ~Logging() { pipe_->close(); } void log(std::string s) { pipe_->write(s) .then([](){}); } private: std::shared_ptr<Pipe> pipe_; std::shared_ptr<LogConfig> config_; }; class Logger { public: Logger(std::shared_ptr<Logging> l) : logger_(l) {} Logger(const std::string& name, std::shared_ptr<Logging> l) : name_(name), logger_(l) { } ~Logger() {} template<class ... Args> void log(int sev , const char* func, int line, const char* file, const char* msg, Args ... args) { std::ostringstream oss; oss << "{\"severity\":\""; switch(sev) { case LOG_LEVEL_FATAL : oss << "FATAL"; break; case LOG_LEVEL_ERROR : oss << "ERROR"; break; case LOG_LEVEL_WARN : oss << "WARN" ; break; case LOG_LEVEL_INFO : oss << "INFO" ; break; case LOG_LEVEL_DEBUG : oss << "DEBUG"; break; } oss << "\", \"logger\":\"" << name_ << "\", \"timestamp\":\"" << now() << "\", "; oss << "\"msg\":\""; log_printf(oss,msg,args...); oss << "\", "; oss << "\"function\":\"" << func << "\", "; oss << "\"file\":\"" << file << "\", "; oss << "\"line\":" << line << " "; oss << "}\n"; logger_->log(oss.str()); } void log() {} // no op template<class ... Args> void operator()(int sev , const char* func, int line, const char* file, const char* msg, Args ... args) { log(sev,func,line,file,msg,args...); } void operator()() {} // no op private: std::string name_; std::shared_ptr<Logging> logger_; }; } #endif #endif
18.473214
104
0.546399
08e5593feb006df43e12d4fd3c8c1e2463563fd7
601
h
C
Applications/Siri/SRSpeechAlternativeTapToEditCellView.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
Applications/Siri/SRSpeechAlternativeTapToEditCellView.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
Applications/Siri/SRSpeechAlternativeTapToEditCellView.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
// // Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20). // // Copyright (C) 1997-2019 Steve Nygard. // #import <UIKit/UIView.h> @class UILabel; @interface SRSpeechAlternativeTapToEditCellView : UIView { UILabel *_tapToEditLabel; // 8 = 0x8 } - (void).cxx_destruct; // IMP=0x000000010008c84c - (void)layoutSubviews; // IMP=0x000000010008c744 - (struct CGSize)sizeThatFits:(struct CGSize)arg1; // IMP=0x000000010008c734 - (void)setTextHidden:(_Bool)arg1; // IMP=0x000000010008c5a8 - (id)init; // IMP=0x000000010008c348 @end
25.041667
120
0.727121
83a14e0302133719c06e1e395be5a7a271f526aa
9,251
h
C
torch/csrc/jit/codegen/fuser/cuda/resource_strings.h
deltabravozulu/pytorch
c6eef589971e45bbedacc7f65533d1b8f80a6895
[ "Intel" ]
1
2021-03-08T03:43:27.000Z
2021-03-08T03:43:27.000Z
torch/csrc/jit/codegen/fuser/cuda/resource_strings.h
deltabravozulu/pytorch
c6eef589971e45bbedacc7f65533d1b8f80a6895
[ "Intel" ]
1
2021-04-12T19:49:08.000Z
2021-04-12T19:49:08.000Z
torch/csrc/jit/codegen/fuser/cuda/resource_strings.h
deltabravozulu/pytorch
c6eef589971e45bbedacc7f65533d1b8f80a6895
[ "Intel" ]
1
2022-02-23T02:34:50.000Z
2022-02-23T02:34:50.000Z
#pragma once #include <torch/csrc/WindowsTorchApiMacro.h> #include <torch/csrc/jit/frontend/code_template.h> namespace torch { namespace jit { namespace fuser { namespace cuda { /*with type_as not checking type of its input, a fusion group can have non-fp32 tensor as input. Correct code for this case is generated, however, nvrtc does not know how to handle int*_t integer types, so typedefs help it handle those cases*/ #ifdef __HIP_PLATFORM_HCC__ static auto type_declarations_template = CodeTemplate(R"( ${RuntimeHeader} ${HalfHeader} ${RandHeader} #define POS_INFINITY INFINITY #define NEG_INFINITY -INFINITY typedef ${IndexType} IndexType; template<typename T, size_t N> struct TensorInfo { T* data; IndexType sizes[N]; IndexType strides[N]; }; template<typename T> struct TensorInfo<T, 0> { T * data; }; )"); #else static auto type_declarations_template = CodeTemplate(R"( typedef unsigned char uint8_t; typedef signed char int8_t; typedef short int int16_t; typedef long long int int64_t; typedef unsigned long long int uint64_t; ${HalfHeader} ${BFloat16Header} ${RandHeader} #define NAN __int_as_float(0x7fffffff) #define POS_INFINITY __int_as_float(0x7f800000) #define NEG_INFINITY __int_as_float(0xff800000) typedef ${IndexType} IndexType; template<typename T, size_t N> struct TensorInfo { T* data; IndexType sizes[N]; IndexType strides[N]; }; template<typename T> struct TensorInfo<T, 0> { T * data; }; )"); #endif // We rewrite the code for philox RNG from curand as nvrtc couldn't resolve the // curand header correctly. constexpr auto rand_support_literal = R"( class Philox { public: __device__ inline Philox(unsigned long long seed, unsigned long long subsequence, unsigned long long offset) { key.x = (unsigned int)seed; key.y = (unsigned int)(seed >> 32); counter = make_uint4(0, 0, 0, 0); counter.z = (unsigned int)(subsequence); counter.w = (unsigned int)(subsequence >> 32); STATE = 0; incr_n(offset / 4); } __device__ inline unsigned long operator()() { if(STATE == 0) { uint4 counter_ = counter; uint2 key_ = key; for(int i = 0; i < 9; i++) { counter_ = single_round(counter_, key_); key_.x += (kPhilox10A); key_.y += (kPhilox10B); } output = single_round(counter_, key_); incr(); } unsigned long ret; switch(STATE) { case 0: ret = output.x; break; case 1: ret = output.y; break; case 2: ret = output.z; break; case 3: ret = output.w; break; } STATE = (STATE + 1) % 4; return ret; } private: uint4 counter; uint4 output; uint2 key; unsigned int STATE; __device__ inline void incr_n(unsigned long long n) { unsigned int nlo = (unsigned int)(n); unsigned int nhi = (unsigned int)(n >> 32); counter.x += nlo; if (counter.x < nlo) nhi++; counter.y += nhi; if (nhi <= counter.y) return; if (++counter.z) return; ++counter.w; } __device__ inline void incr() { if (++counter.x) return; if (++counter.y) return; if (++counter.z) return; ++counter.w; } __device__ unsigned int mulhilo32(unsigned int a, unsigned int b, unsigned int *result_high) { *result_high = __umulhi(a, b); return a*b; } __device__ inline uint4 single_round(uint4 ctr, uint2 key) { unsigned int hi0; unsigned int hi1; unsigned int lo0 = mulhilo32(kPhiloxSA, ctr.x, &hi0); unsigned int lo1 = mulhilo32(kPhiloxSB, ctr.z, &hi1); uint4 ret = {hi1 ^ ctr.y ^ key.x, lo1, hi0 ^ ctr.w ^ key.y, lo0}; return ret; } static const unsigned long kPhilox10A = 0x9E3779B9; static const unsigned long kPhilox10B = 0xBB67AE85; static const unsigned long kPhiloxSA = 0xD2511F53; static const unsigned long kPhiloxSB = 0xCD9E8D57; }; // Inverse of 2^32. #define M_RAN_INVM32 2.3283064e-10f __device__ __inline__ float uniform(unsigned int x) { return x * M_RAN_INVM32; } )"; constexpr auto rand_param = ",unsigned long long seed, unsigned long long offset"; constexpr auto rand_init = R"( int idx = blockIdx.x*blockDim.x + threadIdx.x; Philox rnd(seed, idx, offset); )"; static auto cuda_compilation_unit_template = CodeTemplate(R"( ${type_declarations} extern "C" __global__ void ${kernelName}(IndexType totalElements, ${formals} ${RandParam}) { ${RandInit} // check whether do vectorized load/store and allocate buffer bool flag_vec4 = true; ${tensorChecks} if (flag_vec4) { for (IndexType linearIndex = 4 * (blockIdx.x * blockDim.x + threadIdx.x); linearIndex < totalElements; linearIndex += 4 * gridDim.x * blockDim.x) { // Convert `linearIndex` into an offset of tensor as it is: ${tensorOffsets} // load 4 at a time ${kernelLoad} #pragma unroll 4 for (int i=0; i<4; i++) { // calculate the results ${kernelBody_vec4} } // store 4 at a time ${kernelStore} } } else { for (IndexType linearIndex = blockIdx.x * blockDim.x + threadIdx.x; linearIndex < totalElements; linearIndex += gridDim.x * blockDim.x) { // Convert `linearIndex` into an offset of tensor: ${tensorOffsets} // calculate the results ${kernelBody} } } } )"); // This snippet enables half support in the jit. Following the pattern for // reductions, fp16 input data is immediately upconverted to float // with __half2float(). All mathematical operations are done on float // values, and if needed the intermediate float representation is // converted to half with __float2half() when writing to a half tensor. #ifdef __HIP_PLATFORM_HCC__ constexpr auto half_support_literal = R"( typedef __half half; )"; #else constexpr auto half_support_literal = R"( #define __HALF_TO_US(var) *(reinterpret_cast<unsigned short *>(&(var))) #define __HALF_TO_CUS(var) *(reinterpret_cast<const unsigned short *>(&(var))) #if defined(__cplusplus) struct __align__(2) __half { __host__ __device__ __half() { } protected: unsigned short __x; }; /* All intrinsic functions are only available to nvcc compilers */ #if defined(__CUDACC__) /* Definitions of intrinsics */ __device__ __half __float2half(const float f) { __half val; asm("{ cvt.rn.f16.f32 %0, %1;}\n" : "=h"(__HALF_TO_US(val)) : "f"(f)); return val; } __device__ float __half2float(const __half h) { float val; asm("{ cvt.f32.f16 %0, %1;}\n" : "=f"(val) : "h"(__HALF_TO_CUS(h))); return val; } )" // MSVC's preprocessor (but not the standard compiler) has a bug // where it incorrectly tokenizes raw string literals, ending when it sees a // " this causes the #endif in this string literal to be treated as a // preprocessor token which, in turn, cause sccache on windows CI to fail. // See https://godbolt.org/z/eVTIJq as an example. // This workaround uses string-pasting to separate the " and the #endif into // different strings R"( #endif /* defined(__CUDACC__) */ #endif /* defined(__cplusplus) */ #undef __HALF_TO_US #undef __HALF_TO_CUS typedef __half half; )"; #endif constexpr auto bfloat16_support_literal = R"( #define __BFLOAT16_TO_US(var) *(reinterpret_cast<unsigned short*>(&(var))) #define __BFLOAT16_TO_CUS(var) \ *(reinterpret_cast<const unsigned short*>(&(var))) typedef struct __align__(2) { unsigned short x; } __nv_bfloat16_raw; #if defined(__cplusplus) struct __align__(2) __nv_bfloat16 { __host__ __device__ __nv_bfloat16() {} __host__ __device__ __nv_bfloat16& operator=(const __nv_bfloat16_raw& hr) { __x = hr.x; return *this; } protected: unsigned short __x; }; #if defined(__CUDACC__) __device__ unsigned short __internal_float2bfloat16( const float f, unsigned int& sign, unsigned int& remainder) { unsigned int x; x = __float_as_uint(f); if ((x & 0x7fffffffU) > 0x7f800000U) { sign = 0U; remainder = 0U; return static_cast<unsigned short>(0x7fffU); } sign = x >> 31; remainder = x << 16; return static_cast<unsigned short>(x >> 16); } /* Definitions of intrinsics */ __device__ __nv_bfloat16 __float2bfloat16(const float a) { __nv_bfloat16 val; #if __CUDA_ARCH__ >= 800 asm("{ cvt.rn.bf16.f32 %0, %1;}\n" : "=h"(__BFLOAT16_TO_US(val)) : "f"(a)); #else __nv_bfloat16_raw r; unsigned int sign; unsigned int remainder; r.x = __internal_float2bfloat16(a, sign, remainder); if ((remainder > 0x80000000U) || ((remainder == 0x80000000U) && ((r.x & 0x1U) != 0U))) { r.x++; } val = r; #endif return val; } __device__ float __bfloat162float(const __nv_bfloat16 a) { float val; asm("{ mov.b32 %0, {0,%1};}\n" : "=f"(val) : "h"(__BFLOAT16_TO_CUS(a))); return val; } #endif /* defined(__CUDACC__) */ #endif /* defined(__cplusplus) */ #undef __BFLOAT16_TO_US #undef __BFLOAT16_TO_CUS )"; } // namespace cuda } // namespace fuser } // namespace jit } // namespace torch
27.208824
80
0.653551
2610f0708a088b08b797125f9d78055dbae052f3
97
h
C
Game/Source/Game/include/MY_Game.h
seleb/ProcJam2015
63702510aec0f5ca7657d60d4132d2a3e8f8a4d3
[ "MIT" ]
null
null
null
Game/Source/Game/include/MY_Game.h
seleb/ProcJam2015
63702510aec0f5ca7657d60d4132d2a3e8f8a4d3
[ "MIT" ]
null
null
null
Game/Source/Game/include/MY_Game.h
seleb/ProcJam2015
63702510aec0f5ca7657d60d4132d2a3e8f8a4d3
[ "MIT" ]
null
null
null
#pragma once #include <Game.h> class MY_Game : public Game{ public: MY_Game(); ~MY_Game(); };
10.777778
28
0.659794
3111f45061c6fb0c5a9b16bb33aacf0d5ce6101c
938
c
C
gcc/tools/synonym.c
razzlefratz/MotleyTools
3c69c574351ce6f4b7e687c13278d4b6cbb200f3
[ "0BSD" ]
2
2015-10-15T19:32:42.000Z
2021-12-20T15:56:04.000Z
gcc/tools/synonym.c
razzlefratz/MotleyTools
3c69c574351ce6f4b7e687c13278d4b6cbb200f3
[ "0BSD" ]
null
null
null
gcc/tools/synonym.c
razzlefratz/MotleyTools
3c69c574351ce6f4b7e687c13278d4b6cbb200f3
[ "0BSD" ]
null
null
null
/*====================================================================* * * char const * synonym (struct _term_ const list [], size_t size, char const * term); * * symbol.h * *. Motley Tools by Charles Maier *: Published 1982-2005 by Charles Maier for personal use *; Licensed under the Internet Software Consortium License * *--------------------------------------------------------------------*/ #ifndef SYNONYM_SOURCE #define SYNONYM_SOURCE #include <string.h> #include "../tools/symbol.h" char const * synonym(struct _term_ const list[], size_t size, char const * term) { size_t lower = 0; size_t upper = size; while (lower < upper) { size_t index = (lower + upper) >> 1; signed order = strcmp(term, list[index].term); if (order < 0) { upper = index - 0; continue; } if (order > 0) { lower = index + 1; continue; } return (list[index].text); } return (term); } #endif
19.541667
88
0.53838
ebf8f12e6fcb898c333aed5edef0ade0c83faddf
499
h
C
xi/core/async_defer.h
Anomander/xi
0340675310c41d659762fc3eea48c84ff13b95db
[ "MIT" ]
null
null
null
xi/core/async_defer.h
Anomander/xi
0340675310c41d659762fc3eea48c84ff13b95db
[ "MIT" ]
null
null
null
xi/core/async_defer.h
Anomander/xi
0340675310c41d659762fc3eea48c84ff13b95db
[ "MIT" ]
null
null
null
#pragma once #include "xi/ext/configure.h" #include "xi/core/async.h" #include "xi/core/shard.h" namespace xi { namespace core { template < class T, class F > void defer(async< T > *a, F &&f) { if (!a || !is_valid(a->shard())) { throw std::logic_error("Invalid async object state."); } a->shard()->post( make_task([ context = a->async_context(), f = move(f) ]() mutable { if (auto lock = context.lock()) { f(); } })); } } }
20.791667
75
0.533066
0365c1b8d1f12cc719e801bbc84da9814fc02b44
2,068
c
C
examples/getstarted/syncsub.c
igor-sinelnikow/nats.c
d746af5f0e695fc4fd82fa765f63c9a230a89530
[ "Apache-2.0" ]
151
2015-10-11T01:18:52.000Z
2019-05-10T12:24:34.000Z
examples/getstarted/syncsub.c
igor-sinelnikow/nats.c
d746af5f0e695fc4fd82fa765f63c9a230a89530
[ "Apache-2.0" ]
164
2019-05-11T01:42:48.000Z
2022-03-08T17:53:37.000Z
examples/getstarted/syncsub.c
igor-sinelnikow/nats.c
d746af5f0e695fc4fd82fa765f63c9a230a89530
[ "Apache-2.0" ]
64
2019-05-22T22:02:16.000Z
2022-03-19T11:59:38.000Z
// Copyright 2017-2018 The NATS 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. #include <nats.h> int main(int argc, char **argv) { natsConnection *conn = NULL; natsSubscription *sub = NULL; natsMsg *msg = NULL; natsStatus s; printf("Listening on subject 'foo'\n"); // Creates a connection to the default NATS URL s = natsConnection_ConnectTo(&conn, NATS_DEFAULT_URL); if (s == NATS_OK) { // Creates an synchronous subscription on subject "foo". s = natsConnection_SubscribeSync(&sub, conn, "foo"); } if (s == NATS_OK) { // With synchronous subscriptions, one need to poll // using this function. A timeout is used to instruct // how long we are willing to wait. The wait is in milliseconds. // So here, we are going to wait for 5 seconds. s = natsSubscription_NextMsg(&msg, sub, 5000); } if (s == NATS_OK) { // If we are here, we should have received a message. printf("Received msg: %s - %.*s\n", natsMsg_GetSubject(msg), natsMsg_GetDataLength(msg), natsMsg_GetData(msg)); // Need to destroy the message! natsMsg_Destroy(msg); } // Anything that is created need to be destroyed natsSubscription_Destroy(sub); natsConnection_Destroy(conn); // If there was an error, print a stack trace and exit if (s != NATS_OK) { nats_PrintLastErrorStack(stderr); exit(2); } return 0; }
31.815385
75
0.637331
d9a3eaa5af1574162522e359e51ccf672c404ca9
16,303
c
C
pango/src/rbpangolayout.c
pkorenev/ruby-gnome2
08011d8535529a3866f877817f29361b1b0703d7
[ "Ruby" ]
2
2016-05-08T20:57:12.000Z
2017-07-28T21:00:42.000Z
pango/src/rbpangolayout.c
pkorenev/ruby-gnome2
08011d8535529a3866f877817f29361b1b0703d7
[ "Ruby" ]
null
null
null
pango/src/rbpangolayout.c
pkorenev/ruby-gnome2
08011d8535529a3866f877817f29361b1b0703d7
[ "Ruby" ]
2
2016-07-23T09:53:08.000Z
2021-07-13T07:21:05.000Z
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ /************************************************ rbpangolayout.c - $Author: ggc $ $Date: 2007/07/13 16:07:33 $ Copyright (C) 2002-2005 Masao Mutoh ************************************************/ #include "rbpango.h" #define _SELF(self) (PANGO_LAYOUT(RVAL2GOBJ(self))) #define RVAL2CONTEXT(v) (PANGO_CONTEXT(RVAL2GOBJ(v))) static VALUE layout_initialize(self, context) VALUE self, context; { G_INITIALIZE(self, pango_layout_new(RVAL2CONTEXT(context))); return Qnil; } static VALUE layout_copy(VALUE self) { return GOBJ2RVAL_UNREF(pango_layout_copy(_SELF(self))); } static VALUE layout_get_context(self) VALUE self; { return GOBJ2RVAL(pango_layout_get_context(_SELF(self))); } static VALUE layout_context_changed(self) VALUE self; { pango_layout_context_changed(_SELF(self)); return Qnil; } static VALUE layout_set_text(self, text) VALUE self, text; { pango_layout_set_text(_SELF(self), RVAL2CSTR(text), RSTRING_LEN(text)); return self; } static VALUE layout_get_text(self) VALUE self; { return CSTR2RVAL(pango_layout_get_text(_SELF(self))); } static VALUE layout_set_markup(argc, argv, self) int argc; VALUE *argv; VALUE self; { VALUE markup, accel_marker; gunichar accel_char = 0; rb_scan_args(argc, argv, "11", &markup, &accel_marker); if (NIL_P(accel_marker)){ pango_layout_set_markup(_SELF(self), RVAL2CSTR(markup), RSTRING_LEN(markup)); } else { pango_layout_set_markup_with_accel(_SELF(self), RVAL2CSTR(markup), RSTRING_LEN(markup), NUM2CHR(accel_marker), &accel_char); } return CHR2FIX(accel_char); } static VALUE layout_set_markup_eq(self, markup) VALUE self, markup; { pango_layout_set_markup(_SELF(self), RVAL2CSTR(markup), RSTRING_LEN(markup)); return markup; } static VALUE layout_set_attributes(self, attrs) VALUE self, attrs; { pango_layout_set_attributes(_SELF(self), (PangoAttrList*)(RVAL2BOXED(attrs, PANGO_TYPE_ATTR_LIST))); return self; } static VALUE layout_get_attributes(self) VALUE self; { return BOXED2RVAL(pango_layout_get_attributes(_SELF(self)), PANGO_TYPE_ATTR_LIST); } static VALUE layout_set_font_description(VALUE self, VALUE rb_desc) { PangoFontDescription *desc; gboolean desc_created = FALSE; if (RVAL2CBOOL(rb_obj_is_kind_of(rb_desc, rb_cString))) { desc = pango_font_description_from_string(RVAL2CSTR(rb_desc)); desc_created = TRUE; } else { desc = RVAL2BOXED(rb_desc, PANGO_TYPE_FONT_DESCRIPTION); } pango_layout_set_font_description(_SELF(self), desc); if (desc_created) pango_font_description_free(desc); return self; } #ifdef HAVE_PANGO_LAYOUT_GET_FONT_DESCRIPTION static VALUE layout_get_font_description(self) VALUE self; { const PangoFontDescription* desc = pango_layout_get_font_description(_SELF(self)); return BOXED2RVAL((gpointer)desc, PANGO_TYPE_FONT_DESCRIPTION); } #endif static VALUE layout_set_width(self, width) VALUE self, width; { pango_layout_set_width(_SELF(self), NUM2INT(width)); return self; } static VALUE layout_get_width(self) VALUE self; { return INT2NUM(pango_layout_get_width(_SELF(self))); } static VALUE layout_set_wrap(self, wrap) VALUE self, wrap; { pango_layout_set_wrap(_SELF(self), RVAL2GENUM(wrap, PANGO_TYPE_WRAP_MODE)); return self; } static VALUE layout_get_wrap(self) VALUE self; { return GENUM2RVAL(pango_layout_get_wrap(_SELF(self)), PANGO_TYPE_WRAP_MODE); } #ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE static VALUE layout_set_ellipsize(self, ellipsize) VALUE self, ellipsize; { pango_layout_set_ellipsize(_SELF(self), RVAL2GENUM(ellipsize, PANGO_TYPE_ELLIPSIZE_MODE)); return self; } static VALUE layout_get_ellipsize(self) VALUE self; { return GENUM2RVAL(pango_layout_get_ellipsize(_SELF(self)), PANGO_TYPE_ELLIPSIZE_MODE); } #endif static VALUE layout_set_indent(self, indent) VALUE self, indent; { pango_layout_set_indent(_SELF(self), NUM2INT(indent)); return self; } static VALUE layout_get_indent(self) VALUE self; { return INT2NUM(pango_layout_get_indent(_SELF(self))); } static VALUE layout_get_spacing(self) VALUE self; { return INT2NUM(pango_layout_get_spacing(_SELF(self))); } static VALUE layout_set_spacing(self, spacing) VALUE self, spacing; { pango_layout_set_spacing(_SELF(self), NUM2INT(spacing)); return self; } static VALUE layout_set_justify(self, justify) VALUE self, justify; { pango_layout_set_justify(_SELF(self), RVAL2CBOOL(justify)); return self; } static VALUE layout_get_justify(self) VALUE self; { return CBOOL2RVAL(pango_layout_get_justify(_SELF(self))); } #if PANGO_CHECK_VERSION(1,4,0) static VALUE layout_set_auto_dir(self, auto_dir) VALUE self, auto_dir; { pango_layout_set_auto_dir(_SELF(self), RVAL2CBOOL(auto_dir)); return self; } static VALUE layout_get_auto_dir(self) VALUE self; { return CBOOL2RVAL(pango_layout_get_auto_dir(_SELF(self))); } #endif static VALUE layout_set_alignment(self, align) VALUE self, align; { pango_layout_set_alignment(_SELF(self), RVAL2GENUM(align, PANGO_TYPE_ALIGNMENT)); return self; } static VALUE layout_get_alignment(self) VALUE self; { return GENUM2RVAL(pango_layout_get_alignment(_SELF(self)), PANGO_TYPE_ALIGNMENT); } static VALUE layout_set_tabs(self, tabs) VALUE self,tabs; { pango_layout_set_tabs(_SELF(self), (PangoTabArray*)RVAL2BOXED(self, PANGO_TYPE_TAB_ARRAY)); return self; } static VALUE layout_get_tabs(self) VALUE self; { VALUE ret = Qnil; PangoTabArray* tabs = pango_layout_get_tabs(_SELF(self)); if (tabs) { ret = BOXED2RVAL(tabs, PANGO_TYPE_TAB_ARRAY); pango_tab_array_free(tabs); } return ret; } static VALUE layout_set_single_paragraph_mode(self, setting) VALUE self, setting; { pango_layout_set_single_paragraph_mode(_SELF(self), RVAL2CBOOL(setting)); return self; } static VALUE layout_get_single_paragraph_mode(self) VALUE self; { return CBOOL2RVAL(pango_layout_get_single_paragraph_mode(_SELF(self))); } static VALUE layout_get_log_attrs(self) VALUE self; { PangoLogAttr* attrs; gint i, n_attrs; VALUE ary; pango_layout_get_log_attrs(_SELF(self), &attrs, &n_attrs); ary = rb_ary_new(); for (i = 0; i < n_attrs; i++) { rb_ary_assoc(ary, BOXED2RVAL(&attrs[i], PANGO_TYPE_LOG_ATTR)); } g_free(attrs); return ary; } static VALUE layout_xy_to_index(self, x, y) VALUE self, x, y; { int index, trailing; gboolean ret = pango_layout_xy_to_index(_SELF(self), NUM2INT(x), NUM2INT(y), &index, &trailing); return rb_ary_new3(3, CBOOL2RVAL(ret), INT2NUM(index), INT2NUM(trailing)); } static VALUE layout_index_to_pos(self, index) VALUE self, index; { PangoRectangle pos; pango_layout_index_to_pos(_SELF(self), NUM2INT(index), &pos); return BOXED2RVAL(&pos, PANGO_TYPE_RECTANGLE); } static VALUE layout_get_cursor_pos(self, index) VALUE self, index; { PangoRectangle strong_pos, weak_pos; pango_layout_get_cursor_pos(_SELF(self), NUM2INT(index), &strong_pos, &weak_pos); return rb_ary_new3(2, BOXED2RVAL(&strong_pos, PANGO_TYPE_RECTANGLE), BOXED2RVAL(&weak_pos, PANGO_TYPE_RECTANGLE)); } static VALUE layout_move_cursor_visually(self, strong, old_index, old_trailing, direction) VALUE self, strong, old_index, old_trailing, direction; { int new_index, new_trailing; pango_layout_move_cursor_visually(_SELF(self), RVAL2CBOOL(strong), NUM2INT(old_index), NUM2INT(old_trailing), NUM2INT(direction), &new_index, &new_trailing); return rb_ary_new3(2, INT2NUM(new_index), INT2NUM(new_trailing)); } static VALUE layout_get_extents(argc, argv, self) int argc; VALUE* argv; VALUE self; { VALUE ink_rect, logical_rect; PangoRectangle rink, rlog; rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect); if (NIL_P(ink_rect)){ rink.x = 0; rink.y = 0; rink.width = 0; rink.height = 0; } else { PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(ink_rect, PANGO_TYPE_RECTANGLE); rink.x = rect->x; rink.y = rect->y; rink.width = rect->width; rink.height = rect->height; } if (NIL_P(logical_rect)){ rlog.x = 0; rlog.y = 0; rlog.width = 0; rlog.height = 0; } else { PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(logical_rect, PANGO_TYPE_RECTANGLE); rlog.x = rect->x; rlog.y = rect->y; rlog.width = rect->width; rlog.height = rect->height; } pango_layout_get_extents(_SELF(self), &rink, &rlog); return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE), BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE)); } static VALUE layout_extents(self) VALUE self; { PangoRectangle rink = {0, 0, 0, 0}; PangoRectangle rlog = {0, 0, 0, 0}; pango_layout_get_extents(_SELF(self), &rink, &rlog); return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE), BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE)); } static VALUE layout_get_pixel_extents(argc, argv, self) int argc; VALUE* argv; VALUE self; { VALUE ink_rect, logical_rect; PangoRectangle rink, rlog; rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect); if (NIL_P(ink_rect)){ rink.x = 0; rink.y = 0; rink.width = 0; rink.height = 0; } else { PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(ink_rect, PANGO_TYPE_RECTANGLE); rink.x = rect->x; rink.y = rect->y; rink.width = rect->width; rink.height = rect->height; } if (NIL_P(logical_rect)){ rlog.x = 0; rlog.y = 0; rlog.width = 0; rlog.height = 0; } else { PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(logical_rect, PANGO_TYPE_RECTANGLE); rlog.x = rect->x; rlog.y = rect->y; rlog.width = rect->width; rlog.height = rect->height; } pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog); return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE), BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE)); } static VALUE layout_pixel_extents(self) VALUE self; { PangoRectangle rink = {0, 0, 0, 0}; PangoRectangle rlog = {0, 0, 0, 0}; pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog); return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE), BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE)); } static VALUE layout_get_size(self) VALUE self; { int width, height; pango_layout_get_size(_SELF(self), &width, &height); return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); } static VALUE layout_get_pixel_size(self) VALUE self; { int width, height; pango_layout_get_pixel_size(_SELF(self), &width, &height); return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); } static VALUE layout_get_line_count(self) VALUE self; { return INT2NUM(pango_layout_get_line_count(_SELF(self))); } static VALUE layout_get_line(self, line) VALUE self, line; { return BOXED2RVAL(pango_layout_get_line(_SELF(self), NUM2INT(line)), PANGO_TYPE_LAYOUT_LINE); } static VALUE layout_get_lines(self) VALUE self; { return GSLIST2ARY2(pango_layout_get_lines(_SELF(self)), PANGO_TYPE_LAYOUT_LINE); } static VALUE layout_get_iter(self) VALUE self; { return BOXED2RVAL(pango_layout_get_iter(_SELF(self)), PANGO_TYPE_LAYOUT_ITER); } void Init_pango_layout() { VALUE pLayout = G_DEF_CLASS(PANGO_TYPE_LAYOUT, "Layout", mPango); rb_define_method(pLayout, "initialize", layout_initialize, 1); rb_define_method(pLayout, "copy", layout_copy, 0); rb_define_method(pLayout, "context", layout_get_context, 0); rb_define_method(pLayout, "context_changed", layout_context_changed, 0); rb_define_method(pLayout, "set_text", layout_set_text, 1); rb_define_method(pLayout, "text", layout_get_text, 0); rb_define_method(pLayout, "set_markup", layout_set_markup, -1); rb_define_method(pLayout, "markup=", layout_set_markup_eq, 1); rb_define_method(pLayout, "set_attributes", layout_set_attributes, 1); rb_define_method(pLayout, "attributes", layout_get_attributes, 0); rb_define_method(pLayout, "set_font_description", layout_set_font_description, 1); #ifdef HAVE_PANGO_LAYOUT_GET_FONT_DESCRIPTION rb_define_method(pLayout, "font_description", layout_get_font_description, 0); #endif rb_define_method(pLayout, "set_width", layout_set_width, 1); rb_define_method(pLayout, "width", layout_get_width, 0); rb_define_method(pLayout, "set_wrap", layout_set_wrap, 1); rb_define_method(pLayout, "wrap", layout_get_wrap, 0); #ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE rb_define_method(pLayout, "set_ellipsize", layout_set_ellipsize, 1); rb_define_method(pLayout, "ellipsize", layout_get_ellipsize, 0); #endif rb_define_method(pLayout, "set_indent", layout_set_indent, 1); rb_define_method(pLayout, "indent", layout_get_indent, 0); rb_define_method(pLayout, "spacing", layout_get_spacing, 0); rb_define_method(pLayout, "set_spacing", layout_set_spacing, 1); rb_define_method(pLayout, "set_justify", layout_set_justify, 1); rb_define_method(pLayout, "justify?", layout_get_justify, 0); #if PANGO_CHECK_VERSION(1,4,0) rb_define_method(pLayout, "set_auto_dir", layout_set_auto_dir, 1); rb_define_method(pLayout, "auto_dir?", layout_get_auto_dir, 0); #endif rb_define_method(pLayout, "set_alignment", layout_set_alignment, 1); rb_define_method(pLayout, "alignment", layout_get_alignment, 0); rb_define_method(pLayout, "set_tabs", layout_set_tabs, 1); rb_define_method(pLayout, "tabs", layout_get_tabs, 0); rb_define_method(pLayout, "set_single_paragraph_mode", layout_set_single_paragraph_mode, 1); rb_define_method(pLayout, "single_paragraph_mode?", layout_get_single_paragraph_mode, 0); rb_define_method(pLayout, "log_attrs", layout_get_log_attrs, 0); rb_define_method(pLayout, "xy_to_index", layout_xy_to_index, 2); rb_define_method(pLayout, "index_to_pos", layout_index_to_pos, 1); rb_define_method(pLayout, "get_cursor_pos", layout_get_cursor_pos, 1); rb_define_method(pLayout, "move_cursor_visually", layout_move_cursor_visually, 4); rb_define_method(pLayout, "get_extents", layout_get_extents, -1); rb_define_method(pLayout, "extents", layout_extents, 0); rb_define_method(pLayout, "get_pixel_extents", layout_get_pixel_extents, -1); rb_define_method(pLayout, "pixel_extents", layout_pixel_extents, 0); rb_define_method(pLayout, "size", layout_get_size, 0); rb_define_method(pLayout, "pixel_size", layout_get_pixel_size, 0); rb_define_method(pLayout, "line_count", layout_get_line_count, 0); rb_define_method(pLayout, "get_line", layout_get_line, 1); rb_define_method(pLayout, "lines", layout_get_lines, 0); rb_define_method(pLayout, "iter", layout_get_iter, 0); G_DEF_SETTERS(pLayout); /* PangoWrapMode */ G_DEF_CLASS(PANGO_TYPE_WRAP_MODE, "WrapMode", pLayout); G_DEF_CONSTANTS(pLayout, PANGO_TYPE_WRAP_MODE, "PANGO_"); /* PangoAlignment */ G_DEF_CLASS(PANGO_TYPE_ALIGNMENT, "Alignment", pLayout); G_DEF_CONSTANTS(pLayout, PANGO_TYPE_ALIGNMENT, "PANGO_"); #ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE /* PangoEllipsizeMode */ G_DEF_CLASS(PANGO_TYPE_ELLIPSIZE_MODE, "EllipsizeMode", pLayout); G_DEF_CONSTANTS(pLayout, PANGO_TYPE_ELLIPSIZE_MODE, "PANGO_"); #endif }
27.446128
97
0.689505
968a641c7350629b37020d6ec07a9653b7da04d0
72
h
C
A.h
Ursinus-CS174-F2020/Week11_Code
bfdeb0942bd9f42284e0a3ddbf4150b02ab6058a
[ "Apache-2.0" ]
null
null
null
A.h
Ursinus-CS174-F2020/Week11_Code
bfdeb0942bd9f42284e0a3ddbf4150b02ab6058a
[ "Apache-2.0" ]
null
null
null
A.h
Ursinus-CS174-F2020/Week11_Code
bfdeb0942bd9f42284e0a3ddbf4150b02ab6058a
[ "Apache-2.0" ]
null
null
null
#ifndef A_H #define A_H class A { public: int x; }; #endif
8
14
0.541667
96a0df70b83c95bf963907a4f456326b70aa6beb
838
c
C
Competive Programming/C/hackerearth/min-max-difference.c
RitamDey/My-Simple-Programs
147b455a6a40c371ec894ce979e8a61d242e03bd
[ "Unlicense" ]
2
2016-10-14T16:58:05.000Z
2017-05-04T04:59:18.000Z
Competive Programming/C/hackerearth/min-max-difference.c
GreenJoey/My-Simple-Programs
147b455a6a40c371ec894ce979e8a61d242e03bd
[ "Unlicense" ]
null
null
null
Competive Programming/C/hackerearth/min-max-difference.c
GreenJoey/My-Simple-Programs
147b455a6a40c371ec894ce979e8a61d242e03bd
[ "Unlicense" ]
null
null
null
#include <stdio.h> void bubble_sort(int *arr, int len) { unsigned long long int t; for(int i=0; i<len; ++i) { for(int j=0; j<len-1; ++j) { if(arr[j]>arr[j+1]) { t = arr[j+1]; arr[j+1] = arr[j]; arr[j] = t; } } } } int main() { int cases, len, m; scanf("%d", &cases); for(int i=1; i<=cases; ++i) { scanf("%d %d", &len, &m); int arr[len]; for(int i=0; i<len; ++i) scanf("%d", &arr[i]); bubble_sort(arr, len); int diff = len - m; unsigned long long int min = 0, max = 0; for(int i=1; i<=diff; ++i) max += arr[len-i]; for(int i=0; i<diff; ++i) min += arr[i]; printf("%llu\n", max-min); } return 0; }
17.829787
48
0.392601
1b0dd0277e8f73538e38347bb3677e7d6395ee4b
1,651
h
C
generator/templates/ClientStubTemplate.h
sajanshakya129/coappbrpc
9d62865c837c924786f952e3882cdad9343ad2c7
[ "MIT" ]
2
2019-11-24T08:32:44.000Z
2020-02-26T17:30:15.000Z
generator/templates/ClientStubTemplate.h
sajanshakya129/coappbrpc
9d62865c837c924786f952e3882cdad9343ad2c7
[ "MIT" ]
1
2018-10-26T11:46:17.000Z
2018-10-26T11:46:17.000Z
generator/templates/ClientStubTemplate.h
sajanshakya129/coappbrpc
9d62865c837c924786f952e3882cdad9343ad2c7
[ "MIT" ]
null
null
null
/* ClientStubTemplate.h -- Template used to create client * * Copyright (C) 2018 Sajan SHAKYA <sajanshakya129@gmail.com> * * This file is part of the CoAPPBRPC library libcoap. Please see * README for terms of use. */ /** * @file ClientStubTemplate.h * @brief Template used to create client stub automatically * when command "coappbrpc <filename.proto>" is executed in terminal * WARNING: THIS FILE IS AUTOGENERATED. MODIFY IT AT YOUR OWN RISK. */ /*[[[cog import cog,json cog.outl("// This code is automatically generated.") cog.outl("#ifndef __ClientStub_H_INCLUDED_") cog.outl("#define __ClientStub_H_INCLUDED_") with open('protofile.json') as fp: jsonData=json.load(fp) cog.outl("#include \"%s\""% jsonData["headerfile"]) cog.outl("#include <coappbrpc/RpcClient.h>") cog.outl("#include <coappbrpc/Config.h>") cog.outl("using ::coappbrpc::RpcClient;") cog.outl("using ::coappbrpc::Request;") cog.outl("using ::coappbrpc::Response;") for item in jsonData["data"]: if item["type"] == "Message": cog.outl("using ::coappbrpc::api::%s;"%item["name"]) cog.outl("using namespace std;") cog.outl("class ClientStub {") cog.outl("public:") for item in jsonData["data"]: if item["type"]=="Service": for method in item["methods"]: cog.outl("void {0}({1},{2} *);".format(method["method_name"], method["input"], method["output"])) cog.outl("private:") cog.outl("RpcClient *client = RpcClient::getInstance();") cog.outl("string makeRpcPayload(string, string, string, string);") cog.outl("template<typename R> string serializeReq(R);") cog.outl("void executeRPC(string, Response *);") cog.outl("};") cog.outl("#endif") ]]]*/ //[[[end]]]
31.75
100
0.695942
0008ca3185ce64eb163695db2deadbfcff54fd99
4,795
c
C
ompi/mpi/fortran/mpif-h/neighbor_allgatherv_f.c
j-xiong/ompi
859dd8a742af56b9e16af5c584bb25ce5ca55dae
[ "BSD-3-Clause-Open-MPI" ]
1,585
2015-01-03T04:10:59.000Z
2022-03-31T19:48:54.000Z
ompi/mpi/fortran/mpif-h/neighbor_allgatherv_f.c
j-xiong/ompi
859dd8a742af56b9e16af5c584bb25ce5ca55dae
[ "BSD-3-Clause-Open-MPI" ]
7,655
2015-01-04T14:42:56.000Z
2022-03-31T22:51:57.000Z
ompi/mpi/fortran/mpif-h/neighbor_allgatherv_f.c
j-xiong/ompi
859dd8a742af56b9e16af5c584bb25ce5ca55dae
[ "BSD-3-Clause-Open-MPI" ]
846
2015-01-20T15:01:44.000Z
2022-03-27T13:06:07.000Z
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ #include "ompi_config.h" #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak PMPI_NEIGHBOR_ALLGATHERV = ompi_neighbor_allgatherv_f #pragma weak pmpi_neighbor_allgatherv = ompi_neighbor_allgatherv_f #pragma weak pmpi_neighbor_allgatherv_ = ompi_neighbor_allgatherv_f #pragma weak pmpi_neighbor_allgatherv__ = ompi_neighbor_allgatherv_f #pragma weak PMPI_Neighbor_allgatherv_f = ompi_neighbor_allgatherv_f #pragma weak PMPI_Neighbor_allgatherv_f08 = ompi_neighbor_allgatherv_f #else OMPI_GENERATE_F77_BINDINGS (PMPI_NEIGHBOR_ALLGATHERV, pmpi_neighbor_allgatherv, pmpi_neighbor_allgatherv_, pmpi_neighbor_allgatherv__, pompi_neighbor_allgatherv_f, (char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr), (sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm, ierr) ) #endif #endif #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_NEIGHBOR_ALLGATHERV = ompi_neighbor_allgatherv_f #pragma weak mpi_neighbor_allgatherv = ompi_neighbor_allgatherv_f #pragma weak mpi_neighbor_allgatherv_ = ompi_neighbor_allgatherv_f #pragma weak mpi_neighbor_allgatherv__ = ompi_neighbor_allgatherv_f #pragma weak MPI_Neighbor_allgatherv_f = ompi_neighbor_allgatherv_f #pragma weak MPI_Neighbor_allgatherv_f08 = ompi_neighbor_allgatherv_f #else #if ! OMPI_BUILD_MPI_PROFILING OMPI_GENERATE_F77_BINDINGS (MPI_NEIGHBOR_ALLGATHERV, mpi_neighbor_allgatherv, mpi_neighbor_allgatherv_, mpi_neighbor_allgatherv__, ompi_neighbor_allgatherv_f, (char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr), (sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm, ierr) ) #else #define ompi_neighbor_allgatherv_f pompi_neighbor_allgatherv_f #endif #endif void ompi_neighbor_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr) { MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; int size, ierr_c; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); c_comm = PMPI_Comm_f2c(*comm); c_sendtype = PMPI_Type_f2c(*sendtype); c_recvtype = PMPI_Type_f2c(*recvtype); PMPI_Comm_size(c_comm, &size); OMPI_ARRAY_FINT_2_INT(recvcounts, size); OMPI_ARRAY_FINT_2_INT(displs, size); sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); ierr_c = PMPI_Neighbor_allgatherv(sendbuf, OMPI_FINT_2_INT(*sendcount), c_sendtype, recvbuf, OMPI_ARRAY_NAME_CONVERT(recvcounts), OMPI_ARRAY_NAME_CONVERT(displs), c_recvtype, c_comm); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(ierr_c); OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); }
44.398148
191
0.660897
15615467ec005b547a66398136eeda5d0f94150a
5,126
h
C
src/qtwallet/irc/cv/ConfigManager.h
Camellia73/cryonote
f1cf0779507226ad8b411321e3e4d9f4122f1d61
[ "MIT" ]
9
2015-07-10T11:40:33.000Z
2020-05-17T01:09:13.000Z
src/qtwallet/irc/cv/ConfigManager.h
Camellia73/cryonote
f1cf0779507226ad8b411321e3e4d9f4122f1d61
[ "MIT" ]
2
2018-11-23T19:14:36.000Z
2018-12-08T17:46:45.000Z
src/qtwallet/irc/cv/ConfigManager.h
Camellia73/cryonote
f1cf0779507226ad8b411321e3e4d9f4122f1d61
[ "MIT" ]
15
2016-03-14T03:14:50.000Z
2020-05-09T11:48:58.000Z
// Copyright (c) 2011 Conviersa Project. Use of this source code // is governed by the MIT License. // // // ConfigManager manages all the configuration settings used by the client. // It allows creating a config file with default options or, if one already // exists, then reading existing options into memory. It owns a map of ConfigOptions, // which hold the value and type of an individual option. Config options are // stored in text files as JSON. // // ConfigOption stores both the value and the type of a config property. It // doesn't need to store the name because they are stored in a map by name. #pragma once #include <QHash> #include <QString> #include <QMap> #include <QList> #include <QRegExp> #include <QVariant> #include <QColor> #include "json.h" #include "cv/EventManager.h" #define GET_OPT(x) g_pCfgManager->getOptionValue(x) #define GET_STRING(x) g_pCfgManager->getOptionValue(x).toString() #define GET_INT(x) g_pCfgManager->getOptionValue(x).toInt() #define GET_BOOL(x) g_pCfgManager->getOptionValue(x).toBool() #define GET_COLOR(x) g_pCfgManager->getOptionValue(x).value<QColor>() #define GET_LIST(x) g_pCfgManager->getOptionValue(x).toList() #define GET_MAP(x) g_pCfgManager->getOptionValue(x).toMap() namespace cv { enum ConfigType { CONFIG_TYPE_UNKNOWN = 0, CONFIG_TYPE_INTEGER, CONFIG_TYPE_STRING, CONFIG_TYPE_BOOLEAN, CONFIG_TYPE_COLOR, CONFIG_TYPE_LIST, CONFIG_TYPE_MAP }; //-----------------------------------// struct ConfigOption { QVariant value; ConfigType type; ConfigOption(const QVariant &v, ConfigType t = CONFIG_TYPE_STRING) : value(v), type(t) { } // Converts the underlying value to the correct type, in case // it's currently being stored as a string; this can happen // if the value gets changed directly in the config file, or // by the user using the input box. void ensureTypeIsCorrect() { switch(type) { case CONFIG_TYPE_INTEGER: { value.convert(QVariant::Int); break; } case CONFIG_TYPE_BOOLEAN: { value.convert(QVariant::Bool); break; } default: break; } } }; //-----------------------------------// class ConfigEvent : public Event { QString m_filename; QString m_name; QVariant m_value; ConfigType m_type; public: ConfigEvent(const QString &filename, const QString &name, const QVariant &value, ConfigType type) : m_filename(filename), m_name(name), m_value(value), m_type(type) { } QString getFilename() const { return m_filename; } QString getName() const { return m_name; } QVariant getValue() const { return m_value; } QString getString() const { return m_value.toString(); } bool getBool() const { return m_value.toBool(); } int getInt() const { return m_value.toInt(); } QColor getColor() const { return m_value.value<QColor>(); } QVariantList getList() const { return m_value.toList(); } QVariantMap getMap() const { return m_value.toMap(); } ConfigType getType() const { return m_type; } }; //-----------------------------------// class ConfigManager { QHash<QString, QMap<QString, ConfigOption> > m_files; QString m_defaultFilename; // Comments start the line with '#'. QRegExp m_commentRegex; QRegExp m_newlineRegex; public: ConfigManager(const QString &defaultFilename); bool setupConfigFile(const QString &filename, QMap<QString, ConfigOption> &options); bool writeToFile(const QString &filename); QVariant getOptionValue(const QString &filename, const QString &optName); ConfigType getOptionType(const QString &filename, const QString &optName); bool setOptionValue(const QString &filename, const QString &optName, const QVariant &optValue, bool fireEvent); bool isValueValid(const QVariant &value, ConfigType type); // Calls setupConfigFile() with the default filename. bool setupDefaultConfigFile(QMap<QString, ConfigOption> &options) { return setupConfigFile(m_defaultFilename, options); } // Calls writeToFile() with the default filename. bool writeToDefaultFile() { return writeToFile(m_defaultFilename); } // Returns the value of the key in the default file. inline QVariant getOptionValue(const QString &optName) { return getOptionValue(m_defaultFilename, optName); } // Returns the type of the key in the default file. inline ConfigType getOptionType(const QString &optName) { return getOptionType(m_defaultFilename, optName); } // Sets the option's value to [optValue] in the default file. inline bool setOptionValue(const QString &optName, const QVariant &optValue, bool fireEvent) { return setOptionValue(m_defaultFilename, optName, optValue, fireEvent); } }; extern ConfigManager *g_pCfgManager; } // End namespace
30.694611
115
0.661334
187d67dbc550bf15c6e6ff70010d420ec56ddb99
3,175
h
C
Core/Inc/hw_config.h
Legged-robot/motor_controller_driver
56582e1f73115b1ca397f8bea1e87c2fe2799046
[ "BSD-3-Clause" ]
null
null
null
Core/Inc/hw_config.h
Legged-robot/motor_controller_driver
56582e1f73115b1ca397f8bea1e87c2fe2799046
[ "BSD-3-Clause" ]
null
null
null
Core/Inc/hw_config.h
Legged-robot/motor_controller_driver
56582e1f73115b1ca397f8bea1e87c2fe2799046
[ "BSD-3-Clause" ]
null
null
null
#ifndef HW_CONFIG_H #define HW_CONFIG_H /* Timer and PWM */ #define TIM_PWM htim1 // PWM/ISR timer handle #define TIM_CH_U TIM_CHANNEL_1 // Terminal U timer channel #define TIM_CH_V TIM_CHANNEL_2 // Terminal V timer channel #define TIM_CH_W TIM_CHANNEL_3 // Terminal W timer channel #define INVERT_DTC 1 // PWM inverting (1) or non-inverting (0) /* ISRs */ #define PWM_ISR TIM1_UP_TIM10_IRQn // PWM Timer ISR #define CAN_ISR CAN1_RX0_IRQn // CAN Receive ISR /* ADC */ #define ADC_CH_MAIN hadc1 // ADC channel handle which drives simultaneous mode #define ADC_CH_IA hadc1 // Phase A current sense ADC channel handle. 0 = unused #define ADC_CH_IB hadc2 // Phase B current sense ADC channel handle. 0 = unused #define ADC_CH_IC 0 // Phase C current sense ADC channel handle. 0 = unused #define ADC_CH_VBUS hadc3 // Bus voltage ADC channel handle. 0 = unused /* DRV Gate drive */ #define ENABLE_PIN GPIOA, GPIO_PIN_11 // Enable gate drive pin. #define DRV_SPI hspi1 // DRV SPI handle #define DRV_CS GPIOA, GPIO_PIN_4 // DRV CS pin /* SPI encoder */ #define ENC_SPI hspi3 // Encoder SPI handle #define ENC_CS GPIOA, GPIO_PIN_15 // Encoder SPI CS pin #define ENC_CPR 65535 // Encoder counts per revolution - 16 bit output = 2^16 - 1 #define INV_CPR 1.0f/ENC_CPR #define ENC_READ_WORD 0x00 // Encoder read command /* Misc. GPIO */ #define LED GPIOC, GPIO_PIN_5 // LED Pin #define DEBUG_LED GPIOE, GPIO_PIN_2 // ADC on indicator /* CAN */ #define CAN_H hcan1 // CAN handle /* Other hardware-related constants */ #define I_SCALE 0.02014160156f // Amps per A/D Count = 3.3v/(40*0,001*2^12) #define V_SCALE 0.012890625f // Bus volts per A/D Count #define DTC_MAX 0.6f // Max duty cycle #define DTC_MIN 0.0f // Min duty cycle #define DTC_COMP 0.000f // deadtime compensation (100 ns / 25 us) #define DT .000025f // Loop period = 1/(180MHz/(2*0x8CA)) #define EN_ENC_LINEARIZATION 1 // Enable/disable encoder linearization /* Current controller */ #define L_D .000003f // D axis inductance #define L_Q .000003f // Q axis inductance #define K_D .05f // Loop gain, Volts/Amp #define K_Q .05f // Loop gain, Volts/Amp #define K_SCALE 0.0001f // K_loop/Loop BW (Hz) 0.0042 #define KI_D 0.045f // PI zero, in radians per sample #define KI_Q 0.045f // PI zero, in radians per sample #define KD_D 0.045f // PI zero, in radians per sample #define KD_Q 0.045f // PI zero, in radians per sample #define OVERMODULATION 1.5f // 1.0 = no overmodulation #define MAX_CALIBRATION_VOLTAGE 3.f// Otherwise currents will be to large since first part of calibration is open loop mode control #define CURRENT_FILT_ALPHA .01f // 1st order d/q current filter (not used in control) #define VBUS_FILT_ALPHA .1f // 1st order bus voltage filter #define INTEGRAL_MAX_TO_VMAX_RATIO 0.4f // Reduce maximum integral value #define D_INT_LIM V_BUS/(K_D*KI_D) // Amps*samples #define Q_INT_LIM V_BUS/(K_Q*KI_Q) // Amps*samples #endif
44.097222
131
0.680945
5bad7c153da88f77b783dc8b6da00334d0e7e6bd
39
h
C
tests/math/test_sphere.h
CraftSpider/AlphaUtils
70ff9cd4ec4184f67d7e8b779538ef88f1e88682
[ "MIT" ]
1
2019-06-23T14:03:16.000Z
2019-06-23T14:03:16.000Z
tests/math/test_sphere.h
CraftSpider/AlphaUtils
70ff9cd4ec4184f67d7e8b779538ef88f1e88682
[ "MIT" ]
null
null
null
tests/math/test_sphere.h
CraftSpider/AlphaUtils
70ff9cd4ec4184f67d7e8b779538ef88f1e88682
[ "MIT" ]
2
2019-06-23T14:03:17.000Z
2020-11-19T02:16:51.000Z
#pragma once void run_sphere_tests();
9.75
24
0.769231
6fbba80ded54fd92e1ef53fd0826e151f2e33440
3,079
c
C
gcc/demo/date.demo.c
razzlefratz/MotleyTools
3c69c574351ce6f4b7e687c13278d4b6cbb200f3
[ "0BSD" ]
2
2015-10-15T19:32:42.000Z
2021-12-20T15:56:04.000Z
gcc/demo/date.demo.c
razzlefratz/MotleyTools
3c69c574351ce6f4b7e687c13278d4b6cbb200f3
[ "0BSD" ]
null
null
null
gcc/demo/date.demo.c
razzlefratz/MotleyTools
3c69c574351ce6f4b7e687c13278d4b6cbb200f3
[ "0BSD" ]
null
null
null
/*====================================================================* * * envp.c - display environment vector; * * this program is a simple debugging tool that displays the environment * vector envp[] on stdout for inspection. * * use it to see how your host system presents environment variables; * *. Motley Tools by Charles Maier *: Published 1982-2005 by Charles Maier for personal use *; Licensed under the Internet Software Consortium License * *--------------------------------------------------------------------*/ #include <stdio.h> #include <time.h> #include "../tools/tools.h" #include "../tools/number.h" #include "../date/date.h" #ifndef MAKEFILE #include "../tools/uintspec.c" #include "../tools/todigit.c" #include "../tools/error.c" #include "../tools/serial.c" #endif #ifndef MAKEFILE #include "../date/startofperiod.c" #include "../date/encodetime.c" #include "../date/datecomp.c" #include "../date/daytime.c" #include "../date/strtime.c" #include "../date/strtm.c" #endif char const *program_name = "date"; /*====================================================================* * * time_t startofperiod (time_t anydate, time_t refdate, unsigned period); * * period is a duration in days, such as a week or a fortnight, that * starts on some reference date; given anydate and a reference date * return the first date of the period in which anydate falls; * *. Motley Tools by Charles Maier *: Published 1982-2005 by Charles Maier for personal use *; Licensed under the Internet Software Consortium License * *--------------------------------------------------------------------*/ #ifndef STARTOFPERIOD_SOURCE #define STARTOFPERIOD_SOURCE #include <time.h> #include "../date/date.h" time_t startofperiod (time_t anydate, time_t refdate, unsigned period) { return (anydate + (refdate - anydate) % (period * 86400) - (period *86400)); } #endif void showdate (char const *title, time_t anytime) { char buffer [100]; encodetime (buffer, sizeof (buffer), (char)(0), localtime (&anytime)); printf ("%s %s ", title, buffer); return; } int main (int argc, char const *argv [], char const *envp []) { extern long timezone; struct tm date1; struct tm date2; int period; time_t anydate; time_t refdate; memset (&date1, 0, sizeof (struct tm)); memset (&date2, 0, sizeof (struct tm)); if (argc > 6) { date1.tm_year = uintspec (*++argv, 1950, 2050) - 1900; date1.tm_mon = uintspec (*++argv, 1, 50) - 1; date1.tm_mday = uintspec (*++argv, 1, 50); refdate = mktime (&date1); date2.tm_year = uintspec (*++argv, 1950, 2050) - 1900; date2.tm_mon = uintspec (*++argv, 1, 50) - 1; date2.tm_mday = uintspec (*++argv, 1, 50); anydate = mktime (&date2); for (period = -15; period < 15; period++) { showdate ("refdate", refdate); showdate ("anydate", refdate + period * 86400); showdate (" < ", startofperiod (refdate + period * 86400, refdate, -7)); showdate (" > ", startofperiod (refdate + period * 86400, refdate, 7)); printf ("\n"); } } exit (0); }
27.247788
77
0.605067
a58ee3346bb602401a706be8b370446d5b090b83
6,016
c
C
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
luutuan2503/AutoBuild-CSCLEDE
881b8f943d748623c10117138a8537b91cc5f806
[ "MIT" ]
null
null
null
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
luutuan2503/AutoBuild-CSCLEDE
881b8f943d748623c10117138a8537b91cc5f806
[ "MIT" ]
null
null
null
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
luutuan2503/AutoBuild-CSCLEDE
881b8f943d748623c10117138a8537b91cc5f806
[ "MIT" ]
null
null
null
/* * Atheros AR71xx built-in ethernet mac driver * * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org> * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> * * Based on Atheros' AG7100 driver * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. */ #include <linux/clk.h> #include <linux/of_mdio.h> #include "ag71xx.h" #define AG71XX_MDIO_RETRY 1000 #define AG71XX_MDIO_DELAY 5 static int bus_count; static int ag71xx_mdio_wait_busy(struct ag71xx_mdio *am) { int i; for (i = 0; i < AG71XX_MDIO_RETRY; i++) { u32 busy; udelay(AG71XX_MDIO_DELAY); regmap_read(am->mii_regmap, AG71XX_REG_MII_IND, &busy); if (!busy) return 0; udelay(AG71XX_MDIO_DELAY); } pr_err("%s: MDIO operation timed out\n", am->mii_bus->name); return -ETIMEDOUT; } static int ag71xx_mdio_mii_read(struct mii_bus *bus, int addr, int reg) { struct ag71xx_mdio *am = bus->priv; int err; int ret; err = ag71xx_mdio_wait_busy(am); if (err) return 0xffff; regmap_write(am->mii_regmap, AG71XX_REG_MII_CMD, MII_CMD_WRITE); regmap_write(am->mii_regmap, AG71XX_REG_MII_ADDR, ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff)); regmap_write(am->mii_regmap, AG71XX_REG_MII_CMD, MII_CMD_READ); err = ag71xx_mdio_wait_busy(am); if (err) return 0xffff; regmap_read(am->mii_regmap, AG71XX_REG_MII_STATUS, &ret); ret &= 0xffff; regmap_write(am->mii_regmap, AG71XX_REG_MII_CMD, MII_CMD_WRITE); DBG("mii_read: addr=%04x, reg=%04x, value=%04x\n", addr, reg, ret); return ret; } static int ag71xx_mdio_mii_write(struct mii_bus *bus, int addr, int reg, u16 val) { struct ag71xx_mdio *am = bus->priv; DBG("mii_write: addr=%04x, reg=%04x, value=%04x\n", addr, reg, val); regmap_write(am->mii_regmap, AG71XX_REG_MII_ADDR, ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff)); regmap_write(am->mii_regmap, AG71XX_REG_MII_CTRL, val); ag71xx_mdio_wait_busy(am); return 0; } static const u32 ar71xx_mdio_div_table[] = { 4, 4, 6, 8, 10, 14, 20, 28, }; static const u32 ar7240_mdio_div_table[] = { 2, 2, 4, 6, 8, 12, 18, 26, 32, 40, 48, 56, 62, 70, 78, 96, }; static const u32 ar933x_mdio_div_table[] = { 4, 4, 6, 8, 10, 14, 20, 28, 34, 42, 50, 58, 66, 74, 82, 98, }; static int ag71xx_mdio_get_divider(struct device_node *np, u32 *div) { struct clk *ref_clk = of_clk_get(np, 0); unsigned long ref_clock; u32 mdio_clock; const u32 *table; int ndivs, i; if (IS_ERR(ref_clk)) return -EINVAL; ref_clock = clk_get_rate(ref_clk); clk_put(ref_clk); if(of_property_read_u32(np, "qca,mdio-max-frequency", &mdio_clock)) { if (of_property_read_bool(np, "builtin-switch")) mdio_clock = 5000000; else mdio_clock = 2000000; } if (of_device_is_compatible(np, "qca,ar9330-mdio") || of_device_is_compatible(np, "qca,ar9340-mdio")) { table = ar933x_mdio_div_table; ndivs = ARRAY_SIZE(ar933x_mdio_div_table); } else if (of_device_is_compatible(np, "qca,ar7240-mdio")) { table = ar7240_mdio_div_table; ndivs = ARRAY_SIZE(ar7240_mdio_div_table); } else { table = ar71xx_mdio_div_table; ndivs = ARRAY_SIZE(ar71xx_mdio_div_table); } for (i = 0; i < ndivs; i++) { unsigned long t; t = ref_clock / table[i]; if (t <= mdio_clock) { *div = i; return 0; } } return -ENOENT; } static int ag71xx_mdio_reset(struct mii_bus *bus) { struct device_node *np = bus->dev.of_node; struct ag71xx_mdio *am = bus->priv; bool builtin_switch; u32 t; builtin_switch = of_property_read_bool(np, "builtin-switch"); if (ag71xx_mdio_get_divider(np, &t)) { if (of_device_is_compatible(np, "qca,ar9340-mdio")) t = MII_CFG_CLK_DIV_58; else if (builtin_switch) t = MII_CFG_CLK_DIV_10; else t = MII_CFG_CLK_DIV_28; } regmap_write(am->mii_regmap, AG71XX_REG_MII_CFG, t | MII_CFG_RESET); udelay(100); regmap_write(am->mii_regmap, AG71XX_REG_MII_CFG, t); udelay(100); return 0; } static int ag71xx_mdio_probe(struct platform_device *pdev) { struct device *amdev = &pdev->dev; struct device_node *np = pdev->dev.of_node; struct ag71xx_mdio *am; struct mii_bus *mii_bus; bool builtin_switch; int i, err; am = devm_kzalloc(amdev, sizeof(*am), GFP_KERNEL); if (!am) return -ENOMEM; am->mii_regmap = syscon_regmap_lookup_by_phandle(np, "regmap"); if (IS_ERR(am->mii_regmap)) return PTR_ERR(am->mii_regmap); mii_bus = devm_mdiobus_alloc(amdev); if (!mii_bus) return -ENOMEM; am->mdio_reset = devm_reset_control_get_exclusive(amdev, "mdio"); builtin_switch = of_property_read_bool(np, "builtin-switch"); mii_bus->name = "ag71xx_mdio"; mii_bus->read = ag71xx_mdio_mii_read; mii_bus->write = ag71xx_mdio_mii_write; mii_bus->reset = ag71xx_mdio_reset; mii_bus->priv = am; mii_bus->parent = amdev; snprintf(mii_bus->id, MII_BUS_ID_SIZE, "%s.%d", np->name, bus_count++); if (!builtin_switch && of_property_read_u32(np, "phy-mask", &mii_bus->phy_mask)) mii_bus->phy_mask = 0; for (i = 0; i < PHY_MAX_ADDR; i++) mii_bus->irq[i] = PHY_POLL; if (!IS_ERR(am->mdio_reset)) { reset_control_assert(am->mdio_reset); msleep(100); reset_control_deassert(am->mdio_reset); msleep(200); } err = of_mdiobus_register(mii_bus, np); if (err) return err; am->mii_bus = mii_bus; platform_set_drvdata(pdev, am); return 0; } static int ag71xx_mdio_remove(struct platform_device *pdev) { struct ag71xx_mdio *am = platform_get_drvdata(pdev); mdiobus_unregister(am->mii_bus); return 0; } static const struct of_device_id ag71xx_mdio_match[] = { { .compatible = "qca,ar7240-mdio" }, { .compatible = "qca,ar9330-mdio" }, { .compatible = "qca,ar9340-mdio" }, { .compatible = "qca,ath79-mdio" }, {} }; static struct platform_driver ag71xx_mdio_driver = { .probe = ag71xx_mdio_probe, .remove = ag71xx_mdio_remove, .driver = { .name = "ag71xx-mdio", .of_match_table = ag71xx_mdio_match, } }; module_platform_driver(ag71xx_mdio_driver); MODULE_LICENSE("GPL");
23.592157
81
0.707447
77bc0a6b856ad5264e467832215937dafe2a9e31
6,561
h
C
include/stringutils.h
xyproto/aoc
11c5bbf6df6e1f5f497ec8cff70c33de198b662d
[ "MIT" ]
null
null
null
include/stringutils.h
xyproto/aoc
11c5bbf6df6e1f5f497ec8cff70c33de198b662d
[ "MIT" ]
null
null
null
include/stringutils.h
xyproto/aoc
11c5bbf6df6e1f5f497ec8cff70c33de198b662d
[ "MIT" ]
null
null
null
#include <algorithm> #include <fstream> #include <string> #include <sstream> #include <vector> using std::find_if; using std::ifstream; using std::isspace; using std::istringstream; using std::pair; using std::string; using std::vector; using namespace std::literals; // for ""s // Trim functions from: // https://stackoverflow.com/a/217605/131264 // trim from start (in place) inline void _ltrim(string &s) { s.erase(s.begin(), find_if(s.begin(), s.end(), [](int ch) { return !isspace(ch); })); } // trim from end (in place) inline void _rtrim(string &s) { s.erase(find_if(s.rbegin(), s.rend(), [](int ch) { return !isspace(ch); }).base(), s.end()); } // trim from both ends (in place) inline void _trim(string &s) { _ltrim(s); _rtrim(s); } // trim from start (copying) inline const string ltrim(string s) { _ltrim(s); return s; } // trim from end (copying) inline const string rtrim(string s) { _rtrim(s); return s; } // trim from both ends (copying) inline const string trim(string s) { _trim(s); return s; } // --- end of trim functions from stackoverflow --- // Get the length of anything with .length(), inspired by Go and Python template<class T> inline auto len(const T& s) { return s.length(); } // Split a string into two pairs const pair<string, string> split(const string& line, const string& sep) { pair<string, string> retval {}; bool afterSep = false; for (unsigned i=0; i < len(line); i++) { if (i >= len(line)) { break; } if (line[i] == sep[0]) { // Found a first match, check the rest bool match = true; for (unsigned i2=0; i2 < len(sep); i2++) { if (i+i2 >= len(line) || line[i+i2] != sep[i2]) { match = false; break; } } if (match) { afterSep = true; } i += len(sep); } if (i >= len(line)) { break; } if (afterSep) { retval.second += line[i]; } else { retval.first += line[i]; } } return retval; } // Trim all strings in a vector of strings // Will remove empty elements after trimming if remove_empty is true const vector<string> trimv(const vector<string> words) { vector<string> trimmed_words {}; string trimmed_word; for (const auto& word: words) { trimmed_word = trim(word); if (len(trimmed_word) > 0) { trimmed_words.push_back(trimmed_word); } } return trimmed_words; } // Split a string into a vector of strings vector<string> splitv(const string& line, const string& sep) { vector<string> retval {""s}; // must start with an empty string because of += below unsigned retcounter = 0; for (unsigned i=0; i < len(line); i++) { if (line[i] == sep[0]) { // Found a first match, check the rest bool match = true; for (unsigned i2=0; i2 < len(sep); i2++) { if (i+i2 >= len(line) || line[i+i2] != sep[i2]) { match = false; break; } } if (match) { retcounter++; retval.push_back(""s); } i += len(sep); } if (i >= len(line) || retcounter >= retval.size()) { break; } retval[retcounter] += line[i]; } return retval; } // Split a string into a words, and also take a char separator vector<string> splitv(const string& line, char sep) { vector<string> words; auto word = ""s; for (const char& letter : line) { if (letter == sep) { words.push_back(word); word = ""s; continue; } word += letter; } if (word.length() > 0) { words.push_back(word); } return words; } // Split a string into words, and also take a string separator inline vector<string> words(const string& line, const string& sep) { return trimv(splitv(line, sep)); } // Split a string into trimmed words, and also take a char separator inline vector<string> words(const string& line, const char sep = ' ') { return trimv(splitv(line, sep)); } // Split a string into a words inline vector<string> splitc(const string& line) { return splitv(line, ' '); } // Count the number of times a word appears in a list of words inline unsigned count(const vector<string> words, const string& word) { auto counter = 0; for (const string& x : words) { if (x == word) { counter++; } } return counter; } // Count the number of times a char appears in a word inline unsigned count(const string& word, const char letter) { auto counter = 0; for (const char& x : word) { if (x == letter) { counter++; } } return counter; } // Read in all the lines in a text file. // Quick and dirty, no particular error checking. const vector<string> readlines(const string& filename) { vector<string> lines {}; string line; ifstream infile {filename, ifstream::in}; if (infile.is_open()) { while (getline(infile, line)) { istringstream is {line}; lines.push_back(is.str()); } } return lines; } // Check if a vector<string> has the given string bool has(vector<string> words, const string& word) { for (const auto& w: words) { if (w == word) { return true; } } return false; } // Return the string between two given strigns, reading from left to right inline const string between(const string& line, const string& sep1 = " "s, const string& sep2 = " "s) { return split(split(line, sep1).second, sep2).first; } // Return the string between two chars, reading from left to right inline const string between(const string& line, const char sep1 = ' ', const char sep2 = ' ') { auto word = ""s; bool in_the_word = false; for (const char& letter : line) { if (letter == sep2) { return word; } if (in_the_word) { word += letter; } if (letter == sep1) { in_the_word = true; continue; } } return word; // did not find sep2 } // convert a string to unsigned long inline unsigned long to_unsigned_long(const string& digits, const unsigned base = 10) { return stoul(digits, 0, base); }
26.244
103
0.562262
cb982ce18385f2afe5303b42c6d4fac64205c69f
5,964
c
C
nx/source/services/psm.c
ischeinkman/libnx
9552e33f76639c2776705b0dfe3900b3393583c4
[ "ISC" ]
null
null
null
nx/source/services/psm.c
ischeinkman/libnx
9552e33f76639c2776705b0dfe3900b3393583c4
[ "ISC" ]
null
null
null
nx/source/services/psm.c
ischeinkman/libnx
9552e33f76639c2776705b0dfe3900b3393583c4
[ "ISC" ]
null
null
null
#include "types.h" #include "result.h" #include "arm/atomics.h" #include "kernel/ipc.h" #include "kernel/event.h" #include "services/psm.h" #include "services/sm.h" static Service g_psmSrv; static u64 g_refCnt; static Result _psmOpenSession(Service* out); static Result _psmBindStateChangeEvent(PsmSession* s, Event* event_out); static Result _psmSetChargerTypeChangeEventEnabled(PsmSession* s, bool flag); static Result _psmSetPowerSupplyChangeEventEnabled(PsmSession* s, bool flag); static Result _psmSetBatteryVoltageStateChangeEventEnabled(PsmSession* s, bool flag); Result psmInitialize(void) { Result rc = 0; atomicIncrement64(&g_refCnt); if (serviceIsActive(&g_psmSrv)) return 0; rc = smGetService(&g_psmSrv, "psm"); if (R_FAILED(rc)) psmExit(); return rc; } void psmExit(void) { if (atomicDecrement64(&g_refCnt) == 0) { serviceClose(&g_psmSrv); } } Service* psmGetServiceSession(void) { return &g_psmSrv; } static Result _psmGetOutU32(u64 cmd_id, u32 *out) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = serviceIpcPrepareHeader(&g_psmSrv, &c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = cmd_id; Result rc = serviceIpcDispatch(&g_psmSrv); if(R_SUCCEEDED(rc)) { IpcParsedCommand r; struct { u64 magic; u64 result; u32 out; } *resp; serviceIpcParse(&g_psmSrv, &r, sizeof(*resp)); resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { *out = resp->out; } } return rc; } Result psmGetBatteryChargePercentage(u32 *out) { return _psmGetOutU32(0, out); } Result psmGetChargerType(ChargerType *out) { return _psmGetOutU32(1, out); } Result psmGetBatteryVoltageState(PsmBatteryVoltageState *out) { u32 state; Result rc = _psmGetOutU32(12, &state); if (R_SUCCEEDED(rc)) { *out = (PsmBatteryVoltageState)state; } return rc; } static Result _psmOpenSession(Service* out) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = serviceIpcPrepareHeader(&g_psmSrv, &c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 7; Result rc = serviceIpcDispatch(&g_psmSrv); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; struct { u64 magic; u64 result; } *resp; serviceIpcParse(&g_psmSrv, &r, sizeof(*resp)); resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) serviceCreateSubservice(out, &g_psmSrv, &r, 0); } return rc; } Result psmBindStateChangeEvent(PsmSession* s, bool ChargerType, bool PowerSupply, bool BatteryVoltage) { Result rc=0; rc = _psmOpenSession(&s->s); if (R_FAILED(rc)) return rc; rc = _psmSetChargerTypeChangeEventEnabled(s, ChargerType); if (R_FAILED(rc)) return rc; rc = _psmSetPowerSupplyChangeEventEnabled(s, PowerSupply); if (R_FAILED(rc)) return rc; rc = _psmSetBatteryVoltageStateChangeEventEnabled(s, BatteryVoltage); if (R_FAILED(rc)) return rc; rc = _psmBindStateChangeEvent(s, &s->StateChangeEvent); if (R_FAILED(rc)) serviceClose(&s->s); return rc; } Result psmWaitStateChangeEvent(PsmSession* s, u64 timeout) { Result rc = 0; rc = eventWait(&s->StateChangeEvent, timeout); if (R_SUCCEEDED(rc)) rc = eventClear(&s->StateChangeEvent); return rc; } static Result _psmBindStateChangeEvent(PsmSession* s, Event *event_out) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = serviceIpcPrepareHeader(&s->s, &c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; Result rc = serviceIpcDispatch(&s->s); if(R_SUCCEEDED(rc)) { IpcParsedCommand r; struct { u64 magic; u64 result; } *resp; serviceIpcParse(&s->s, &r, sizeof(*resp)); resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { eventLoadRemote(event_out, r.Handles[0], false); } } return rc; } Result psmUnbindStateChangeEvent(PsmSession* s) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = serviceIpcPrepareHeader(&s->s, &c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; Result rc = serviceIpcDispatch(&s->s); if(R_SUCCEEDED(rc)) { IpcParsedCommand r; struct { u64 magic; u64 result; } *resp; serviceIpcParse(&s->s, &r, sizeof(*resp)); resp = r.Raw; rc = resp->result; } eventClose(&s->StateChangeEvent); serviceClose(&s->s); return rc; } static Result _psmSetEventEnabled(PsmSession* s, u64 cmd_id, bool flag) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u8 flag; } *raw; raw = serviceIpcPrepareHeader(&s->s, &c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = cmd_id; raw->flag = (flag != 0); Result rc = serviceIpcDispatch(&s->s); if(R_SUCCEEDED(rc)) { IpcParsedCommand r; struct { u64 magic; u64 result; } *resp; serviceIpcParse(&s->s, &r, sizeof(*resp)); resp = r.Raw; rc = resp->result; } return rc; } static Result _psmSetChargerTypeChangeEventEnabled(PsmSession* s, bool flag) { return _psmSetEventEnabled(s, 2, flag); } static Result _psmSetPowerSupplyChangeEventEnabled(PsmSession* s, bool flag) { return _psmSetEventEnabled(s, 3, flag); } static Result _psmSetBatteryVoltageStateChangeEventEnabled(PsmSession* s, bool flag) { return _psmSetEventEnabled(s, 4, flag); }
21.074205
104
0.610832
a023cc9696a5132f38f9dcd9824bc2284b4fb4f9
8,012
h
C
include/tensorview/core/printf2.h
FindDefinition/cumm
3d58e85b660afa05c20514afe65b8aa3a4995953
[ "Apache-2.0" ]
20
2021-10-13T03:41:59.000Z
2022-03-31T07:23:14.000Z
include/tensorview/core/printf2.h
FindDefinition/cumm
3d58e85b660afa05c20514afe65b8aa3a4995953
[ "Apache-2.0" ]
3
2021-11-21T11:25:55.000Z
2022-03-08T06:12:35.000Z
include/tensorview/core/printf2.h
FindDefinition/cumm
3d58e85b660afa05c20514afe65b8aa3a4995953
[ "Apache-2.0" ]
4
2021-10-13T03:42:01.000Z
2022-03-21T13:07:56.000Z
// Copyright 2021 Yan Yan // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include "array.h" #include "defs.h" #ifndef __CUDACC_RTC__ #include <cstdio> #endif #include "const_string.h" namespace tv { namespace detail { template <typename T> struct type_to_format; template <> struct type_to_format<int> { static constexpr auto value = make_const_string("%d"); }; template <> struct type_to_format<bool> { static constexpr auto value = make_const_string("%d"); }; template <> struct type_to_format<unsigned int> { static constexpr auto value = make_const_string("%u"); }; template <> struct type_to_format<long> { static constexpr auto value = make_const_string("%ld"); }; template <> struct type_to_format<unsigned long> { static constexpr auto value = make_const_string("%lu"); }; template <> struct type_to_format<long long> { static constexpr auto value = make_const_string("%lld"); }; template <> struct type_to_format<unsigned long long> { static constexpr auto value = make_const_string("%llu"); }; template <> struct type_to_format<float> { static constexpr auto value = make_const_string("%f"); }; template <> struct type_to_format<double> { static constexpr auto value = make_const_string("%lf"); }; template <> struct type_to_format<char *> { static constexpr auto value = make_const_string("%s"); }; template <> struct type_to_format<const char *> { static constexpr auto value = make_const_string("%s"); }; template <> struct type_to_format<char> { static constexpr auto value = make_const_string("%c"); }; template <> struct type_to_format<int8_t> { static constexpr auto value = make_const_string("%hd"); }; template <> struct type_to_format<int16_t> { static constexpr auto value = make_const_string("%hd"); }; template <> struct type_to_format<uint8_t> { static constexpr auto value = make_const_string("%hu"); }; template <> struct type_to_format<uint16_t> { static constexpr auto value = make_const_string("%hu"); }; template <class T, size_t N> TV_HOST_DEVICE_INLINE constexpr auto generate_array_format() { // [%d, %d, %d, %d] auto elem_fmt = type_to_format<T>::value; int elem_fmt_size = elem_fmt.size(); tv::const_string<2 + (type_to_format<T>::value).size() * N + 2 * (N - 1)> res{}; res[0] = '['; res[res.size() - 1] = ']'; for (int i = 0; i < N; ++i) { for (int j = 1 + i * (elem_fmt_size + 2); j < 1 + i * (elem_fmt_size + 2) + elem_fmt_size; ++j) { res[j] = elem_fmt[j - (1 + i * (elem_fmt_size + 2))]; } if (i != N - 1) { res[1 + i * (elem_fmt_size + 2) + elem_fmt_size] = ','; res[1 + i * (elem_fmt_size + 2) + elem_fmt_size + 1] = ' '; } } return res; } template <class T, size_t N> struct type_to_format<array<T, N>> { static constexpr auto value = generate_array_format<T, N>(); }; template <class T, size_t N> struct type_to_format<T[N]> { static constexpr auto value = generate_array_format<T, N>(); }; template <char Sep, class... Ts> struct types_to_format; template <char Sep, class T> struct types_to_format<Sep, T> { static constexpr auto value = type_to_format<std::decay_t<T>>::value + "\n"; }; template <char Sep, class T, class... Ts> struct types_to_format<Sep, T, Ts...> { static constexpr auto value = type_to_format<std::decay_t<T>>::value + const_string<1>(Sep) + types_to_format<Sep, Ts...>::value; }; } // namespace detail template <char Sep = ' ', class... Ts> TV_HOST_DEVICE_INLINE void printf2(Ts... args) { // this function should only be used for cuda code. host code // should use tv::ssprint. static constexpr auto fmt = detail::types_to_format<Sep, Ts...>::value; printf(fmt.c_str(), args...); } template <char Sep = ' ', unsigned Tx = 0, class... Ts> TV_HOST_DEVICE_INLINE void printf2_once(Ts... args) { // this function should only be used for cuda code. host code // should use tv::ssprint. static constexpr auto fmt = detail::types_to_format<Sep, Ts...>::value; #if defined(__CUDA_ARCH__) if ((threadIdx.x == Tx && threadIdx.y == 0 && threadIdx.z == 0 && blockIdx.x == 0 && blockIdx.y == 0)) printf(fmt.c_str(), args...); #else printf(fmt.c_str(), args...); #endif } template <char Sep = ' ', class... Ts> TV_HOST_DEVICE_INLINE void printf2_block_once(Ts... args) { // this function should only be used for cuda code. host code // should use tv::ssprint. static constexpr auto fmt = detail::types_to_format<Sep, Ts...>::value; #if defined(__CUDA_ARCH__) if ((blockIdx.x == 0 && blockIdx.y == 0)) printf(fmt.c_str(), args...); #else printf(fmt.c_str(), args...); #endif } template <char Sep = ' ', class... Ts> TV_HOST_DEVICE_INLINE void printf2_thread_once(Ts... args) { // this function should only be used for cuda code. host code // should use tv::ssprint. static constexpr auto fmt = detail::types_to_format<Sep, Ts...>::value; #if defined(__CUDA_ARCH__) if ((threadIdx.x == 0 && threadIdx.y == 0 && threadIdx.z == 0)) printf(fmt.c_str(), args...); #else printf(fmt.c_str(), args...); #endif } namespace detail { template <char Sep = ' ', typename T, size_t N, int... Indexes, class... Ts> TV_HOST_DEVICE_INLINE void printf2_array_impl(array<T, N> arg, mp_list_int<Indexes...>, Ts &&...args) { // this function should only be used for cuda code. host code // should use tv::ssprint. static constexpr auto fmt = detail::types_to_format<Sep, array<T, N>, Ts...>::value; printf(fmt.c_str(), arg[Indexes]..., args...); } template <char Sep = ' ', typename T, size_t N, int... Indexes, class... Ts> TV_HOST_DEVICE_INLINE void printf2_array_impl(T const (&arg)[N], mp_list_int<Indexes...>, Ts &&...args) { // this function should only be used for cuda code. host code // should use tv::ssprint. static constexpr auto fmt = detail::types_to_format<Sep, array<T, N>, Ts...>::value; printf(fmt.c_str(), arg[Indexes]..., args...); } } // namespace detail template <char Sep = ' ', typename T, size_t N, class... Ts> TV_HOST_DEVICE_INLINE void printf2_array(array<T, N> arg, Ts &&...args) { // this function should only be used for cuda code. host code // should use tv::ssprint. return detail::printf2_array_impl<Sep>(arg, mp_make_list_c_sequence<int, N>{}, std::forward<Ts>(args)...); } template <char Sep = ' ', typename T, size_t N, class... Ts> TV_HOST_DEVICE_INLINE void printf2_array(T const (&arg)[N], Ts &&...args) { // this function should only be used for cuda code. host code // should use tv::ssprint. return detail::printf2_array_impl<Sep>(arg, mp_make_list_c_sequence<int, N>{}, std::forward<Ts>(args)...); } template <char Sep = ' ', unsigned Tx = 0, class... Ts> TV_HOST_DEVICE_INLINE void printf2_array_once(Ts &&...args) { #if defined(__CUDA_ARCH__) if ((threadIdx.x == Tx && threadIdx.y == 0 && threadIdx.z == 0 && blockIdx.x == 0 && blockIdx.y == 0)) printf2_array(args...); #else printf2_array(std::forward<Ts>(args)...); #endif } template <char Sep = ' ', class... Ts> TV_HOST_DEVICE_INLINE void printf2_array_block_once(Ts &&...args) { // this function should only be used for cuda code. host code // should use tv::ssprint. #if defined(__CUDA_ARCH__) if ((blockIdx.x == 0 && blockIdx.y == 0)) printf2_array(args...); #else printf2_array(std::forward<Ts>(args)...); #endif } } // namespace tv
32.176707
80
0.663005
ae22d6cacc9225fb29f9774b9f083c03861bc887
92,188
c
C
kernels/linux-2.4.0/drivers/sound/es1371.c
liuhaozzu/linux
bdf9758cd23e34b5f53e8e6339d9b29348615e14
[ "Apache-2.0" ]
4
2020-01-01T20:26:42.000Z
2021-10-17T21:51:58.000Z
kernels/linux-2.4.0/drivers/sound/es1371.c
liuhaozzu/linux
bdf9758cd23e34b5f53e8e6339d9b29348615e14
[ "Apache-2.0" ]
4
2020-07-23T11:20:30.000Z
2020-07-24T20:09:09.000Z
linux/drivers/sound/es1371.c
CodeAsm/PS1Linux
8c3c4d9ffccf446dd061a38186efc924da8a66be
[ "CC0-1.0" ]
null
null
null
/*****************************************************************************/ /* * es1371.c -- Creative Ensoniq ES1371. * * Copyright (C) 1998-2000 Thomas Sailer (sailer@ife.ee.ethz.ch) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Special thanks to Ensoniq * * * Module command line parameters: * joystick must be set to the base I/O-Port to be used for * the gameport. Legal values are 0x200, 0x208, 0x210 and 0x218. * The gameport is mirrored eight times. * * Supported devices: * /dev/dsp standard /dev/dsp device, (mostly) OSS compatible * /dev/mixer standard /dev/mixer device, (mostly) OSS compatible * /dev/dsp1 additional DAC, like /dev/dsp, but outputs to mixer "SYNTH" setting * /dev/midi simple MIDI UART interface, no ioctl * * NOTE: the card does not have any FM/Wavetable synthesizer, it is supposed * to be done in software. That is what /dev/dac is for. By now (Q2 1998) * there are several MIDI to PCM (WAV) packages, one of them is timidity. * * Revision history * 04.06.1998 0.1 Initial release * Mixer stuff should be overhauled; especially optional AC97 mixer bits * should be detected. This results in strange behaviour of some mixer * settings, like master volume and mic. * 08.06.1998 0.2 First release using Alan Cox' soundcore instead of miscdevice * 03.08.1998 0.3 Do not include modversions.h * Now mixer behaviour can basically be selected between * "OSS documented" and "OSS actual" behaviour * 31.08.1998 0.4 Fix realplayer problems - dac.count issues * 27.10.1998 0.5 Fix joystick support * -- Oliver Neukum (c188@org.chemie.uni-muenchen.de) * 10.12.1998 0.6 Fix drain_dac trying to wait on not yet initialized DMA * 23.12.1998 0.7 Fix a few f_file & FMODE_ bugs * Don't wake up app until there are fragsize bytes to read/write * 06.01.1999 0.8 remove the silly SA_INTERRUPT flag. * hopefully killed the egcs section type conflict * 12.03.1999 0.9 cinfo.blocks should be reset after GETxPTR ioctl. * reported by Johan Maes <joma@telindus.be> * 22.03.1999 0.10 return EAGAIN instead of EBUSY when O_NONBLOCK * read/write cannot be executed * 07.04.1999 0.11 implemented the following ioctl's: SOUND_PCM_READ_RATE, * SOUND_PCM_READ_CHANNELS, SOUND_PCM_READ_BITS; * Alpha fixes reported by Peter Jones <pjones@redhat.com> * Another Alpha fix (wait_src_ready in init routine) * reported by "Ivan N. Kokshaysky" <ink@jurassic.park.msu.ru> * Note: joystick address handling might still be wrong on archs * other than i386 * 15.06.1999 0.12 Fix bad allocation bug. * Thanks to Deti Fliegl <fliegl@in.tum.de> * 28.06.1999 0.13 Add pci_set_master * 03.08.1999 0.14 adapt to Linus' new __setup/__initcall * added kernel command line option "es1371=joystickaddr" * removed CONFIG_SOUND_ES1371_JOYPORT_BOOT kludge * 10.08.1999 0.15 (Re)added S/PDIF module option for cards revision >= 4. * Initial version by Dave Platt <dplatt@snulbug.mtview.ca.us>. * module_init/__setup fixes * 08.16.1999 0.16 Joe Cotellese <joec@ensoniq.com> * Added detection for ES1371 revision ID so that we can * detect the ES1373 and later parts. * added AC97 #defines for readability * added a /proc file system for dumping hardware state * updated SRC and CODEC w/r functions to accomodate bugs * in some versions of the ES137x chips. * 31.08.1999 0.17 add spin_lock_init * replaced current->state = x with set_current_state(x) * 03.09.1999 0.18 change read semantics for MIDI to match * OSS more closely; remove possible wakeup race * 21.10.1999 0.19 Round sampling rates, requested by * Kasamatsu Kenichi <t29w0267@ip.media.kyoto-u.ac.jp> * 27.10.1999 0.20 Added SigmaTel 3D enhancement string * Codec ID printing changes * 28.10.1999 0.21 More waitqueue races fixed * Joe Cotellese <joec@ensoniq.com> * Changed PCI detection routine so we can more easily * detect ES137x chip and derivatives. * 05.01.2000 0.22 Should now work with rev7 boards; patch by * Eric Lemar, elemar@cs.washington.edu * 08.01.2000 0.23 Prevent some ioctl's from returning bad count values on underrun/overrun; * Tim Janik's BSE (Bedevilled Sound Engine) found this * 07.02.2000 0.24 Use pci_alloc_consistent and pci_register_driver * 07.02.2000 0.25 Use ac97_codec * 01.03.2000 0.26 SPDIF patch by Mikael Bouillot <mikael.bouillot@bigfoot.com> * Use pci_module_init * 21.11.2000 0.27 Initialize dma buffers in poll, otherwise poll may return a bogus mask */ /*****************************************************************************/ #include <linux/version.h> #include <linux/module.h> #include <linux/string.h> #include <linux/ioport.h> #include <linux/sched.h> #include <linux/delay.h> #include <linux/sound.h> #include <linux/malloc.h> #include <linux/soundcard.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/bitops.h> #include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/ac97_codec.h> #include <linux/wrapper.h> #include <asm/io.h> #include <asm/dma.h> #include <asm/uaccess.h> #include <asm/hardirq.h> /* --------------------------------------------------------------------- */ #undef OSS_DOCUMENTED_MIXER_SEMANTICS #define ES1371_DEBUG #define DBG(x) {} /*#define DBG(x) {x}*/ /* --------------------------------------------------------------------- */ #ifndef PCI_VENDOR_ID_ENSONIQ #define PCI_VENDOR_ID_ENSONIQ 0x1274 #endif #ifndef PCI_VENDOR_ID_ECTIVA #define PCI_VENDOR_ID_ECTIVA 0x1102 #endif #ifndef PCI_DEVICE_ID_ENSONIQ_ES1371 #define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 #endif #ifndef PCI_DEVICE_ID_ENSONIQ_CT5880 #define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 #endif #ifndef PCI_DEVICE_ID_ECTIVA_EV1938 #define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938 #endif /* ES1371 chip ID */ /* This is a little confusing because all ES1371 compatible chips have the same DEVICE_ID, the only thing differentiating them is the REV_ID field. This is only significant if you want to enable features on the later parts. Yes, I know it's stupid and why didn't we use the sub IDs? */ #define ES1371REV_ES1373_A 0x04 #define ES1371REV_ES1373_B 0x06 #define ES1371REV_CT5880_A 0x07 #define CT5880REV_CT5880_C 0x02 #define ES1371REV_ES1371_B 0x09 #define EV1938REV_EV1938_A 0x00 #define ES1371REV_ES1373_8 0x08 #define ES1371_MAGIC ((PCI_VENDOR_ID_ENSONIQ<<16)|PCI_DEVICE_ID_ENSONIQ_ES1371) #define ES1371_EXTENT 0x40 #define JOY_EXTENT 8 #define ES1371_REG_CONTROL 0x00 #define ES1371_REG_STATUS 0x04 /* on the 5880 it is control/status */ #define ES1371_REG_UART_DATA 0x08 #define ES1371_REG_UART_STATUS 0x09 #define ES1371_REG_UART_CONTROL 0x09 #define ES1371_REG_UART_TEST 0x0a #define ES1371_REG_MEMPAGE 0x0c #define ES1371_REG_SRCONV 0x10 #define ES1371_REG_CODEC 0x14 #define ES1371_REG_LEGACY 0x18 #define ES1371_REG_SERIAL_CONTROL 0x20 #define ES1371_REG_DAC1_SCOUNT 0x24 #define ES1371_REG_DAC2_SCOUNT 0x28 #define ES1371_REG_ADC_SCOUNT 0x2c #define ES1371_REG_DAC1_FRAMEADR 0xc30 #define ES1371_REG_DAC1_FRAMECNT 0xc34 #define ES1371_REG_DAC2_FRAMEADR 0xc38 #define ES1371_REG_DAC2_FRAMECNT 0xc3c #define ES1371_REG_ADC_FRAMEADR 0xd30 #define ES1371_REG_ADC_FRAMECNT 0xd34 #define ES1371_FMT_U8_MONO 0 #define ES1371_FMT_U8_STEREO 1 #define ES1371_FMT_S16_MONO 2 #define ES1371_FMT_S16_STEREO 3 #define ES1371_FMT_STEREO 1 #define ES1371_FMT_S16 2 #define ES1371_FMT_MASK 3 static const unsigned sample_size[] = { 1, 2, 2, 4 }; static const unsigned sample_shift[] = { 0, 1, 1, 2 }; #define CTRL_RECEN_B 0x08000000 /* 1 = don't mix analog in to digital out */ #define CTRL_SPDIFEN_B 0x04000000 #define CTRL_JOY_SHIFT 24 #define CTRL_JOY_MASK 3 #define CTRL_JOY_200 0x00000000 /* joystick base address */ #define CTRL_JOY_208 0x01000000 #define CTRL_JOY_210 0x02000000 #define CTRL_JOY_218 0x03000000 #define CTRL_GPIO_IN0 0x00100000 /* general purpose inputs/outputs */ #define CTRL_GPIO_IN1 0x00200000 #define CTRL_GPIO_IN2 0x00400000 #define CTRL_GPIO_IN3 0x00800000 #define CTRL_GPIO_OUT0 0x00010000 #define CTRL_GPIO_OUT1 0x00020000 #define CTRL_GPIO_OUT2 0x00040000 #define CTRL_GPIO_OUT3 0x00080000 #define CTRL_MSFMTSEL 0x00008000 /* MPEG serial data fmt: 0 = Sony, 1 = I2S */ #define CTRL_SYNCRES 0x00004000 /* AC97 warm reset */ #define CTRL_ADCSTOP 0x00002000 /* stop ADC transfers */ #define CTRL_PWR_INTRM 0x00001000 /* 1 = power level ints enabled */ #define CTRL_M_CB 0x00000800 /* recording source: 0 = ADC, 1 = MPEG */ #define CTRL_CCB_INTRM 0x00000400 /* 1 = CCB "voice" ints enabled */ #define CTRL_PDLEV0 0x00000000 /* power down level */ #define CTRL_PDLEV1 0x00000100 #define CTRL_PDLEV2 0x00000200 #define CTRL_PDLEV3 0x00000300 #define CTRL_BREQ 0x00000080 /* 1 = test mode (internal mem test) */ #define CTRL_DAC1_EN 0x00000040 /* enable DAC1 */ #define CTRL_DAC2_EN 0x00000020 /* enable DAC2 */ #define CTRL_ADC_EN 0x00000010 /* enable ADC */ #define CTRL_UART_EN 0x00000008 /* enable MIDI uart */ #define CTRL_JYSTK_EN 0x00000004 /* enable Joystick port */ #define CTRL_XTALCLKDIS 0x00000002 /* 1 = disable crystal clock input */ #define CTRL_PCICLKDIS 0x00000001 /* 1 = disable PCI clock distribution */ #define STAT_INTR 0x80000000 /* wired or of all interrupt bits */ #define CSTAT_5880_AC97_RST 0x20000000 /* CT5880 Reset bit */ #define STAT_EN_SPDIF 0x00040000 /* enable S/PDIF circuitry */ #define STAT_TS_SPDIF 0x00020000 /* test S/PDIF circuitry */ #define STAT_TESTMODE 0x00010000 /* test ASIC */ #define STAT_SYNC_ERR 0x00000100 /* 1 = codec sync error */ #define STAT_VC 0x000000c0 /* CCB int source, 0=DAC1, 1=DAC2, 2=ADC, 3=undef */ #define STAT_SH_VC 6 #define STAT_MPWR 0x00000020 /* power level interrupt */ #define STAT_MCCB 0x00000010 /* CCB int pending */ #define STAT_UART 0x00000008 /* UART int pending */ #define STAT_DAC1 0x00000004 /* DAC1 int pending */ #define STAT_DAC2 0x00000002 /* DAC2 int pending */ #define STAT_ADC 0x00000001 /* ADC int pending */ #define USTAT_RXINT 0x80 /* UART rx int pending */ #define USTAT_TXINT 0x04 /* UART tx int pending */ #define USTAT_TXRDY 0x02 /* UART tx ready */ #define USTAT_RXRDY 0x01 /* UART rx ready */ #define UCTRL_RXINTEN 0x80 /* 1 = enable RX ints */ #define UCTRL_TXINTEN 0x60 /* TX int enable field mask */ #define UCTRL_ENA_TXINT 0x20 /* enable TX int */ #define UCTRL_CNTRL 0x03 /* control field */ #define UCTRL_CNTRL_SWR 0x03 /* software reset command */ /* sample rate converter */ #define SRC_OKSTATE 1 #define SRC_RAMADDR_MASK 0xfe000000 #define SRC_RAMADDR_SHIFT 25 #define SRC_DAC1FREEZE (1UL << 21) #define SRC_DAC2FREEZE (1UL << 20) #define SRC_ADCFREEZE (1UL << 19) #define SRC_WE 0x01000000 /* read/write control for SRC RAM */ #define SRC_BUSY 0x00800000 /* SRC busy */ #define SRC_DIS 0x00400000 /* 1 = disable SRC */ #define SRC_DDAC1 0x00200000 /* 1 = disable accum update for DAC1 */ #define SRC_DDAC2 0x00100000 /* 1 = disable accum update for DAC2 */ #define SRC_DADC 0x00080000 /* 1 = disable accum update for ADC2 */ #define SRC_CTLMASK 0x00780000 #define SRC_RAMDATA_MASK 0x0000ffff #define SRC_RAMDATA_SHIFT 0 #define SRCREG_ADC 0x78 #define SRCREG_DAC1 0x70 #define SRCREG_DAC2 0x74 #define SRCREG_VOL_ADC 0x6c #define SRCREG_VOL_DAC1 0x7c #define SRCREG_VOL_DAC2 0x7e #define SRCREG_TRUNC_N 0x00 #define SRCREG_INT_REGS 0x01 #define SRCREG_ACCUM_FRAC 0x02 #define SRCREG_VFREQ_FRAC 0x03 #define CODEC_PIRD 0x00800000 /* 0 = write AC97 register */ #define CODEC_PIADD_MASK 0x007f0000 #define CODEC_PIADD_SHIFT 16 #define CODEC_PIDAT_MASK 0x0000ffff #define CODEC_PIDAT_SHIFT 0 #define CODEC_RDY 0x80000000 /* AC97 read data valid */ #define CODEC_WIP 0x40000000 /* AC97 write in progress */ #define CODEC_PORD 0x00800000 /* 0 = write AC97 register */ #define CODEC_POADD_MASK 0x007f0000 #define CODEC_POADD_SHIFT 16 #define CODEC_PODAT_MASK 0x0000ffff #define CODEC_PODAT_SHIFT 0 #define LEGACY_JFAST 0x80000000 /* fast joystick timing */ #define LEGACY_FIRQ 0x01000000 /* force IRQ */ #define SCTRL_DACTEST 0x00400000 /* 1 = DAC test, test vector generation purposes */ #define SCTRL_P2ENDINC 0x00380000 /* */ #define SCTRL_SH_P2ENDINC 19 #define SCTRL_P2STINC 0x00070000 /* */ #define SCTRL_SH_P2STINC 16 #define SCTRL_R1LOOPSEL 0x00008000 /* 0 = loop mode */ #define SCTRL_P2LOOPSEL 0x00004000 /* 0 = loop mode */ #define SCTRL_P1LOOPSEL 0x00002000 /* 0 = loop mode */ #define SCTRL_P2PAUSE 0x00001000 /* 1 = pause mode */ #define SCTRL_P1PAUSE 0x00000800 /* 1 = pause mode */ #define SCTRL_R1INTEN 0x00000400 /* enable interrupt */ #define SCTRL_P2INTEN 0x00000200 /* enable interrupt */ #define SCTRL_P1INTEN 0x00000100 /* enable interrupt */ #define SCTRL_P1SCTRLD 0x00000080 /* reload sample count register for DAC1 */ #define SCTRL_P2DACSEN 0x00000040 /* 1 = DAC2 play back last sample when disabled */ #define SCTRL_R1SEB 0x00000020 /* 1 = 16bit */ #define SCTRL_R1SMB 0x00000010 /* 1 = stereo */ #define SCTRL_R1FMT 0x00000030 /* format mask */ #define SCTRL_SH_R1FMT 4 #define SCTRL_P2SEB 0x00000008 /* 1 = 16bit */ #define SCTRL_P2SMB 0x00000004 /* 1 = stereo */ #define SCTRL_P2FMT 0x0000000c /* format mask */ #define SCTRL_SH_P2FMT 2 #define SCTRL_P1SEB 0x00000002 /* 1 = 16bit */ #define SCTRL_P1SMB 0x00000001 /* 1 = stereo */ #define SCTRL_P1FMT 0x00000003 /* format mask */ #define SCTRL_SH_P1FMT 0 /* misc stuff */ #define POLL_COUNT 0x1000 #define FMODE_DAC 4 /* slight misuse of mode_t */ /* MIDI buffer sizes */ #define MIDIINBUF 256 #define MIDIOUTBUF 256 #define FMODE_MIDI_SHIFT 3 #define FMODE_MIDI_READ (FMODE_READ << FMODE_MIDI_SHIFT) #define FMODE_MIDI_WRITE (FMODE_WRITE << FMODE_MIDI_SHIFT) #define ES1371_MODULE_NAME "es1371" #define PFX ES1371_MODULE_NAME ": " /* --------------------------------------------------------------------- */ struct es1371_state { /* magic */ unsigned int magic; /* list of es1371 devices */ struct list_head devs; /* the corresponding pci_dev structure */ struct pci_dev *dev; /* soundcore stuff */ int dev_audio; int dev_dac; int dev_midi; /* hardware resources */ unsigned long io; /* long for SPARC */ unsigned int irq; /* PCI ID's */ u16 vendor; u16 device; u8 rev; /* the chip revision */ /* options */ int spdif_volume; /* S/PDIF output is enabled if != -1 */ #ifdef ES1371_DEBUG /* debug /proc entry */ struct proc_dir_entry *ps; #endif /* ES1371_DEBUG */ struct ac97_codec codec; /* wave stuff */ unsigned ctrl; unsigned sctrl; unsigned dac1rate, dac2rate, adcrate; spinlock_t lock; struct semaphore open_sem; mode_t open_mode; wait_queue_head_t open_wait; struct dmabuf { void *rawbuf; dma_addr_t dmaaddr; unsigned buforder; unsigned numfrag; unsigned fragshift; unsigned hwptr, swptr; unsigned total_bytes; int count; unsigned error; /* over/underrun */ wait_queue_head_t wait; /* redundant, but makes calculations easier */ unsigned fragsize; unsigned dmasize; unsigned fragsamples; /* OSS stuff */ unsigned mapped:1; unsigned ready:1; unsigned endcleared:1; unsigned ossfragshift; int ossmaxfrags; unsigned subdivision; } dma_dac1, dma_dac2, dma_adc; /* midi stuff */ struct { unsigned ird, iwr, icnt; unsigned ord, owr, ocnt; wait_queue_head_t iwait; wait_queue_head_t owait; unsigned char ibuf[MIDIINBUF]; unsigned char obuf[MIDIOUTBUF]; } midi; }; /* --------------------------------------------------------------------- */ static LIST_HEAD(devs); /* --------------------------------------------------------------------- */ extern inline unsigned ld2(unsigned int x) { unsigned r = 0; if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 4) { x >>= 2; r += 2; } if (x >= 2) r++; return r; } /* --------------------------------------------------------------------- */ static unsigned wait_src_ready(struct es1371_state *s) { unsigned int t, r; for (t = 0; t < POLL_COUNT; t++) { if (!((r = inl(s->io + ES1371_REG_SRCONV)) & SRC_BUSY)) return r; udelay(1); } printk(KERN_DEBUG PFX "sample rate converter timeout r = 0x%08x\n", r); return r; } static unsigned src_read(struct es1371_state *s, unsigned reg) { unsigned int temp,i,orig; /* wait for ready */ temp = wait_src_ready (s); /* we can only access the SRC at certain times, make sure we're allowed to before we read */ orig = temp; /* expose the SRC state bits */ outl ( (temp & SRC_CTLMASK) | (reg << SRC_RAMADDR_SHIFT) | 0x10000UL, s->io + ES1371_REG_SRCONV); /* now, wait for busy and the correct time to read */ temp = wait_src_ready (s); if ( (temp & 0x00870000UL ) != ( SRC_OKSTATE << 16 )){ /* wait for the right state */ for (i=0; i<POLL_COUNT; i++){ temp = inl (s->io + ES1371_REG_SRCONV); if ( (temp & 0x00870000UL ) == ( SRC_OKSTATE << 16 )) break; } } /* hide the state bits */ outl ((orig & SRC_CTLMASK) | (reg << SRC_RAMADDR_SHIFT), s->io + ES1371_REG_SRCONV); return temp; } static void src_write(struct es1371_state *s, unsigned reg, unsigned data) { unsigned int r; r = wait_src_ready(s) & (SRC_DIS | SRC_DDAC1 | SRC_DDAC2 | SRC_DADC); r |= (reg << SRC_RAMADDR_SHIFT) & SRC_RAMADDR_MASK; r |= (data << SRC_RAMDATA_SHIFT) & SRC_RAMDATA_MASK; outl(r | SRC_WE, s->io + ES1371_REG_SRCONV); } /* --------------------------------------------------------------------- */ /* most of the following here is black magic */ static void set_adc_rate(struct es1371_state *s, unsigned rate) { unsigned long flags; unsigned int n, truncm, freq; if (rate > 48000) rate = 48000; if (rate < 4000) rate = 4000; n = rate / 3000; if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9))) n--; truncm = (21 * n - 1) | 1; freq = ((48000UL << 15) / rate) * n; s->adcrate = (48000UL << 15) / (freq / n); spin_lock_irqsave(&s->lock, flags); if (rate >= 24000) { if (truncm > 239) truncm = 239; src_write(s, SRCREG_ADC+SRCREG_TRUNC_N, (((239 - truncm) >> 1) << 9) | (n << 4)); } else { if (truncm > 119) truncm = 119; src_write(s, SRCREG_ADC+SRCREG_TRUNC_N, 0x8000 | (((119 - truncm) >> 1) << 9) | (n << 4)); } src_write(s, SRCREG_ADC+SRCREG_INT_REGS, (src_read(s, SRCREG_ADC+SRCREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); src_write(s, SRCREG_ADC+SRCREG_VFREQ_FRAC, freq & 0x7fff); src_write(s, SRCREG_VOL_ADC, n << 8); src_write(s, SRCREG_VOL_ADC+1, n << 8); spin_unlock_irqrestore(&s->lock, flags); } static void set_dac1_rate(struct es1371_state *s, unsigned rate) { unsigned long flags; unsigned int freq, r; if (rate > 48000) rate = 48000; if (rate < 4000) rate = 4000; freq = ((rate << 15) + 1500) / 3000; s->dac1rate = (freq * 3000 + 16384) >> 15; spin_lock_irqsave(&s->lock, flags); r = (wait_src_ready(s) & (SRC_DIS | SRC_DDAC2 | SRC_DADC)) | SRC_DDAC1; outl(r, s->io + ES1371_REG_SRCONV); src_write(s, SRCREG_DAC1+SRCREG_INT_REGS, (src_read(s, SRCREG_DAC1+SRCREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); src_write(s, SRCREG_DAC1+SRCREG_VFREQ_FRAC, freq & 0x7fff); r = (wait_src_ready(s) & (SRC_DIS | SRC_DDAC2 | SRC_DADC)); outl(r, s->io + ES1371_REG_SRCONV); spin_unlock_irqrestore(&s->lock, flags); } static void set_dac2_rate(struct es1371_state *s, unsigned rate) { unsigned long flags; unsigned int freq, r; if (rate > 48000) rate = 48000; if (rate < 4000) rate = 4000; freq = ((rate << 15) + 1500) / 3000; s->dac2rate = (freq * 3000 + 16384) >> 15; spin_lock_irqsave(&s->lock, flags); r = (wait_src_ready(s) & (SRC_DIS | SRC_DDAC1 | SRC_DADC)) | SRC_DDAC2; outl(r, s->io + ES1371_REG_SRCONV); src_write(s, SRCREG_DAC2+SRCREG_INT_REGS, (src_read(s, SRCREG_DAC2+SRCREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); src_write(s, SRCREG_DAC2+SRCREG_VFREQ_FRAC, freq & 0x7fff); r = (wait_src_ready(s) & (SRC_DIS | SRC_DDAC1 | SRC_DADC)); outl(r, s->io + ES1371_REG_SRCONV); spin_unlock_irqrestore(&s->lock, flags); } /* --------------------------------------------------------------------- */ static void __init src_init(struct es1371_state *s) { unsigned int i; /* before we enable or disable the SRC we need to wait for it to become ready */ wait_src_ready(s); outl(SRC_DIS, s->io + ES1371_REG_SRCONV); for (i = 0; i < 0x80; i++) src_write(s, i, 0); src_write(s, SRCREG_DAC1+SRCREG_TRUNC_N, 16 << 4); src_write(s, SRCREG_DAC1+SRCREG_INT_REGS, 16 << 10); src_write(s, SRCREG_DAC2+SRCREG_TRUNC_N, 16 << 4); src_write(s, SRCREG_DAC2+SRCREG_INT_REGS, 16 << 10); src_write(s, SRCREG_VOL_ADC, 1 << 12); src_write(s, SRCREG_VOL_ADC+1, 1 << 12); src_write(s, SRCREG_VOL_DAC1, 1 << 12); src_write(s, SRCREG_VOL_DAC1+1, 1 << 12); src_write(s, SRCREG_VOL_DAC2, 1 << 12); src_write(s, SRCREG_VOL_DAC2+1, 1 << 12); set_adc_rate(s, 22050); set_dac1_rate(s, 22050); set_dac2_rate(s, 22050); /* WARNING: * enabling the sample rate converter without properly programming * its parameters causes the chip to lock up (the SRC busy bit will * be stuck high, and I've found no way to rectify this other than * power cycle) */ wait_src_ready(s); outl(0, s->io+ES1371_REG_SRCONV); } /* --------------------------------------------------------------------- */ static void wrcodec(struct ac97_codec *codec, u8 addr, u16 data) { struct es1371_state *s = (struct es1371_state *)codec->private_data; unsigned long flags; unsigned t, x; for (t = 0; t < POLL_COUNT; t++) if (!(inl(s->io+ES1371_REG_CODEC) & CODEC_WIP)) break; spin_lock_irqsave(&s->lock, flags); /* save the current state for later */ x = wait_src_ready(s); /* enable SRC state data in SRC mux */ outl((x & (SRC_DIS | SRC_DDAC1 | SRC_DDAC2 | SRC_DADC)) | 0x00010000, s->io+ES1371_REG_SRCONV); /* wait for not busy (state 0) first to avoid transition states */ for (t=0; t<POLL_COUNT; t++){ if((inl(s->io+ES1371_REG_SRCONV) & 0x00870000) ==0 ) break; udelay(1); } /* wait for a SAFE time to write addr/data and then do it, dammit */ for (t=0; t<POLL_COUNT; t++){ if((inl(s->io+ES1371_REG_SRCONV) & 0x00870000) ==0x00010000) break; udelay(1); } outl(((addr << CODEC_POADD_SHIFT) & CODEC_POADD_MASK) | ((data << CODEC_PODAT_SHIFT) & CODEC_PODAT_MASK), s->io+ES1371_REG_CODEC); /* restore SRC reg */ wait_src_ready(s); outl(x, s->io+ES1371_REG_SRCONV); spin_unlock_irqrestore(&s->lock, flags); } static u16 rdcodec(struct ac97_codec *codec, u8 addr) { struct es1371_state *s = (struct es1371_state *)codec->private_data; unsigned long flags; unsigned t, x; /* wait for WIP to go away */ for (t = 0; t < 0x1000; t++) if (!(inl(s->io+ES1371_REG_CODEC) & CODEC_WIP)) break; spin_lock_irqsave(&s->lock, flags); /* save the current state for later */ x = (wait_src_ready(s) & (SRC_DIS | SRC_DDAC1 | SRC_DDAC2 | SRC_DADC)); /* enable SRC state data in SRC mux */ outl( x | 0x00010000, s->io+ES1371_REG_SRCONV); /* wait for not busy (state 0) first to avoid transition states */ for (t=0; t<POLL_COUNT; t++){ if((inl(s->io+ES1371_REG_SRCONV) & 0x00870000) ==0 ) break; udelay(1); } /* wait for a SAFE time to write addr/data and then do it, dammit */ for (t=0; t<POLL_COUNT; t++){ if((inl(s->io+ES1371_REG_SRCONV) & 0x00870000) ==0x00010000) break; udelay(1); } outl(((addr << CODEC_POADD_SHIFT) & CODEC_POADD_MASK) | CODEC_PORD, s->io+ES1371_REG_CODEC); /* restore SRC reg */ wait_src_ready(s); outl(x, s->io+ES1371_REG_SRCONV); spin_unlock_irqrestore(&s->lock, flags); /* wait for WIP again */ for (t = 0; t < 0x1000; t++) if (!(inl(s->io+ES1371_REG_CODEC) & CODEC_WIP)) break; /* now wait for the stinkin' data (RDY) */ for (t = 0; t < POLL_COUNT; t++) if ((x = inl(s->io+ES1371_REG_CODEC)) & CODEC_RDY) break; return ((x & CODEC_PIDAT_MASK) >> CODEC_PIDAT_SHIFT); } /* --------------------------------------------------------------------- */ extern inline void stop_adc(struct es1371_state *s) { unsigned long flags; spin_lock_irqsave(&s->lock, flags); s->ctrl &= ~CTRL_ADC_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } extern inline void stop_dac1(struct es1371_state *s) { unsigned long flags; spin_lock_irqsave(&s->lock, flags); s->ctrl &= ~CTRL_DAC1_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } extern inline void stop_dac2(struct es1371_state *s) { unsigned long flags; spin_lock_irqsave(&s->lock, flags); s->ctrl &= ~CTRL_DAC2_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } static void start_dac1(struct es1371_state *s) { unsigned long flags; unsigned fragremain, fshift; spin_lock_irqsave(&s->lock, flags); if (!(s->ctrl & CTRL_DAC1_EN) && (s->dma_dac1.mapped || s->dma_dac1.count > 0) && s->dma_dac1.ready) { s->ctrl |= CTRL_DAC1_EN; s->sctrl = (s->sctrl & ~(SCTRL_P1LOOPSEL | SCTRL_P1PAUSE | SCTRL_P1SCTRLD)) | SCTRL_P1INTEN; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); fragremain = ((- s->dma_dac1.hwptr) & (s->dma_dac1.fragsize-1)); fshift = sample_shift[(s->sctrl & SCTRL_P1FMT) >> SCTRL_SH_P1FMT]; if (fragremain < 2*fshift) fragremain = s->dma_dac1.fragsize; outl((fragremain >> fshift) - 1, s->io+ES1371_REG_DAC1_SCOUNT); outl(s->ctrl, s->io+ES1371_REG_CONTROL); outl((s->dma_dac1.fragsize >> fshift) - 1, s->io+ES1371_REG_DAC1_SCOUNT); } spin_unlock_irqrestore(&s->lock, flags); } static void start_dac2(struct es1371_state *s) { unsigned long flags; unsigned fragremain, fshift; spin_lock_irqsave(&s->lock, flags); if (!(s->ctrl & CTRL_DAC2_EN) && (s->dma_dac2.mapped || s->dma_dac2.count > 0) && s->dma_dac2.ready) { s->ctrl |= CTRL_DAC2_EN; s->sctrl = (s->sctrl & ~(SCTRL_P2LOOPSEL | SCTRL_P2PAUSE | SCTRL_P2DACSEN | SCTRL_P2ENDINC | SCTRL_P2STINC)) | SCTRL_P2INTEN | (((s->sctrl & SCTRL_P2FMT) ? 2 : 1) << SCTRL_SH_P2ENDINC) | (0 << SCTRL_SH_P2STINC); outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); fragremain = ((- s->dma_dac2.hwptr) & (s->dma_dac2.fragsize-1)); fshift = sample_shift[(s->sctrl & SCTRL_P2FMT) >> SCTRL_SH_P2FMT]; if (fragremain < 2*fshift) fragremain = s->dma_dac2.fragsize; outl((fragremain >> fshift) - 1, s->io+ES1371_REG_DAC2_SCOUNT); outl(s->ctrl, s->io+ES1371_REG_CONTROL); outl((s->dma_dac2.fragsize >> fshift) - 1, s->io+ES1371_REG_DAC2_SCOUNT); } spin_unlock_irqrestore(&s->lock, flags); } static void start_adc(struct es1371_state *s) { unsigned long flags; unsigned fragremain, fshift; spin_lock_irqsave(&s->lock, flags); if (!(s->ctrl & CTRL_ADC_EN) && (s->dma_adc.mapped || s->dma_adc.count < (signed)(s->dma_adc.dmasize - 2*s->dma_adc.fragsize)) && s->dma_adc.ready) { s->ctrl |= CTRL_ADC_EN; s->sctrl = (s->sctrl & ~SCTRL_R1LOOPSEL) | SCTRL_R1INTEN; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); fragremain = ((- s->dma_adc.hwptr) & (s->dma_adc.fragsize-1)); fshift = sample_shift[(s->sctrl & SCTRL_R1FMT) >> SCTRL_SH_R1FMT]; if (fragremain < 2*fshift) fragremain = s->dma_adc.fragsize; outl((fragremain >> fshift) - 1, s->io+ES1371_REG_ADC_SCOUNT); outl(s->ctrl, s->io+ES1371_REG_CONTROL); outl((s->dma_adc.fragsize >> fshift) - 1, s->io+ES1371_REG_ADC_SCOUNT); } spin_unlock_irqrestore(&s->lock, flags); } /* --------------------------------------------------------------------- */ #define DMABUF_DEFAULTORDER (17-PAGE_SHIFT) #define DMABUF_MINORDER 1 extern inline void dealloc_dmabuf(struct es1371_state *s, struct dmabuf *db) { struct page *page, *pend; if (db->rawbuf) { /* undo marking the pages as reserved */ pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1); for (page = virt_to_page(db->rawbuf); page <= pend; page++) mem_map_unreserve(page); pci_free_consistent(s->dev, PAGE_SIZE << db->buforder, db->rawbuf, db->dmaaddr); } db->rawbuf = NULL; db->mapped = db->ready = 0; } static int prog_dmabuf(struct es1371_state *s, struct dmabuf *db, unsigned rate, unsigned fmt, unsigned reg) { int order; unsigned bytepersec; unsigned bufs; struct page *page, *pend; db->hwptr = db->swptr = db->total_bytes = db->count = db->error = db->endcleared = 0; if (!db->rawbuf) { db->ready = db->mapped = 0; for (order = DMABUF_DEFAULTORDER; order >= DMABUF_MINORDER; order--) if ((db->rawbuf = pci_alloc_consistent(s->dev, PAGE_SIZE << order, &db->dmaaddr))) break; if (!db->rawbuf) return -ENOMEM; db->buforder = order; /* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */ pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1); for (page = virt_to_page(db->rawbuf); page <= pend; page++) mem_map_reserve(page); } fmt &= ES1371_FMT_MASK; bytepersec = rate << sample_shift[fmt]; bufs = PAGE_SIZE << db->buforder; if (db->ossfragshift) { if ((1000 << db->ossfragshift) < bytepersec) db->fragshift = ld2(bytepersec/1000); else db->fragshift = db->ossfragshift; } else { db->fragshift = ld2(bytepersec/100/(db->subdivision ? db->subdivision : 1)); if (db->fragshift < 3) db->fragshift = 3; } db->numfrag = bufs >> db->fragshift; while (db->numfrag < 4 && db->fragshift > 3) { db->fragshift--; db->numfrag = bufs >> db->fragshift; } db->fragsize = 1 << db->fragshift; if (db->ossmaxfrags >= 4 && db->ossmaxfrags < db->numfrag) db->numfrag = db->ossmaxfrags; db->fragsamples = db->fragsize >> sample_shift[fmt]; db->dmasize = db->numfrag << db->fragshift; memset(db->rawbuf, (fmt & ES1371_FMT_S16) ? 0 : 0x80, db->dmasize); outl((reg >> 8) & 15, s->io+ES1371_REG_MEMPAGE); outl(db->dmaaddr, s->io+(reg & 0xff)); outl((db->dmasize >> 2)-1, s->io+((reg + 4) & 0xff)); db->ready = 1; return 0; } extern inline int prog_dmabuf_adc(struct es1371_state *s) { stop_adc(s); return prog_dmabuf(s, &s->dma_adc, s->adcrate, (s->sctrl >> SCTRL_SH_R1FMT) & ES1371_FMT_MASK, ES1371_REG_ADC_FRAMEADR); } extern inline int prog_dmabuf_dac2(struct es1371_state *s) { stop_dac2(s); return prog_dmabuf(s, &s->dma_dac2, s->dac2rate, (s->sctrl >> SCTRL_SH_P2FMT) & ES1371_FMT_MASK, ES1371_REG_DAC2_FRAMEADR); } extern inline int prog_dmabuf_dac1(struct es1371_state *s) { stop_dac1(s); return prog_dmabuf(s, &s->dma_dac1, s->dac1rate, (s->sctrl >> SCTRL_SH_P1FMT) & ES1371_FMT_MASK, ES1371_REG_DAC1_FRAMEADR); } extern inline unsigned get_hwptr(struct es1371_state *s, struct dmabuf *db, unsigned reg) { unsigned hwptr, diff; outl((reg >> 8) & 15, s->io+ES1371_REG_MEMPAGE); hwptr = (inl(s->io+(reg & 0xff)) >> 14) & 0x3fffc; diff = (db->dmasize + hwptr - db->hwptr) % db->dmasize; db->hwptr = hwptr; return diff; } extern inline void clear_advance(void *buf, unsigned bsize, unsigned bptr, unsigned len, unsigned char c) { if (bptr + len > bsize) { unsigned x = bsize - bptr; memset(((char *)buf) + bptr, c, x); bptr = 0; len -= x; } memset(((char *)buf) + bptr, c, len); } /* call with spinlock held! */ static void es1371_update_ptr(struct es1371_state *s) { int diff; /* update ADC pointer */ if (s->ctrl & CTRL_ADC_EN) { diff = get_hwptr(s, &s->dma_adc, ES1371_REG_ADC_FRAMECNT); s->dma_adc.total_bytes += diff; s->dma_adc.count += diff; if (s->dma_adc.count >= (signed)s->dma_adc.fragsize) wake_up(&s->dma_adc.wait); if (!s->dma_adc.mapped) { if (s->dma_adc.count > (signed)(s->dma_adc.dmasize - ((3 * s->dma_adc.fragsize) >> 1))) { s->ctrl &= ~CTRL_ADC_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); s->dma_adc.error++; } } } /* update DAC1 pointer */ if (s->ctrl & CTRL_DAC1_EN) { diff = get_hwptr(s, &s->dma_dac1, ES1371_REG_DAC1_FRAMECNT); s->dma_dac1.total_bytes += diff; if (s->dma_dac1.mapped) { s->dma_dac1.count += diff; if (s->dma_dac1.count >= (signed)s->dma_dac1.fragsize) wake_up(&s->dma_dac1.wait); } else { s->dma_dac1.count -= diff; if (s->dma_dac1.count <= 0) { s->ctrl &= ~CTRL_DAC1_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); s->dma_dac1.error++; } else if (s->dma_dac1.count <= (signed)s->dma_dac1.fragsize && !s->dma_dac1.endcleared) { clear_advance(s->dma_dac1.rawbuf, s->dma_dac1.dmasize, s->dma_dac1.swptr, s->dma_dac1.fragsize, (s->sctrl & SCTRL_P1SEB) ? 0 : 0x80); s->dma_dac1.endcleared = 1; } if (s->dma_dac1.count + (signed)s->dma_dac1.fragsize <= (signed)s->dma_dac1.dmasize) wake_up(&s->dma_dac1.wait); } } /* update DAC2 pointer */ if (s->ctrl & CTRL_DAC2_EN) { diff = get_hwptr(s, &s->dma_dac2, ES1371_REG_DAC2_FRAMECNT); s->dma_dac2.total_bytes += diff; if (s->dma_dac2.mapped) { s->dma_dac2.count += diff; if (s->dma_dac2.count >= (signed)s->dma_dac2.fragsize) wake_up(&s->dma_dac2.wait); } else { s->dma_dac2.count -= diff; if (s->dma_dac2.count <= 0) { s->ctrl &= ~CTRL_DAC2_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); s->dma_dac2.error++; } else if (s->dma_dac2.count <= (signed)s->dma_dac2.fragsize && !s->dma_dac2.endcleared) { clear_advance(s->dma_dac2.rawbuf, s->dma_dac2.dmasize, s->dma_dac2.swptr, s->dma_dac2.fragsize, (s->sctrl & SCTRL_P2SEB) ? 0 : 0x80); s->dma_dac2.endcleared = 1; } if (s->dma_dac2.count + (signed)s->dma_dac2.fragsize <= (signed)s->dma_dac2.dmasize) wake_up(&s->dma_dac2.wait); } } } /* hold spinlock for the following! */ static void es1371_handle_midi(struct es1371_state *s) { unsigned char ch; int wake; if (!(s->ctrl & CTRL_UART_EN)) return; wake = 0; while (inb(s->io+ES1371_REG_UART_STATUS) & USTAT_RXRDY) { ch = inb(s->io+ES1371_REG_UART_DATA); if (s->midi.icnt < MIDIINBUF) { s->midi.ibuf[s->midi.iwr] = ch; s->midi.iwr = (s->midi.iwr + 1) % MIDIINBUF; s->midi.icnt++; } wake = 1; } if (wake) wake_up(&s->midi.iwait); wake = 0; while ((inb(s->io+ES1371_REG_UART_STATUS) & USTAT_TXRDY) && s->midi.ocnt > 0) { outb(s->midi.obuf[s->midi.ord], s->io+ES1371_REG_UART_DATA); s->midi.ord = (s->midi.ord + 1) % MIDIOUTBUF; s->midi.ocnt--; if (s->midi.ocnt < MIDIOUTBUF-16) wake = 1; } if (wake) wake_up(&s->midi.owait); outb((s->midi.ocnt > 0) ? UCTRL_RXINTEN | UCTRL_ENA_TXINT : UCTRL_RXINTEN, s->io+ES1371_REG_UART_CONTROL); } static void es1371_interrupt(int irq, void *dev_id, struct pt_regs *regs) { struct es1371_state *s = (struct es1371_state *)dev_id; unsigned int intsrc, sctl; /* fastpath out, to ease interrupt sharing */ intsrc = inl(s->io+ES1371_REG_STATUS); if (!(intsrc & 0x80000000)) return; spin_lock(&s->lock); /* clear audio interrupts first */ sctl = s->sctrl; if (intsrc & STAT_ADC) sctl &= ~SCTRL_R1INTEN; if (intsrc & STAT_DAC1) sctl &= ~SCTRL_P1INTEN; if (intsrc & STAT_DAC2) sctl &= ~SCTRL_P2INTEN; outl(sctl, s->io+ES1371_REG_SERIAL_CONTROL); outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); es1371_update_ptr(s); es1371_handle_midi(s); spin_unlock(&s->lock); } /* --------------------------------------------------------------------- */ static const char invalid_magic[] = KERN_CRIT PFX "invalid magic value\n"; #define VALIDATE_STATE(s) \ ({ \ if (!(s) || (s)->magic != ES1371_MAGIC) { \ printk(invalid_magic); \ return -ENXIO; \ } \ }) /* --------------------------------------------------------------------- */ static loff_t es1371_llseek(struct file *file, loff_t offset, int origin) { return -ESPIPE; } /* --------------------------------------------------------------------- */ /* Conversion table for S/PDIF PCM volume emulation through the SRC */ /* dB-linear table of DAC vol values; -0dB to -46.5dB with mute */ static const unsigned short DACVolTable[101] = { 0x1000, 0x0f2a, 0x0e60, 0x0da0, 0x0cea, 0x0c3e, 0x0b9a, 0x0aff, 0x0a6d, 0x09e1, 0x095e, 0x08e1, 0x086a, 0x07fa, 0x078f, 0x072a, 0x06cb, 0x0670, 0x061a, 0x05c9, 0x057b, 0x0532, 0x04ed, 0x04ab, 0x046d, 0x0432, 0x03fa, 0x03c5, 0x0392, 0x0363, 0x0335, 0x030b, 0x02e2, 0x02bc, 0x0297, 0x0275, 0x0254, 0x0235, 0x0217, 0x01fb, 0x01e1, 0x01c8, 0x01b0, 0x0199, 0x0184, 0x0170, 0x015d, 0x014b, 0x0139, 0x0129, 0x0119, 0x010b, 0x00fd, 0x00f0, 0x00e3, 0x00d7, 0x00cc, 0x00c1, 0x00b7, 0x00ae, 0x00a5, 0x009c, 0x0094, 0x008c, 0x0085, 0x007e, 0x0077, 0x0071, 0x006b, 0x0066, 0x0060, 0x005b, 0x0057, 0x0052, 0x004e, 0x004a, 0x0046, 0x0042, 0x003f, 0x003c, 0x0038, 0x0036, 0x0033, 0x0030, 0x002e, 0x002b, 0x0029, 0x0027, 0x0025, 0x0023, 0x0021, 0x001f, 0x001e, 0x001c, 0x001b, 0x0019, 0x0018, 0x0017, 0x0016, 0x0014, 0x0000 }; /* * when we are in S/PDIF mode, we want to disable any analog output so * we filter the mixer ioctls */ static int mixdev_ioctl(struct ac97_codec *codec, unsigned int cmd, unsigned long arg) { struct es1371_state *s = (struct es1371_state *)codec->private_data; int val; unsigned long flags; unsigned int left, right; VALIDATE_STATE(s); /* filter mixer ioctls to catch PCM and MASTER volume when in S/PDIF mode */ if (s->spdif_volume == -1) return codec->mixer_ioctl(codec, cmd, arg); switch (cmd) { case SOUND_MIXER_WRITE_VOLUME: return 0; case SOUND_MIXER_WRITE_PCM: /* use SRC for PCM volume */ if (get_user(val, (int *)arg)) return -EFAULT; right = ((val >> 8) & 0xff); left = (val & 0xff); if (right > 100) right = 100; if (left > 100) left = 100; s->spdif_volume = (right << 8) | left; spin_lock_irqsave(&s->lock, flags); src_write(s, SRCREG_VOL_DAC2, DACVolTable[100 - left]); src_write(s, SRCREG_VOL_DAC2+1, DACVolTable[100 - right]); spin_unlock_irqrestore(&s->lock, flags); return 0; case SOUND_MIXER_READ_PCM: return put_user(s->spdif_volume, (int *)arg); } return codec->mixer_ioctl(codec, cmd, arg); } /* --------------------------------------------------------------------- */ /* * AC97 Mixer Register to Connections mapping of the Concert 97 board * * AC97_MASTER_VOL_STEREO Line Out * AC97_MASTER_VOL_MONO TAD Output * AC97_PCBEEP_VOL none * AC97_PHONE_VOL TAD Input (mono) * AC97_MIC_VOL MIC Input (mono) * AC97_LINEIN_VOL Line Input (stereo) * AC97_CD_VOL CD Input (stereo) * AC97_VIDEO_VOL none * AC97_AUX_VOL Aux Input (stereo) * AC97_PCMOUT_VOL Wave Output (stereo) */ static int es1371_open_mixdev(struct inode *inode, struct file *file) { int minor = MINOR(inode->i_rdev); struct list_head *list; struct es1371_state *s; for (list = devs.next; ; list = list->next) { if (list == &devs) return -ENODEV; s = list_entry(list, struct es1371_state, devs); if (s->codec.dev_mixer == minor) break; } VALIDATE_STATE(s); file->private_data = s; return 0; } static int es1371_release_mixdev(struct inode *inode, struct file *file) { struct es1371_state *s = (struct es1371_state *)file->private_data; VALIDATE_STATE(s); return 0; } static int es1371_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct es1371_state *s = (struct es1371_state *)file->private_data; struct ac97_codec *codec = &s->codec; return mixdev_ioctl(codec, cmd, arg); } static /*const*/ struct file_operations es1371_mixer_fops = { owner: THIS_MODULE, llseek: es1371_llseek, ioctl: es1371_ioctl_mixdev, open: es1371_open_mixdev, release: es1371_release_mixdev, }; /* --------------------------------------------------------------------- */ static int drain_dac1(struct es1371_state *s, int nonblock) { DECLARE_WAITQUEUE(wait, current); unsigned long flags; int count, tmo; if (s->dma_dac1.mapped || !s->dma_dac1.ready) return 0; add_wait_queue(&s->dma_dac1.wait, &wait); for (;;) { __set_current_state(TASK_INTERRUPTIBLE); spin_lock_irqsave(&s->lock, flags); count = s->dma_dac1.count; spin_unlock_irqrestore(&s->lock, flags); if (count <= 0) break; if (signal_pending(current)) break; if (nonblock) { remove_wait_queue(&s->dma_dac1.wait, &wait); set_current_state(TASK_RUNNING); return -EBUSY; } tmo = 3 * HZ * (count + s->dma_dac1.fragsize) / 2 / s->dac1rate; tmo >>= sample_shift[(s->sctrl & SCTRL_P1FMT) >> SCTRL_SH_P1FMT]; if (!schedule_timeout(tmo + 1)) DBG(printk(KERN_DEBUG PFX "dac1 dma timed out??\n");) } remove_wait_queue(&s->dma_dac1.wait, &wait); set_current_state(TASK_RUNNING); if (signal_pending(current)) return -ERESTARTSYS; return 0; } static int drain_dac2(struct es1371_state *s, int nonblock) { DECLARE_WAITQUEUE(wait, current); unsigned long flags; int count, tmo; if (s->dma_dac2.mapped || !s->dma_dac2.ready) return 0; add_wait_queue(&s->dma_dac2.wait, &wait); for (;;) { __set_current_state(TASK_UNINTERRUPTIBLE); spin_lock_irqsave(&s->lock, flags); count = s->dma_dac2.count; spin_unlock_irqrestore(&s->lock, flags); if (count <= 0) break; if (signal_pending(current)) break; if (nonblock) { remove_wait_queue(&s->dma_dac2.wait, &wait); set_current_state(TASK_RUNNING); return -EBUSY; } tmo = 3 * HZ * (count + s->dma_dac2.fragsize) / 2 / s->dac2rate; tmo >>= sample_shift[(s->sctrl & SCTRL_P2FMT) >> SCTRL_SH_P2FMT]; if (!schedule_timeout(tmo + 1)) DBG(printk(KERN_DEBUG PFX "dac2 dma timed out??\n");) } remove_wait_queue(&s->dma_dac2.wait, &wait); set_current_state(TASK_RUNNING); if (signal_pending(current)) return -ERESTARTSYS; return 0; } /* --------------------------------------------------------------------- */ static ssize_t es1371_read(struct file *file, char *buffer, size_t count, loff_t *ppos) { struct es1371_state *s = (struct es1371_state *)file->private_data; DECLARE_WAITQUEUE(wait, current); ssize_t ret; unsigned long flags; unsigned swptr; int cnt; VALIDATE_STATE(s); if (ppos != &file->f_pos) return -ESPIPE; if (s->dma_adc.mapped) return -ENXIO; if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) return ret; if (!access_ok(VERIFY_WRITE, buffer, count)) return -EFAULT; ret = 0; add_wait_queue(&s->dma_adc.wait, &wait); while (count > 0) { spin_lock_irqsave(&s->lock, flags); swptr = s->dma_adc.swptr; cnt = s->dma_adc.dmasize-swptr; if (s->dma_adc.count < cnt) cnt = s->dma_adc.count; if (cnt <= 0) __set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irqrestore(&s->lock, flags); if (cnt > count) cnt = count; if (cnt <= 0) { start_adc(s); if (file->f_flags & O_NONBLOCK) { if (!ret) ret = -EAGAIN; break; } schedule(); if (signal_pending(current)) { if (!ret) ret = -ERESTARTSYS; break; } continue; } if (copy_to_user(buffer, s->dma_adc.rawbuf + swptr, cnt)) { if (!ret) ret = -EFAULT; break; } swptr = (swptr + cnt) % s->dma_adc.dmasize; spin_lock_irqsave(&s->lock, flags); s->dma_adc.swptr = swptr; s->dma_adc.count -= cnt; spin_unlock_irqrestore(&s->lock, flags); count -= cnt; buffer += cnt; ret += cnt; start_adc(s); } remove_wait_queue(&s->dma_adc.wait, &wait); set_current_state(TASK_RUNNING); return ret; } static ssize_t es1371_write(struct file *file, const char *buffer, size_t count, loff_t *ppos) { struct es1371_state *s = (struct es1371_state *)file->private_data; DECLARE_WAITQUEUE(wait, current); ssize_t ret; unsigned long flags; unsigned swptr; int cnt; VALIDATE_STATE(s); if (ppos != &file->f_pos) return -ESPIPE; if (s->dma_dac2.mapped) return -ENXIO; if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) return ret; if (!access_ok(VERIFY_READ, buffer, count)) return -EFAULT; ret = 0; add_wait_queue(&s->dma_dac2.wait, &wait); while (count > 0) { spin_lock_irqsave(&s->lock, flags); if (s->dma_dac2.count < 0) { s->dma_dac2.count = 0; s->dma_dac2.swptr = s->dma_dac2.hwptr; } swptr = s->dma_dac2.swptr; cnt = s->dma_dac2.dmasize-swptr; if (s->dma_dac2.count + cnt > s->dma_dac2.dmasize) cnt = s->dma_dac2.dmasize - s->dma_dac2.count; if (cnt <= 0) __set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irqrestore(&s->lock, flags); if (cnt > count) cnt = count; if (cnt <= 0) { start_dac2(s); if (file->f_flags & O_NONBLOCK) { if (!ret) ret = -EAGAIN; break; } schedule(); if (signal_pending(current)) { if (!ret) ret = -ERESTARTSYS; break; } continue; } if (copy_from_user(s->dma_dac2.rawbuf + swptr, buffer, cnt)) { if (!ret) ret = -EFAULT; break; } swptr = (swptr + cnt) % s->dma_dac2.dmasize; spin_lock_irqsave(&s->lock, flags); s->dma_dac2.swptr = swptr; s->dma_dac2.count += cnt; s->dma_dac2.endcleared = 0; spin_unlock_irqrestore(&s->lock, flags); count -= cnt; buffer += cnt; ret += cnt; start_dac2(s); } remove_wait_queue(&s->dma_dac2.wait, &wait); set_current_state(TASK_RUNNING); return ret; } /* No kernel lock - we have our own spinlock */ static unsigned int es1371_poll(struct file *file, struct poll_table_struct *wait) { struct es1371_state *s = (struct es1371_state *)file->private_data; unsigned long flags; unsigned int mask = 0; VALIDATE_STATE(s); if (file->f_mode & FMODE_WRITE) { if (!s->dma_dac2.ready && prog_dmabuf_dac2(s)) return 0; poll_wait(file, &s->dma_dac2.wait, wait); } if (file->f_mode & FMODE_READ) { if (!s->dma_adc.ready && prog_dmabuf_adc(s)) return 0; poll_wait(file, &s->dma_adc.wait, wait); } spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); if (file->f_mode & FMODE_READ) { if (s->dma_adc.count >= (signed)s->dma_adc.fragsize) mask |= POLLIN | POLLRDNORM; } if (file->f_mode & FMODE_WRITE) { if (s->dma_dac2.mapped) { if (s->dma_dac2.count >= (signed)s->dma_dac2.fragsize) mask |= POLLOUT | POLLWRNORM; } else { if ((signed)s->dma_dac2.dmasize >= s->dma_dac2.count + (signed)s->dma_dac2.fragsize) mask |= POLLOUT | POLLWRNORM; } } spin_unlock_irqrestore(&s->lock, flags); return mask; } static int es1371_mmap(struct file *file, struct vm_area_struct *vma) { struct es1371_state *s = (struct es1371_state *)file->private_data; struct dmabuf *db; int ret; unsigned long size; VALIDATE_STATE(s); lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf_dac2(s)) != 0) { unlock_kernel(); return ret; } db = &s->dma_dac2; } else if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf_adc(s)) != 0) { unlock_kernel(); return ret; } db = &s->dma_adc; } else { unlock_kernel(); return -EINVAL; } if (vma->vm_pgoff != 0) { unlock_kernel(); return -EINVAL; } size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << db->buforder)) { unlock_kernel(); return -EINVAL; } if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) { unlock_kernel(); return -EAGAIN; } db->mapped = 1; unlock_kernel(); return 0; } static int es1371_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct es1371_state *s = (struct es1371_state *)file->private_data; unsigned long flags; audio_buf_info abinfo; count_info cinfo; int count; int val, mapped, ret; VALIDATE_STATE(s); mapped = ((file->f_mode & FMODE_WRITE) && s->dma_dac2.mapped) || ((file->f_mode & FMODE_READ) && s->dma_adc.mapped); switch (cmd) { case OSS_GETVERSION: return put_user(SOUND_VERSION, (int *)arg); case SNDCTL_DSP_SYNC: if (file->f_mode & FMODE_WRITE) return drain_dac2(s, 0/*file->f_flags & O_NONBLOCK*/); return 0; case SNDCTL_DSP_SETDUPLEX: return 0; case SNDCTL_DSP_GETCAPS: return put_user(DSP_CAP_DUPLEX | DSP_CAP_REALTIME | DSP_CAP_TRIGGER | DSP_CAP_MMAP, (int *)arg); case SNDCTL_DSP_RESET: if (file->f_mode & FMODE_WRITE) { stop_dac2(s); synchronize_irq(); s->dma_dac2.swptr = s->dma_dac2.hwptr = s->dma_dac2.count = s->dma_dac2.total_bytes = 0; } if (file->f_mode & FMODE_READ) { stop_adc(s); synchronize_irq(); s->dma_adc.swptr = s->dma_adc.hwptr = s->dma_adc.count = s->dma_adc.total_bytes = 0; } return 0; case SNDCTL_DSP_SPEED: if (get_user(val, (int *)arg)) return -EFAULT; if (val >= 0) { if (file->f_mode & FMODE_READ) { stop_adc(s); s->dma_adc.ready = 0; set_adc_rate(s, val); } if (file->f_mode & FMODE_WRITE) { stop_dac2(s); s->dma_dac2.ready = 0; set_dac2_rate(s, val); } } return put_user((file->f_mode & FMODE_READ) ? s->adcrate : s->dac2rate, (int *)arg); case SNDCTL_DSP_STEREO: if (get_user(val, (int *)arg)) return -EFAULT; if (file->f_mode & FMODE_READ) { stop_adc(s); s->dma_adc.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val) s->sctrl |= SCTRL_R1SMB; else s->sctrl &= ~SCTRL_R1SMB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } if (file->f_mode & FMODE_WRITE) { stop_dac2(s); s->dma_dac2.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val) s->sctrl |= SCTRL_P2SMB; else s->sctrl &= ~SCTRL_P2SMB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } return 0; case SNDCTL_DSP_CHANNELS: if (get_user(val, (int *)arg)) return -EFAULT; if (val != 0) { if (file->f_mode & FMODE_READ) { stop_adc(s); s->dma_adc.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val >= 2) s->sctrl |= SCTRL_R1SMB; else s->sctrl &= ~SCTRL_R1SMB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } if (file->f_mode & FMODE_WRITE) { stop_dac2(s); s->dma_dac2.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val >= 2) s->sctrl |= SCTRL_P2SMB; else s->sctrl &= ~SCTRL_P2SMB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } } return put_user((s->sctrl & ((file->f_mode & FMODE_READ) ? SCTRL_R1SMB : SCTRL_P2SMB)) ? 2 : 1, (int *)arg); case SNDCTL_DSP_GETFMTS: /* Returns a mask */ return put_user(AFMT_S16_LE|AFMT_U8, (int *)arg); case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/ if (get_user(val, (int *)arg)) return -EFAULT; if (val != AFMT_QUERY) { if (file->f_mode & FMODE_READ) { stop_adc(s); s->dma_adc.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val == AFMT_S16_LE) s->sctrl |= SCTRL_R1SEB; else s->sctrl &= ~SCTRL_R1SEB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } if (file->f_mode & FMODE_WRITE) { stop_dac2(s); s->dma_dac2.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val == AFMT_S16_LE) s->sctrl |= SCTRL_P2SEB; else s->sctrl &= ~SCTRL_P2SEB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } } return put_user((s->sctrl & ((file->f_mode & FMODE_READ) ? SCTRL_R1SEB : SCTRL_P2SEB)) ? AFMT_S16_LE : AFMT_U8, (int *)arg); case SNDCTL_DSP_POST: return 0; case SNDCTL_DSP_GETTRIGGER: val = 0; if (file->f_mode & FMODE_READ && s->ctrl & CTRL_ADC_EN) val |= PCM_ENABLE_INPUT; if (file->f_mode & FMODE_WRITE && s->ctrl & CTRL_DAC2_EN) val |= PCM_ENABLE_OUTPUT; return put_user(val, (int *)arg); case SNDCTL_DSP_SETTRIGGER: if (get_user(val, (int *)arg)) return -EFAULT; if (file->f_mode & FMODE_READ) { if (val & PCM_ENABLE_INPUT) { if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) return ret; start_adc(s); } else stop_adc(s); } if (file->f_mode & FMODE_WRITE) { if (val & PCM_ENABLE_OUTPUT) { if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) return ret; start_dac2(s); } else stop_dac2(s); } return 0; case SNDCTL_DSP_GETOSPACE: if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) return ret; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); abinfo.fragsize = s->dma_dac2.fragsize; count = s->dma_dac2.count; if (count < 0) count = 0; abinfo.bytes = s->dma_dac2.dmasize - count; abinfo.fragstotal = s->dma_dac2.numfrag; abinfo.fragments = abinfo.bytes >> s->dma_dac2.fragshift; spin_unlock_irqrestore(&s->lock, flags); return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0; case SNDCTL_DSP_GETISPACE: if (!(file->f_mode & FMODE_READ)) return -EINVAL; if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) return ret; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); abinfo.fragsize = s->dma_adc.fragsize; count = s->dma_adc.count; if (count < 0) count = 0; abinfo.bytes = count; abinfo.fragstotal = s->dma_adc.numfrag; abinfo.fragments = abinfo.bytes >> s->dma_adc.fragshift; spin_unlock_irqrestore(&s->lock, flags); return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0; case SNDCTL_DSP_NONBLOCK: file->f_flags |= O_NONBLOCK; return 0; case SNDCTL_DSP_GETODELAY: if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) return ret; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); count = s->dma_dac2.count; spin_unlock_irqrestore(&s->lock, flags); if (count < 0) count = 0; return put_user(count, (int *)arg); case SNDCTL_DSP_GETIPTR: if (!(file->f_mode & FMODE_READ)) return -EINVAL; if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) return ret; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); cinfo.bytes = s->dma_adc.total_bytes; count = s->dma_adc.count; if (count < 0) count = 0; cinfo.blocks = count >> s->dma_adc.fragshift; cinfo.ptr = s->dma_adc.hwptr; if (s->dma_adc.mapped) s->dma_adc.count &= s->dma_adc.fragsize-1; spin_unlock_irqrestore(&s->lock, flags); return copy_to_user((void *)arg, &cinfo, sizeof(cinfo)); case SNDCTL_DSP_GETOPTR: if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) return ret; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); cinfo.bytes = s->dma_dac2.total_bytes; count = s->dma_dac2.count; if (count < 0) count = 0; cinfo.blocks = count >> s->dma_dac2.fragshift; cinfo.ptr = s->dma_dac2.hwptr; if (s->dma_dac2.mapped) s->dma_dac2.count &= s->dma_dac2.fragsize-1; spin_unlock_irqrestore(&s->lock, flags); return copy_to_user((void *)arg, &cinfo, sizeof(cinfo)); case SNDCTL_DSP_GETBLKSIZE: if (file->f_mode & FMODE_WRITE) { if ((val = prog_dmabuf_dac2(s))) return val; return put_user(s->dma_dac2.fragsize, (int *)arg); } if ((val = prog_dmabuf_adc(s))) return val; return put_user(s->dma_adc.fragsize, (int *)arg); case SNDCTL_DSP_SETFRAGMENT: if (get_user(val, (int *)arg)) return -EFAULT; if (file->f_mode & FMODE_READ) { s->dma_adc.ossfragshift = val & 0xffff; s->dma_adc.ossmaxfrags = (val >> 16) & 0xffff; if (s->dma_adc.ossfragshift < 4) s->dma_adc.ossfragshift = 4; if (s->dma_adc.ossfragshift > 15) s->dma_adc.ossfragshift = 15; if (s->dma_adc.ossmaxfrags < 4) s->dma_adc.ossmaxfrags = 4; } if (file->f_mode & FMODE_WRITE) { s->dma_dac2.ossfragshift = val & 0xffff; s->dma_dac2.ossmaxfrags = (val >> 16) & 0xffff; if (s->dma_dac2.ossfragshift < 4) s->dma_dac2.ossfragshift = 4; if (s->dma_dac2.ossfragshift > 15) s->dma_dac2.ossfragshift = 15; if (s->dma_dac2.ossmaxfrags < 4) s->dma_dac2.ossmaxfrags = 4; } return 0; case SNDCTL_DSP_SUBDIVIDE: if ((file->f_mode & FMODE_READ && s->dma_adc.subdivision) || (file->f_mode & FMODE_WRITE && s->dma_dac2.subdivision)) return -EINVAL; if (get_user(val, (int *)arg)) return -EFAULT; if (val != 1 && val != 2 && val != 4) return -EINVAL; if (file->f_mode & FMODE_READ) s->dma_adc.subdivision = val; if (file->f_mode & FMODE_WRITE) s->dma_dac2.subdivision = val; return 0; case SOUND_PCM_READ_RATE: return put_user((file->f_mode & FMODE_READ) ? s->adcrate : s->dac2rate, (int *)arg); case SOUND_PCM_READ_CHANNELS: return put_user((s->sctrl & ((file->f_mode & FMODE_READ) ? SCTRL_R1SMB : SCTRL_P2SMB)) ? 2 : 1, (int *)arg); case SOUND_PCM_READ_BITS: return put_user((s->sctrl & ((file->f_mode & FMODE_READ) ? SCTRL_R1SEB : SCTRL_P2SEB)) ? 16 : 8, (int *)arg); case SOUND_PCM_WRITE_FILTER: case SNDCTL_DSP_SETSYNCRO: case SOUND_PCM_READ_FILTER: return -EINVAL; } return mixdev_ioctl(&s->codec, cmd, arg); } static int es1371_open(struct inode *inode, struct file *file) { int minor = MINOR(inode->i_rdev); DECLARE_WAITQUEUE(wait, current); unsigned long flags; struct list_head *list; struct es1371_state *s; for (list = devs.next; ; list = list->next) { if (list == &devs) return -ENODEV; s = list_entry(list, struct es1371_state, devs); if (!((s->dev_audio ^ minor) & ~0xf)) break; } VALIDATE_STATE(s); file->private_data = s; /* wait for device to become free */ down(&s->open_sem); while (s->open_mode & file->f_mode) { if (file->f_flags & O_NONBLOCK) { up(&s->open_sem); return -EBUSY; } add_wait_queue(&s->open_wait, &wait); __set_current_state(TASK_INTERRUPTIBLE); up(&s->open_sem); schedule(); remove_wait_queue(&s->open_wait, &wait); set_current_state(TASK_RUNNING); if (signal_pending(current)) return -ERESTARTSYS; down(&s->open_sem); } if (file->f_mode & FMODE_READ) { s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.subdivision = 0; set_adc_rate(s, 8000); } if (file->f_mode & FMODE_WRITE) { s->dma_dac2.ossfragshift = s->dma_dac2.ossmaxfrags = s->dma_dac2.subdivision = 0; set_dac2_rate(s, 8000); } spin_lock_irqsave(&s->lock, flags); if (file->f_mode & FMODE_READ) { s->sctrl &= ~SCTRL_R1FMT; if ((minor & 0xf) == SND_DEV_DSP16) s->sctrl |= ES1371_FMT_S16_MONO << SCTRL_SH_R1FMT; else s->sctrl |= ES1371_FMT_U8_MONO << SCTRL_SH_R1FMT; } if (file->f_mode & FMODE_WRITE) { s->sctrl &= ~SCTRL_P2FMT; if ((minor & 0xf) == SND_DEV_DSP16) s->sctrl |= ES1371_FMT_S16_MONO << SCTRL_SH_P2FMT; else s->sctrl |= ES1371_FMT_U8_MONO << SCTRL_SH_P2FMT; } outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); up(&s->open_sem); return 0; } static int es1371_release(struct inode *inode, struct file *file) { struct es1371_state *s = (struct es1371_state *)file->private_data; VALIDATE_STATE(s); lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac2(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); if (file->f_mode & FMODE_WRITE) { stop_dac2(s); dealloc_dmabuf(s, &s->dma_dac2); } if (file->f_mode & FMODE_READ) { stop_adc(s); dealloc_dmabuf(s, &s->dma_adc); } s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); up(&s->open_sem); wake_up(&s->open_wait); unlock_kernel(); return 0; } static /*const*/ struct file_operations es1371_audio_fops = { owner: THIS_MODULE, llseek: es1371_llseek, read: es1371_read, write: es1371_write, poll: es1371_poll, ioctl: es1371_ioctl, mmap: es1371_mmap, open: es1371_open, release: es1371_release, }; /* --------------------------------------------------------------------- */ static ssize_t es1371_write_dac(struct file *file, const char *buffer, size_t count, loff_t *ppos) { struct es1371_state *s = (struct es1371_state *)file->private_data; DECLARE_WAITQUEUE(wait, current); ssize_t ret = 0; unsigned long flags; unsigned swptr; int cnt; VALIDATE_STATE(s); if (ppos != &file->f_pos) return -ESPIPE; if (s->dma_dac1.mapped) return -ENXIO; if (!s->dma_dac1.ready && (ret = prog_dmabuf_dac1(s))) return ret; if (!access_ok(VERIFY_READ, buffer, count)) return -EFAULT; add_wait_queue(&s->dma_dac1.wait, &wait); while (count > 0) { spin_lock_irqsave(&s->lock, flags); if (s->dma_dac1.count < 0) { s->dma_dac1.count = 0; s->dma_dac1.swptr = s->dma_dac1.hwptr; } swptr = s->dma_dac1.swptr; cnt = s->dma_dac1.dmasize-swptr; if (s->dma_dac1.count + cnt > s->dma_dac1.dmasize) cnt = s->dma_dac1.dmasize - s->dma_dac1.count; if (cnt <= 0) __set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irqrestore(&s->lock, flags); if (cnt > count) cnt = count; if (cnt <= 0) { start_dac1(s); if (file->f_flags & O_NONBLOCK) { if (!ret) ret = -EAGAIN; break; } schedule(); if (signal_pending(current)) { if (!ret) ret = -ERESTARTSYS; break; } continue; } if (copy_from_user(s->dma_dac1.rawbuf + swptr, buffer, cnt)) { if (!ret) ret = -EFAULT; break; } swptr = (swptr + cnt) % s->dma_dac1.dmasize; spin_lock_irqsave(&s->lock, flags); s->dma_dac1.swptr = swptr; s->dma_dac1.count += cnt; s->dma_dac1.endcleared = 0; spin_unlock_irqrestore(&s->lock, flags); count -= cnt; buffer += cnt; ret += cnt; start_dac1(s); } remove_wait_queue(&s->dma_dac1.wait, &wait); set_current_state(TASK_RUNNING); return ret; } /* No kernel lock - we have our own spinlock */ static unsigned int es1371_poll_dac(struct file *file, struct poll_table_struct *wait) { struct es1371_state *s = (struct es1371_state *)file->private_data; unsigned long flags; unsigned int mask = 0; VALIDATE_STATE(s); if (!s->dma_dac1.ready && prog_dmabuf_dac1(s)) return 0; poll_wait(file, &s->dma_dac1.wait, wait); spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); if (s->dma_dac1.mapped) { if (s->dma_dac1.count >= (signed)s->dma_dac1.fragsize) mask |= POLLOUT | POLLWRNORM; } else { if ((signed)s->dma_dac1.dmasize >= s->dma_dac1.count + (signed)s->dma_dac1.fragsize) mask |= POLLOUT | POLLWRNORM; } spin_unlock_irqrestore(&s->lock, flags); return mask; } static int es1371_mmap_dac(struct file *file, struct vm_area_struct *vma) { struct es1371_state *s = (struct es1371_state *)file->private_data; int ret; unsigned long size; VALIDATE_STATE(s); if (!(vma->vm_flags & VM_WRITE)) return -EINVAL; lock_kernel(); if ((ret = prog_dmabuf_dac1(s)) != 0) goto out; ret = -EINVAL; if (vma->vm_pgoff != 0) goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << s->dma_dac1.buforder)) goto out; ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot)) goto out; s->dma_dac1.mapped = 1; ret = 0; out: unlock_kernel(); return ret; } static int es1371_ioctl_dac(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct es1371_state *s = (struct es1371_state *)file->private_data; unsigned long flags; audio_buf_info abinfo; count_info cinfo; int count; int val, ret; VALIDATE_STATE(s); switch (cmd) { case OSS_GETVERSION: return put_user(SOUND_VERSION, (int *)arg); case SNDCTL_DSP_SYNC: return drain_dac1(s, 0/*file->f_flags & O_NONBLOCK*/); case SNDCTL_DSP_SETDUPLEX: return -EINVAL; case SNDCTL_DSP_GETCAPS: return put_user(DSP_CAP_REALTIME | DSP_CAP_TRIGGER | DSP_CAP_MMAP, (int *)arg); case SNDCTL_DSP_RESET: stop_dac1(s); synchronize_irq(); s->dma_dac1.swptr = s->dma_dac1.hwptr = s->dma_dac1.count = s->dma_dac1.total_bytes = 0; return 0; case SNDCTL_DSP_SPEED: if (get_user(val, (int *)arg)) return -EFAULT; if (val >= 0) { stop_dac1(s); s->dma_dac1.ready = 0; set_dac1_rate(s, val); } return put_user(s->dac1rate, (int *)arg); case SNDCTL_DSP_STEREO: if (get_user(val, (int *)arg)) return -EFAULT; stop_dac1(s); s->dma_dac1.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val) s->sctrl |= SCTRL_P1SMB; else s->sctrl &= ~SCTRL_P1SMB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); return 0; case SNDCTL_DSP_CHANNELS: if (get_user(val, (int *)arg)) return -EFAULT; if (val != 0) { stop_dac1(s); s->dma_dac1.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val >= 2) s->sctrl |= SCTRL_P1SMB; else s->sctrl &= ~SCTRL_P1SMB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } return put_user((s->sctrl & SCTRL_P1SMB) ? 2 : 1, (int *)arg); case SNDCTL_DSP_GETFMTS: /* Returns a mask */ return put_user(AFMT_S16_LE|AFMT_U8, (int *)arg); case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/ if (get_user(val, (int *)arg)) return -EFAULT; if (val != AFMT_QUERY) { stop_dac1(s); s->dma_dac1.ready = 0; spin_lock_irqsave(&s->lock, flags); if (val == AFMT_S16_LE) s->sctrl |= SCTRL_P1SEB; else s->sctrl &= ~SCTRL_P1SEB; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); } return put_user((s->sctrl & SCTRL_P1SEB) ? AFMT_S16_LE : AFMT_U8, (int *)arg); case SNDCTL_DSP_POST: return 0; case SNDCTL_DSP_GETTRIGGER: return put_user((s->ctrl & CTRL_DAC1_EN) ? PCM_ENABLE_OUTPUT : 0, (int *)arg); case SNDCTL_DSP_SETTRIGGER: if (get_user(val, (int *)arg)) return -EFAULT; if (val & PCM_ENABLE_OUTPUT) { if (!s->dma_dac1.ready && (ret = prog_dmabuf_dac1(s))) return ret; start_dac1(s); } else stop_dac1(s); return 0; case SNDCTL_DSP_GETOSPACE: if (!(s->ctrl & CTRL_DAC1_EN) && (val = prog_dmabuf_dac1(s)) != 0) return val; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); abinfo.fragsize = s->dma_dac1.fragsize; count = s->dma_dac1.count; if (count < 0) count = 0; abinfo.bytes = s->dma_dac1.dmasize - count; abinfo.fragstotal = s->dma_dac1.numfrag; abinfo.fragments = abinfo.bytes >> s->dma_dac1.fragshift; spin_unlock_irqrestore(&s->lock, flags); return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0; case SNDCTL_DSP_NONBLOCK: file->f_flags |= O_NONBLOCK; return 0; case SNDCTL_DSP_GETODELAY: spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); count = s->dma_dac1.count; spin_unlock_irqrestore(&s->lock, flags); if (count < 0) count = 0; return put_user(count, (int *)arg); case SNDCTL_DSP_GETOPTR: if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; spin_lock_irqsave(&s->lock, flags); es1371_update_ptr(s); cinfo.bytes = s->dma_dac1.total_bytes; count = s->dma_dac1.count; if (count < 0) count = 0; cinfo.blocks = count >> s->dma_dac1.fragshift; cinfo.ptr = s->dma_dac1.hwptr; if (s->dma_dac1.mapped) s->dma_dac1.count &= s->dma_dac1.fragsize-1; spin_unlock_irqrestore(&s->lock, flags); return copy_to_user((void *)arg, &cinfo, sizeof(cinfo)); case SNDCTL_DSP_GETBLKSIZE: if ((val = prog_dmabuf_dac1(s))) return val; return put_user(s->dma_dac1.fragsize, (int *)arg); case SNDCTL_DSP_SETFRAGMENT: if (get_user(val, (int *)arg)) return -EFAULT; s->dma_dac1.ossfragshift = val & 0xffff; s->dma_dac1.ossmaxfrags = (val >> 16) & 0xffff; if (s->dma_dac1.ossfragshift < 4) s->dma_dac1.ossfragshift = 4; if (s->dma_dac1.ossfragshift > 15) s->dma_dac1.ossfragshift = 15; if (s->dma_dac1.ossmaxfrags < 4) s->dma_dac1.ossmaxfrags = 4; return 0; case SNDCTL_DSP_SUBDIVIDE: if (s->dma_dac1.subdivision) return -EINVAL; if (get_user(val, (int *)arg)) return -EFAULT; if (val != 1 && val != 2 && val != 4) return -EINVAL; s->dma_dac1.subdivision = val; return 0; case SOUND_PCM_READ_RATE: return put_user(s->dac1rate, (int *)arg); case SOUND_PCM_READ_CHANNELS: return put_user((s->sctrl & SCTRL_P1SMB) ? 2 : 1, (int *)arg); case SOUND_PCM_READ_BITS: return put_user((s->sctrl & SCTRL_P1SEB) ? 16 : 8, (int *)arg); case SOUND_PCM_WRITE_FILTER: case SNDCTL_DSP_SETSYNCRO: case SOUND_PCM_READ_FILTER: return -EINVAL; } return mixdev_ioctl(&s->codec, cmd, arg); } static int es1371_open_dac(struct inode *inode, struct file *file) { int minor = MINOR(inode->i_rdev); DECLARE_WAITQUEUE(wait, current); unsigned long flags; struct list_head *list; struct es1371_state *s; for (list = devs.next; ; list = list->next) { if (list == &devs) return -ENODEV; s = list_entry(list, struct es1371_state, devs); if (!((s->dev_dac ^ minor) & ~0xf)) break; } VALIDATE_STATE(s); /* we allow opening with O_RDWR, most programs do it although they will only write */ #if 0 if (file->f_mode & FMODE_READ) return -EPERM; #endif if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; file->private_data = s; /* wait for device to become free */ down(&s->open_sem); while (s->open_mode & FMODE_DAC) { if (file->f_flags & O_NONBLOCK) { up(&s->open_sem); return -EBUSY; } add_wait_queue(&s->open_wait, &wait); __set_current_state(TASK_INTERRUPTIBLE); up(&s->open_sem); schedule(); remove_wait_queue(&s->open_wait, &wait); set_current_state(TASK_RUNNING); if (signal_pending(current)) return -ERESTARTSYS; down(&s->open_sem); } s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0; set_dac1_rate(s, 8000); spin_lock_irqsave(&s->lock, flags); s->sctrl &= ~SCTRL_P1FMT; if ((minor & 0xf) == SND_DEV_DSP16) s->sctrl |= ES1371_FMT_S16_MONO << SCTRL_SH_P1FMT; else s->sctrl |= ES1371_FMT_U8_MONO << SCTRL_SH_P1FMT; outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); spin_unlock_irqrestore(&s->lock, flags); s->open_mode |= FMODE_DAC; up(&s->open_sem); return 0; } static int es1371_release_dac(struct inode *inode, struct file *file) { struct es1371_state *s = (struct es1371_state *)file->private_data; VALIDATE_STATE(s); lock_kernel(); drain_dac1(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); stop_dac1(s); dealloc_dmabuf(s, &s->dma_dac1); s->open_mode &= ~FMODE_DAC; up(&s->open_sem); wake_up(&s->open_wait); unlock_kernel(); return 0; } static /*const*/ struct file_operations es1371_dac_fops = { owner: THIS_MODULE, llseek: es1371_llseek, write: es1371_write_dac, poll: es1371_poll_dac, ioctl: es1371_ioctl_dac, mmap: es1371_mmap_dac, open: es1371_open_dac, release: es1371_release_dac, }; /* --------------------------------------------------------------------- */ static ssize_t es1371_midi_read(struct file *file, char *buffer, size_t count, loff_t *ppos) { struct es1371_state *s = (struct es1371_state *)file->private_data; DECLARE_WAITQUEUE(wait, current); ssize_t ret; unsigned long flags; unsigned ptr; int cnt; VALIDATE_STATE(s); if (ppos != &file->f_pos) return -ESPIPE; if (!access_ok(VERIFY_WRITE, buffer, count)) return -EFAULT; if (count == 0) return 0; ret = 0; add_wait_queue(&s->midi.iwait, &wait); while (count > 0) { spin_lock_irqsave(&s->lock, flags); ptr = s->midi.ird; cnt = MIDIINBUF - ptr; if (s->midi.icnt < cnt) cnt = s->midi.icnt; if (cnt <= 0) __set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irqrestore(&s->lock, flags); if (cnt > count) cnt = count; if (cnt <= 0) { if (file->f_flags & O_NONBLOCK) { if (!ret) ret = -EAGAIN; break; } schedule(); if (signal_pending(current)) { if (!ret) ret = -ERESTARTSYS; break; } continue; } if (copy_to_user(buffer, s->midi.ibuf + ptr, cnt)) { if (!ret) ret = -EFAULT; break; } ptr = (ptr + cnt) % MIDIINBUF; spin_lock_irqsave(&s->lock, flags); s->midi.ird = ptr; s->midi.icnt -= cnt; spin_unlock_irqrestore(&s->lock, flags); count -= cnt; buffer += cnt; ret += cnt; break; } __set_current_state(TASK_RUNNING); remove_wait_queue(&s->midi.iwait, &wait); return ret; } static ssize_t es1371_midi_write(struct file *file, const char *buffer, size_t count, loff_t *ppos) { struct es1371_state *s = (struct es1371_state *)file->private_data; DECLARE_WAITQUEUE(wait, current); ssize_t ret; unsigned long flags; unsigned ptr; int cnt; VALIDATE_STATE(s); if (ppos != &file->f_pos) return -ESPIPE; if (!access_ok(VERIFY_READ, buffer, count)) return -EFAULT; if (count == 0) return 0; ret = 0; add_wait_queue(&s->midi.owait, &wait); while (count > 0) { spin_lock_irqsave(&s->lock, flags); ptr = s->midi.owr; cnt = MIDIOUTBUF - ptr; if (s->midi.ocnt + cnt > MIDIOUTBUF) cnt = MIDIOUTBUF - s->midi.ocnt; if (cnt <= 0) { __set_current_state(TASK_INTERRUPTIBLE); es1371_handle_midi(s); } spin_unlock_irqrestore(&s->lock, flags); if (cnt > count) cnt = count; if (cnt <= 0) { if (file->f_flags & O_NONBLOCK) { if (!ret) ret = -EAGAIN; break; } schedule(); if (signal_pending(current)) { if (!ret) ret = -ERESTARTSYS; break; } continue; } if (copy_from_user(s->midi.obuf + ptr, buffer, cnt)) { if (!ret) ret = -EFAULT; break; } ptr = (ptr + cnt) % MIDIOUTBUF; spin_lock_irqsave(&s->lock, flags); s->midi.owr = ptr; s->midi.ocnt += cnt; spin_unlock_irqrestore(&s->lock, flags); count -= cnt; buffer += cnt; ret += cnt; spin_lock_irqsave(&s->lock, flags); es1371_handle_midi(s); spin_unlock_irqrestore(&s->lock, flags); } __set_current_state(TASK_RUNNING); remove_wait_queue(&s->midi.owait, &wait); return ret; } /* No kernel lock - we have our own spinlock */ static unsigned int es1371_midi_poll(struct file *file, struct poll_table_struct *wait) { struct es1371_state *s = (struct es1371_state *)file->private_data; unsigned long flags; unsigned int mask = 0; VALIDATE_STATE(s); if (file->f_mode & FMODE_WRITE) poll_wait(file, &s->midi.owait, wait); if (file->f_mode & FMODE_READ) poll_wait(file, &s->midi.iwait, wait); spin_lock_irqsave(&s->lock, flags); if (file->f_mode & FMODE_READ) { if (s->midi.icnt > 0) mask |= POLLIN | POLLRDNORM; } if (file->f_mode & FMODE_WRITE) { if (s->midi.ocnt < MIDIOUTBUF) mask |= POLLOUT | POLLWRNORM; } spin_unlock_irqrestore(&s->lock, flags); return mask; } static int es1371_midi_open(struct inode *inode, struct file *file) { int minor = MINOR(inode->i_rdev); DECLARE_WAITQUEUE(wait, current); unsigned long flags; struct list_head *list; struct es1371_state *s; for (list = devs.next; ; list = list->next) { if (list == &devs) return -ENODEV; s = list_entry(list, struct es1371_state, devs); if (s->dev_midi == minor) break; } VALIDATE_STATE(s); file->private_data = s; /* wait for device to become free */ down(&s->open_sem); while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { if (file->f_flags & O_NONBLOCK) { up(&s->open_sem); return -EBUSY; } add_wait_queue(&s->open_wait, &wait); __set_current_state(TASK_INTERRUPTIBLE); up(&s->open_sem); schedule(); remove_wait_queue(&s->open_wait, &wait); set_current_state(TASK_RUNNING); if (signal_pending(current)) return -ERESTARTSYS; down(&s->open_sem); } spin_lock_irqsave(&s->lock, flags); if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { s->midi.ird = s->midi.iwr = s->midi.icnt = 0; s->midi.ord = s->midi.owr = s->midi.ocnt = 0; outb(UCTRL_CNTRL_SWR, s->io+ES1371_REG_UART_CONTROL); outb(0, s->io+ES1371_REG_UART_CONTROL); outb(0, s->io+ES1371_REG_UART_TEST); } if (file->f_mode & FMODE_READ) { s->midi.ird = s->midi.iwr = s->midi.icnt = 0; } if (file->f_mode & FMODE_WRITE) { s->midi.ord = s->midi.owr = s->midi.ocnt = 0; } s->ctrl |= CTRL_UART_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); es1371_handle_midi(s); spin_unlock_irqrestore(&s->lock, flags); s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); up(&s->open_sem); return 0; } static int es1371_midi_release(struct inode *inode, struct file *file) { struct es1371_state *s = (struct es1371_state *)file->private_data; DECLARE_WAITQUEUE(wait, current); unsigned long flags; unsigned count, tmo; VALIDATE_STATE(s); lock_kernel(); if (file->f_mode & FMODE_WRITE) { add_wait_queue(&s->midi.owait, &wait); for (;;) { __set_current_state(TASK_INTERRUPTIBLE); spin_lock_irqsave(&s->lock, flags); count = s->midi.ocnt; spin_unlock_irqrestore(&s->lock, flags); if (count <= 0) break; if (signal_pending(current)) break; if (file->f_flags & O_NONBLOCK) { remove_wait_queue(&s->midi.owait, &wait); set_current_state(TASK_RUNNING); return -EBUSY; } tmo = (count * HZ) / 3100; if (!schedule_timeout(tmo ? : 1) && tmo) printk(KERN_DEBUG PFX "midi timed out??\n"); } remove_wait_queue(&s->midi.owait, &wait); set_current_state(TASK_RUNNING); } down(&s->open_sem); s->open_mode &= (~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE); spin_lock_irqsave(&s->lock, flags); if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { s->ctrl &= ~CTRL_UART_EN; outl(s->ctrl, s->io+ES1371_REG_CONTROL); } spin_unlock_irqrestore(&s->lock, flags); up(&s->open_sem); wake_up(&s->open_wait); unlock_kernel(); return 0; } static /*const*/ struct file_operations es1371_midi_fops = { owner: THIS_MODULE, llseek: es1371_llseek, read: es1371_midi_read, write: es1371_midi_write, poll: es1371_midi_poll, open: es1371_midi_open, release: es1371_midi_release, }; /* --------------------------------------------------------------------- */ /* * for debugging purposes, we'll create a proc device that dumps the * CODEC chipstate */ #ifdef ES1371_DEBUG static int proc_es1371_dump (char *buf, char **start, off_t fpos, int length, int *eof, void *data) { struct es1371_state *s; int cnt, len = 0; if (list_empty(&devs)) return 0; s = list_entry(devs.next, struct es1371_state, devs); /* print out header */ len += sprintf(buf + len, "\t\tCreative ES137x Debug Dump-o-matic\n"); /* print out CODEC state */ len += sprintf (buf + len, "AC97 CODEC state\n"); for (cnt=0; cnt <= 0x7e; cnt = cnt +2) len+= sprintf (buf + len, "reg:0x%02x val:0x%04x\n", cnt, rdcodec(&s->codec, cnt)); if (fpos >=len){ *start = buf; *eof =1; return 0; } *start = buf + fpos; if ((len -= fpos) > length) return length; *eof =1; return len; } #endif /* ES1371_DEBUG */ /* --------------------------------------------------------------------- */ /* maximum number of devices; only used for command line params */ #define NR_DEVICE 5 static int joystick[NR_DEVICE] = { 0, }; static int spdif[NR_DEVICE] = { 0, }; static int nomix[NR_DEVICE] = { 0, }; static unsigned int devindex = 0; MODULE_PARM(joystick, "1-" __MODULE_STRING(NR_DEVICE) "i"); MODULE_PARM_DESC(joystick, "sets address and enables joystick interface (still need separate driver)"); MODULE_PARM(spdif, "1-" __MODULE_STRING(NR_DEVICE) "i"); MODULE_PARM_DESC(spdif, "if 1 the output is in S/PDIF digital mode"); MODULE_PARM(nomix, "1-" __MODULE_STRING(NR_DEVICE) "i"); MODULE_PARM_DESC(nomix, "if 1 no analog audio is mixed to the digital output"); MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu"); MODULE_DESCRIPTION("ES1371 AudioPCI97 Driver"); /* --------------------------------------------------------------------- */ static struct initvol { int mixch; int vol; } initvol[] __initdata = { { SOUND_MIXER_WRITE_LINE, 0x4040 }, { SOUND_MIXER_WRITE_CD, 0x4040 }, { MIXER_WRITE(SOUND_MIXER_VIDEO), 0x4040 }, { SOUND_MIXER_WRITE_LINE1, 0x4040 }, { SOUND_MIXER_WRITE_PCM, 0x4040 }, { SOUND_MIXER_WRITE_VOLUME, 0x4040 }, { MIXER_WRITE(SOUND_MIXER_PHONEOUT), 0x4040 }, { SOUND_MIXER_WRITE_OGAIN, 0x4040 }, { MIXER_WRITE(SOUND_MIXER_PHONEIN), 0x4040 }, { SOUND_MIXER_WRITE_SPEAKER, 0x4040 }, { SOUND_MIXER_WRITE_MIC, 0x4040 }, { SOUND_MIXER_WRITE_RECLEV, 0x4040 }, { SOUND_MIXER_WRITE_IGAIN, 0x4040 } }; #define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \ (pci_resource_flags((dev), (num)) & IORESOURCE_IO)) static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) { struct es1371_state *s; mm_segment_t fs; int i, val; unsigned long tmo; signed long tmo2; unsigned int cssr; if (!RSRCISIOREGION(pcidev, 0)) return -1; if (pcidev->irq == 0) return -1; if (!pci_dma_supported(pcidev, 0xffffffff)) { printk(KERN_WARNING "es1371: architecture does not support 32bit PCI busmaster DMA\n"); return -1; } if (!(s = kmalloc(sizeof(struct es1371_state), GFP_KERNEL))) { printk(KERN_WARNING PFX "out of memory\n"); return -1; } memset(s, 0, sizeof(struct es1371_state)); init_waitqueue_head(&s->dma_adc.wait); init_waitqueue_head(&s->dma_dac1.wait); init_waitqueue_head(&s->dma_dac2.wait); init_waitqueue_head(&s->open_wait); init_waitqueue_head(&s->midi.iwait); init_waitqueue_head(&s->midi.owait); init_MUTEX(&s->open_sem); spin_lock_init(&s->lock); s->magic = ES1371_MAGIC; s->dev = pcidev; s->io = pci_resource_start(pcidev, 0); s->irq = pcidev->irq; s->vendor = pcidev->vendor; s->device = pcidev->device; pci_read_config_byte(pcidev, PCI_REVISION_ID, &s->rev); s->codec.private_data = s; s->codec.id = 0; s->codec.codec_read = rdcodec; s->codec.codec_write = wrcodec; printk(KERN_INFO PFX "found chip, vendor id 0x%04x device id 0x%04x revision 0x%02x\n", s->vendor, s->device, s->rev); if (!request_region(s->io, ES1371_EXTENT, "es1371")) { printk(KERN_ERR PFX "io ports %#lx-%#lx in use\n", s->io, s->io+ES1371_EXTENT-1); goto err_region; } if (pci_enable_device(pcidev)) goto err_irq; if (request_irq(s->irq, es1371_interrupt, SA_SHIRQ, "es1371", s)) { printk(KERN_ERR PFX "irq %u in use\n", s->irq); goto err_irq; } printk(KERN_INFO PFX "found es1371 rev %d at io %#lx irq %u\n" KERN_INFO PFX "features: joystick 0x%x\n", s->rev, s->io, s->irq, joystick[devindex]); /* register devices */ if ((s->dev_audio = register_sound_dsp(&es1371_audio_fops, -1)) < 0) goto err_dev1; if ((s->codec.dev_mixer = register_sound_mixer(&es1371_mixer_fops, -1)) < 0) goto err_dev2; if ((s->dev_dac = register_sound_dsp(&es1371_dac_fops, -1)) < 0) goto err_dev3; if ((s->dev_midi = register_sound_midi(&es1371_midi_fops, -1)) < 0) goto err_dev4; #ifdef ES1371_DEBUG /* intialize the debug proc device */ s->ps = create_proc_read_entry("es1371",0,NULL,proc_es1371_dump,NULL); #endif /* ES1371_DEBUG */ /* initialize codec registers */ s->ctrl = 0; if (pcidev->subsystem_vendor == 0x107b && pcidev->subsystem_device == 0x2150) { s->ctrl |= CTRL_GPIO_OUT0; printk(KERN_INFO PFX "Running On Gateway 2000 Solo 2510 - Amp On \n"); } if ((joystick[devindex] & ~0x18) == 0x200) { if (check_region(joystick[devindex], JOY_EXTENT)) printk(KERN_ERR PFX "joystick address 0x%x already in use\n", joystick[devindex]); else { s->ctrl |= CTRL_JYSTK_EN | (((joystick[devindex] >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT); } } s->sctrl = 0; cssr = 0; s->spdif_volume = -1; /* check to see if s/pdif mode is being requested */ if (spdif[devindex]) { if (s->rev >= 4) { printk(KERN_INFO PFX "enabling S/PDIF output\n"); s->spdif_volume = 0; cssr |= STAT_EN_SPDIF; s->ctrl |= CTRL_SPDIFEN_B; if (nomix[devindex]) /* don't mix analog inputs to s/pdif output */ s->ctrl |= CTRL_RECEN_B; } else { printk(KERN_ERR PFX "revision %d does not support S/PDIF\n", s->rev); } } /* initialize the chips */ outl(s->ctrl, s->io+ES1371_REG_CONTROL); outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); outl(0, s->io+ES1371_REG_LEGACY); pci_set_master(pcidev); /* enable bus mastering */ /* if we are a 5880 turn on the AC97 */ if (s->vendor == PCI_VENDOR_ID_ENSONIQ && ((s->device == PCI_DEVICE_ID_ENSONIQ_CT5880 && s->rev == CT5880REV_CT5880_C) || (s->device == PCI_DEVICE_ID_ENSONIQ_ES1371 && s->rev == ES1371REV_CT5880_A) || (s->device == PCI_DEVICE_ID_ENSONIQ_ES1371 && s->rev == ES1371REV_ES1373_8))) { cssr |= CSTAT_5880_AC97_RST; outl(cssr, s->io+ES1371_REG_STATUS); /* need to delay around 20ms(bleech) to give some CODECs enough time to wakeup */ tmo = jiffies + (HZ / 50) + 1; for (;;) { tmo2 = tmo - jiffies; if (tmo2 <= 0) break; schedule_timeout(tmo2); } } /* AC97 warm reset to start the bitclk */ outl(s->ctrl | CTRL_SYNCRES, s->io+ES1371_REG_CONTROL); udelay(2); outl(s->ctrl, s->io+ES1371_REG_CONTROL); /* init the sample rate converter */ src_init(s); /* codec init */ if (!ac97_probe_codec(&s->codec)) goto err_dev4; /* set default values */ fs = get_fs(); set_fs(KERNEL_DS); val = SOUND_MASK_LINE; mixdev_ioctl(&s->codec, SOUND_MIXER_WRITE_RECSRC, (unsigned long)&val); for (i = 0; i < sizeof(initvol)/sizeof(initvol[0]); i++) { val = initvol[i].vol; mixdev_ioctl(&s->codec, initvol[i].mixch, (unsigned long)&val); } /* mute master and PCM when in S/PDIF mode */ if (s->spdif_volume != -1) { val = 0x0000; s->codec.mixer_ioctl(&s->codec, SOUND_MIXER_WRITE_VOLUME, (unsigned long)&val); s->codec.mixer_ioctl(&s->codec, SOUND_MIXER_WRITE_PCM, (unsigned long)&val); } set_fs(fs); /* turn on S/PDIF output driver if requested */ outl(cssr, s->io+ES1371_REG_STATUS); /* store it in the driver field */ pci_set_drvdata(pcidev, s); pcidev->dma_mask = 0xffffffff; /* put it into driver list */ list_add_tail(&s->devs, &devs); /* increment devindex */ if (devindex < NR_DEVICE-1) devindex++; return 0; err_dev4: unregister_sound_dsp(s->dev_dac); err_dev3: unregister_sound_mixer(s->codec.dev_mixer); err_dev2: unregister_sound_dsp(s->dev_audio); err_dev1: printk(KERN_ERR PFX "cannot register misc device\n"); free_irq(s->irq, s); err_irq: release_region(s->io, ES1371_EXTENT); err_region: kfree(s); return -1; } static void __devinit es1371_remove(struct pci_dev *dev) { struct es1371_state *s = pci_get_drvdata(dev); if (!s) return; list_del(&s->devs); #ifdef ES1371_DEBUG if (s->ps) remove_proc_entry("es1371", NULL); #endif /* ES1371_DEBUG */ outl(0, s->io+ES1371_REG_CONTROL); /* switch everything off */ outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */ synchronize_irq(); free_irq(s->irq, s); release_region(s->io, ES1371_EXTENT); unregister_sound_dsp(s->dev_audio); unregister_sound_mixer(s->codec.dev_mixer); unregister_sound_dsp(s->dev_dac); unregister_sound_midi(s->dev_midi); kfree(s); pci_set_drvdata(dev, NULL); } static struct pci_device_id id_table[] __devinitdata = { { PCI_VENDOR_ID_ENSONIQ, PCI_DEVICE_ID_ENSONIQ_ES1371, PCI_ANY_ID, PCI_ANY_ID, 0, 0 }, { PCI_VENDOR_ID_ENSONIQ, PCI_DEVICE_ID_ENSONIQ_CT5880, PCI_ANY_ID, PCI_ANY_ID, 0, 0 }, { PCI_VENDOR_ID_ECTIVA, PCI_DEVICE_ID_ECTIVA_EV1938, PCI_ANY_ID, PCI_ANY_ID, 0, 0 }, { 0, } }; MODULE_DEVICE_TABLE(pci, id_table); static struct pci_driver es1371_driver = { name: "es1371", id_table: id_table, probe: es1371_probe, remove: es1371_remove }; static int __init init_es1371(void) { if (!pci_present()) /* No PCI bus in this machine! */ return -ENODEV; printk(KERN_INFO PFX "version v0.27 time " __TIME__ " " __DATE__ "\n"); return pci_module_init(&es1371_driver); } static void __exit cleanup_es1371(void) { printk(KERN_INFO PFX "unloading\n"); pci_unregister_driver(&es1371_driver); } module_init(init_es1371); module_exit(cleanup_es1371); /* --------------------------------------------------------------------- */ #ifndef MODULE /* format is: es1371=[joystick] */ static int __init es1371_setup(char *str) { static unsigned __initdata nr_dev = 0; if (nr_dev >= NR_DEVICE) return 0; if (get_option(&str, &joystick[nr_dev]) == 2) (void)get_option(&str, &spdif[nr_dev]); nr_dev++; return 1; } __setup("es1371=", es1371_setup); #endif /* MODULE */
30.945955
127
0.639432
e29d64c27f0dd2ff43078feb4c8a901dec9fb8be
982
h
C
UIChatViewPlug/SessionTransferWnd.h
qunarcorp/startalk_pc_v2
59d873ddcd41052d9a1379a9c35cb69075fcef3c
[ "MIT" ]
30
2019-08-22T08:33:23.000Z
2022-03-15T02:04:20.000Z
UIChatViewPlug/SessionTransferWnd.h
lirui1111/startalk_pc
7d625f812e784bca68b3d6f6ffe21d383b400491
[ "MIT" ]
4
2019-12-11T08:18:55.000Z
2021-03-19T07:23:50.000Z
UIChatViewPlug/SessionTransferWnd.h
lirui1111/startalk_pc
7d625f812e784bca68b3d6f6ffe21d383b400491
[ "MIT" ]
19
2019-08-22T17:09:24.000Z
2021-08-10T08:24:39.000Z
// // Created by lihaibin on 2019-06-18. // #ifndef QTALK_V2_SESSIONTRANSFERWND_H #define QTALK_V2_SESSIONTRANSFERWND_H #if _MSC_VER >= 1600 #pragma execution_character_set("utf-8") #endif #include <QButtonGroup> #include <QTextEdit> #include <QVBoxLayout> #include "../CustomUi/UShadowWnd.h" #include "../entity/im_transfer.h" class SessionTransferWnd : public UShadowDialog{ Q_OBJECT public: explicit SessionTransferWnd(QWidget* parent = nullptr); ~SessionTransferWnd() override; public: void initUI(); void showSeats(std::vector<QTalk::Entity::ImTransfer> _transfers); private slots: void operatingModeButtonsToggled(int, bool); Q_SIGNALS: void sessiontransfer(std::string&,std::string&); public: bool isHaveShow = false; private: QLabel* _pTitleLabel; QButtonGroup *_pButtonGroup; QTextEdit *_pEdit; QVBoxLayout* _pSeats; QFrame* _pTitleFrm; std::string newCsrName; }; #endif //QTALK_V2_SESSIONTRANSFERWND_H
19.64
70
0.736253
e2c900e850d9ac601fb80f34bf6e84dbb652f068
5,778
h
C
src/xchat/xcommon.h
aparcar/allnet
3b245e9eeae3fa3133578b3462ca134234585357
[ "MIT" ]
3
2018-02-10T01:45:53.000Z
2021-09-23T02:19:24.000Z
src/xchat/xcommon.h
aparcar/allnet
3b245e9eeae3fa3133578b3462ca134234585357
[ "MIT" ]
2
2018-08-03T09:34:09.000Z
2021-10-01T04:53:35.000Z
src/xchat/xcommon.h
aparcar/allnet
3b245e9eeae3fa3133578b3462ca134234585357
[ "MIT" ]
4
2018-02-10T01:46:16.000Z
2021-10-05T10:39:29.000Z
/* xcommon.h: send and receive messages for xchat */ #ifndef ALLNET_XCHAT_COMMON_H #define ALLNET_XCHAT_COMMON_H #include <inttypes.h> #include "chat.h" #include "lib/keys.h" #include "lib/mgmt.h" /* struct allnet_mgmt_trace_reply */ /* returns the socket if successful, -1 otherwise */ /* path is usually NULL. It should be non-null only when the system * has a hard-to-find path to config files, and the caller can * specify the path to the directory to use. */ extern int xchat_init (const char * program_name, const char * path); /* optional... */ extern void xchat_end (int sock); /* only returns new acks, discarding acks received previously */ struct allnet_ack_info { int num_acks; /* num acks received */ uint64_t acks [ALLNET_MAX_ACKS]; /* seq numbers acknowledged */ char * peers [ALLNET_MAX_ACKS]; /* for these peers */ }; /* handle an incoming packet, acking it if it is a data packet for us * if psize is 0, checks internal buffer for previously unprocessed packets * and behaves as if a data packet was received. * * returns the message length > 0 if this was a valid data message from a peer. * if it gets a valid key, returns -1 (details below) * if it gets a new valid subscription, returns -2 (details below) * if it gets a new valid ack, returns -3 (details below) * if it gets a new valid trace message, returns -4 (details below) * Otherwise returns 0 and does not fill in any of the following results. * * if it is a data message, it is saved in the xchat log * if it is a valid data message from a peer or a broadcaster, * fills in verified and broadcast and prev_missing * fills in contact, message (to point to malloc'd buffers, must be freed) * if not broadcast, fills in desc (also malloc'd), seq, sent (if not null) * prev_missing, and duplicate. * if verified and not broadcast, fills in kset. * the data message (if any) is null-terminated * * if it is a key exchange message matching one of my pending key * exchanges, saves the key, fills in *peer, and returns -1. * * if it is a broadcast key message matching a pending key request, * saves the key, fills in *peer, and returns -2. * * if it is a new ack to something we sent, saves it in the xchat log * and if acks is not null, fills it in. Returns -3 * * if it is a trace reply, fills in trace_reply if not null (must be free'd), * and returns -4 */ extern int handle_packet (int sock, char * packet, unsigned int psize, unsigned int priority, char ** contact, keyset * kset, char ** message, char ** desc, int * verified, uint64_t * seq, time_t * sent, uint64_t * prev_missing, int * duplicate, int * broadcast, struct allnet_ack_info * acks, struct allnet_mgmt_trace_reply ** trace_reply); /* send this message and save it in the xchat log. */ /* returns the sequence number of this message, or 0 for errors */ extern uint64_t send_data_message (int sock, const char * peer, const char * message, int mlen); /* if a previously received key matches one of the secrets, returns 1, * otherwise returns 0 */ extern int key_received_before (int sock, char ** peer, keyset * kset); /* returns 1 for a successful parse, 0 otherwise */ /* *s1 and *s2, if not NULL, are malloc'd (as needed), should be free'd */ extern int parse_exchange_file (const char * contact, int * nhops, char ** s1, char ** s2); /* if there is anyting unacked, resends it. If any sequence number is known * to be missing, requests it */ /* returns: * -1 if it is too soon to request again * 0 if it it did not send a retransmit request for this contact/key * (e.g. if nothing is known to be missing) * 1 if it sent a retransmit request */ /* eagerly should be set when there is some chance that our peer is online, * i.e. when we've received a message or an ack from the peer. In this * case, we retransmit and request data right away, independently of the * time since the last request */ extern int request_and_resend (int sock, char * peer, keyset kset, int eagerly); /* call every once in a while, e.g. every 1-10s, to poke all our * contacts and get any outstanding messages. */ /* each time it is called, queries a different contact or keyset */ extern void do_request_and_resend (int sock); /* create the contact and key, and send * the public key followed by * the hmac of the public key using the secret as the key for the hmac. * the secrets should be normalized by the caller * secret2 may be NULL, secret1 should not be. * return 1 if successful, 0 for failure (usually if the contact already * exists, but other errors are possible) */ extern int create_contact_send_key (int sock, const char * contact, const char * secret1, const char * secret2, unsigned int hops); /* for an incomplete key exchange, resends the key * return 1 if successful, 0 for failure (e.g. the key exchange is complete) */ extern int resend_contact_key (int sock, const char * contact); /* return the number of secrets returned, 0, 1 (only s1), or 2 */ /* the secret(s) are malloc'd (must be freed) and assigned to s1 * and s2 if not NULL */ extern int key_exchange_secrets (const char * contact, char ** s1, char ** s2); /* sends out a request for a key matching the subscription. * returns 1 for success (and fills in my_addr and nbits), 0 for failure */ extern int subscribe_broadcast (int sock, char * ahra); #endif /* ALLNET_XCHAT_COMMON_H */
45.857143
80
0.671859
3ea3dba1292e5caaa464f690db458a5119025947
2,583
c
C
monitor/src/info_citizen_list.c
EPantelaios/System-Programming-System-calls-Low-level-IO-and-Signals
c128dd536bcf499a3ccc6d430ef807495f14303a
[ "MIT" ]
null
null
null
monitor/src/info_citizen_list.c
EPantelaios/System-Programming-System-calls-Low-level-IO-and-Signals
c128dd536bcf499a3ccc6d430ef807495f14303a
[ "MIT" ]
null
null
null
monitor/src/info_citizen_list.c
EPantelaios/System-Programming-System-calls-Low-level-IO-and-Signals
c128dd536bcf499a3ccc6d430ef807495f14303a
[ "MIT" ]
null
null
null
#include "../include/info_citizen_list.h" info_citizen_node *insert_citizen(info_citizen_node **head, char *name, char *surname, country_node *country, int age){ info_citizen_node *new_node = (info_citizen_node *)calloc(1, sizeof(info_citizen_node)); new_node->name=(char *)calloc(strlen(name)+1, sizeof(char)); strncpy(new_node->name, name, strlen(name)); memset(new_node->name+strlen(name), '\0', 1); new_node->surname=(char *)calloc(strlen(surname)+1, sizeof(char)); strncpy(new_node->surname, surname, strlen(surname)); memset(new_node->surname+strlen(surname), '\0', 1); //new_node->country_list=(country_node *)calloc(1, sizeof(country_node)); new_node->country_list=country; new_node->age=age; new_node->next = *head; *head = new_node; return new_node; } int delete_first_node_citizen(info_citizen_node **head){ int ret_val = 0; info_citizen_node *next_node = NULL; //if list is empty if(*head == NULL){ return -1; } next_node = (*head)->next; free((*head)->name); free((*head)->surname); free(*head); *head = next_node; return ret_val; } int delete_list_citizen(info_citizen_node **head){ int ret_val=0; while(ret_val != -1){ ret_val=delete_first_node_citizen(head); } return 0; } int search_citizen(info_citizen_node *head, char *name, char *surname, char *country, int age){ info_citizen_node *current = head; while(current != NULL){ if(!strcmp(current->name, name) && !strcmp(current->surname, surname) && !strcmp(current->country_list->country, country) && current->age==age){ return true; } current = current->next; } return false; } info_citizen_node *find_citizen(info_citizen_node *head, char *name, char *surname, char *country, int age){ info_citizen_node *current = head; while(current != NULL){ if(!strcmp(current->name, name) && !strcmp(current->surname, surname) && !strcmp(current->country_list->country, country) && current->age==age){ return current; } current = current->next; } return NULL; } void print_list_citizen(info_citizen_node *head){ info_citizen_node *current = head; if(current==NULL){ printf("List is empty\n"); } while(current != NULL){ printf("%s %s %s %d\n", current->name, current->surname, current->country_list->country, current->age); current = current->next; } printf("\n"); }
21.347107
152
0.630275
0eedf64ae50c34cd46dd06beafed57bb3f5e564b
601
c
C
IP/Lista Vetores/ex21.c
savio-matheus/exercicios
8c91e5608be132de5ef95730292bf2c21386ff7d
[ "MIT" ]
null
null
null
IP/Lista Vetores/ex21.c
savio-matheus/exercicios
8c91e5608be132de5ef95730292bf2c21386ff7d
[ "MIT" ]
null
null
null
IP/Lista Vetores/ex21.c
savio-matheus/exercicios
8c91e5608be132de5ef95730292bf2c21386ff7d
[ "MIT" ]
1
2021-01-10T20:55:47.000Z
2021-01-10T20:55:47.000Z
//Pares e ímpares - ex21 #include <stdio.h> main() { int n, i, j, min, temp; scanf("%d", &n); int vetor[n]; for(i = 0; i < n; i++) { scanf("%d", &vetor[i]); } for(i = 0; i < n; i++) { min = i; for(j = i + 1; j < n; j++) { if(vetor[j] < vetor[min]) { min = j; } } temp = vetor[i]; vetor[i] = vetor[min]; vetor[min] = temp; } for(i = 0; i < n; i++) { if(vetor[i] % 2 == 0) { printf("%d\n", vetor[i]); } } for(i = (n - 1); i >= 0; i--) { if(vetor[i] % 2 != 0) { printf("%d\n", vetor[i]); } } }
13.355556
31
0.374376
12fb9afd7f50e67166b3ff07149b839ad1604735
972
h
C
src/Inputs/Lorenz63.h
dsiuta/Comps
2071279280d33946e975de25deedc60f1881eda0
[ "BSD-3-Clause" ]
null
null
null
src/Inputs/Lorenz63.h
dsiuta/Comps
2071279280d33946e975de25deedc60f1881eda0
[ "BSD-3-Clause" ]
null
null
null
src/Inputs/Lorenz63.h
dsiuta/Comps
2071279280d33946e975de25deedc60f1881eda0
[ "BSD-3-Clause" ]
null
null
null
#ifndef INPUT_LORENZ63_H #define INPUT_LORENZ63_H #include "Input.h" #include <boost/random.hpp> #include <boost/random/normal_distribution.hpp> //! Simulates the Lorenz 1963 system of ordinary differential equations class InputLorenz63 : public Input { public: InputLorenz63(const Options& iOptions); ~InputLorenz63(); float getValueCore(const Key::Input& iKey) const; private: void getMembersCore(std::vector<Member>& iMembers) const; static void getDateTime(std::string iStamp, int& iDate, float& iTime); bool hasDataFiles() const {return false;}; std::string mFilenamePrefix; std::string mFilenamePostfix; float mX0; float mY0; float mZ0; float mR; float mS; float mB; float mDt; int mEnsSize; float mXVar; float mYVar; float mZVar; mutable boost::variate_generator<boost::mt19937, boost::normal_distribution<> > mRand; }; #endif
28.588235
92
0.67284
8f7dee320c1c716a2e148a7eb541a500bde54216
656
h
C
gl/glcamera.h
rduan036/YoMap
60fc5ac86740765d168d1e54c11faa4fcb190a07
[ "MIT" ]
1
2021-05-22T10:31:49.000Z
2021-05-22T10:31:49.000Z
gl/glcamera.h
rduan036/YoMap
60fc5ac86740765d168d1e54c11faa4fcb190a07
[ "MIT" ]
null
null
null
gl/glcamera.h
rduan036/YoMap
60fc5ac86740765d168d1e54c11faa4fcb190a07
[ "MIT" ]
null
null
null
#ifndef GLCAMERA_H #define GLCAMERA_H class GLCamera { public: GLCamera(); float x; float y; float z; float look_x; float look_y; float look_z; float moveSpeed; float zoomLevel; float zoomSpeed; double planeLeft; double planeRight; double planeBottom; double planeTop; double planeNear; double planeFar; int canvasWidth; int canvasHeight; void left(); void right(); void up(); void down(); void move(int, int); void zoomIn(); void zoomOut(); void setViewingVolume(); void setProjection(); void center(); }; #endif // GLCAMERA_H
12.615385
28
0.609756
f5f62939e4f80a27e1b58a3d7a394a0071a2b606
555
h
C
components/node.h
Leo3738/candle
33b8e12bd6311f1d6e11e3ce76d653be605535fd
[ "MIT" ]
null
null
null
components/node.h
Leo3738/candle
33b8e12bd6311f1d6e11e3ce76d653be605535fd
[ "MIT" ]
null
null
null
components/node.h
Leo3738/candle
33b8e12bd6311f1d6e11e3ce76d653be605535fd
[ "MIT" ]
null
null
null
#ifndef NODE_H #define NODE_H #include "../glutil.h" #include <ecm.h> #include <components/spacial.h> typedef struct { c_t super; /* extends c_t */ mat4_t model; int cached; entity_t *children; ulong children_size; entity_t parent; } c_node_t; DEF_CASTER("node", c_node, c_node_t) c_node_t *c_node_new(void); entity_t c_node_get_by_name(c_node_t *self, const char *name); void c_node_add(c_node_t *self, int num, ...); void c_node_update_model(c_node_t *self); vec3_t c_node_global_to_local(c_node_t *self, vec3_t vec); #endif /* !NODE_H */
18.5
62
0.736937
b9e3e254063e2da40c75ee7aed52f39ef2cb4aa7
2,584
h
C
src/TON/Address.h
EnoRage/wallet-core
4e1f6f635e234bcda42d678df2dd26d1e3272311
[ "MIT" ]
2
2020-05-02T10:05:37.000Z
2020-05-02T10:05:37.000Z
src/TON/Address.h
EnoRage/wallet-core
4e1f6f635e234bcda42d678df2dd26d1e3272311
[ "MIT" ]
null
null
null
src/TON/Address.h
EnoRage/wallet-core
4e1f6f635e234bcda42d678df2dd26d1e3272311
[ "MIT" ]
3
2020-02-14T03:25:58.000Z
2021-07-04T23:20:29.000Z
// Copyright © 2017-2019 Trust Wallet. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. #pragma once #include "../PublicKey.h" #include <string> namespace TW::TON { using WorkchainId_t = int32_t; /// Workchain ID, currently supported: masterchain: -1, basic workchain: 0 class Workchain { public: static constexpr WorkchainId_t MasterChainId = -1; static constexpr WorkchainId_t BasicChainId = 0; static constexpr WorkchainId_t InvalidChainId = 0x80000000; // The default workchain ID static WorkchainId_t defaultChain() { return BasicChainId; } static bool isValid(WorkchainId_t workchainId_in); }; /// TON smart contract address, also account address class Address { public: WorkchainId_t workchainId; static const uint8_t AddressLength = 32; // Address: 256 bits (for chains -1 and 0) TW::Data addrBytes; bool isBounceable{true}; bool isTestOnly{false}; /// Initializes a TON address with a string representation, either raw or user friendly explicit Address(const std::string& address); /// Initializes a TON address with a public key. WorkchainId is optional, Basic chain by default. explicit Address(const PublicKey& publicKey, WorkchainId_t workchain = Workchain::defaultChain()); /// Determines whether a string makes a valid address, in any format static bool isValid(const std::string& address, WorkchainId_t workchain = Workchain::defaultChain()); /// Returns a string representation of the address (user friendly format) std::string string() const; /// Returns a string representation of the address, raw format std::string stringRaw() const; private: /// Empty constructor Address() = default; static bool parseAddress(const std::string& addressStr_in, Address& addr_inout); static bool parseRawAddress(const std::string& addressStr_in, Address& addr_inout); // Accepts user-friendly base64 format, also accepts Base64Url format static bool parseUserAddress(const std::string& addressStr_in, Address& addr_inout); }; inline bool operator==(const Address& lhs, const Address& rhs) { return (lhs.workchainId == rhs.workchainId && lhs.addrBytes == rhs.addrBytes && lhs.isBounceable == rhs.isBounceable && lhs.isTestOnly == rhs.isTestOnly); } } // namespace TW::TON /// Wrapper for C interface. struct TWTONAddress { TW::TON::Address impl; };
33.128205
105
0.726006
6a02deeab82d62c3e1daa5f581e164010cc5bbd2
8,067
h
C
components/zerodop/topozero/include/topozeromodule.h
vincentschut/isce2
1557a05b7b6a3e65abcfc32f89c982ccc9b65e3c
[ "ECL-2.0", "Apache-2.0" ]
1,133
2022-01-07T21:24:57.000Z
2022-01-07T21:33:08.000Z
components/zerodop/topozero/include/topozeromodule.h
vincentschut/isce2
1557a05b7b6a3e65abcfc32f89c982ccc9b65e3c
[ "ECL-2.0", "Apache-2.0" ]
276
2019-02-10T07:18:28.000Z
2022-03-31T21:45:55.000Z
components/zerodop/topozero/include/topozeromodule.h
vincentschut/isce2
1557a05b7b6a3e65abcfc32f89c982ccc9b65e3c
[ "ECL-2.0", "Apache-2.0" ]
235
2019-02-10T05:00:53.000Z
2022-03-18T07:37:24.000Z
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Copyright 2012 California Institute of Technology. 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. // // United States Government Sponsorship acknowledged. This software is subject to // U.S. export control laws and regulations and has been classified as 'EAR99 NLR' // (No [Export] License Required except when exporting to an embargoed country, // end user, or in support of a prohibited end use). By downloading this software, // the user agrees to comply with all applicable U.S. export laws and regulations. // The user has the responsibility to obtain export licenses, or other export // authority as may be required before exporting this software to any 'EAR99' // embargoed foreign country or citizen of those countries. // // Author: Giangi Sacco //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #ifndef topozeromodule_h #define topozeromodule_h #include <Python.h> #include <stdint.h> #include "topozeromoduleFortTrans.h" extern "C" { #include "orbit.h" void topo_f(uint64_t *, uint64_t *, uint64_t *); PyObject * topo_C(PyObject *, PyObject *); void setNumberIterations_f(int *); PyObject * setNumberIterations_C(PyObject *, PyObject *); void setDemWidth_f(int *); PyObject * setDemWidth_C(PyObject *, PyObject *); void setDemLength_f(int *); PyObject * setDemLength_C(PyObject *, PyObject *); void setOrbit_f(cOrbit *orb); PyObject * setOrbit_C(PyObject *, PyObject *); void setFirstLatitude_f(double *); PyObject * setFirstLatitude_C(PyObject *, PyObject *); void setFirstLongitude_f(double *); PyObject * setFirstLongitude_C(PyObject *, PyObject *); void setDeltaLatitude_f(double *); PyObject * setDeltaLatitude_C(PyObject *, PyObject *); void setDeltaLongitude_f(double *); PyObject * setDeltaLongitude_C(PyObject *, PyObject *); void setEllipsoidMajorSemiAxis_f(double *); PyObject * setEllipsoidMajorSemiAxis_C(PyObject *, PyObject *); void setEllipsoidEccentricitySquared_f(double *); PyObject * setEllipsoidEccentricitySquared_C(PyObject *, PyObject *); void setLength_f(int *); PyObject * setLength_C(PyObject *, PyObject *); void setWidth_f(int *); PyObject * setWidth_C(PyObject *, PyObject *); void setRangePixelSpacing_f(double *); PyObject * setRangePixelSpacing_C(PyObject *, PyObject *); void setRangeFirstSample_f(double *); PyObject * setRangeFirstSample_C(PyObject *, PyObject *); void setNumberRangeLooks_f(int *); PyObject * setNumberRangeLooks_C(PyObject *, PyObject *); void setNumberAzimuthLooks_f(int *); PyObject * setNumberAzimuthLooks_C(PyObject *, PyObject *); void setLookSide_f(int *); PyObject * setLookSide_C(PyObject *, PyObject *); void setPegHeading_f(double *); PyObject * setPegHeading_C(PyObject *, PyObject *); void setPRF_f(double *); PyObject * setPRF_C(PyObject *, PyObject *); void setSensingStart_f(double *); PyObject * setSensingStart_C(PyObject *, PyObject *); void setRadarWavelength_f(double *); PyObject * setRadarWavelength_C(PyObject *, PyObject *); void setLatitudePointer_f(uint64_t *); PyObject * setLatitudePointer_C(PyObject *, PyObject *); void setLongitudePointer_f(uint64_t *); PyObject * setLongitudePointer_C(PyObject *, PyObject *); void setHeightPointer_f(uint64_t *); PyObject * setHeightPointer_C(PyObject *, PyObject *); void setLosPointer_f(uint64_t *); PyObject * setLosPointer_C(PyObject *, PyObject *); void setIncPointer_f(uint64_t *); PyObject * setIncPointer_C(PyObject *, PyObject *); void setMaskPointer_f(uint64_t*); PyObject * setMaskPointer_C(PyObject *, PyObject *); void getMinimumLatitude_f(double *); PyObject * getMinimumLatitude_C(PyObject *, PyObject *); void getMinimumLongitude_f(double *); PyObject * getMinimumLongitude_C(PyObject *, PyObject *); void getMaximumLatitude_f(double *); PyObject * getMaximumLatitude_C(PyObject *, PyObject *); void getMaximumLongitude_f(double *); PyObject * getMaximumLongitude_C(PyObject *, PyObject *); void setSecondaryIterations_f(int *); PyObject *setSecondaryIterations_C(PyObject *, PyObject *); void setThreshold_f(double*); PyObject *setThreshold_C(PyObject*, PyObject*); void setMethod_f(int*); PyObject *setMethod_C(PyObject*, PyObject*); void setOrbitMethod_f(int*); PyObject *setOrbitMethod_C(PyObject*, PyObject*); } static PyMethodDef topozero_methods[] = { {"topo_Py", topo_C, METH_VARARGS, " "}, {"setNumberIterations_Py", setNumberIterations_C, METH_VARARGS, " "}, {"setDemWidth_Py", setDemWidth_C, METH_VARARGS, " "}, {"setDemLength_Py", setDemLength_C, METH_VARARGS, " "}, {"setOrbit_Py", setOrbit_C, METH_VARARGS, " "}, {"setFirstLatitude_Py", setFirstLatitude_C, METH_VARARGS, " "}, {"setFirstLongitude_Py", setFirstLongitude_C, METH_VARARGS, " "}, {"setDeltaLatitude_Py", setDeltaLatitude_C, METH_VARARGS, " "}, {"setDeltaLongitude_Py", setDeltaLongitude_C, METH_VARARGS, " "}, {"setEllipsoidMajorSemiAxis_Py", setEllipsoidMajorSemiAxis_C, METH_VARARGS, " "}, {"setEllipsoidEccentricitySquared_Py", setEllipsoidEccentricitySquared_C, METH_VARARGS, " "}, {"setLength_Py", setLength_C, METH_VARARGS, " "}, {"setWidth_Py", setWidth_C, METH_VARARGS, " "}, {"setRangePixelSpacing_Py", setRangePixelSpacing_C, METH_VARARGS, " "}, {"setRangeFirstSample_Py", setRangeFirstSample_C, METH_VARARGS, " "}, {"setNumberRangeLooks_Py", setNumberRangeLooks_C, METH_VARARGS, " "}, {"setNumberAzimuthLooks_Py", setNumberAzimuthLooks_C, METH_VARARGS, " "}, {"setPegHeading_Py", setPegHeading_C, METH_VARARGS, " "}, {"setPRF_Py", setPRF_C, METH_VARARGS, " "}, {"setSensingStart_Py", setSensingStart_C, METH_VARARGS, " "}, {"setRadarWavelength_Py", setRadarWavelength_C, METH_VARARGS, " "}, {"setLatitudePointer_Py", setLatitudePointer_C, METH_VARARGS, " "}, {"setLongitudePointer_Py", setLongitudePointer_C, METH_VARARGS, " "}, {"setHeightPointer_Py", setHeightPointer_C, METH_VARARGS, " "}, {"setLosPointer_Py", setLosPointer_C, METH_VARARGS, " "}, {"setIncPointer_Py", setIncPointer_C, METH_VARARGS, " "}, {"setMaskPointer_Py", setMaskPointer_C, METH_VARARGS, " "}, {"setLookSide_Py", setLookSide_C, METH_VARARGS, " "}, {"getMinimumLatitude_Py", getMinimumLatitude_C, METH_VARARGS, " "}, {"getMinimumLongitude_Py", getMinimumLongitude_C, METH_VARARGS, " "}, {"getMaximumLatitude_Py", getMaximumLatitude_C, METH_VARARGS, " "}, {"getMaximumLongitude_Py", getMaximumLongitude_C, METH_VARARGS, " "}, {"setSecondaryIterations_Py", setSecondaryIterations_C, METH_VARARGS, " "}, {"setThreshold_Py", setThreshold_C, METH_VARARGS, " "}, {"setMethod_Py", setMethod_C, METH_VARARGS, " "}, {"setOrbitMethod_Py", setOrbitMethod_C, METH_VARARGS, " "}, {NULL, NULL, 0, NULL} }; #endif //topozeromodule_h
51.056962
101
0.668154
5fe813270d7f5b8b8e112a371f2079a84c1db0c6
160
h
C
if_levar_adds.h
rakslice/leaix
4134680157836a75c7a715b4d31f9ae8803ae4e3
[ "BSD-4-Clause-UC" ]
4
2019-01-05T10:40:02.000Z
2021-04-08T14:09:24.000Z
if_levar_adds.h
retrohun/leaix
4134680157836a75c7a715b4d31f9ae8803ae4e3
[ "BSD-4-Clause-UC" ]
3
2018-06-04T04:29:15.000Z
2020-08-17T06:14:55.000Z
if_levar_adds.h
retrohun/leaix
4134680157836a75c7a715b4d31f9ae8803ae4e3
[ "BSD-4-Clause-UC" ]
1
2019-01-05T10:39:38.000Z
2019-01-05T10:39:38.000Z
#ifndef _IF_LEVAR_ADDS_H_ #define _IF_LEVAR_ADDS_H_ /* Additional definitions for if_levar.h */ #define ETHERNETMTU 1500 #include <sys/if_ieee802.h> #endif
14.545455
43
0.7875
55de5182fc0234604ece591edee167be7efe8c2c
520
h
C
TimeCountDownFour/CETimeCountDownLabelTextStlyeTool.h
GitNilCom/CountDownFour
700b4bf4259129a5cb2b6ff0ada3f859cd873df1
[ "MIT" ]
1
2020-06-30T02:07:27.000Z
2020-06-30T02:07:27.000Z
TimeCountDownFour/CETimeCountDownLabelTextStlyeTool.h
GitNilCom/CountDownFour
700b4bf4259129a5cb2b6ff0ada3f859cd873df1
[ "MIT" ]
null
null
null
TimeCountDownFour/CETimeCountDownLabelTextStlyeTool.h
GitNilCom/CountDownFour
700b4bf4259129a5cb2b6ff0ada3f859cd873df1
[ "MIT" ]
null
null
null
// // CETimeCountDownLabelTextStlyeTool.h // CountDownFour // // Created by CE on 2017/7/15. // Copyright © 2017年 CE. All rights reserved. // #import <Foundation/Foundation.h> #import "CETimeCountDownLabel.h" @interface CETimeCountDownLabelTextStlyeTool : NSObject + (NSArray *)getTextArrayWithLabel:(CETimeCountDownLabel *)label; + (BOOL)isBoxStyleWithLabel:(CETimeCountDownLabel *)label; + (CGRect)textBoxAlignmentRectWithLabel:(CETimeCountDownLabel *)label boxWidth:(CGFloat)boxWidth rect:(CGRect)rect; @end
26
115
0.778846
df3ae949bd3443c64ec3d4b3976fee717ed715db
8,724
h
C
src/isolate/platform_delegate.h
alufers/isolated-vm
5bca9b3b6d32c8065d7c7cd68d7421e84df1a699
[ "ISC" ]
null
null
null
src/isolate/platform_delegate.h
alufers/isolated-vm
5bca9b3b6d32c8065d7c7cd68d7421e84df1a699
[ "ISC" ]
null
null
null
src/isolate/platform_delegate.h
alufers/isolated-vm
5bca9b3b6d32c8065d7c7cd68d7421e84df1a699
[ "ISC" ]
null
null
null
#pragma once #include <v8.h> #include <v8-platform.h> #include "environment.h" #include "v8_version.h" #include "../timer.h" namespace v8 { namespace internal { class V8 { public: static v8::Platform* GetCurrentPlatform(); // naughty }; } // namespace internal } // namespace v8 namespace ivm { class PlatformDelegate : public v8::Platform { private: v8::Isolate* node_isolate; v8::Platform* node_platform; v8::Isolate* tmp_isolate = nullptr; class TaskHolder : public Runnable { private: std::unique_ptr<v8::Task> task; public: explicit TaskHolder(v8::Task* task) : task(task) {} explicit TaskHolder(std::unique_ptr<v8::Task>&& task) : task(std::move(task)) {} explicit TaskHolder(TaskHolder&& task) : task(std::move(task.task)) {} void Run() final { task->Run(); } }; public: struct TmpIsolateScope { explicit TmpIsolateScope(v8::Isolate* isolate) { PlatformDelegate::DelegateInstance().tmp_isolate = isolate; } TmpIsolateScope(TmpIsolateScope&) = delete; TmpIsolateScope& operator=(const TmpIsolateScope&) = delete; ~TmpIsolateScope() { PlatformDelegate::DelegateInstance().tmp_isolate = nullptr; } }; PlatformDelegate(v8::Isolate* node_isolate, v8::Platform* node_platform) : node_isolate(node_isolate), node_platform(node_platform) {} static PlatformDelegate& DelegateInstance() { static PlatformDelegate delegate(v8::Isolate::GetCurrent(), v8::internal::V8::GetCurrentPlatform()); return delegate; } static void InitializeDelegate() { PlatformDelegate& instance = DelegateInstance(); v8::V8::ShutdownPlatform(); v8::V8::InitializePlatform(&instance); } /** * ~ An Abridged History of v8's threading and task API ~ * * 6.4.168: * - `GetForegroundTaskRunner(Isolate*)` and `GetBackgroundTaskRunner(Isolate*)` are introduced [c690f54d] * * 6.7.1: * - `GetBackgroundTaskRunner` renamed to `GetWorkerThreadsTaskRunner` [70222a9d] * - `CallOnWorkerThread(Task* task)` added [86b4b534] * - `ExpectedRuntime` parameter removed from `CallOnBackgroundThread(Task*, ExpectedRuntime)` [86b4b534] * - `CallBlockingTaskFromBackgroundThread(Task* task)` added [2600038d] * * 6.7.179: * - `CallOnWorkerThread` and `CallBlockingTaskOnWorkerThread` parameters both * changed to `(std::unique_ptr<Task> task)` [1983f305] * * 6.8.117: * - `GetWorkerThreadsTaskRunner` removed [4ac96190] * - `CallDelayedOnWorkerThread(std::unique_ptr<Task> task, double delay_in_seconds)` added [4b13a22f] * * 6.8.242: * - `CallOnBackgroundThread`, `NumberOfWorkerThreads`, `GetForegroundTaskRunner`, and * `CallOnWorkerThread` removed [8f6ffbfc] * - `CallDelayedOnWorkerThread` becomse pure virtual [8f6ffbfc] * * 7.1.263: * - `CallOnForegroundThread`, `CallDelayedOnForegroundThread`, and `CallIdleOnForegroundThread` * deprecated * * 7.1.316: * - `PostNonNestableTask(std::unique_ptr<Task> task)` and `NonNestableTasksEnabled()` added to * `v8::TaskRunner` * * * ~ Meanwhile in nodejs ~ * * 10.0.0: * - Updates v8 to 6.6.346 but includes random internal changes from v8 6.7.x [2a3f8c3a] * * 10.9.0: * - Updates v8 to 6.8.275 but continues to include old API requirements from v8 v6.7.x [5fa3ffad] * */ #if V8_AT_LEAST(6, 7, 1) int NumberOfWorkerThreads() final { return node_platform->NumberOfWorkerThreads(); } #endif #if defined(NODE_MODULE_VERSION) ? NODE_MODULE_VERSION >= 64 : V8_AT_LEAST(6, 7, 179) // v8 commit 86b4b534 renamed this function and changed the signature. This made it to v8 // v6.7.1, but 1983f305 further changed the signature. // These were both backported to nodejs in commmit 2a3f8c3a. void CallOnWorkerThread(std::unique_ptr<v8::Task> task) final { node_platform->CallOnWorkerThread(std::move(task)); } void CallOnBackgroundThread(v8::Task* task, ExpectedRuntime /* expected_runtime */) final { // TODO: Properly count these tasks against isolate timers. How common are background tasks?? node_platform->CallOnWorkerThread(std::unique_ptr<v8::Task>(task)); } #else void CallOnBackgroundThread(v8::Task* task, ExpectedRuntime expected_runtime) final { node_platform->CallOnBackgroundThread(task, expected_runtime); } #endif #if V8_AT_LEAST(6, 4, 168) std::shared_ptr<v8::TaskRunner> GetBackgroundTaskRunner(v8::Isolate* /* isolate */) final { return node_platform->GetBackgroundTaskRunner(node_isolate); } private: // nb: The v8 documentation says that methods on this object may be called from any thread. class ForegroundTaskRunner : public v8::TaskRunner { private: std::weak_ptr<IsolateHolder> holder; public: ForegroundTaskRunner(std::shared_ptr<IsolateHolder> holder) : holder(std::move(holder)) {} void PostTask(std::unique_ptr<v8::Task> task) final { auto ref = holder.lock(); if (ref) { ref->ScheduleTask(std::make_unique<TaskHolder>(std::move(task)), false, false, true); } } void PostDelayedTask(std::unique_ptr<v8::Task> task, double delay_in_seconds) final { auto shared_task = std::make_shared<TaskHolder>(std::move(task)); auto holder = this->holder; timer_t::wait_detached(delay_in_seconds * 1000, [holder, shared_task](void* next) { auto ref = holder.lock(); if (ref) { // Don't wake the isolate because that will affect the libuv ref/unref stuff. Instead, // if this isolate is not running then whatever task v8 wanted to run will fire first // thing next time the isolate is awake. ref->ScheduleTask(std::make_unique<TaskHolder>(std::move(*shared_task)), false, false, true); } timer_t::chain(next); }); } void PostIdleTask(std::unique_ptr<v8::IdleTask> task) final { std::terminate(); } bool IdleTasksEnabled() final { return false; } }; public: std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(v8::Isolate* isolate) final { if (isolate == node_isolate) { node_platform->GetForegroundTaskRunner(isolate); } else if (isolate != tmp_isolate) { auto s_isolate = IsolateEnvironment::LookupIsolate(isolate); // We could further assert that IsolateEnvironment::GetCurrent() == s_isolate assert(s_isolate); // TODO: Don't make a new runner each time return std::make_shared<ForegroundTaskRunner>(s_isolate); } return {nullptr}; } #endif void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) final { if (isolate == node_isolate) { node_platform->CallOnForegroundThread(isolate, task); } else if (isolate != tmp_isolate) { auto s_isolate = IsolateEnvironment::LookupIsolate(isolate); // We could further assert that IsolateEnvironment::GetCurrent() == s_isolate assert(s_isolate); // wakeup == false but it shouldn't matter because this isolate is already awake s_isolate->ScheduleTask(std::make_unique<TaskHolder>(task), false, false, true); } } void CallDelayedOnForegroundThread(v8::Isolate* isolate, v8::Task* task, double delay_in_seconds) final { if (isolate == node_isolate) { node_platform->CallDelayedOnForegroundThread(isolate, task, delay_in_seconds); } else if (isolate != tmp_isolate) { timer_t::wait_detached(delay_in_seconds * 1000, [isolate, task](void* next) { auto holder = std::make_unique<TaskHolder>(task); auto s_isolate = IsolateEnvironment::LookupIsolate(isolate); if (s_isolate) { // Don't wake the isolate because that will affect the libuv ref/unref stuff. Instead, // if this isolate is not running then whatever task v8 wanted to run will fire first // thing next time the isolate is awake. s_isolate->ScheduleTask(std::move(holder), false, false, true); } timer_t::chain(next); }); } } void CallIdleOnForegroundThread(v8::Isolate* isolate, v8::IdleTask* task) final { if (isolate == node_isolate) { node_platform->CallIdleOnForegroundThread(isolate, task); } else { assert(false); } } bool IdleTasksEnabled(v8::Isolate* isolate) final { if (isolate == node_isolate) { return node_platform->IdleTasksEnabled(isolate); } else { return false; } } #if V8_AT_LEAST(6, 2, 383) // 11ba497c made this implementation required, 837b8016 added `SystemClockTimeMillis()` double CurrentClockTimeMillis() final { return node_platform->CurrentClockTimeMillis(); } #endif double MonotonicallyIncreasingTime() final { return node_platform->MonotonicallyIncreasingTime(); } v8::TracingController* GetTracingController() final { return node_platform->GetTracingController(); } }; } // namespace ivm
34.346457
136
0.700023
8dd861d3cba62c1395e86afd4b1330f56c778440
244
h
C
StringReplacer/StringReplacer/src/tools/ReplaceHelper.h
andronov-alexey/job_tests_string_replacer
f7a52bb5bd9caac818cde8283237d673e23ff20e
[ "Apache-2.0" ]
null
null
null
StringReplacer/StringReplacer/src/tools/ReplaceHelper.h
andronov-alexey/job_tests_string_replacer
f7a52bb5bd9caac818cde8283237d673e23ff20e
[ "Apache-2.0" ]
null
null
null
StringReplacer/StringReplacer/src/tools/ReplaceHelper.h
andronov-alexey/job_tests_string_replacer
f7a52bb5bd9caac818cde8283237d673e23ff20e
[ "Apache-2.0" ]
null
null
null
#pragma once #include <string> #include <vector> class ReplaceHelper { public: static void replaceAll(const std::string & _src, const std::string & _outputFileName, const std::vector<std::pair<std::string, std::string>> & _replacements); };
24.4
159
0.733607
c00bb25146abc34c6fd39561541062d4acac9209
403
h
C
CYSuperDemo/Pods/Target Support Files/MYBlurIntroductionView/MYBlurIntroductionView-umbrella.h
cywd/CYSuperDemo
b5b8cd81f0b312d9f6d343c3aabfc6abfb8fd67d
[ "MIT" ]
9
2018-10-19T09:49:33.000Z
2021-08-14T13:11:49.000Z
CYSuperDemo/Pods/Target Support Files/MYBlurIntroductionView/MYBlurIntroductionView-umbrella.h
cywd/CYSuperDemo
b5b8cd81f0b312d9f6d343c3aabfc6abfb8fd67d
[ "MIT" ]
1
2019-08-06T01:19:00.000Z
2019-08-06T01:19:00.000Z
CYSuperDemo/Pods/Target Support Files/MYBlurIntroductionView/MYBlurIntroductionView-umbrella.h
cywd/CYSuperDemo
b5b8cd81f0b312d9f6d343c3aabfc6abfb8fd67d
[ "MIT" ]
3
2019-08-05T15:53:35.000Z
2020-11-30T00:40:09.000Z
#ifdef __OBJC__ #import <UIKit/UIKit.h> #else #ifndef FOUNDATION_EXPORT #if defined(__cplusplus) #define FOUNDATION_EXPORT extern "C" #else #define FOUNDATION_EXPORT extern #endif #endif #endif #import "MYBlurIntroductionView.h" #import "MYIntroductionPanel.h" FOUNDATION_EXPORT double MYBlurIntroductionViewVersionNumber; FOUNDATION_EXPORT const unsigned char MYBlurIntroductionViewVersionString[];
21.210526
76
0.836228
4bc892793f8d9176b853457b5439d7feb0fb56f4
2,278
h
C
external/win_timegm.h
sgherbst/simple-base-lib
6c5f96fd0f8d588b3b9eebbe542465a618f08d96
[ "MIT" ]
1
2022-02-21T19:14:10.000Z
2022-02-21T19:14:10.000Z
external/win_timegm.h
sgherbst/simple-base-lib
6c5f96fd0f8d588b3b9eebbe542465a618f08d96
[ "MIT" ]
null
null
null
external/win_timegm.h
sgherbst/simple-base-lib
6c5f96fd0f8d588b3b9eebbe542465a618f08d96
[ "MIT" ]
3
2017-01-05T08:12:05.000Z
2022-02-21T20:39:49.000Z
#ifndef _WIN_TIMEGM_H_ #define _WIN_TIMEGM_H_ /* Converts struct tm to time_t, assuming the data in tm is UTC rather than local timezone. mktime is similar but assumes struct tm, also known as the "broken-down" form of time, is in local time zone. mktime_frog_utc uses mktime to make the conversion understanding that an offset will be introduced by the local time assumption. mktime_frog_utc then measures the introduced offset by applying gmtime to the initial result and applying mktime to the resulting "broken-down" form. The difference between the two mktime results is the measured offset which is then subtracted from the initial mktime result to yield a calendar time which is the value returned. tm_isdst in struct tm is set to 0 to force mktime to introduce a consistent offset (the non DST offset) since tm and tm+o might be on opposite sides of a DST change. Some implementations of mktime return -1 for the nonexistent localtime hour at the beginning of DST. In this event, use mktime(tm - 1hr) + 3600. Schematically mktime(tm) --> t+o gmtime(t+o) --> tm+o mktime(tm+o) --> t+2o t+o - (t+2o - t+o) = t Note that glibc contains a function of the same purpose named `timegm' (reverse of gmtime). But obviously, it is not universally available, and unfortunately it is not straightforwardly extractable for use here. Perhaps configure should detect timegm and use it where available. Contributed by Roger Beeman <beeman@cisco.com>, with the help of Mark Baushke <mdb@cisco.com> and the rest of the Gurus at CISCO. Further improved by Roger with assistance from Edward J. Sabol based on input by Jamie Zawinski. */ static time_t timegm(struct tm *t) { time_t tl, tb; struct tm *tg; tl = mktime (t); if (tl == -1) { t->tm_hour--; tl = mktime (t); if (tl == -1) return -1; /* can't deal with output from strptime */ tl += 3600; } tg = gmtime (&tl); tg->tm_isdst = 0; tb = mktime (tg); if (tb == -1) { tg->tm_hour--; tb = mktime (tg); if (tb == -1) return -1; /* can't deal with output from gmtime */ tb += 3600; } return (tl - (tb - tl)); } #endif // _WIN_TIMEGM_H_
30.783784
70
0.674715
370360b4a1481518a8264cbc596a5f45109442a6
237
h
C
kernel/linux-5.4/drivers/gpu/drm/i915/gem/selftests/mock_gem_object.h
josehu07/SplitFS
d7442fa67a17de7057664f91defbfdbf10dd7f4a
[ "Apache-2.0" ]
27
2021-10-04T18:56:52.000Z
2022-03-28T08:23:06.000Z
kernel/linux-5.4/drivers/gpu/drm/i915/gem/selftests/mock_gem_object.h
josehu07/SplitFS
d7442fa67a17de7057664f91defbfdbf10dd7f4a
[ "Apache-2.0" ]
1
2022-01-12T04:05:36.000Z
2022-01-16T15:48:42.000Z
kernel/linux-5.4/drivers/gpu/drm/i915/gem/selftests/mock_gem_object.h
josehu07/SplitFS
d7442fa67a17de7057664f91defbfdbf10dd7f4a
[ "Apache-2.0" ]
6
2021-11-02T10:56:19.000Z
2022-03-06T11:58:20.000Z
/* * SPDX-License-Identifier: MIT * * Copyright © 2016 Intel Corporation */ #ifndef __MOCK_GEM_OBJECT_H__ #define __MOCK_GEM_OBJECT_H__ struct mock_object { struct drm_i915_gem_object base; }; #endif /* !__MOCK_GEM_OBJECT_H__ */
15.8
37
0.755274
54b83560b67b47cb8ea8407800758b1bb54e99a6
4,714
c
C
src/arch/win32/uilightpen.c
swingflip/C64_mini_VICE
7a6d9d41ae60409a2bb985bb8d6324a7269a0daa
[ "Apache-2.0" ]
2
2018-11-15T19:52:34.000Z
2022-01-17T19:45:01.000Z
src/arch/win32/uilightpen.c
Classicmods/C64_mini_VICE
7a6d9d41ae60409a2bb985bb8d6324a7269a0daa
[ "Apache-2.0" ]
null
null
null
src/arch/win32/uilightpen.c
Classicmods/C64_mini_VICE
7a6d9d41ae60409a2bb985bb8d6324a7269a0daa
[ "Apache-2.0" ]
3
2019-06-30T05:37:04.000Z
2021-12-04T17:12:35.000Z
/* * uilightpen.c - Implementation of the lightpen settings dialog box. * * Written by * Marco van den Heuvel <blackystardust68@yahoo.com> * * This file is part of VICE, the Versatile Commodore Emulator. * See README for copyright notice. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. * */ #include "vice.h" #include <stdio.h> #include <string.h> #include <windows.h> #include <tchar.h> #include "res.h" #include "resources.h" #include "system.h" #include "translate.h" #include "ui.h" #include "uilib.h" #include "uilightpen.h" #include "winmain.h" #include "intl.h" static void enable_lightpen_controls(HWND hwnd) { int is_enabled; is_enabled = (IsDlgButtonChecked(hwnd, IDC_LIGHTPEN_ENABLE) == BST_CHECKED) ? 1 : 0; EnableWindow(GetDlgItem(hwnd, IDC_LIGHTPEN_TYPE), is_enabled); } static uilib_localize_dialog_param lightpen_dialog[] = { { 0, IDS_LIGHTPEN_CAPTION, -1 }, { IDC_LIGHTPEN_ENABLE, IDS_LIGHTPEN_ENABLE, 0 }, { IDC_LIGHTPEN_TYPE_LABEL, IDS_LIGHTPEN_TYPE, 0 }, { IDOK, IDS_OK, 0 }, { IDCANCEL, IDS_CANCEL, 0 }, { 0, 0, 0 } }; static uilib_dialog_group lightpen_leftgroup[] = { { IDC_LIGHTPEN_TYPE_LABEL, 0 }, { 0, 0 } }; static uilib_dialog_group lightpen_rightgroup[] = { { IDC_LIGHTPEN_TYPE, 0 }, { 0, 0 } }; static int move_buttons_group[] = { IDOK, IDCANCEL, 0 }; static void init_lightpen_dialog(HWND hwnd) { HWND temp_hwnd; int res_value; int xsize, ysize; RECT rect; uilib_localize_dialog(hwnd, lightpen_dialog); uilib_get_group_extent(hwnd, lightpen_leftgroup, &xsize, &ysize); uilib_adjust_group_width(hwnd, lightpen_leftgroup); uilib_move_group(hwnd, lightpen_rightgroup, xsize + 30); /* get the max x of the right group */ uilib_get_group_max_x(hwnd, lightpen_rightgroup, &xsize); /* set the width of the dialog to 'surround' all the elements */ GetWindowRect(hwnd, &rect); MoveWindow(hwnd, rect.left, rect.top, xsize + 20, rect.bottom - rect.top, TRUE); /* recenter the buttons in the newly resized dialog window */ uilib_center_buttons(hwnd, move_buttons_group, 0); resources_get_int("Lightpen", &res_value); CheckDlgButton(hwnd, IDC_LIGHTPEN_ENABLE, res_value ? BST_CHECKED : BST_UNCHECKED); temp_hwnd = GetDlgItem(hwnd, IDC_LIGHTPEN_TYPE); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Pen with button Up"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Pen with button Left"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Datel Pen"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Magnum Light Phaser"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Stack Light Rifle"); resources_get_int("LightpenType", &res_value); SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0); enable_lightpen_controls(hwnd); } static void end_lightpen_dialog(HWND hwnd) { resources_set_int("Lightpen", (IsDlgButtonChecked(hwnd, IDC_LIGHTPEN_ENABLE) == BST_CHECKED ? 1 : 0 )); resources_set_int("LightpenType", (int)SendMessage(GetDlgItem(hwnd, IDC_LIGHTPEN_TYPE), CB_GETCURSEL, 0, 0)); } static INT_PTR CALLBACK dialog_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { int command; switch (msg) { case WM_COMMAND: command = LOWORD(wparam); switch (command) { case IDC_LIGHTPEN_ENABLE: enable_lightpen_controls(hwnd); break; case IDOK: end_lightpen_dialog(hwnd); case IDCANCEL: EndDialog(hwnd, 0); return TRUE; } return FALSE; case WM_CLOSE: EndDialog(hwnd, 0); return TRUE; case WM_INITDIALOG: init_lightpen_dialog(hwnd); return TRUE; } return FALSE; } void ui_lightpen_settings_dialog(HWND hwnd) { DialogBox(winmain_instance, (LPCTSTR)IDD_LIGHTPEN_SETTINGS_DIALOG, hwnd, dialog_proc); }
30.217949
113
0.680526
60772d8dcae2af1a2be1ded0186b67cbab9a1397
17,743
h
C
src/third_party/beaengine/src/Includes/instr_set/Data_opcode.h
CrackerCat/rp
5fe693c26d76b514efaedb4084f6e37d820db023
[ "MIT" ]
1
2022-01-17T17:40:29.000Z
2022-01-17T17:40:29.000Z
src/third_party/beaengine/src/Includes/instr_set/Data_opcode.h
CrackerCat/rp
5fe693c26d76b514efaedb4084f6e37d820db023
[ "MIT" ]
null
null
null
src/third_party/beaengine/src/Includes/instr_set/Data_opcode.h
CrackerCat/rp
5fe693c26d76b514efaedb4084f6e37d820db023
[ "MIT" ]
null
null
null
/* Copyright 2006-2020, BeatriX * File coded by BeatriX * * This file is part of BeaEngine. * * BeaEngine is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * BeaEngine 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 BeaEngine. If not, see <http://www.gnu.org/licenses/>. */ /* ======================================================================= */ /* */ /* */ /* 1 BYTE OPCODE MAP */ /* */ /* */ /* ======================================================================= */ void (__bea_callspec__ * opcode_map1[])(PDISASM) = { add_EbGb , add_EvGv , add_GbEb , add_GvEv , add_ALIb , add_eAX_Iv, push_es , pop_es , or_EbGb , or_EvGv , or_GbEb , or_GvEv , or_ALIb , or_eAX_Iv , push_cs , Esc_2byte , adc_EbGb , adc_EvGv , adc_GbEb , adc_GvEv , adc_ALIb , adc_eAX_Iv, push_ss , pop_ss , sbb_EbGb , sbb_EvGv , sbb_GbEb , sbb_GvEv , sbb_ALIb , sbb_eAX_Iv, push_ds , pop_ds , and_EbGb , and_EvGv , and_GbEb , and_GvEv , and_ALIb , and_eAX_Iv, PrefSEGES , daa_ , sub_EbGb , sub_EvGv , sub_GbEb , sub_GvEv , sub_ALIb , sub_eAX_Iv, PrefSEGCS , das_ , xor_EbGb , xor_EvGv , xor_GbEb , xor_GvEv , xor_ALIb , xor_eAX_Iv, PrefSEGSS , aaa_ , cmp_EbGb , cmp_EvGv , cmp_GbEb , cmp_GvEv , cmp_ALIb , cmp_eAX_Iv, PrefSEGDS , aas_ , inc_eax , inc_ecx , inc_edx , inc_ebx , inc_esp , inc_ebp , inc_esi , inc_edi , dec_eax , dec_ecx , dec_edx , dec_ebx , dec_esp , dec_ebp , dec_esi , dec_edi , push_eax , push_ecx , push_edx , push_ebx , push_esp , push_ebp , push_esi , push_edi , pop_eax , pop_ecx , pop_edx , pop_ebx , pop_esp , pop_ebp , pop_esi , pop_edi , pushad_ , popad_ , bound_ , arpl_ , PrefSEGFS , PrefSEGGS , PrefOpSize, PrefAdSize, push_Iv ,imul_GvEvIv, push_Ib ,imul_GvEvIb, insb_ , ins_ , outsb_ , outsw_ , jo_ , jno_ , jc_ , jnc_ , je_ , jne_ , jbe_ , jnbe_ , js_ , jns_ , jp_ , jnp_ , jl_ , jnl_ , jle_ , jnle_ , G1_EbIb , G1_EvIv , G1_EbIb2 , G1_EvIb , test_EbGb , test_EvGv , xchg_EbGb , xchg_EvGv , mov_EbGb , mov_EvGv , mov_GbEb , mov_GvEv , mov_EwSreg, lea_GvM , mov_SregEw, pop_Ev , nop_ , xchg_ecx , xchg_edx , xchg_ebx , xchg_esp , xchg_ebp , xchg_esi , xchg_edi , cwde_ , cdq_ , callf_ , wait_ , pushfd_ , popfd_ , sahf_ , lahf_ , mov_ALOb , mov_eAXOv , mov_ObAL , mov_OveAX , movs_ , movsw_ , cmpsb_ , cmps_ , test_ALIb ,test_eAX_Iv, stos_ , stosw_ , lodsb_ , lodsw_ , scasb_ , scas_ , mov_ALIb , mov_CLIb , mov_DLIb , mov_BLIb , mov_AHIb , mov_CHIb , mov_DHIb , mov_BHIb , mov_EAX , mov_ECX , mov_EDX , mov_EBX , mov_ESP , mov_EBP , mov_ESI , mov_EDI , G2_EbIb , G2_EvIb , retn_ , ret_ , les_GvM , lds_GvM , mov_EbIb , mov_EvIv , enter_ , leave_ , retf_Iw , retf_ , int3_ , int_ , into_ , iret_ , G2_Eb1 , G2_Ev1 , G2_EbCL , G2_EvCL , aam_ , aad_ , salc_ , xlat_ , D8_ , D9_ , DA_ , DB_ , DC_ , DD_ , DE_ , DF_ , loopne_ , loope_ , loop_ , jecxz_ , in_ALIb , in_eAX_Ib , out_IbAL , out_Ib_eAX, call_ , jmp_near , jmp_far , jmp_short , in_ALDX , in_eAX , out_DXAL , out_DXeAX , PrefLock , int1_ , PrefREPNE , PrefREPE , hlt_ , cmc_ , G3_Eb , G3_Ev , clc_ , stc_ , cli_ , sti_ , cld_ , std_ , G4_Eb , G5_Ev , }; /* =======================================================================*/ /* */ /* */ /* 2 BYTES OPCODE MAP --> 0F xx */ /* */ /* */ /* =======================================================================*/ void (__bea_callspec__ *opcode_map2[])(PDISASM) = { G6_ , G7_ , lar_GvEw , lsl_GvEw , failDecode, syscall_ , clts_ , sysret_ , invd_ , wbinvd_ , failDecode, ud2_ , failDecode, nop_Ev , femms_ , failDecode, movups_VW , movups_WV , movlps_VM , movlps_MV , unpcklps_ , unpckhps_ , movhps_VM , movhps_MV , G16_ , hint_nop , bndcl_GvEv, bndcn_GvEv, hint_nop , hint_nop , nop_1e , nop_Ev , mov_RdCd , mov_RdDd , mov_CdRd , mov_DdRd , failDecode, failDecode, failDecode, failDecode, movaps_VW , movaps_WV , cvtpi2ps_ , movntps_ , cvttps2pi_, cvtps2pi_ , ucomiss_VW, comiss_VW , wrmsr_ , rdtsc_ , rdmsr_ , rdpmc_ , sysenter_ , sysexit_ , failDecode, getsec_ ,Esc_tableA4, failDecode,Esc_tableA5, failDecode, failDecode, failDecode, failDecode, failDecode, cmovo_ , cmovno_ , cmovb_ , cmovnb_ , cmove_ , cmovne_ , cmovbe_ , cmovnbe_ , cmovs_ , cmovns_ , cmovp_ , cmovnp_ , cmovl_ , cmovnl_ , cmovle_ , cmovnle_ , movmskps_ , sqrtps_VW , rsqrtps_ , rcpps_ , andps_VW , andnps_VW , orps_VW , xorps_VW , addps_VW , mulps_VW , cvtps2pd_ , cvtdq2ps_ , subps_VW , minps_VW , divps_VW , maxps_VW , punpcklbw_, punpcklwd_, punpckldq_, packsswb_ , pcmpgtb_ , pcmpgtw_ , pcmpgtd_ , packuswb_ , punpckhbw_, punpckhwd_, punpckhdq_, packssdw_ ,punpcklqdq_,punpckhqdq_, movd_PE , movq_PQ , pshufw_ , G12_ , G13_ , G14_ , pcmpeqb_ , pcmpeqw_ , pcmpeqd_ , emms_ , vmread_ , vmwrite_ ,vcvttps2qq_, vcvtps2qq_, haddpd_VW , hsubpd_VW , movd_EP , movq_QP , jo_near , jno_near , jc_near , jnc_near , je_near , jne_near , jbe_near , ja_near , js_near , jns_near , jp_near , jnp_near , jl_near , jnl_near , jle_near , jnle_near , seto_ , setno_ , setb_ , setnb_ , sete_ , setne_ , setbe_ , setnbe_ , sets_ , setns_ , setp_ , setnp_ , setnge_ , setge_ , setle_ , setnle_ , push_fs , pop_fs , cpuid_ , bt_EvGv ,shld_EvGvIb,shld_EvGvCL, failDecode, failDecode, push_gs , pop_gs , rsm_ , bts_EvGv ,shrd_EvGvIb,shrd_EvGvCL, G15_ , imul_GvEv , cmpx_EbGb , cmpx_EvGv , lss_Mp , btr_EvGv , lfs_Mp , lgs_Mp , movzx_GvEb, movzx_GvEw, popcnt_ , ud2_ , G8_EvIb , btc_EvGv , bsf_GvEv , bsr_GvEv , movsx_GvEb, movsx_GvEw, xadd_EbGb , xadd_EvGv , cmpps_VW , movnti_ , pinsrw_ , pextrw_ , shufps_ , G9_ , bswap_eax , bswap_ecx , bswap_edx , bswap_ebx , bswap_esp , bswap_ebp , bswap_esi , bswap_edi , addsubpd_ , psrlw_ , psrld_ , psrlq_ , paddq_ , pmullw_ , movq_WV , pmovmskb_ , psubusb_ , psubusw_ , pminub_ , pand_ , paddusb_ , paddusw_ , pmaxub_ , pandn_ , pavgb_ , psraw_ , psrad_ , pavgw_ , pmulhuw_ , pmulhw_ , cvtpd2dq_ , movntq_ , psubsb_ , psubsw_ , pminsw_ , por_ , paddsb_ , paddsw_ , pmaxsw_ , pxor_ , lddqu_ , psllw_ , pslld_ , psllq_ , pmuludq_ , pmaddwd_ , psadbw_ , maskmovq_ , psubb_ , psubw_ , psubd_ , psubq_ , paddb_ , paddw_ , paddd_ , ud0_ , }; /* ====================================================================== */ /* */ /* */ /* 3 BYTES OPCODE MAP --> 0F 38 xx */ /* */ /* */ /* ========================================================================*/ void (__bea_callspec__ *opcode_map3[])(PDISASM) = { pshufb_ , phaddw_ , phaddd_ , phaddsw_ , pmaddubsw_ , phsubw_ , phsubd_ , phsubsw_ , psignb_ , psignw_ , psignd_ , pmulhrsw_ , vpermilps_ , vpermilpd_ , vtestps_ , vtestpd_ , pblendvb_ , vpsravw_ , vpsllvw_ , vcvtph2ps_ , blendvps_ , blendvpd_ , vpermps_ , ptest_ , vbroadcastss , vbroadcastsd ,vbroadcastf128, vbroadcastf32 , pabsb_ , pabsw_ , pabsd_ , vpabsq_ , pmovsxbw_ , pmovsxbd_ , pmovsxbq_ , pmovsxwd_ , pmovsxwq_ , pmovsxdq_ , vptestmb_ , vptestmd_ , pmuldq_ , pcmpeqq_ , movntdqa_ , packusdw_ , vmaskmovps_ , vmaskmovpd_ , vmaskmovps2_ , vmaskmovpd2_ , pmovzxbw_ , pmovzxbd_ , pmovzxbq_ , pmovzxwd_ , pmovzxwq_ , pmovzxdq_ , vpermd_ , pcmpgtq_ , pminsb_ , pminsd_ , pminuw_ , pminud_ , pmaxsb_ , pmaxsd_ , pmaxuw_ , pmaxud_ , pmulld_ , phminposuw_ , vgetexpps_ , vgetexpss_ , vplzcntd_ , psrlvd_ , psravd_ , psllvd_ , failDecode , ldtilecfg_ , failDecode , tileload_ , vrcp14ps_ , vrcp14ss_ , vrsqrt14ps_ , vrsqrt14ss_ , vpdpbusd_ , vpdpbusds_ , vpdpwssd_ , vpdpwssds_ , vpopcntb_ , vpopcntd_ , failDecode , failDecode , vpbroadcastd , vpbroadcastq ,vbroadcasti128,vbroadcasti32x8 , tdpbf16ps_ , failDecode , tdpbssd_ , failDecode , failDecode , failDecode , vpexpandb_ , vpcompressb_ , vpblendmd_ , vpblendmps_ , vpblendmb_ , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , vpshldvw_ , vpshldvd_ , vpshrdvw_ , vpshrdvd_ , failDecode , vpermi2b_ , vpermi2d_ , vpermi2ps_ , vpbroadcastb , vpbroadcastw , vpbroadcastb2, vpbroadcastw2 , vpbroadcastd2 , vpermt2b , vpermt2d , vpermt2ps , invept_ , invvpid_ , invpcid_ , vpmultishift , failDecode , failDecode , failDecode , failDecode , vexpandps , vpexpandd , vcompressps , vpcompressd , vpmaskmovd , vpermb , vpmaskmovd2 , vpshufbitqmb , vgatherdd_ , vgatherqd_ , vgatherps_ , vgatherqps_ , failDecode , failDecode , vfmaddsub132ps_ , vfmsubadd132ps_ , vfmadd132ps_ , vfmadd132ss_ , vfmsub132ps_ , vfmsub132ss_ , vfnmadd132ps_ , vfnmadd132ss_ , vfnmsub132ps_ , vfnmsub132ss_ , vpscatterdd , vpscatterqd , vpscatterdps , vpscatterqps , failDecode , failDecode , vfmaddsub213ps_ , vfmsubadd213ps_ , vfmadd213ps_ , vfmadd213ss_ , vfmsub213ps_ , vfmsub213ss_ , vfnmadd213ps_ , vfnmadd213ss_ , vfnmsub213ps_ , vfnmsub213ss_ , failDecode , failDecode , failDecode , failDecode , vpmadd52luq , vpmadd52huq , vfmaddsub231ps_ , vfmsubadd231ps_ , vfmadd231ps_ , vfmadd231ss_ , vfmsub231ps_ , vfmsub231ss_ , vfnmadd231ps_ , vfnmadd231ss_ , vfnmsub231ps_ , vfnmsub231ss_ , failDecode , failDecode , failDecode , failDecode , vpconflictd , failDecode , failDecode , failDecode , sha1nexte_ , sha1msg1_ , sha1msg2_ , sha256rnd_ , sha256msg1_ , sha256msg2_ , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , aesencwide128, failDecode , failDecode , aesimc , aesenc , aesenclast , aesdec , aesdeclast , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , failDecode , crc32_GvEb , crc32_GvEv , andn_GyEy , G17_ , failDecode , bzhi_GyEy , adcx_GyEy , bextr_GyEy , failDecode , failDecode , encodekey128_, encodekey256_ , failDecode , failDecode , failDecode , failDecode , }; /* ======================================================================== */ /* */ /* */ /* 3 BYTES OPCODE MAP --> 0F 3A xx */ /* */ /* */ /* ==========================================================================*/ void (__bea_callspec__ *opcode_map4[])(PDISASM) = { vpermq_ , vpermpd , vpblendd , valignd , vpermilps2, vpermilpd2, vperm2f128, failDecode, roundps_ , roundpd_ , roundss_ , roundsd_ , blendps_ , blendpd_ , pblendw_ , palignr_ , failDecode, failDecode, failDecode, failDecode, pextrb_ , pextrw2_ , pextrd_ , extractps_,vinsertf128, vextractf128 , vinsertf32x8 , vextractf32x8 , failDecode, vcvtps2ph , vpcmpccud , vpcmpccd , pinsrb_ , insertps_ , pinsrd_ , vshuff32x4, failDecode, vpternlogd, vgetmantps, vgetmantss, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, kshiftrb , kshiftrd , kshiftlb , kshiftld , failDecode, failDecode, failDecode, failDecode,vinserti128, vextracti128 , vinserti32x8 , vextracti32x8 , failDecode, failDecode, vpcmpccub , vpcmpccb , dpps_ , dppd_ , mpsadbw_ , vshufi32x4, pclmulqdq_, failDecode, vperm2i128, failDecode, failDecode, failDecode , blendvps_ , blendvpd_ , pblendvb_ , failDecode, failDecode, failDecode, vrangeps , vrangess , failDecode, failDecode, vfixupmmps, vfixupmmss, vreduceps , vreducess , failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, pcmpestrm_, pcmpestri_, pcmpistrm_, pcmpistri_, failDecode, failDecode, vfpclassps, vfpclassss, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, vpshldw , vpshldd , vpshrdw , vpshrdd , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , sha1rnds4_, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, aeskeygen , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, rorx_ , failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode, failDecode , failDecode , failDecode , failDecode, failDecode, failDecode, failDecode, }; void (__bea_callspec__ *ModRM_0[])(OPTYPE*, PDISASM) = { Addr_EAX, Addr_ECX, Addr_EDX, Addr_EBX, Addr_SIB, Addr_disp32, Addr_ESI, Addr_EDI, }; void (__bea_callspec__ *ModRM_1[])(OPTYPE*, PDISASM) = { Addr_EAX_disp8, Addr_ECX_disp8, Addr_EDX_disp8, Addr_EBX_disp8, Addr_SIB_disp8, Addr_EBP_disp8, Addr_ESI_disp8, Addr_EDI_disp8, }; void (__bea_callspec__ *ModRM_2[])(OPTYPE*, PDISASM) = { Addr_EAX_disp32, Addr_ECX_disp32, Addr_EDX_disp32, Addr_EBX_disp32, Addr_SIB_disp32, Addr_EBP_disp32, Addr_ESI_disp32, Addr_EDI_disp32, }; void (__bea_callspec__ *ModRM_3[])(OPTYPE*, PDISASM) = { _rEAX, _rECX, _rEDX, _rEBX, _rESP, _rEBP, _rESI, _rEDI, }; size_t (__bea_callspec__ *SIB[])(OPTYPE*, size_t, PDISASM) = { SIB_0, SIB_1, SIB_2, SIB_3, };
101.388571
251
0.567435
a1bb1250a4a4d51cd8dc721ca8de696ffe236e86
1,432
h
C
DupFind/MD5/HHH/MessageDigest.h
avrionov/DupFind
bb5016628c11e4e59f243956a1fae22ff1f9c867
[ "MIT" ]
null
null
null
DupFind/MD5/HHH/MessageDigest.h
avrionov/DupFind
bb5016628c11e4e59f243956a1fae22ff1f9c867
[ "MIT" ]
null
null
null
DupFind/MD5/HHH/MessageDigest.h
avrionov/DupFind
bb5016628c11e4e59f243956a1fae22ff1f9c867
[ "MIT" ]
null
null
null
//MessageDigest.h #ifndef __MESSAGEDIGEST_H__ #define __MESSAGEDIGEST_H__ using namespace std; //Typical DISCLAIMER: //The code in this project is Copyright (C) 2003 by George Anescu. You have the right to //use and distribute the code in any way you see fit as long as this paragraph is included //with the distribution. No warranties or claims are made as to the validity of the //information and code contained herein, so use it at your own risk. //General Message Digest Interface class IMessageDigest { public: //CONSTRUCTOR IMessageDigest() : m_bAddData(false) {} //DESTRUCTOR virtual ~IMessageDigest() {} //Update context to reflect the concatenation of another buffer of bytes virtual void AddData(char const* pcData, int iDataLength) = 0; //Final wrapup - pad to BLOCKSIZE-byte boundary with the bit pattern //10000...(64-bit count of bits processed, MSB-first) virtual void FinalDigest(char* pcDigest) = 0; //Reset current operation in order to prepare for a new one virtual void Reset() = 0; //Digesting a Full File void DigestFile(CString const& rostrFileIn, char* pcDigest); protected: enum { BLOCKSIZE=64 }; //Control Flag bool m_bAddData; //The core of the MessageDigest algorithm, this alters an existing MessageDigest hash to //reflect the addition of 64 bytes of new data virtual void Transform() = 0; private: enum { DATA_LEN=384, BUFF_LEN=1024 }; }; #endif // __MESSAGEDIGEST_H__
29.22449
90
0.756285
749f0d1340e8d5e1188ddfdf36ee3e8bde65b157
4,834
h
C
Modules/IGT/TrackingDevices/mitkClaronInterface.h
danielknorr/MITK
b1b9780b2a6671d8118313c5ef71e9aa128362be
[ "BSD-3-Clause" ]
1
2017-03-05T05:29:32.000Z
2017-03-05T05:29:32.000Z
Modules/IGT/TrackingDevices/mitkClaronInterface.h
danielknorr/MITK
b1b9780b2a6671d8118313c5ef71e9aa128362be
[ "BSD-3-Clause" ]
null
null
null
Modules/IGT/TrackingDevices/mitkClaronInterface.h
danielknorr/MITK
b1b9780b2a6671d8118313c5ef71e9aa128362be
[ "BSD-3-Clause" ]
2
2020-10-27T06:51:00.000Z
2020-10-27T06:51:01.000Z
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKCLARONINTERFACE_H_HEADER_INCLUDED_ #define MITKCLARONINTERFACE_H_HEADER_INCLUDED_ #define MTC(func) {int r = func; if (r!=mtOK) printf("MTC error: %s\n",MTLastErrorString()); }; #include <vector> #include <string> #include <MitkIGTExports.h> #include "mitkCommon.h" #include <itkObject.h> #include <itkObjectFactory.h> #ifdef _WIN64 //Defined for applications for Win64. typedef long mtHandle; #else typedef int mtHandle; #endif namespace mitk { typedef int claronToolHandle; /** Documentation: * \brief An object of this class represents the interface to the MicronTracker. The methods of this class * are calling the c-functions which are provided by the MTC-library. If the MicronTracker is not in * use, which means the CMake-variable "MITK_USE_MICRON_TRACKER" is set to OFF, this class is replaced * by a stub class called "ClaronInterfaceStub". * \ingroup IGT */ class MitkIGT_EXPORT ClaronInterface : public itk::Object { public: mitkClassMacro(ClaronInterface,itk::Object); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** * \brief Initialization of claroninterface. * \param calibrationDir The directory where the device can find the camera calibration file. * \param toolFilesDir The directory for the tool files. */ void Initialize(std::string calibrationDir, std::string toolFilesDir); /** * \brief Opens the connection to the device and makes it ready to track tools. * \return Returns true if there is a connection to the device and the device is ready to track tools, false if not. */ bool StartTracking(); /** * \brief Clears all resources. After this method have been called the system isn't ready to track any longer. * \return Returns true if the operation was succesful, false if not. */ bool StopTracking(); /** * \return Returns all tools which have been detected at the last frame grab. */ std::vector<claronToolHandle> GetAllActiveTools(); /** * \return Returns the position of the tooltip. If no tooltip is defined the Method returns the position of the tool. */ std::vector<double> GetTipPosition(claronToolHandle c); /** * \return Returns the quarternions of the tooltip. If no tooltip is defined the Method returns the quarternions of the tool. */ std::vector<double> GetTipQuaternions(claronToolHandle c); /** * \return Returns the position of the tool */ std::vector<double> GetPosition(claronToolHandle c); /** * \return Returns the quaternion of the tool. */ std::vector<double> GetQuaternions(claronToolHandle c); /** * \return Returns the name of the tool. This name is given by the calibration file. * \param c The handle of the tool, which name should be given back. */ const char* GetName(claronToolHandle c); /** * \brief Grabs a frame from the camera. */ void GrabFrame(); /** * \return Returns wether the tracking device is tracking or not. */ bool IsTracking(); /** * \return Returns wether the MicronTracker is installed (means wether the C-Make-Variable "MITK_USE_MICRON_TRACKER" is set ON), * so returns true in this case. This is because the class mitkClaronInterfaceStub, in which the same Method returns false * is used otherways. */ bool IsMicronTrackerInstalled(); protected: /** * \brief standard constructor */ ClaronInterface(); /** * \brief standard destructor */ ~ClaronInterface(); /** \brief Variable is true if the device is tracking at the moment, false if not.*/ bool isTracking; /** \brief Variable which holds the directory which should contain the file BumbleBee_6400420.calib. This directory is needed by the MTC library.*/ char calibrationDir[512]; /** \brief Variable which holds a directory with some tool files in it. All this tools are trackable when the path is given to the MTC library.*/ char markerDir[512]; //Some handles to communicate with the MTC library. mtHandle IdentifiedMarkers; mtHandle PoseXf; mtHandle CurrCamera; mtHandle IdentifyingCamera; //------------------------------------------------ }; }//mitk #endif
32.226667
151
0.673149
1c7bd9f199029bf26b5345834d29fb379645915f
3,799
h
C
extras/ogl-sample/main/gfx/lib/glu/libnurbs/internals/quilt.h
sourcecode-reloaded/Xming
b9f2e99d00f9445a29803d622d24b5314ee35991
[ "X11", "MIT" ]
4
2020-08-21T04:21:14.000Z
2022-01-15T11:26:11.000Z
extras/ogl-sample/main/gfx/lib/glu/libnurbs/internals/quilt.h
sourcecode-reloaded/Xming
b9f2e99d00f9445a29803d622d24b5314ee35991
[ "X11", "MIT" ]
1
2020-02-23T19:22:52.000Z
2020-02-23T19:22:52.000Z
extras/ogl-sample/main/gfx/lib/glu/libnurbs/internals/quilt.h
talregev/Xming
e7a997e3c6441c572df6953468fd8e88ca9e07e7
[ "X11", "MIT" ]
3
2020-12-18T06:33:36.000Z
2022-02-22T16:25:50.000Z
/* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free ** Software License B, Version 1.1 (the "License"), the contents of this ** file are subject only to the provisions of the License. You may not use ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: ** ** http://oss.sgi.com/projects/FreeB ** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. ** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. ** ** Additional Notice Provisions: The application programming interfaces ** established by SGI in conjunction with the Original Code are The ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X ** Window System(R) (Version 1.3), released October 19, 1998. This software ** was created using the OpenGL(R) version 1.2.1 Sample Implementation ** published by SGI, but has not been independently verified as being ** compliant with the OpenGL(R) version 1.2.1 Specification. */ /* * quilt.h * * $Date: 2004/03/14 08:29:11 $ $Revision: 1.1.1.4 $ * $Header: /cvs/xorg/xc/extras/ogl-sample/main/gfx/lib/glu/libnurbs/internals/quilt.h,v 1.1.1.4 2004/03/14 08:29:11 eich Exp $ */ #ifndef __gluquilt_h_ #define __gluquilt_h_ #include "defines.h" #include "bufpool.h" #include "types.h" class Backend; class Mapdesc; class Flist; class Knotvector; /* constants for memory allocation of NURBS to Bezier conversion */ #define MAXDIM 2 struct Quiltspec { /* a specification for a dimension of a quilt */ int stride; /* words between points */ int width; /* number of segments */ int offset; /* words to first point */ int order; /* order */ int index; /* current segment number */ int bdry[2]; /* boundary edge flag */ REAL step_size; Knot * breakpoints; }; typedef Quiltspec *Quiltspec_ptr; class Quilt : public PooledObj { /* an array of bezier patches */ public: Quilt( Mapdesc * ); Mapdesc * mapdesc; /* map descriptor */ REAL * cpts; /* control points */ Quiltspec qspec[MAXDIM]; /* the dimensional data */ Quiltspec_ptr eqspec; /* qspec trailer */ Quilt *next; /* next quilt in linked list */ public: void deleteMe( Pool& ); void toBezier( Knotvector &, INREAL *, long ); void toBezier( Knotvector &, Knotvector &, INREAL *, long ); void select( REAL *, REAL * ); int getDimension( void ) { return eqspec - qspec; } void download( Backend & ); void downloadAll( REAL *, REAL *, Backend & ); int isCulled( void ); void getRange( REAL *, REAL *, Flist&, Flist & ); void getRange( REAL *, REAL *, int, Flist & ); void getRange( REAL *, REAL *, Flist& ); void findRates( Flist& slist, Flist& tlist, REAL[2] ); void findSampleRates( Flist& slist, Flist& tlist ); void show(); }; typedef class Quilt *Quilt_ptr; #endif /* __gluquilt_h_ */
38.373737
127
0.689655
e3cbb297c65dbf5a143ff08c5cf9b6848466b594
447
h
C
DreamDaq/codeBackup/DreamDaq.101104/dreamtcpserv.h
ivivarel/DREMTubes
ac768990b4c5e2c23d986284ed10189f31796b38
[ "MIT" ]
3
2021-07-22T12:17:48.000Z
2021-07-27T07:22:54.000Z
DreamDaq/codeBackup/DreamDaq.101104/dreamtcpserv.h
ivivarel/DREMTubes
ac768990b4c5e2c23d986284ed10189f31796b38
[ "MIT" ]
38
2021-07-14T15:41:04.000Z
2022-03-29T14:18:20.000Z
DreamDaq/codeBackup/DreamDaq.101104/dreamtcpserv.h
ivivarel/DREMTubes
ac768990b4c5e2c23d986284ed10189f31796b38
[ "MIT" ]
7
2021-07-21T12:00:33.000Z
2021-11-13T10:45:30.000Z
#ifndef _DREAM_TCP_SERV_H #define _DREAM_TCP_SERV_H #include <stdint.h> #include <string.h> class tcpserv; class dreamtcpserv { public: dreamtcpserv(); ~dreamtcpserv(); void open(uint16_t port); bool accept(const char * host = 0); void disc(); void sendcommand(const void * cmd, size_t len); int getcommand(void * cmd, size_t len); private: tcpserv * ts; bool isthere; }; #endif // _DREAM_TCP_SERV_H
17.88
51
0.668904
91bbdee9a972dbcc55da343daf0675adb7dd3198
1,208
h
C
source/Shader.h
redagito/RenderTest
b57f4c9dc3ae911a1db844e6abccd5a9fb096a01
[ "MIT" ]
null
null
null
source/Shader.h
redagito/RenderTest
b57f4c9dc3ae911a1db844e6abccd5a9fb096a01
[ "MIT" ]
null
null
null
source/Shader.h
redagito/RenderTest
b57f4c9dc3ae911a1db844e6abccd5a9fb096a01
[ "MIT" ]
null
null
null
#pragma once #include <glad/glad.h> #include <glm/glm.hpp> #include <string> #include <unordered_map> class Shader { public: Shader(const std::string& vertexShaderCode, const std::string& fragmentShaderCode); ~Shader(); void setActive() const; void set(const std::string& name, const int value, bool required = false); void set(const std::string& name, const unsigned int value, bool required = false); void set(const std::string& name, const float value, bool required = false); void set(const std::string& name, const glm::vec2& value, bool required = false); void set(const std::string& name, const glm::vec3& value, bool required = false); void set(const std::string& name, const glm::vec4& value, bool required = false); void set(const std::string& name, const glm::mat4& value, bool required = false); private: int getUniformLocation(const std::string& name, bool required) const; GLuint id = 0; mutable std::unordered_map<std::string, int> uniformLocations; }; GLuint createShaderObject(const std::string& code, GLenum shaderType); GLuint createShaderProgram(const std::string& vertexShaderCode, const std::string& fragmentShaderCode);
36.606061
103
0.714404
dc4a0aae6a06c0eae88925744b2838de8291de5a
476
h
C
swig/classes/include/wxEraseEvent.h
eumario/wxruby
c348d0dd64f9549f51cbfd22658de42e7ca37194
[ "MIT" ]
7
2019-02-18T23:54:31.000Z
2021-12-04T01:06:37.000Z
swig/classes/include/wxEraseEvent.h
eumario/wxruby
c348d0dd64f9549f51cbfd22658de42e7ca37194
[ "MIT" ]
null
null
null
swig/classes/include/wxEraseEvent.h
eumario/wxruby
c348d0dd64f9549f51cbfd22658de42e7ca37194
[ "MIT" ]
null
null
null
// wxEraseEvent.h // This file was automatically generated // by extractxml.rb, part of the wxRuby project // Do not make changes directly to this file! #if !defined(_wxEraseEvent_h_) #define _wxEraseEvent_h_ class wxEraseEvent : public wxEvent { public: /** * \brief Constructor. * \param int * \param wxDC* */ wxEraseEvent(int id = 0, wxDC* dc = NULL) ; /** * \brief Returns the device context to draw into. */ wxDC* GetDC() const; }; #endif
17.62963
52
0.665966
91297c51ef431822f44661f300a7c8d629a41e74
11,521
c
C
project_test-scenario.em.c
wywxidian/Trajectory_transformation_SMUO_to_OPNET
e7fda2d3b07db4659b05b4ebfc435cb1e3a5ff8b
[ "Apache-2.0" ]
null
null
null
project_test-scenario.em.c
wywxidian/Trajectory_transformation_SMUO_to_OPNET
e7fda2d3b07db4659b05b4ebfc435cb1e3a5ff8b
[ "Apache-2.0" ]
null
null
null
project_test-scenario.em.c
wywxidian/Trajectory_transformation_SMUO_to_OPNET
e7fda2d3b07db4659b05b4ebfc435cb1e3a5ff8b
[ "Apache-2.0" ]
null
null
null
#include <opnet.h> #include <ema.h> #include <opnet_emadefs.h> #include <opnet_constants.h> # include <stdlib.h> /* array for all textlist attributes in model */ Prg_List* prg_lptr [5]; /* array for all objects in model */ EmaT_Object_Id obj [10]; # define NODE_NUMBER 300 /* 节点数量 */ # define X_MIN 9468.45 /* 场景大小,可以采用SUMO_Pretreatment.java输出区域的范围 */ # define X_MAX 13047.56 # define Y_MIN 12293.16 # define Y_MAX 16284.85 # define X_LENGTH 3579.11 # define Y_LENGTH 3991.25 # define MIN_DISTANCE_2 400 /* 节点最小距离的平方, 这个值越大, 节点生成越均匀, 这个值理论最大为25*25*1.414, 值越大生成的时间越长 */ int PosChooseAgain; /* 是否重新生成 */ int NodeNumber; /* 节点数 */ int i, k; /* 循环变量 */ char node_name[5]; /* 节点名称 */ char tra[20]; /* 轨迹名称 */ double x_pos,y_pos; /* 节点坐标 */ double NodeXList[300], NodeYList[300]; /* 节点坐标数组 */ EmaT_Object_Id wsn_node_objid; /* 对象变量 */ int main (int argc, char* argv []) { EmaT_Model_Id model_id; int i; /* initialize EMA package */ Ema_Init (EMAC_MODE_ERR_PRINT | EMAC_MODE_REL_60, argc, argv); /* create an empty model */ model_id = Ema_Model_Create (MOD_NETWORK); /* create all objects */ obj [0] = Ema_Object_Create (model_id, OBJ_NT_SUBNET_FIX); obj [1] = Ema_Object_Create (model_id, OBJ_NT_SUBNET_VIEW); obj [2] = Ema_Object_Create (model_id, OBJ_NT_SUBNET_FIX); obj [3] = Ema_Object_Create (model_id, OBJ_NT_SUBNET_VIEW); //obj [4] = Ema_Object_Create (model_id, OBJ_NT_NODE_MOBILE); obj [5] = Ema_Object_Create (model_id, OBJ_NT_ISO_ELEV_MAP_COLOR_SETTING); obj [6] = Ema_Object_Create (model_id, OBJ_NT_ISO_ELEV_MAP_COLOR_SETTING); obj [7] = Ema_Object_Create (model_id, OBJ_NT_ISO_ELEV_MAP_COLOR_SETTING); obj [8] = Ema_Object_Create (model_id, OBJ_NT_ISO_ELEV_MAP_COLOR_SETTING); obj [9] = Ema_Object_Create (model_id, OBJ_NT_ISO_ELEV_MAP_COLOR_SETTING); /* set the model level attributes */ /* create and init prg list 'prg_lptr [0]' */ prg_lptr [0] = (Prg_List *)prg_list_create (); /* create and init prg list 'prg_lptr [1]' */ prg_lptr [1] = (Prg_List *)prg_list_create (); prg_list_strings_append (prg_lptr [1], "custom_model_list", "internet_toolbox", PRGC_NIL); /* create and init prg list 'prg_lptr [2]' */ prg_lptr [2] = (Prg_List *)prg_list_create (); Ema_Model_Attr_Set (model_id, "ext fileset", COMP_CONTENTS, prg_lptr [0], "keywords list", COMP_CONTENTS, prg_lptr [1], "view subnet", COMP_CONTENTS, obj [2], "iso elev map color levels",COMP_ARRAY_CONTENTS (0), obj [5], "iso elev map color levels",COMP_ARRAY_CONTENTS (1), obj [6], "iso elev map color levels",COMP_ARRAY_CONTENTS (2), obj [7], "iso elev map color levels",COMP_ARRAY_CONTENTS (3), obj [8], "iso elev map color levels",COMP_ARRAY_CONTENTS (4), obj [9], "iso elev map label color",COMP_CONTENTS, 0, "view index list", COMP_CONTENTS, prg_lptr [2], EMAC_EOL); /* assign attrs for object 'obj [0]' */ /* create and init prg list 'prg_lptr [3]' */ prg_lptr [3] = (Prg_List *)prg_list_create (); Ema_Object_Attr_Set (model_id, obj [0], "name", COMP_CONTENTS, "top", "name", COMP_USER_INTENDED, EMAC_ENABLED, "x position", COMP_CONTENTS, (double) 0, "x position", COMP_USER_INTENDED, EMAC_ENABLED, "y position", COMP_CONTENTS, (double) 0, "y position", COMP_USER_INTENDED, EMAC_ENABLED, "x span", COMP_CONTENTS, (double) 360, "x span", COMP_USER_INTENDED, EMAC_ENABLED, "y span", COMP_CONTENTS, (double) 180, "y span", COMP_USER_INTENDED, EMAC_ENABLED, "icon name", COMP_CONTENTS, "subnet", "icon name", COMP_INTENDED, EMAC_DISABLED, "map", COMP_CONTENTS, "world", "map", COMP_USER_INTENDED, EMAC_ENABLED, "subnet", COMP_CONTENTS, EMAC_NULL_OBJ_ID, "view stack", COMP_ARRAY_CONTENTS (0), obj [1], EMAC_EOL); Ema_Object_Attr_Set (model_id, obj [0], "grid unit", COMP_CONTENTS, 5, "ui status", COMP_CONTENTS, 0, "iso-elev-map list", COMP_CONTENTS, prg_lptr [3], "iso-elev-map line threshold",COMP_CONTENTS, (double) 50, "view", COMP_CONTENTS, "Default View", "view mode", COMP_CONTENTS, 0, "view positions", COMP_INTENDED, EMAC_DISABLED, EMAC_EOL); /* assign attrs for object 'obj [2]' */ /* create and init prg list 'prg_lptr [4]' */ prg_lptr [4] = (Prg_List *)prg_list_create (); Ema_Object_Attr_Set (model_id, obj [2], "name", COMP_CONTENTS, "Campus Network", "name", COMP_USER_INTENDED, EMAC_ENABLED, "user id", COMP_CONTENTS, 0, "user id", COMP_USER_INTENDED, EMAC_ENABLED, "x position", COMP_CONTENTS, (double) 0, "x position", COMP_USER_INTENDED, EMAC_ENABLED, "y position", COMP_CONTENTS, (double) 0, "y position", COMP_USER_INTENDED, EMAC_ENABLED, "x span", COMP_CONTENTS, (double) 5.54715743194246, "x span", COMP_USER_INTENDED, EMAC_ENABLED, "y span", COMP_CONTENTS, (double) 35.9326113647809, "y span", COMP_USER_INTENDED, EMAC_ENABLED, "priority", COMP_CONTENTS, 0, "priority", COMP_USER_INTENDED, EMAC_ENABLED, "outline color", COMP_CONTENTS, 3, "outline color", COMP_USER_INTENDED, EMAC_ENABLED, EMAC_EOL); Ema_Object_Attr_Set (model_id, obj [2], "icon name", COMP_CONTENTS, "subnet", "icon name", COMP_INTENDED, EMAC_DISABLED, "icon name", COMP_USER_INTENDED, EMAC_ENABLED, "map", COMP_CONTENTS, "NONE", "map", COMP_USER_INTENDED, EMAC_ENABLED, "subnet", COMP_CONTENTS, obj [0], "view stack", COMP_ARRAY_CONTENTS (0), obj [3], "grid unit", COMP_CONTENTS, 1, "ui status", COMP_CONTENTS, 0, "iso-elev-map list", COMP_CONTENTS, prg_lptr [4], "iso-elev-map line threshold",COMP_CONTENTS, (double) 50, "view", COMP_CONTENTS, "Default View", "view mode", COMP_CONTENTS, 0, "view positions", COMP_INTENDED, EMAC_DISABLED, EMAC_EOL); NodeNumber=0; for (k=1; k <= NODE_NUMBER; k++){ sprintf(node_name, "%d", k); /*节点依次命名" 0,1,2,3,....,NODE_NUMBER" */ sprintf(tra, "10ms_2_Real_SUMO_%d", k); /*节点轨迹依则以SUMO_To_OPNET_Trj.java最终生成的轨迹文件名称为准*/ PosChooseAgain = 1; while(PosChooseAgain == 1) /* 随机生成节点坐标*/ { x_pos= ((double)rand()/((double)(RAND_MAX) + (double)(1)))*(double)X_LENGTH + X_MIN; y_pos= ((double)rand()/((double)(RAND_MAX) + (double)(0)))*(double)Y_LENGTH + Y_MIN; for (i=0; i< NodeNumber; i++) { if (((NodeXList[i]- x_pos)*(NodeXList[i]- x_pos)+(NodeYList[i]- y_pos)*(NodeYList[i]- y_pos))< MIN_DISTANCE_2) { break; } } if(i == NodeNumber) { PosChooseAgain = 0; } } NodeNumber++; NodeXList[NodeNumber-1] = x_pos; NodeYList[NodeNumber-1] = y_pos; wsn_node_objid= Ema_Object_Create(model_id, OBJ_NT_NODE_MOBILE); /*创建一个节点*/ /*下面是刚才obj[4]的代码, 将其中节点名称和纵横坐标替换*/ Ema_Object_Attr_Set (model_id, wsn_node_objid, "name", COMP_CONTENTS, node_name, "name", COMP_USER_INTENDED, EMAC_ENABLED, "model", COMP_CONTENTS, "apr_node_model", "model", COMP_USER_INTENDED, EMAC_ENABLED, "x position", COMP_CONTENTS, (double) x_pos, "x position", COMP_USER_INTENDED, EMAC_ENABLED, "y position", COMP_CONTENTS, (double) y_pos, "y position", COMP_USER_INTENDED, EMAC_ENABLED, "trajectory", COMP_CONTENTS, tra, "trajectory", COMP_INTENDED, EMAC_DISABLED, "trajectory", COMP_USER_INTENDED, EMAC_ENABLED, "ground speed", COMP_CONTENTS, "", "ground speed", COMP_INTENDED, EMAC_DISABLED, "ground speed", COMP_USER_INTENDED, EMAC_ENABLED, "ascent rate", COMP_CONTENTS, "", "ascent rate", COMP_INTENDED, EMAC_DISABLED, EMAC_EOL); Ema_Object_Attr_Set (model_id, wsn_node_objid, "ascent rate", COMP_USER_INTENDED, EMAC_ENABLED, "color", COMP_CONTENTS, 1090519039, "color", COMP_INTENDED, EMAC_DISABLED, "color", COMP_USER_INTENDED, EMAC_ENABLED, "doc file", COMP_CONTENTS, "", "doc file", COMP_INTENDED, EMAC_DISABLED, "doc file", COMP_USER_INTENDED, EMAC_ENABLED, "subnet", COMP_CONTENTS, obj [2], "alias", COMP_INTENDED, EMAC_DISABLED, "tooltip", COMP_CONTENTS, "", "tooltip", COMP_INTENDED, EMAC_DISABLED, "tooltip", COMP_USER_INTENDED, EMAC_ENABLED, "ui status", COMP_CONTENTS, 512, "view positions", COMP_INTENDED, EMAC_DISABLED, EMAC_EOL); } /* assign attrs for object 'obj [1]' */ Ema_Object_Attr_Set (model_id, obj [1], "min x", COMP_CONTENTS, (double) -180, "min y", COMP_CONTENTS, (double) 90, "sbar x", COMP_CONTENTS, (double) 0, "sbar y", COMP_CONTENTS, (double) 0, "grid step", COMP_CONTENTS, (double) 15, "resolution", COMP_CONTENTS, (double) 2.5, "grid style", COMP_CONTENTS, 2, "grid color", COMP_CONTENTS, 21, EMAC_EOL); /* assign attrs for object 'obj [3]' */ Ema_Object_Attr_Set (model_id, obj [3], "min x", COMP_CONTENTS, (double) 0, "min y", COMP_CONTENTS, (double) 0, "sbar x", COMP_CONTENTS, (double) 0, "sbar y", COMP_CONTENTS, (double) 0, "grid step", COMP_CONTENTS, (double) 500, "resolution", COMP_CONTENTS, (double) 0.147503369652425, "grid style", COMP_CONTENTS, 2, "grid color", COMP_CONTENTS, 21, EMAC_EOL); /* assign attrs for object 'obj [5]' */ Ema_Object_Attr_Set (model_id, obj [5], "elevation", COMP_CONTENTS, (double) 1e+100, "color", COMP_CONTENTS, 1090519039, EMAC_EOL); /* assign attrs for object 'obj [6]' */ Ema_Object_Attr_Set (model_id, obj [6], "elevation", COMP_CONTENTS, (double) 5000, "color", COMP_CONTENTS, 1073741824, EMAC_EOL); /* assign attrs for object 'obj [7]' */ Ema_Object_Attr_Set (model_id, obj [7], "elevation", COMP_CONTENTS, (double) 3000, "color", COMP_CONTENTS, 1086806624, EMAC_EOL); /* assign attrs for object 'obj [8]' */ Ema_Object_Attr_Set (model_id, obj [8], "elevation", COMP_CONTENTS, (double) 1000, "color", COMP_CONTENTS, 1073745152, EMAC_EOL); /* assign attrs for object 'obj [9]' */ Ema_Object_Attr_Set (model_id, obj [9], "elevation", COMP_CONTENTS, (double) 1, "color", COMP_CONTENTS, 1079591136, EMAC_EOL); /* write the model to application-readable form */ Ema_Model_Write (model_id, "Test"); return 0; }
39.054237
117
0.59691
f445a7c87a2150f7f215bd4fed4255daf6b203ef
507
h
C
src/common/wbt_ssl.h
fcten/BitMQ
cef989bc8085db2d56767cdb90063a82cf528300
[ "BSD-3-Clause" ]
null
null
null
src/common/wbt_ssl.h
fcten/BitMQ
cef989bc8085db2d56767cdb90063a82cf528300
[ "BSD-3-Clause" ]
null
null
null
src/common/wbt_ssl.h
fcten/BitMQ
cef989bc8085db2d56767cdb90063a82cf528300
[ "BSD-3-Clause" ]
null
null
null
/* * File: wbt_ssl.h * Author: fcten * * Created on 2015年12月8日, 下午8:57 */ #ifndef __WBT_SSL_H__ #define __WBT_SSL_H__ #ifdef __cplusplus extern "C" { #endif #include <openssl/crypto.h> #include <openssl/ssl.h> #include <openssl/err.h> #include <openssl/rand.h> #include "../webit.h" wbt_status wbt_ssl_init(); wbt_status wbt_ssl_exit(); wbt_status wbt_ssl_on_conn( wbt_event_t *ev ); wbt_status wbt_ssl_on_close( wbt_event_t *ev ); #ifdef __cplusplus } #endif #endif /* __WBT_SSL_H__ */
15.363636
47
0.714004
566eaf43525a77e2ec288462a11388a220d4cbb5
1,071
h
C
ezio/io_service_context.h
oceancx/ezio
87107d2ab1a2c52625b89d490782dc1ffe5e7a5c
[ "MIT" ]
13
2018-08-20T10:37:24.000Z
2021-11-07T13:43:10.000Z
ezio/io_service_context.h
oceancx/ezio
87107d2ab1a2c52625b89d490782dc1ffe5e7a5c
[ "MIT" ]
5
2018-10-10T06:17:27.000Z
2019-12-17T02:53:51.000Z
ezio/io_service_context.h
oceancx/ezio
87107d2ab1a2c52625b89d490782dc1ffe5e7a5c
[ "MIT" ]
7
2018-10-09T07:28:45.000Z
2021-10-11T01:51:54.000Z
/* @ 0xCCCCCCCC */ #ifndef EZIO_IO_SERVICE_CONTEXT_H_ #define EZIO_IO_SERVICE_CONTEXT_H_ #include "kbase/basic_macros.h" #if defined(OS_POSIX) #include "ezio/ignore_sigpipe.h" #elif defined(OS_WIN) #include "ezio/winsock_context.h" #endif namespace ezio { // Users of ezio must first call IOServiceContext::Init() to initialize the conceptual // io-service-context, which wraps global-wide components needed by each platform. // This class relies on kbase::AtExitManager for cleanup. class IOServiceContext { public: ~IOServiceContext() = default; DISALLOW_COPY(IOServiceContext); DISALLOW_MOVE(IOServiceContext); static void Init(); static const IOServiceContext& current(); #if defined(OS_WIN) const WinsockContext& AsWinsockContext() const noexcept { return winsock_context_; } #endif private: IOServiceContext(); private: #if defined(OS_WIN) WinsockContext winsock_context_; #elif defined(OS_POSIX) IgnoreSigPipe ignore_sigpipe_; #endif }; } // namespace ezio #endif // EZIO_IO_SERVICE_CONTEXT_H_
19.833333
86
0.747899
981d639b9dd17973e5da354c10d9aef8f9fcb3ed
1,072
h
C
include/retdec/llvmir2hll/var_renamer/var_renamers/simple_var_renamer.h
mehrdad-shokri/retdec
a82f16e97b163afe789876e0a819489c5b9b358e
[ "MIT", "Zlib", "BSD-3-Clause" ]
4,816
2017-12-12T18:07:09.000Z
2019-04-17T02:01:04.000Z
include/retdec/llvmir2hll/var_renamer/var_renamers/simple_var_renamer.h
mehrdad-shokri/retdec
a82f16e97b163afe789876e0a819489c5b9b358e
[ "MIT", "Zlib", "BSD-3-Clause" ]
514
2017-12-12T18:22:52.000Z
2019-04-16T16:07:11.000Z
include/retdec/llvmir2hll/var_renamer/var_renamers/simple_var_renamer.h
mehrdad-shokri/retdec
a82f16e97b163afe789876e0a819489c5b9b358e
[ "MIT", "Zlib", "BSD-3-Clause" ]
579
2017-12-12T18:38:02.000Z
2019-04-11T13:32:53.000Z
/** * @file include/retdec/llvmir2hll/var_renamer/var_renamers/simple_var_renamer.h * @brief A renamer of variable names which names them simply by using the * given variable name generator. * @copyright (c) 2017 Avast Software, licensed under the MIT license */ #ifndef RETDEC_LLVMIR2HLL_VAR_RENAMER_VAR_RENAMERS_SIMPLE_VAR_RENAMER_H #define RETDEC_LLVMIR2HLL_VAR_RENAMER_VAR_RENAMERS_SIMPLE_VAR_RENAMER_H #include <string> #include "retdec/llvmir2hll/support/smart_ptr.h" #include "retdec/llvmir2hll/var_renamer/var_renamer.h" namespace retdec { namespace llvmir2hll { /** * @brief A renamer of variable names which names them simply by using the * given variable name generator. * * Use create() to create instances. */ class SimpleVarRenamer: public VarRenamer { public: static ShPtr<VarRenamer> create(ShPtr<VarNameGen> varNameGen, bool useDebugNames = true); virtual std::string getId() const override; private: SimpleVarRenamer(ShPtr<VarNameGen> varNameGen, bool useDebugNames); }; } // namespace llvmir2hll } // namespace retdec #endif
26.8
79
0.784515
7161db9a4d9a30b52cab07162d7901d18b50b3c9
255
h
C
MR100AerialPhotography/AWLinkProtocol/AWProgressView.h
xzwgithub/MR100
57d3c873594274aebad9fab7743dc2d9f1c0b046
[ "MIT" ]
1
2019-09-11T06:34:22.000Z
2019-09-11T06:34:22.000Z
MR100AerialPhotography/AWLinkProtocol/AWProgressView.h
xzwgithub/MR100
57d3c873594274aebad9fab7743dc2d9f1c0b046
[ "MIT" ]
null
null
null
MR100AerialPhotography/AWLinkProtocol/AWProgressView.h
xzwgithub/MR100
57d3c873594274aebad9fab7743dc2d9f1c0b046
[ "MIT" ]
null
null
null
// // AWProgressView.h // MR100AerialPhotography // // Created by xzw on 17/8/7. // Copyright © 2017年 AllWinner. All rights reserved. // #import <UIKit/UIKit.h> @interface AWProgressView : UIView @property (nonatomic, assign) CGFloat progress; @end
18.214286
53
0.713725