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
d01ca2630dcfda1f73757462460fd21824592b89
258
c
C
src/main.c
yansyaf/cmake-c-cpp-library-template
cc2ffb3e56ef06d8b48d50b6695c4cacbae80253
[ "Apache-2.0" ]
1
2016-02-27T23:35:30.000Z
2016-02-27T23:35:30.000Z
src/main.c
yansyaf/cmake-c-cpp-library-template
cc2ffb3e56ef06d8b48d50b6695c4cacbae80253
[ "Apache-2.0" ]
null
null
null
src/main.c
yansyaf/cmake-c-cpp-library-template
cc2ffb3e56ef06d8b48d50b6695c4cacbae80253
[ "Apache-2.0" ]
null
null
null
#include <stdio.h> #include "func.h" int main(int argc, char *argv[]) { int a, b, c; if (argc < 2) return 1; //need two argument a = atoi(argv[1]); b = atoi(argv[2]); c = func(a, b); if (c == (a+b)) return 0; else return 1; }
11.727273
33
0.511628
40145cc5b000569a171bad7a1c8e2ba736747dab
294
c
C
hello-world/main.c
omelianlevkovych/c-more-than-hello-world
09f9806994a1c0cd6bd233af835454491a2a74d5
[ "MIT" ]
null
null
null
hello-world/main.c
omelianlevkovych/c-more-than-hello-world
09f9806994a1c0cd6bd233af835454491a2a74d5
[ "MIT" ]
null
null
null
hello-world/main.c
omelianlevkovych/c-more-than-hello-world
09f9806994a1c0cd6bd233af835454491a2a74d5
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> struct Pet { char name[50]; char breed[50]; int age; }; int main() { struct Pet pet; pet.age = 2; strcpy(pet.name, "Jeck"); strcpy(pet.breed, "French BDog"); printf("%s", strcat(pet.name, pet.breed)); return 0; }
12.25
46
0.561224
f4329efc41c0d2765bfee619a870baa94c560f7d
10,341
c
C
test/qs_ignore_sp/test_qs_ignore_sp.c
unpush/mod_chxj
b4dc76ad0f5c843c1b250fd0ee4c0616bbc39c48
[ "Apache-2.0" ]
1
2016-05-08T13:23:59.000Z
2016-05-08T13:23:59.000Z
test/qs_ignore_sp/test_qs_ignore_sp.c
unpush/mod_chxj
b4dc76ad0f5c843c1b250fd0ee4c0616bbc39c48
[ "Apache-2.0" ]
null
null
null
test/qs_ignore_sp/test_qs_ignore_sp.c
unpush/mod_chxj
b4dc76ad0f5c843c1b250fd0ee4c0616bbc39c48
[ "Apache-2.0" ]
null
null
null
#include <CUnit/CUnit.h> #include <CUnit/Console.h> #include <CUnit/Basic.h> #include <stdio.h> #define CHXJ_TEST #define IMG_NOT_CONVERT_FILENAME #include "apr.h" #include "apr_strings.h" #include "chxj_apache.h" #include "chxj_str_util.h" #include "chxj_str_util.c" #include "qs_ignore_sp.c" #include "qs_log.c" #include "qs_malloc.c" #include "qs_parse_string.c" #include "qs_parse_attr.c" #include "qs_parse_tag.c" #include <iconv.h> /*===========================================================================*/ /* qs_ignore_sp() */ /*===========================================================================*/ void test_qs_ignore_sp_001(); void test_qs_ignore_sp_002(); void test_qs_ignore_sp_003(); void test_qs_ignore_sp_004(); void test_qs_ignore_sp_005(); void test_qs_ignore_sp_006(); void test_qs_ignore_sp_007(); void test_qs_ignore_sp_008(); void test_qs_ignore_sp_009(); /*===========================================================================*/ /* qs_ignore_sp_and_quote() */ /*===========================================================================*/ void test_qs_ignore_sp_and_quote_001(); void test_qs_ignore_sp_and_quote_002(); void test_qs_ignore_sp_and_quote_003(); void test_qs_ignore_sp_and_quote_004(); void test_qs_ignore_sp_and_quote_005(); void test_qs_ignore_sp_and_quote_006(); void test_qs_ignore_sp_and_quote_007(); void test_qs_ignore_sp_and_quote_008(); void test_qs_ignore_sp_and_quote_009(); void test_qs_ignore_sp_and_quote_010(); /* pend */ void test_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...) { va_list ap; fprintf(stderr, "ERROR LOG %s:%d ", file,line); va_start(ap, fmt); vfprintf(stderr, fmt,ap); va_end(ap); fprintf(stderr, "\n"); } void test_log_error(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...) { va_list ap; fprintf(stderr, "ERROR LOG %s:%d ", file,line); va_start(ap, fmt); vfprintf(stderr, fmt,ap); va_end(ap); fprintf(stderr, "\n"); } int main() { CU_pSuite str_util_suite; CU_initialize_registry(); str_util_suite = CU_add_suite("test qs_ignore_sp.c", NULL, NULL); /*=========================================================================*/ /* qs_ignore_sp() */ /*=========================================================================*/ CU_add_test(str_util_suite, "qs_ignore_sp() 001", test_qs_ignore_sp_001); CU_add_test(str_util_suite, "qs_ignore_sp() 002", test_qs_ignore_sp_002); CU_add_test(str_util_suite, "qs_ignore_sp() 003", test_qs_ignore_sp_003); CU_add_test(str_util_suite, "qs_ignore_sp() 004", test_qs_ignore_sp_004); CU_add_test(str_util_suite, "qs_ignore_sp() 005", test_qs_ignore_sp_005); CU_add_test(str_util_suite, "qs_ignore_sp() 006", test_qs_ignore_sp_006); CU_add_test(str_util_suite, "qs_ignore_sp() 007", test_qs_ignore_sp_007); CU_add_test(str_util_suite, "qs_ignore_sp() 008", test_qs_ignore_sp_008); CU_add_test(str_util_suite, "qs_ignore_sp() 009", test_qs_ignore_sp_009); /*=========================================================================*/ /* qs_ignore_sp_and_quote() */ /*=========================================================================*/ CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 001", test_qs_ignore_sp_and_quote_001); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 002", test_qs_ignore_sp_and_quote_002); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 003", test_qs_ignore_sp_and_quote_003); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 004", test_qs_ignore_sp_and_quote_004); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 005", test_qs_ignore_sp_and_quote_005); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 006", test_qs_ignore_sp_and_quote_006); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 007", test_qs_ignore_sp_and_quote_007); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 008", test_qs_ignore_sp_and_quote_008); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 009", test_qs_ignore_sp_and_quote_009); CU_add_test(str_util_suite, "qs_ignore_sp_and_quote() 010", test_qs_ignore_sp_and_quote_010); /* aend */ CU_basic_run_tests(); CU_cleanup_registry(); return(0); } #define APR_INIT \ apr_pool_t *p; \ Doc doc; \ do { \ apr_initialize(); \ apr_pool_create(&p, NULL); \ memset(&doc, 0, sizeof(Doc)); \ doc.pool = p; \ } \ while (0) #define APR_TERM \ do { \ apr_terminate(); \ } while (0) #define COOKIE_INIT(X) \ do { \ X.cookie_id = "test_cookie_id"; \ } while (0) \ #define SPEC_INIT(X) \ do { \ X.html_spec_type = CHXJ_SPEC_Chtml_1_0; \ } while (0) /*===========================================================================*/ /* qs_parse_attr() */ /*===========================================================================*/ #if 0 int qs_ignore_sp(Doc *UNUSED(doc), const char *s, int len) { int ii; char *sp; sp = (char *)s; for(ii=0; *sp && is_white_space(*sp) && ii<len; ii++, sp++) ; return (sp - s); } #endif void test_qs_ignore_sp_001() { #define TEST_STRING "a" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_002() { #define TEST_STRING " a" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 1); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_003() { #define TEST_STRING " a" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 3); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_004() { #define TEST_STRING "\t\n\ra" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 3); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_005() { #define TEST_STRING " a " int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 1); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_006() { #define TEST_STRING "" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_007() { #define TEST_STRING NULL int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, 0); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_008() { #define TEST_STRING "abc" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, -1); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_009() { #define TEST_STRING "abc" int ret; APR_INIT; ret = qs_ignore_sp(&doc, TEST_STRING, 0); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } /*===========================================================================*/ /* qs_ignore_sp_and_quote() */ /*===========================================================================*/ #if 0 int qs_ignore_sp_and_quote(Doc *UNUSED(doc), const char *s, int len) { int ii; char *sp = (char *)s; for(ii=0; *sp && (is_white_space(*sp) || is_quote(*sp)) && ii<len; ii++, sp++) ; return (sp - s); } #endif void test_qs_ignore_sp_and_quote_001() { #define TEST_STRING "abc" int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_002() { #define TEST_STRING " abc" int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 1); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_003() { #define TEST_STRING " abc" int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 2); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_004() { #define TEST_STRING "\n\r\tabc" int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 3); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_005() { #define TEST_STRING "" int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_006() { #define TEST_STRING " " int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 3); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_007() { #define TEST_STRING " \" " int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 4); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_008() { #define TEST_STRING " ' " int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, sizeof(TEST_STRING)-1); CU_ASSERT(ret == 4); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_009() { #define TEST_STRING NULL int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, 0); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } void test_qs_ignore_sp_and_quote_010() { #define TEST_STRING "abc" int ret; APR_INIT; ret = qs_ignore_sp_and_quote(&doc, TEST_STRING, -1); CU_ASSERT(ret == 0); APR_TERM; #undef TEST_STRING } /* * vim:ts=2 et */
25.407862
124
0.600135
4871856545141a703b6cfe766124fd5886c59750
1,884
h
C
BigFishLib/bleptables.h
ThisIsNotRocketScience/Eurorack-KDS
1e8d76e1313cc910b9dcdf8811bec15de17489eb
[ "MIT" ]
16
2016-01-02T01:20:31.000Z
2021-10-05T17:45:36.000Z
BigFishLib/bleptables.h
ThisIsNotRocketScience/Eurorack-KDS
1e8d76e1313cc910b9dcdf8811bec15de17489eb
[ "MIT" ]
1
2017-04-21T14:25:31.000Z
2017-04-21T14:25:31.000Z
BigFishLib/bleptables.h
ThisIsNotRocketScience/Eurorack-KDS
1e8d76e1313cc910b9dcdf8811bec15de17489eb
[ "MIT" ]
9
2016-01-02T01:20:44.000Z
2022-02-02T03:51:33.000Z
/* * Copyright (C) 2011 by Lauri Koponen, lauri.koponen@iki.fi * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, UNICORN OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #pragma once typedef float zoh_sample_t; #include "mblep_44100.h" #include "mblep_48000.h" #include "mblep_88200.h" #include "mblep_96000.h" #include "mblep_176400.h" #include "mblep_192000.h" #define BLEPSTEPS 32 #define BLEPSAMPLES 32 #define BLEPLEN (BLEPSAMPLES * BLEPSTEPS) struct bleptable_entry { int sr; zoh_sample_t *data; } bleptables[] = { 44100, mblep_44100, 48000, mblep_48000, 88200, mblep_88200, 96000, mblep_96000, 176400, mblep_176400, 192000, mblep_192000, 0, NULL };
34.888889
79
0.759554
73aee8247c51e75b3178c5dd0d282df4bd175cd0
1,501
h
C
src/query_engine/test/query_test.h
sysbot/contrail-controller
893de3e41aa7b8e40092fba4a5da34284f5ee00f
[ "Apache-2.0" ]
1
2015-11-08T07:28:10.000Z
2015-11-08T07:28:10.000Z
src/query_engine/test/query_test.h
sysbot/contrail-controller
893de3e41aa7b8e40092fba4a5da34284f5ee00f
[ "Apache-2.0" ]
null
null
null
src/query_engine/test/query_test.h
sysbot/contrail-controller
893de3e41aa7b8e40092fba4a5da34284f5ee00f
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ #ifndef QUERY_TEST_H_ #define QUERY_TEST_H_ #include "base/logging.h" #include <boost/assign/list_of.hpp> #include <exception> #include <boost/lexical_cast.hpp> #include <boost/bind.hpp> #include <boost/assign/list_of.hpp> #include "base/task.h" #include "base/parse_object.h" #include "io/event_manager.h" #include "sandesh/sandesh_types.h" #include "sandesh/sandesh.h" #include "sandesh/sandesh_session.h" #include "query.h" #include "cdb_if.h" class CdbIfMock : public CdbIf { public: CdbIfMock(boost::asio::io_service *ioservice, GenDb::GenDbIf::DbErrorHandler handler) : CdbIf(ioservice, handler, "127.0.0.1", 9160) { initialize_tables(); }; ~CdbIfMock() { MessageTable.clear();} bool Db_Init(); bool Db_AddSetTablespace(const std::string& tablespace); bool Db_GetRangeSlices(std::vector<GenDb::Column>&,const GenDb::Cf&, const GenDb::ColumnRange&, const GenDb::RowKeyRange&); bool Db_GetMultiRow(std::map<std::string, std::vector<GenDb::ColElement> >& ret, const std::string& cfname, const std::vector<std::string>& key); private: void initialize_tables(); std::vector<std::map<std::string, std::string> > MessageTable; // return data for a particular MessageTable index bool Db_GetStringIndexRange(std::string index_field, std::vector<GenDb::Column>&,const GenDb::Cf&, const GenDb::ColumnRange&, const GenDb::RowKeyRange&); }; #endif
31.93617
157
0.710859
214afc45abe13e6d884a33110e6e2dfb9cd3517a
8,422
c
C
student-distrib/keyboard.c
rishabnathan/LinuxOperatingSystem
7153c57e7d989f7c769e943c9a8139244f8b09bb
[ "AFL-1.1" ]
null
null
null
student-distrib/keyboard.c
rishabnathan/LinuxOperatingSystem
7153c57e7d989f7c769e943c9a8139244f8b09bb
[ "AFL-1.1" ]
null
null
null
student-distrib/keyboard.c
rishabnathan/LinuxOperatingSystem
7153c57e7d989f7c769e943c9a8139244f8b09bb
[ "AFL-1.1" ]
null
null
null
/* * keyboard.c --> functions for the Keyboard */ #include "keyboard.h" #include "terminal.h" #include "i8259.h" #include "lib.h" volatile uint8_t isShift; volatile uint8_t isCaps; static uint8_t isAlt; volatile uint8_t isCtrl; volatile uint8_t isTab; // arrays to translate hexadecimal values from keyboard to characters static uint8_t scancodes00[NUM_KEYS] = {'\0', '\0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\0', '\0', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\0', '\0', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l' , ';', '\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm',',', '.', '/', '\0', '*', '\0', ' ', '\0'}; static uint8_t scancodes01[NUM_KEYS] = {'\0', '\0', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\0', '\0', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\0', '\0', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L' , ':', '"', '~', '\0', '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '\0', '*', '\0', ' ', '\0'}; static uint8_t scancodes10[NUM_KEYS] = {'\0', '\0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\0', '\0', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', '\0', '\0', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L' , ';', '\'', '`', '\0', '\\', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', '\0', '*', '\0', ' ', '\0'}; static uint8_t scancodes11[NUM_KEYS] = {'\0', '\0', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\0', '\0', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '{', '}', '\0', '\0', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l' , ':', '"', '~', '\0', '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '<', '>', '?', '\0', '*', '\0', ' ', '\0'}; /* initialize_keyboard * * DESCRIPTION: Initialization for keyboard * INPUTS: NONE * OUTPUTS: NONE * SIDE EFFECTS: enables interrupt on pic */ void initialize_keyboard(){ enable_irq(KEYBOARD_IRQ); //enables keyboard on pic keyboard_buffer = terminals[active_terminal_id].buf; buffer_clear(); } /* keyboard_handler * * DESCRIPTION: handles keyboard interrupts, gets data from keyboard * INPUTS: NONE * OUTPUTS: NONE * SIDE EFFECTS: sends keyboard data to be translated to char */ void keyboard_handler(){ cli(); disable_irq(KEYBOARD_IRQ); sti(); uint8_t input = 0; input = inb(KEYBOARD_PORTNUM) & 0xFF; //get data from keyboard and masking for lower 8 bits cli(); enable_irq(KEYBOARD_IRQ); sti(); send_eoi(KEYBOARD_IRQ); //end of interrupt signal if(input == LEFTSHIFTD || input == RIGHTSHIFTD){ //check is left shift or right shift are pressed down isShift = 1; } else if(input == LEFTSHIFTU || input == RIGHTSHIFTU){ //check is left shift or right shift are pressed up isShift = 0; } else if(input == CAPS){ //check if caps is toggled if(isCaps == 1){ //toggle caps isCaps = 0; } else { isCaps = 1; } } else if(input == BACKSPACE){ //check if backspace backspace_handler(); } else if(input == ENTER){ //check if enter enter_handler(); } else if(input == CTRLD){ //check if ctrl press downed isCtrl = 1; } else if(input == CTRLU){ //check if ctrl press up isCtrl = 0; } else if(input == ALTD){ //check if alt pressed down isAlt = 1; } else if(input == ALTU){ //check if alt pressed up isAlt = 0; } else if(input == F1){ if(isAlt == 1){ switch_terminals(active_terminal_id, 0); //putc('h'); } } else if(input == F2){ if(isAlt == 1){ switch_terminals(active_terminal_id, 1); } } else if(input == F3){ if(isAlt == 1){ switch_terminals(active_terminal_id, 2); } } else { if(input == 0x0F){ //0x0F is ascii value for tab, replace input with space value input = 0x39; //0x39 is space value } get_char(input); //helper function to get char } } /* get_char * * DESCRIPTION: helper function to access scancodes array * INPUTS: NONE * OUTPUTS: NONE * SIDE EFFECTS: NONE */ void get_char(uint8_t scancode_data){ uint8_t temp_terminal_id = 0; //if hex value is outside of array, do nothing if (scancode_data >= NUM_KEYS){ return; } //get char to be echoed uint8_t character; if(isCaps == 0 && isShift == 0){ //char is obtaineed based off shift and caps buttons character = scancodes00[scancode_data]; } else if(isCaps == 0 && isShift == 1){ character = scancodes01[scancode_data]; } else if(isCaps == 1 && isShift == 0){ character = scancodes10[scancode_data]; } else if(isCaps == 1 && isShift == 1){ character = scancodes11[scancode_data]; } if (character == NULL){ //dont do anything with null bytes return; } if(isCtrl == 1){ //clear screen if ctrl+l or ctrl+L if(character == 'l' || character == 'L'){ cli(); temp_terminal_id = curr_terminal_id; curr_terminal_id = active_terminal_id; shell_clear(); curr_terminal_id = temp_terminal_id; sti(); //set_screen_position(0,0,0); } else if (character == 'c'){ //quit with ctrl+c return; } } else if(bufferIndex < BUFFER_SIZE - 1){ buffer_insert(character); //add char to buffer cli(); temp_terminal_id = curr_terminal_id; curr_terminal_id = active_terminal_id; putc(character); //echoes to screen curr_terminal_id = temp_terminal_id; sti(); } return; } /* buffer_clear() * * DESCRIPTION: helper function to clear keyboard_buffer * INPUTS: NONE * OUTPUTS: NONE * SIDE EFFECTS: clears keyboard buffer */ void buffer_clear(){ uint8_t i; for(i = 0; i < BUFFER_SIZE - 1; i++){ keyboard_buffer[i] = '\0'; //puts empty space in buffer } bufferIndex = 0; } /* buffer_insert * * DESCRIPTION: inserts character into repsective terminal keyboard buffer * INPUTS: character, char to be inserted * OUTPUTS: NONE * SIDE EFFECTS: keyboard buffer and buffer index is updated */ void buffer_insert(uint8_t character){ if(bufferIndex < BUFFER_SIZE - 1){ if(bufferIndex == 80){ //if buffer reaches right side of screen (80), scroll up //keyboard_buffer[bufferIndex++] = '\n'; //putc('\n'); //vertical_scroll(); } keyboard_buffer[bufferIndex] = character; bufferIndex++; } } /* enter_handler() * * DESCRIPTION: helper function that handles enter key * INPUTS: NONE * OUTPUTS: NONE * SIDE EFFECTS: adds newline to buffer */ void enter_handler(){ uint8_t temp_terminal_id = 0; temp_terminal_id = curr_terminal_id; curr_terminal_id = active_terminal_id; putc('\0'); //set screen when enter is pressed curr_terminal_id = temp_terminal_id; sti(); if(keyboard_buffer[0] != '\0'){ keyboard_buffer[bufferIndex++] = '\n'; //adds newline to buffer } uint8_t i; for(i = bufferIndex; i < BUFFER_SIZE; i++){ keyboard_buffer[i] = '\0'; //puts empty space in buffer } terminals[active_terminal_id].E_flag = 1; cli(); temp_terminal_id = curr_terminal_id; curr_terminal_id = active_terminal_id; set_screen_position(0, 0, 1); //set screen when enter is pressed curr_terminal_id = temp_terminal_id; sti(); bufferIndex = 0; //clearing buffer } /* backspace_handler() * * DESCRIPTION: helper function that handles backspace key * INPUTS: NONE * OUTPUTS: NONE * SIDE EFFECTS: clears last index, decrements buffer index */ void backspace_handler(){ if(bufferIndex > 0){ //handle backspace on terminal to remove character from screen backspace(); bufferIndex--; keyboard_buffer[bufferIndex] = '\0'; } }
30.18638
123
0.518879
f604c7f125463d4d391e0f96cc630a5ad4ff2b3d
250
h
C
CMWAFSManager/CMWAFSManager/Misc/SegueBetweenEmbedded.h
Deadpikle/CMWAFSManager
90a79fef1ce00c5839420a9bf88ca5c7e3e91e0c
[ "MIT" ]
2
2018-05-01T09:03:14.000Z
2020-12-23T21:18:25.000Z
CMWAFSManager/CMWAFSManager/Misc/SegueBetweenEmbedded.h
Deadpikle/CMWAFSManager
90a79fef1ce00c5839420a9bf88ca5c7e3e91e0c
[ "MIT" ]
1
2017-08-22T16:46:38.000Z
2017-08-22T17:00:22.000Z
CMWAFSManager/CMWAFSManager/Misc/SegueBetweenEmbedded.h
Deadpikle/CMWAFSManager
90a79fef1ce00c5839420a9bf88ca5c7e3e91e0c
[ "MIT" ]
null
null
null
// // SegueBetweenEmbedded.h // SampleContainerViewUse // // Created by School of Computing Macbook on 3/29/17. // Copyright © 2017 CIRC. All rights reserved. // #import <Cocoa/Cocoa.h> @interface SegueBetweenEmbedded : NSStoryboardSegue @end
17.857143
54
0.732
1fd3648072a022c0d2ef794456bdfafb39919a74
787
c
C
src/arch/x86_64/kernel/panic.c
malbx/willOS
ebda1e15515aa0f6c83596995513fe23b0410279
[ "MIT" ]
229
2017-05-22T16:48:19.000Z
2021-11-18T18:43:03.000Z
src/arch/x86_64/kernel/panic.c
malbx/willOS
ebda1e15515aa0f6c83596995513fe23b0410279
[ "MIT" ]
95
2017-05-22T16:35:44.000Z
2021-11-17T22:28:36.000Z
src/arch/x86_64/kernel/panic.c
malbx/willOS
ebda1e15515aa0f6c83596995513fe23b0410279
[ "MIT" ]
28
2017-05-23T16:06:42.000Z
2021-11-15T07:15:15.000Z
#include "panic.h" #include <core/isr.h> #include <drivers/vga_text.h> #include <stdio.h> void kernel_panic(const char* format, ...) { printf("\033[0;31m"); va_list arg; va_start(arg, format); vprintf(format, arg); va_end(arg); kernel_dump_stacktrace(); printf("\n\n%45s\033[0m", "SYSTEM HALTED!"); vga_text_disable_cursor(); isr_disable_interrupts(); while (1) { __asm__("hlt"); } } void kernel_dump_stacktrace() { printf("\n Kernel stacktrace:\n\n"); DEBUG("%s", "kernel stacktrace:"); stack_frame_t* stackframe = NULL; __asm__("movq %%rbp, %0" : "=r"(stackframe)); while (stackframe != NULL) { uint64_t address = stackframe->rip; printf(" %p\n", address); DEBUG(" %p", address); stackframe = stackframe->rbp; } }
17.886364
47
0.628971
7937bcf796e79a99d1e0d6ef0def6356bada149f
87
c
C
contrib/gnu/gdb/dist/ld/testsuite/ld-ctf/slice.c
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
3
2021-05-04T17:09:06.000Z
2021-10-04T07:19:26.000Z
contrib/gnu/gdb/dist/ld/testsuite/ld-ctf/slice.c
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
null
null
null
contrib/gnu/gdb/dist/ld/testsuite/ld-ctf/slice.c
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
null
null
null
struct slices { int one : 1; int two : 2; int six : 6; int ten :10; } slices;
12.428571
15
0.54023
e843ae0e332232cbb59d1bf6b97f2d8ebda219b4
7,144
c
C
src/i2c_twi.c
mkm684/TMP102-driver
ef4c82853bdb147f47225dda2e4bac06382b4477
[ "BSD-2-Clause" ]
null
null
null
src/i2c_twi.c
mkm684/TMP102-driver
ef4c82853bdb147f47225dda2e4bac06382b4477
[ "BSD-2-Clause" ]
null
null
null
src/i2c_twi.c
mkm684/TMP102-driver
ef4c82853bdb147f47225dda2e4bac06382b4477
[ "BSD-2-Clause" ]
null
null
null
#include "i2c_twi.h" //I2C struct TMP102 *me; // intenral use /* equation SCL frequency (BR) = (F_CPU) / (16 + 2*TWBR * prescaler)*/ static void i2c_init_baud_rate(uint8_t buad_rate, uint8_t prescaler) { // SCL freq 50khz TWSR = 0x00; TWBR = 0x96; TWCR |= 1 << TWEN; } //TRANSMISSION static void i2c_write(uint8_t data[], int size) { // START BIT _i2cStart(); while (!(TWCR & (1<<TWINT))); if ((TWSR & 0xF8) != START && (TWSR & 0xF8) != REPEATED_START) _error_check(0); // no specfifc error case // TRANSMIT ADDRESS TWDR = (me->addr << 1) & 0xFE; _i2cReply(); while (!(TWCR & (1<<TWINT))); _i2cStatus(MT_SLA_ACK, MT_SLA_NOACK); // TRANSMIT DATA int i = 0; while(i < size){ TWDR = data[i]; _i2cReply(); while (!(TWCR & (1<<TWINT))); _i2cStatus(MT_SLA_DATA_ACK, MT_SLA_DATA_NOACK); i++; } // STOP _i2cStop(); } static double i2c_read(uint8_t reg_addr, uint8_t *pbyte) { // POINT _i2c_point(reg_addr); // START BIT _i2cStart(); while (!(TWCR & (1<<TWINT))); if ((TWSR & 0xF8) != START && (TWSR & 0xF8) != REPEATED_START) _error_check(0); // no specfifc error case // TRANSMIT ADDRESS TWDR = (me->addr << 1) | 0x01; _i2cReply(); while (!(TWCR & (1<<TWINT))); _i2cStatus(MT_SLA_ACK_R, MT_SLA_NOACK_R); // GET DATA uint8_t bytes_num = 0; while (bytes_num < 2) { _i2cReply(); while (!(TWCR & (1<<TWINT))); pbyte[bytes_num] = (uint8_t)TWDR; if ((TWSR & 0xF8) != MT_SLA_DATA_ACK_R && (TWSR & 0xF8) != MT_SLA_DATA_ACK_REP_R) _error_check(MT_SLA_DATA_NOACK_R); bytes_num++; } // STOP _i2cStop(); uint16_t temprature = me->cal_temp(pbyte); return (double)temprature/100; } static bool alert(void) { uint8_t curr_conf[2]; i2c_read(CONFIG_REG, curr_conf); if (curr_conf[1] & (1 << AL)) { return true; } return false; } //CONFIG static void config_bit(ConfigBit_t bit, bool val) { uint8_t curr_conf[2]; i2c_read(CONFIG_REG, curr_conf); if (bit == AL){ strcpy(me->ErrPtr, "Err: Write to AL read-only bit\n"); return; } uint8_t data[3] = {CONFIG_REG, curr_conf[0], curr_conf[1]}; if (bit > 7) { if (val) { data[1] |= (1<<bit-8); } else { data[1] &= ~(1<<bit-8); } } else { if(val){ data[2] |= (1<<bit); } else { data[2] &= ~(1<<bit); } } i2c_write(data, 3); if (bit == EM) me->em = val; else if (bit == POL) me->local_POL = val; else if (bit == TM) me->local_ISR = val; } //0:0.25hz static void config_conv_rate(uint8_t val) { if (val == 0) { // 0.25 hz config_bit(R0, false); config_bit(R1, false); }else if(val == 1) { // 1 hz config_bit(R0, false); config_bit(R1, true); }else if(val == 4) { // 4 hz config_bit(R0, true); config_bit(R1, false); }else if(val == 8) { // 8 hz config_bit(R0, true); config_bit(R1, true); }else{ strcpy(me->ErrPtr, "Err: Invalid conv rate mode\n"); } } static void config_faults(uint8_t val) { if (val == 1) { // 1 fault config_bit(F0, false); config_bit(F1, false); }else if(val == 2){ // 2 fault config_bit(F0, false); config_bit(F1, true); }else if(val == 4){ // 4 fault config_bit(F0, true); config_bit(F1, false); }else if(val == 8){ // 8 fault config_bit(F0, true); config_bit(F1, true); }else{ strcpy(me->ErrPtr, "Err: Invalid config fault mode\n"); } } //T_HIGH and T_LOW static void config_THIGH(double temp) { int16_t data = temp * 16; if (me->em){ data = data << 3; } else { data = data << 4; } uint8_t buffer[3] = {THIGH_REG, (uint8_t)(data >> 8), (uint8_t)(data & 0xFF)}; me->i2c_write(buffer, 3); } static void config_TLOW(double temp) { int16_t data = temp * 16; if (me->em){ data = data << 3; } else { data = data << 4; } uint8_t buffer[3] = {TLOW_REG, (uint8_t)(data >> 8), (uint8_t)(data & 0xFF)}; me->i2c_write(buffer, 3); } static uint16_t cal_temp(uint8_t byte[]) { uint16_t data; if (me->em){ data = ((uint16_t)byte[0] << 5) | (byte[1] >> 3); if (data > 0xFFF) data |= 0xF000; } else { data = ((uint16_t)byte[0] << 4) | (byte[1] >> 4); if (data > 0x7FF) data |= 0xF000; } return data* 6.25 ; } //private void _i2c_point(uint8_t reg_addr) { uint8_t data[1] ={reg_addr}; me->i2c_write(data, 1); } void _i2cStart(void) { TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWEA);//|(1<<TWIE); } void _i2cStop(void) { TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN)|(1<<TWEA);//|(1<<TWIE); } void _i2cReply(void) { TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA);//|(1<<TWIE); } void _i2cStatus(uint8_t expected, uint8_t error) { if ((TWSR & 0xF8) != expected) _error_check(error); } void _error_check(uint8_t error) { if ((TWSR & 0xF8) == error){ strcpy(me->ErrPtr, "Error NO_ACK: TWSR : "); }else{ strcpy(me->ErrPtr, "Err TWSR!=NO_ACK| TWSR: "); } // extract upper and lower nibbles from input value uint8_t upperNibble = (TWSR & 0xF0) >> 4; uint8_t lowerNibble = TWSR & 0x0F; // convert nibble to its ASCII hex equivalent upperNibble += upperNibble > 9 ? 'A' - 10 : '0'; lowerNibble += lowerNibble > 9 ? 'A' - 10 : '0'; //put the error code in error pointer strcpy(me->ErrPtr+26, &upperNibble); strcpy(me->ErrPtr+27, &lowerNibble); } static void new(void* this, uint8_t address, bool extended_mode) { //OBJ INIT char* temp_ptr = malloc(sizeof(char)*MAX_SIZE_STR + 1); strcpy(temp_ptr, ""); // init error to empty string // me = malloc(sizeof(struct TMP102)); me = (struct TMP102*)this; me->em = extended_mode; me->local_ISR = false; // default me->local_POL = false; // default me->addr = address; me->ErrPtr = temp_ptr; me->i2c_init_baud_rate = &i2c_init_baud_rate; me->i2c_write = &i2c_write; me->i2c_read = &i2c_read; me->alert = &alert; me->config_bit = &config_bit; me->config_conv_rate = &config_conv_rate; me->config_faults = &config_faults; me->config_THIGH = &config_THIGH; me->config_TLOW = &config_TLOW; me->cal_temp = &cal_temp; //EXT Interupt Enable; EICRA = 0x05; //Any logical change on INT0 and INT1 generates an interrupt request. EIMSK = 0x03; sei(); // return *me; } const struct TMP102Class TMP102={.new=&new};
25.790614
88
0.528835
e5f061566a6b52d477b31b2783fab33b5ee1174f
5,390
c
C
EfiLib/BdsHelper.c
startergo/NextLoader
af3389f09dfd966c4270a062de0d7389afbe0e00
[ "BSD-3-Clause" ]
null
null
null
EfiLib/BdsHelper.c
startergo/NextLoader
af3389f09dfd966c4270a062de0d7389afbe0e00
[ "BSD-3-Clause" ]
1
2021-03-25T18:58:06.000Z
2021-03-25T18:59:07.000Z
EfiLib/BdsHelper.c
startergo/NextLoader
af3389f09dfd966c4270a062de0d7389afbe0e00
[ "BSD-3-Clause" ]
null
null
null
/* * EfiLib/BdsHelper.c * Functions to call legacy BIOS API. * */ /** Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "BdsHelper.h" #include "legacy.h" #include "mystrings.h" #include "../loader/screen.h" #include "../loader/lib.h" #include "../include/refit_call_wrapper.h" EFI_GUID gEfiLegacyBootProtocolGuid = { 0xdb9a1e3d, 0x45cb, 0x4abb, { 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d }}; /** Internal helper function. Update the BBS Table so that devices of DeviceType have their boot priority updated to a high/bootable value. See "DeviceType values" in http://www.intel.com/content/dam/doc/reference-guide/efi-compatibility-support-module-specification-v097.pdf NOTE: This function should probably be refactored! Currently, all devices of type are enabled. This should be updated so that only a specific device is enabled. The wrong device could boot if there are multiple targets of the same type. @param DeviceType The device type that we wish to enable **/ VOID UpdateBbsTable (BDS_COMMON_OPTION *Option) { UINT16 Idx; EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; EFI_STATUS Status; UINT16 HddCount = 0; HDD_INFO *HddInfo = NULL; UINT16 BbsCount = 0; BBS_TABLE *LocalBbsTable = NULL; BBS_BBS_DEVICE_PATH *OptionBBS; CHAR16 Desc[100]; Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios); if (EFI_ERROR (Status) || (Option == NULL)) { return; } OptionBBS = (BBS_BBS_DEVICE_PATH *) Option->DevicePath; Status = refit_call5_wrapper(LegacyBios->GetBbsInfo, LegacyBios, &HddCount, &HddInfo, &BbsCount, &LocalBbsTable); // Print (L"\n"); // Print (L" NO Prio bb/dd/ff cl/sc Type Stat segm:offs\n"); // Print (L"=============================================\n"); for (Idx = 0; Idx < BbsCount; Idx++) { if(LocalBbsTable[Idx].DeviceType == 0) { continue; } BdsBuildLegacyDevNameString (&LocalBbsTable[Idx], Idx, sizeof (Desc), Desc); // Set devices of a particular type to BootPriority of 0 or 1. 0 is the highest priority. if (LocalBbsTable[Idx].DeviceType == OptionBBS->DeviceType) { if (MyStriCmp(Desc, Option->Description)) { // This entry exactly matches what we're looking for; make it highest priority LocalBbsTable[Idx].BootPriority = 0; } else { // This entry doesn't exactly match, but is the right disk type; make it a bit lower // in priority. Done mainly as a fallback in case of string-matching weirdness. LocalBbsTable[Idx].BootPriority = 1; } // if/else } else if (LocalBbsTable[Idx].BootPriority <= 1) { // Something's got a high enough boot priority to interfere with booting // our chosen entry, so bump it down a bit.... LocalBbsTable[Idx].BootPriority = 2; } // if/else if // Print ( // L" %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n", // (UINTN) Idx, // (UINTN) LocalBbsTable[Idx].BootPriority, // (UINTN) LocalBbsTable[Idx].Bus, // (UINTN) LocalBbsTable[Idx].Device, // (UINTN) LocalBbsTable[Idx].Function, // (UINTN) LocalBbsTable[Idx].Class, // (UINTN) LocalBbsTable[Idx].SubClass, // (UINTN) LocalBbsTable[Idx].DeviceType, // (UINTN) * (UINT16 *) &LocalBbsTable[Idx].StatusFlags, // (UINTN) LocalBbsTable[Idx].BootHandlerSegment, // (UINTN) LocalBbsTable[Idx].BootHandlerOffset, // (UINTN) ((LocalBbsTable[Idx].MfgStringSegment << 4) + LocalBbsTable[Idx].MfgStringOffset), // (UINTN) ((LocalBbsTable[Idx].DescStringSegment << 4) + LocalBbsTable[Idx].DescStringOffset) // ); // Print(L"%s\n", Desc); } // for // PauseForKey(); } /** Boot the legacy system with the boot option @param Option The legacy boot option which have BBS device path @retval EFI_UNSUPPORTED There is no legacybios protocol, do not support legacy boot. @retval EFI_STATUS Return the status of LegacyBios->LegacyBoot (). **/ EFI_STATUS BdsLibDoLegacyBoot ( IN BDS_COMMON_OPTION *Option ) { EFI_STATUS Status; EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios); if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } UpdateBbsTable(Option); return refit_call4_wrapper(LegacyBios->LegacyBoot, LegacyBios, (BBS_BBS_DEVICE_PATH *) Option->DevicePath, Option->LoadOptionsSize, Option->LoadOptions); }
38.5
124
0.632839
b26c367500b8b90ec7bb98891af9e69729275771
4,093
h
C
src/media/playback/mediaplayer/test/fakes/fake_audio.h
gnoliyil/fuchsia
a98c2d6ae44b7c485c2ee55855d0441da422f4cf
[ "BSD-2-Clause" ]
4
2020-02-23T09:02:06.000Z
2022-01-08T17:06:28.000Z
src/media/playback/mediaplayer/test/fakes/fake_audio.h
gnoliyil/fuchsia
a98c2d6ae44b7c485c2ee55855d0441da422f4cf
[ "BSD-2-Clause" ]
null
null
null
src/media/playback/mediaplayer/test/fakes/fake_audio.h
gnoliyil/fuchsia
a98c2d6ae44b7c485c2ee55855d0441da422f4cf
[ "BSD-2-Clause" ]
1
2021-08-23T11:33:57.000Z
2021-08-23T11:33:57.000Z
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SRC_MEDIA_PLAYBACK_MEDIAPLAYER_TEST_FAKES_FAKE_AUDIO_H_ #define SRC_MEDIA_PLAYBACK_MEDIAPLAYER_TEST_FAKES_FAKE_AUDIO_H_ #include <fuchsia/media/cpp/fidl.h> #include <memory> #include <queue> #include <vector> #include "lib/fidl/cpp/binding_set.h" #include "src/media/playback/mediaplayer/test/fakes/fake_audio_renderer.h" namespace media_player { namespace test { // Implements Audio for testing. class FakeAudio : public fuchsia::media::Audio { public: // Returns a request handler for binding to this fake service. fidl::InterfaceRequestHandler<fuchsia::media::Audio> GetRequestHandler() { return bindings_.GetHandler(this); } FakeAudioRenderer& renderer() { return fake_audio_renderer_; } // Audio implementation. void CreateAudioRenderer( fidl::InterfaceRequest<fuchsia::media::AudioRenderer> audio_renderer_request) override { fake_audio_renderer_.Bind(std::move(audio_renderer_request)); } void CreateAudioCapturer( fidl::InterfaceRequest<fuchsia::media::AudioCapturer> audio_capturer_request, bool loopback) override { FX_NOTIMPLEMENTED(); } private: fidl::BindingSet<fuchsia::media::Audio> bindings_; FakeAudioRenderer fake_audio_renderer_; }; class FakeAudioCore : public fuchsia::media::AudioCore { public: FakeAudioCore() { fake_audio_renderers_.emplace_back(std::make_unique<FakeAudioRenderer>()); } // Returns a request handler for binding to this fake service. fidl::InterfaceRequestHandler<fuchsia::media::AudioCore> GetRequestHandler() { return bindings_.GetHandler(this); } // Returns default/first renderer to be created FakeAudioRenderer& renderer() { return *fake_audio_renderers_.front(); } // Audio implementation. void CreateAudioRenderer( fidl::InterfaceRequest<fuchsia::media::AudioRenderer> audio_renderer_request) override { // Some tests create multiple renderers, so support that, although we don't currently expose a // way to expect packets on the later ones. if (fake_audio_renderers_.front()->is_bound()) { fake_audio_renderers_.emplace_back(std::make_unique<FakeAudioRenderer>()); } fake_audio_renderers_.back()->Bind(std::move(audio_renderer_request)); } void CreateAudioCapturerWithConfiguration( ::fuchsia::media::AudioStreamType stream_type, ::fuchsia::media::AudioCapturerConfiguration configuration, ::fidl::InterfaceRequest<::fuchsia::media::AudioCapturer> audio_capturer_request) override {} void CreateAudioCapturer( bool loopback, ::fidl::InterfaceRequest<::fuchsia::media::AudioCapturer> audio_in_request) override {} void EnableDeviceSettings(bool enabled) override {} void SetRenderUsageGain(::fuchsia::media::AudioRenderUsage usage, float gain_db) override {} void SetCaptureUsageGain(::fuchsia::media::AudioCaptureUsage usage, float gain_db) override {} void BindUsageVolumeControl( ::fuchsia::media::Usage usage, ::fidl::InterfaceRequest<::fuchsia::media::audio::VolumeControl> volume_control) override {} void GetVolumeFromDb(::fuchsia::media::Usage usage, float gain_db, GetVolumeFromDbCallback callback) override { // Value to check in test callback(0.5f); } void GetDbFromVolume(::fuchsia::media::Usage usage, float volume, GetDbFromVolumeCallback callback) override { // Value to check in test callback(-20.0f); } void SetInteraction(::fuchsia::media::Usage active, ::fuchsia::media::Usage affected, ::fuchsia::media::Behavior behavior) override {} void ResetInteractions() override {} void LoadDefaults() override {} private: fidl::BindingSet<fuchsia::media::AudioCore> bindings_; std::vector<std::unique_ptr<FakeAudioRenderer>> fake_audio_renderers_; }; } // namespace test } // namespace media_player #endif // SRC_MEDIA_PLAYBACK_MEDIAPLAYER_TEST_FAKES_FAKE_AUDIO_H_
35.284483
99
0.74493
209286a099083ed829016c5870ce905b085be55e
16,049
c
C
src/espgoodies/system.c
qtoggle/espqtoggle
265d5749975908403aa0f1b66148e0ee0c2bfa68
[ "Apache-2.0" ]
3
2020-05-01T20:26:22.000Z
2021-11-11T10:04:31.000Z
src/espgoodies/system.c
qtoggle/espqtoggle
265d5749975908403aa0f1b66148e0ee0c2bfa68
[ "Apache-2.0" ]
13
2020-04-19T22:28:31.000Z
2021-02-03T21:52:34.000Z
src/espgoodies/system.c
qtoggle/espqtoggle
265d5749975908403aa0f1b66148e0ee0c2bfa68
[ "Apache-2.0" ]
3
2019-07-27T15:08:09.000Z
2021-04-21T05:13:11.000Z
/* * Copyright 2019 The qToggle Team * * 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 <stdlib.h> #include <limits.h> #include <user_interface.h> #include <gpio.h> #include <os_type.h> #include "espgoodies/battery.h" #include "espgoodies/common.h" #include "espgoodies/dnsserver.h" #include "espgoodies/drivers/gpio.h" #include "espgoodies/flashcfg.h" #include "espgoodies/ota.h" #include "espgoodies/rtc.h" #include "espgoodies/tcpserver.h" #include "espgoodies/wifi.h" #include "espgoodies/system.h" #define RESET_DELAY 3000 /* Milliseconds */ #define SETUP_MODE_IDLE 0 #define SETUP_MODE_PRESSED 1 #define SETUP_MODE_TRIGGERED 2 #define SETUP_MODE_RESET 3 #define RTC_UNEXP_RESET_COUNT_ADDR RTC_USER_ADDR + 0 /* 130 * 4 bytes = 520 */ #define MAX_UNEXP_RESET_COUNT 16 #define TASK_QUEUE_SIZE 8 #define TASK_ID_SYSTEM_UPDATE 100 static int8 setup_button_pin = -1; static bool setup_button_level = FALSE; static uint8 setup_button_hold = 5; static uint8 setup_button_reset_hold = 20; static int8 status_led_pin = -1; static bool status_led_level = TRUE; static uint32 last_time_us = 0; static uint64 uptime_us = 0; static os_timer_t reset_timer; static system_reset_callback_t reset_callback = NULL; static system_reset_callback_t reset_factory_callback = NULL; static system_setup_mode_callback_t setup_mode_callback; static uint64 setup_mode_button_time_ms = 0; static uint8 setup_mode_state = SETUP_MODE_IDLE; static bool setup_mode = FALSE; static int8 setup_mode_ap_client_count = 0; static uint32 fw_version_int = 0; static os_event_t task_queue[TASK_QUEUE_SIZE]; static system_task_handler_t task_handler = NULL; static void ICACHE_FLASH_ATTR system_task(os_event_t *e); static void ICACHE_FLASH_ATTR update(void); static void ICACHE_FLASH_ATTR on_system_reset(void *arg); static void ICACHE_FLASH_ATTR on_setup_mode_ap_client(bool connected, ip_addr_t ip_address, uint8 *mac); void system_config_load(void) { /* Load system config from flash */ uint8 *config_data = zalloc(FLASH_CONFIG_SIZE_SYSTEM); flashcfg_load(FLASH_CONFIG_SLOT_SYSTEM, config_data); /* If config data is full of 0xFF, that usually indicates erased flash. Fill it with 0s in that case, which is what * we use for default config. */ uint16 i; bool erased = TRUE; for (i = 0; i < 32; i++) { if (config_data[i] != 0xFF) { erased = FALSE; break; } } if (erased) { DEBUG_SYSTEM("detected erased flash config"); memset(config_data, 0, FLASH_CONFIG_SIZE_SYSTEM); flashcfg_save(FLASH_CONFIG_SLOT_SYSTEM, config_data); } /* If config data is full of 0x00, that indicates default config */ bool null = TRUE; for (i = 0; i < 32; i++) { if (config_data[i] != 0) { null = FALSE; break; } } if (null) { DEBUG_SYSTEM("detected default flash config"); /* Leave settings as they are initialized */ } else { setup_button_pin = config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_PIN]; setup_button_level = config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_LEVEL]; setup_button_hold = config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_HOLD]; setup_button_reset_hold = config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_HOLDR]; status_led_pin = config_data[SYSTEM_CONFIG_OFFS_STATUS_LED_PIN]; status_led_level = config_data[SYSTEM_CONFIG_OFFS_STATUS_LED_LEVEL]; memcpy(&fw_version_int, config_data + SYSTEM_CONFIG_OFFS_FW_VERSION, 4); } #if defined(_DEBUG_SYSTEM) && defined(_DEBUG) version_t fw_version; system_get_fw_version(&fw_version); char *version_str = version_dump(&fw_version); DEBUG_SYSTEM("loaded FW version = %s", version_str); free(version_str); #endif DEBUG_SYSTEM( "loaded setup button: pin = %d, level = %d, hold = %d, reset_hold = %d", setup_button_pin, setup_button_level, setup_button_hold, setup_button_reset_hold ); DEBUG_SYSTEM("loaded status LED: pin = %d, level = %d", status_led_pin, status_led_level); #ifdef _BATTERY battery_config_load(config_data); #endif free(config_data); } void system_config_save(void) { /* Save system config to flash */ uint8 *config_data = zalloc(FLASH_CONFIG_SIZE_SYSTEM); flashcfg_load(FLASH_CONFIG_SLOT_SYSTEM, config_data); config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_PIN] = setup_button_pin; config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_LEVEL] = setup_button_level; config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_HOLD] = setup_button_hold; config_data[SYSTEM_CONFIG_OFFS_SETUP_BUTTON_HOLDR] = setup_button_reset_hold; config_data[SYSTEM_CONFIG_OFFS_STATUS_LED_PIN] = status_led_pin; config_data[SYSTEM_CONFIG_OFFS_STATUS_LED_LEVEL] = status_led_level; memcpy(config_data + SYSTEM_CONFIG_OFFS_FW_VERSION, &fw_version_int, 4); #ifdef _BATTERY battery_config_save(config_data); #endif flashcfg_save(FLASH_CONFIG_SLOT_SYSTEM, config_data); free(config_data); } void system_init(void) { if (setup_button_pin >= 0) { gpio_configure_input(setup_button_pin, !setup_button_level); if (gpio_read_value(setup_button_pin) == setup_button_level) { DEBUG_SYSTEM("setup button active at boot time, disabling"); setup_button_pin = -1; } } if (status_led_pin >= 0) { gpio_configure_output(status_led_pin, !status_led_level); } system_os_task(system_task, USER_TASK_PRIO_0, task_queue, TASK_QUEUE_SIZE); system_task_schedule(TASK_ID_SYSTEM_UPDATE, NULL); } void system_task_set_handler(system_task_handler_t handler) { task_handler = handler; } void system_task_schedule(uint32 task_id, void *param) { system_os_post(USER_TASK_PRIO_0, task_id, (os_param_t) param); } uint32 system_uptime(void) { /* Call system_uptime_us() to update the internal uptime value */ system_uptime_us(); return uptime_us / 1000000; } uint64 system_uptime_ms(void) { /* Call system_uptime_us() to update the internal uptime value */ system_uptime_us(); return uptime_us / 1000; } uint64 system_uptime_us(void) { int64 time = system_get_time(); if (time - last_time_us < -1000000) { /* Time overflow */ uptime_us += time + UINT_MAX - last_time_us; } else { uptime_us += time - last_time_us; } last_time_us = time; return uptime_us; } int system_get_flash_size(void) { return (1UL << ((spi_flash_get_id() >> 16) & 0xff)); } void system_reset(bool delayed) { if (reset_callback) { reset_callback(); } if (delayed) { DEBUG_SYSTEM("will reset in %d seconds", RESET_DELAY / 1000); os_timer_disarm(&reset_timer); os_timer_setfn(&reset_timer, on_system_reset, NULL); os_timer_arm(&reset_timer, RESET_DELAY, /* repeat = */ FALSE); } else { on_system_reset(NULL); } } void system_reset_set_callbacks(system_reset_callback_t callback, system_reset_callback_t factory_callback) { reset_callback = callback; reset_factory_callback = factory_callback; } void system_reset_callback(bool factory) { if (factory) { if (reset_factory_callback) { reset_factory_callback(); } } else { if (reset_callback) { reset_callback(); } } wifi_save_config(); /* This will save configuration only if changed */ rtc_reset(); } void system_check_reboot_loop(void) { struct rst_info *reset_info = system_get_rst_info(); uint32 unexp_reset_count; switch (reset_info->reason) { case REASON_DEFAULT_RST: DEBUG_SYSTEM("reset reason: %s", "power reboot"); break; case REASON_WDT_RST: DEBUG_SYSTEM("reset reason: %s", "hardware watchdog"); break; case REASON_EXCEPTION_RST: DEBUG_SYSTEM("reset reason: %s", "fatal exception"); break; case REASON_SOFT_WDT_RST: DEBUG_SYSTEM("reset reason: %s", "software watchdog"); break; case REASON_SOFT_RESTART: DEBUG_SYSTEM("reset reason: %s", "software reset"); break; case REASON_DEEP_SLEEP_AWAKE: DEBUG_SYSTEM("reset reason: %s", "deep-sleep wake"); break; case REASON_EXT_SYS_RST: DEBUG_SYSTEM("reset reason: %s", "hardware reset"); break; } if (reset_info->reason == REASON_WDT_RST || reset_info->reason == REASON_SOFT_WDT_RST || reset_info->reason == REASON_EXCEPTION_RST) { unexp_reset_count = rtc_get_value(RTC_UNEXP_RESET_COUNT_ADDR); DEBUG_SYSTEM("unexpected reset detected (count = %d)", unexp_reset_count); if (unexp_reset_count >= MAX_UNEXP_RESET_COUNT) { DEBUG_SYSTEM("too many unexpected resets, resetting configuration"); flashcfg_reset(FLASH_CONFIG_SLOT_DEFAULT); } unexp_reset_count++; } else { unexp_reset_count = 0; } rtc_set_value(RTC_UNEXP_RESET_COUNT_ADDR, unexp_reset_count); } void system_get_fw_version(version_t *version) { version_from_int(version, fw_version_int); } void system_set_fw_version(version_t *version) { fw_version_int = version_to_int(version); #if defined(_DEBUG_SYSTEM) && defined(_DEBUG) char *version_str = version_dump(version); DEBUG_SYSTEM("setting FW version = %s", version_str); free(version_str); #endif } void system_setup_button_set_config(int8 pin, bool level, uint8 hold, uint8 reset_hold) { DEBUG_SYSTEM( "configuring setup button: pin = %d, level = %d, hold = %d, reset_hold = %d", pin, level, hold, reset_hold ); setup_button_pin = pin; setup_button_level = level; setup_button_hold = hold; setup_button_reset_hold = reset_hold; if (setup_button_pin >= 0) { gpio_configure_input(setup_button_pin, !setup_button_level); } } void system_setup_button_get_config(int8 *pin, bool *level, uint8 *hold, uint8 *reset_hold) { *pin = setup_button_pin; *level = setup_button_level; *hold = setup_button_hold; *reset_hold = setup_button_reset_hold; } void system_status_led_set_config(int8 pin, bool level) { DEBUG_SYSTEM("configuring status LED: pin = %d, level = %d", pin, level); status_led_pin = pin; status_led_level = level; if (status_led_pin >= 0) { gpio_configure_output(status_led_pin, !status_led_level); } } void system_status_led_get_config(int8 *pin, bool *level) { *pin = status_led_pin; *level = status_led_level; } void system_setup_mode_set_callback(system_setup_mode_callback_t callback) { setup_mode_callback = callback; } bool system_setup_mode_active(void) { return setup_mode; } void system_setup_mode_toggle(bool external) { if (setup_mode) { DEBUG_SYSTEM("exiting setup mode (external = %d)", external); if (setup_mode_callback) { setup_mode_callback(FALSE, external); } system_reset(/* delayed = */ FALSE); } else { setup_mode = TRUE; DEBUG_SYSTEM("entering setup mode (external = %d)", external); char ssid[WIFI_SSID_MAX_LEN + 1]; snprintf(ssid, sizeof(ssid), DEFAULT_HOSTNAME, system_get_chip_id()); wifi_ap_enable(ssid, /* psk = */ NULL, on_setup_mode_ap_client); dnsserver_start_captive(); if (setup_mode_callback) { setup_mode_callback(TRUE, external); } } } bool system_setup_mode_has_ap_clients(void) { return setup_mode_ap_client_count > 0; } void system_task(os_event_t *e) { switch (e->sig) { case TASK_ID_SYSTEM_UPDATE: { /* Schedule next system update */ system_os_post(USER_TASK_PRIO_0, TASK_ID_SYSTEM_UPDATE, (os_param_t) NULL); update(); break; } default: { if (task_handler) { task_handler(e->sig, (void *) e->par); } } } } void update(void) { uint64 now_us = system_uptime_us(); uint64 now_ms = now_us / 1000; /* If system reset has been triggered, stop polling setup button/blinking status LED */ if (setup_mode_state == SETUP_MODE_RESET) { return; } /* Do a factory reset if setup button was held pressed enough */ if (setup_mode_button_time_ms > 0 && now_ms - setup_mode_button_time_ms > setup_button_reset_hold * 1000) { DEBUG_SYSTEM("resetting to factory defaults"); setup_mode_state = SETUP_MODE_RESET; if (reset_factory_callback) { reset_factory_callback(); } else { flashcfg_reset(FLASH_CONFIG_SLOT_DEFAULT); } wifi_reset(); system_reset(/* delayed = */ TRUE); return; } /* Enter setup mode if setup button was held pressed enough */ if (setup_mode_state == SETUP_MODE_PRESSED && now_ms - setup_mode_button_time_ms > setup_button_hold * 1000) { setup_mode_state = SETUP_MODE_TRIGGERED; system_setup_mode_toggle(/* external = */ TRUE); } /* Read setup mode pin state */ if (setup_button_pin >= 0) { bool value = gpio_read_value(setup_button_pin); if (value == setup_button_level && setup_mode_state == SETUP_MODE_IDLE) { DEBUG_SYSTEM("setup mode timer started"); setup_mode_button_time_ms = now_ms; setup_mode_state = SETUP_MODE_PRESSED; } else if (value != setup_button_level && setup_mode_state != SETUP_MODE_IDLE) { DEBUG_SYSTEM("setup mode timer reset"); setup_mode_button_time_ms = 0; setup_mode_state = SETUP_MODE_IDLE; } } /* Blink the status LED according to OTA state, setup mode and Wi-Fi connection */ if (status_led_pin >= 0) { int ota_state = ota_current_state(); bool ota_active = ota_state == OTA_STATE_DOWNLOADING || ota_state == OTA_STATE_RESTARTING; bool current_led_value = gpio_read_value(status_led_pin); bool new_led_value = current_led_value; if (ota_active || setup_mode) { new_led_value = (now_us * 7 / 1000000) % 2; } else { if (!wifi_station_is_connected()) { new_led_value = (now_us * 2 / 1000000) % 2; } else { new_led_value = !status_led_level; } } if (current_led_value != new_led_value) { gpio_write_value(status_led_pin, new_led_value); } } } void on_system_reset(void *arg) { DEBUG_SYSTEM("resetting"); wifi_save_config(); /* This will save configuration only if changed */ rtc_reset(); system_restart(); } void on_setup_mode_ap_client(bool connected, ip_addr_t ip_address, uint8 *mac) { if (connected) { setup_mode_ap_client_count++; } else { setup_mode_ap_client_count--; } DEBUG_SYSTEM("setup mode AP clients: %d", setup_mode_ap_client_count); }
30.110694
119
0.660913
7cb93491a9eaa73f0e88169f03fa3176def50d4d
7,901
h
C
benchmarks/src/cuda/oop-coal/PR/kernel.h
charitha22/asplos_2021_ae
cd9316a57ee4db85ba3ceaa362e839ab4075d0df
[ "BSD-2-Clause" ]
null
null
null
benchmarks/src/cuda/oop-coal/PR/kernel.h
charitha22/asplos_2021_ae
cd9316a57ee4db85ba3ceaa362e839ab4075d0df
[ "BSD-2-Clause" ]
null
null
null
benchmarks/src/cuda/oop-coal/PR/kernel.h
charitha22/asplos_2021_ae
cd9316a57ee4db85ba3ceaa362e839ab4075d0df
[ "BSD-2-Clause" ]
2
2021-07-21T23:52:36.000Z
2022-02-10T17:14:39.000Z
void initContext(GraphChiContext *context, int vertices, int edges) { context->setNumIterations(0); context->setNumVertices(vertices); context->setNumEdges(edges); } void part0_initObject(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col, int *inrow, int *incol, obj_alloc *alloc) { int tid = 0; for (tid = 0; tid < context->getNumVertices(); tid++) { vertex[tid] = (ChiVertex<float, float> *)alloc->calloc<ChiVertex<float, float> >(1); } } void part1_initObject(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col, int *inrow, int *incol, obj_alloc *alloc) { int tid = 0; for (tid = 0; tid < context->getNumVertices(); tid++) { // int out_start = row[tid]; // int out_end; // if (tid + 1 < context->getNumVertices()) { // out_end = row[tid + 1]; // } else { // out_end = context->getNumEdges(); // } // int in_start = inrow[tid]; // int in_end; // if (tid + 1 < context->getNumVertices()) { // in_end = inrow[tid + 1]; // } else { // in_end = context->getNumEdges(); // } // int indegree = in_end - in_start; // int outdegree = out_end - out_start; // vertex[tid].inEdgeDataArray = // (ChiEdge<myType> *)alloc->my_new<Edge<myType>>(indegree); // vertex[tid].outEdgeDataArray = // (ChiEdge<myType> **)alloc->my_new<Edge<myType> *>(outdegree); // new (&vertex[tid]) ChiVertex<int, int>(tid, indegree, outdegree,alloc); vertex[tid]->set_in_out(alloc); // vertex[tid].setValue(INT_MAX); // for (int i = in_start; i < in_end; i++) { // vertex[tid].setInEdge(i - in_start, incol[i], INT_MAX); // } // for (int i = out_start; i < out_end; i++) { // vertex[tid]->setOutEdge(vertex, tid, i - out_start, col[i], 0.0f); //} } } __global__ void part_kern0_initObject(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col, int *inrow, int *incol) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < context->getNumVertices()) { int out_start = row[tid]; int out_end; if (tid + 1 < context->getNumVertices()) { out_end = row[tid + 1]; } else { out_end = context->getNumEdges(); } int in_start = inrow[tid]; int in_end; if (tid + 1 < context->getNumVertices()) { in_end = inrow[tid + 1]; } else { in_end = context->getNumEdges(); } int indegree = in_end - in_start; int outdegree = out_end - out_start; new (vertex[tid]) ChiVertex<float, float>(tid, indegree, outdegree); } } __global__ void part_kern1_initObject(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col, int *inrow, int *incol) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < context->getNumVertices()) { // int out_start = row[tid]; // int out_end; // if (tid + 1 < context->getNumVertices()) { // out_end = row[tid + 1]; // } else { // out_end = context->getNumEdges(); // } int in_start = inrow[tid]; int in_end; if (tid + 1 < context->getNumVertices()) { in_end = inrow[tid + 1]; } else { in_end = context->getNumEdges(); } for (int i = in_start; i < in_end; i++) { vertex[tid]->setInEdge(i - in_start, incol[i], 0.0f); } } } __global__ void kern_initOutEdge(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < context->getNumVertices()) { int out_start = row[tid]; int out_end; if (tid + 1 < context->getNumVertices()) { out_end = row[tid + 1]; } else { out_end = context->getNumEdges(); } // int in_start = inrow[tid]; // int in_end; // if (tid + 1 < context->getNumVertices()) { // in_end = inrow[tid + 1]; //} else { // in_end = context->getNumEdges(); //} // int indegree = in_end - in_start; // int outdegree = out_end - out_start; // vertex[tid] = new ChiVertex<float, float>(tid, indegree, outdegree); // for (int i = in_start; i < in_end; i++) { // vertex[tid]->setInEdge(i - in_start, incol[i], 0.0f); //} for (int i = out_start; i < out_end; i++) { vertex[tid]->setOutEdge(vertex, tid, i - out_start, col[i], 0.0f); } } } __global__ void initObject(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col, int *inrow, int *incol) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < context->getNumVertices()) { int out_start = row[tid]; int out_end; if (tid + 1 < context->getNumVertices()) { out_end = row[tid + 1]; } else { out_end = context->getNumEdges(); } int in_start = inrow[tid]; int in_end; if (tid + 1 < context->getNumVertices()) { in_end = inrow[tid + 1]; } else { in_end = context->getNumEdges(); } int indegree = in_end - in_start; int outdegree = out_end - out_start; vertex[tid] = new ChiVertex<float, float>(tid, indegree, outdegree); for (int i = in_start; i < in_end; i++) { vertex[tid]->setInEdge(i - in_start, incol[i], 0.0f); } // for (int i = out_start; i < out_end; i++) { // vertex[tid]->setOutEdge(vertex, tid, i - out_start, col[i], 0.0f); //} } } __global__ void initOutEdge(ChiVertex<float, float> **vertex, GraphChiContext *context, int *row, int *col) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < context->getNumVertices()) { int out_start = row[tid]; int out_end; if (tid + 1 < context->getNumVertices()) { out_end = row[tid + 1]; } else { out_end = context->getNumEdges(); } // int in_start = inrow[tid]; // int in_end; // if (tid + 1 < context->getNumVertices()) { // in_end = inrow[tid + 1]; //} else { // in_end = context->getNumEdges(); //} // int indegree = in_end - in_start; // int outdegree = out_end - out_start; // vertex[tid] = new ChiVertex<float, float>(tid, indegree, outdegree); // for (int i = in_start; i < in_end; i++) { // vertex[tid]->setInEdge(i - in_start, incol[i], 0.0f); //} for (int i = out_start; i < out_end; i++) { vertex[tid]->setOutEdge(vertex, tid, i - out_start, col[i], 0.0f); } } } __managed__ range_tree_node *range_tree; __managed__ unsigned tree_size_g; __managed__ void *temp_copyBack; __managed__ void *temp_coal; __global__ void PageRank(ChiVertex<float, float> **vertex, GraphChiContext *context, int iteration) { int tid = blockDim.x * blockIdx.x + threadIdx.x; unsigned tree_size = tree_size_g; range_tree_node *table = range_tree; void **vtable2; if (tid < context->getNumVertices()) { if (iteration == 0) { vertex[tid]->setValue(1.0f); } else { float sum = 0.0f; int numInEdge; numInEdge = vertex[tid]->numInEdges(); for (int i = 0; i < numInEdge; i++) { ChiEdge<float> *inEdge; inEdge = vertex[tid]->getInEdge(i); vtable2 = get_vfunc(inEdge, table, tree_size); temp_coal = vtable2[1]; sum += inEdge->getValue(); } vertex[tid]->setValue(0.15f + 0.85f * sum); /* Write my value (divided by my out-degree) to my out-edges so neighbors * can read it. */ int numOutEdge; numOutEdge = vertex[tid]->numOutEdges(); float outValue = vertex[tid]->getValue() / numOutEdge; for (int i = 0; i < numOutEdge; i++) { ChiEdge<float> *outEdge; outEdge = vertex[tid]->getOutEdge(i); vtable2 = get_vfunc(outEdge, table, tree_size); temp_coal = vtable2[2]; outEdge->setValue(outValue); } } } } __global__ void copyBack(ChiVertex<float, float> **vertex, GraphChiContext *context, float *pagerank) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < context->getNumVertices()) { pagerank[tid] = vertex[tid]->getValue(); } }
30.624031
77
0.60448
0c63080dd403c2e3e67a70b027ac24d8704d0e3c
1,758
h
C
graph djikstra/cs250final.h
zlb323/Portfolio
f8c86790b274968c6971756b50db4454df48b079
[ "Apache-2.0" ]
null
null
null
graph djikstra/cs250final.h
zlb323/Portfolio
f8c86790b274968c6971756b50db4454df48b079
[ "Apache-2.0" ]
null
null
null
graph djikstra/cs250final.h
zlb323/Portfolio
f8c86790b274968c6971756b50db4454df48b079
[ "Apache-2.0" ]
null
null
null
#pragma once class Graph { private: int** adjacencyMatrix; int vertexCount; public: int getvertcount() { return vertexCount; } Graph(int vertexCount) { this->vertexCount = vertexCount; adjacencyMatrix = new int*[vertexCount]; for (int i = 0; i < vertexCount; i++) { adjacencyMatrix[i] = new int[vertexCount]; for (int j = 0; j < vertexCount; j++) adjacencyMatrix[i][j] =0; } } void addEdge(int i, int j, int weight) { if (i >= 0 && i < vertexCount && j > 0 && j < vertexCount) { adjacencyMatrix[i][j] = weight; adjacencyMatrix[j][i] = weight;//delete this line if directed graph } } void removeEdge(int i, int j) { if (i >= 0 && i < vertexCount && j > 0 && j < vertexCount) { adjacencyMatrix[i][j] = 0; adjacencyMatrix[j][i] = 0; //delete this line if directed graph } } bool isEdge(int i, int j) { if (i >= 0 && i < vertexCount && j >= 0 && j < vertexCount) return true; else return false; } int edgeWeight(int i, int j) { if (isEdge (i, j)) return adjacencyMatrix[i][j]; else return 0; } //printGraph below has not been debugged so it may not work as shown. I.e., you may need to modify it. //Also it only works for graphs with 25 nodes or fewer. Assume weights are integers ranging from 0 to 99. void printGraph (ofstream& fout) { int i; fout << setw(3) << " "; for (i = 0; i < vertexCount; i++) fout << setw(3) << i; fout << endl; for (i = 0; i < vertexCount; i++) { fout << setw(3) << i; for (int j = 0; j < vertexCount; j++) fout << setw(3) << adjacencyMatrix[i][j]; fout << endl; } } ~Graph() { for (int i = 0; i < vertexCount; i++) delete[] adjacencyMatrix[i]; delete[] adjacencyMatrix; } }; struct pathNode { int i; pathNode* next; };
22.831169
210
0.608646
672ec2d2127dbb07a26adba88a15fb46970ed335
1,019
h
C
topAndBottomRefreshing/topAndBottomRefreshing/topAndBottomRefresh.h
bianzhifeng/topAndBottomRefreshing
4dab6cb6163db0cc80eaf64ebee65dcbeb75ff5b
[ "Apache-2.0" ]
2
2015-08-16T12:38:40.000Z
2015-08-18T07:39:49.000Z
topAndBottomRefreshing/topAndBottomRefreshing/topAndBottomRefresh.h
bianzhifeng/topAndBottomRefreshing
4dab6cb6163db0cc80eaf64ebee65dcbeb75ff5b
[ "Apache-2.0" ]
null
null
null
topAndBottomRefreshing/topAndBottomRefreshing/topAndBottomRefresh.h
bianzhifeng/topAndBottomRefreshing
4dab6cb6163db0cc80eaf64ebee65dcbeb75ff5b
[ "Apache-2.0" ]
null
null
null
// // topAndBottomRefresh.h // 上拉刷新与下拉刷新 // // Created by 边智峰 on 15/8/16. // Copyright (c) 2015年 边智峰. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface topAndBottomRefresh : NSObject // 上拉刷新 */ // ** urlStr 网络请求的地址 // ** vc 显示数据的控制器 // ** dict 网络请求的参数 // ** clazz 存储网络请求数据的模型 // ** success 成功回调 // ** failure 失败回调 + (void)topRefreshWithUrl:(NSString *)urlStr viewCtrl:(UITableViewController *)vc dict:(NSMutableDictionary *)dict clazz:(Class)clazz success:(void(^)(id responseObj))success failure:(void(^)(NSError *))failure; // 下拉刷新 */ // ** urlStr 网络请求的地址 // ** scrollView 需要传递scrollViewDidScroll的scrollView参数 // ** vc 显示数据的控制器 // ** dict 网络请求的参数 // ** clazz 存储网络请求数据的模型 // ** success 成功回调 // ** failure 失败回调 + (void)bottomRefreshWithUrl:(NSString *)urlStr scrollView:(UIScrollView *)scrollView viewCtrl:(UITableViewController *)vc dict:(NSMutableDictionary *)dict clazz:(Class)clazz success:(void(^)(id responseObj))success failure:(void(^)(NSError *))failure; @end
31.84375
252
0.713445
56426325bc1a934e7ca961a55223cb658aa6d6b5
6,825
h
C
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/sunrpc/rpc/auth.h
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/sunrpc/rpc/auth.h
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/sunrpc/rpc/auth.h
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
/* * auth.h, Authentication interface. * * Copyright (c) 2010, Oracle America, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the "Oracle America, Inc." nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The data structures are completely opaque to the client. The client * is required to pass a AUTH * to routines that create rpc * "sessions". */ #ifndef _RPC_AUTH_H #define _RPC_AUTH_H 1 #include <features.h> #include <rpc/xdr.h> __BEGIN_DECLS #define MAX_AUTH_BYTES 400 #define MAXNETNAMELEN 255 /* maximum length of network user's name */ /* * Status returned from authentication check */ enum auth_stat { AUTH_OK = 0, /* * failed at remote end */ AUTH_BADCRED = 1, /* bogus credentials (seal broken) */ AUTH_REJECTEDCRED = 2, /* client should begin new session */ AUTH_BADVERF = 3, /* bogus verifier (seal broken) */ AUTH_REJECTEDVERF = 4, /* verifier expired or was replayed */ AUTH_TOOWEAK = 5, /* rejected due to security reasons */ /* * failed locally */ AUTH_INVALIDRESP = 6, /* bogus response verifier */ AUTH_FAILED = 7 /* some unknown reason */ }; union des_block { struct { uint32_t high; uint32_t low; } key; char c[8]; }; typedef union des_block des_block; extern bool_t xdr_des_block(XDR* __xdrs, des_block* __blkp) __THROW; /* * Authentication info. Opaque to client. */ struct opaque_auth { enum_t oa_flavor; /* flavor of auth */ caddr_t oa_base; /* address of more auth stuff */ u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ }; /* * Auth handle, interface to client side authenticators. */ typedef struct AUTH AUTH; struct AUTH { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; struct auth_ops { void (*ah_nextverf)(AUTH*); int (*ah_marshal)(AUTH*, XDR*); /* nextverf & serialize */ int (*ah_validate)(AUTH*, struct opaque_auth*); /* validate verifier */ int (*ah_refresh)(AUTH*); /* refresh credentials */ void (*ah_destroy)(AUTH*); /* destroy this structure */ } * ah_ops; caddr_t ah_private; }; /* * Authentication ops. * The ops and the auth handle provide the interface to the authenticators. * * AUTH *auth; * XDR *xdrs; * struct opaque_auth verf; */ #define AUTH_NEXTVERF(auth) ((*((auth)->ah_ops->ah_nextverf))(auth)) #define auth_nextverf(auth) ((*((auth)->ah_ops->ah_nextverf))(auth)) #define AUTH_MARSHALL(auth, xdrs) ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) #define auth_marshall(auth, xdrs) ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) #define AUTH_VALIDATE(auth, verfp) \ ((*((auth)->ah_ops->ah_validate))((auth), verfp)) #define auth_validate(auth, verfp) \ ((*((auth)->ah_ops->ah_validate))((auth), verfp)) #define AUTH_REFRESH(auth) ((*((auth)->ah_ops->ah_refresh))(auth)) #define auth_refresh(auth) ((*((auth)->ah_ops->ah_refresh))(auth)) #define AUTH_DESTROY(auth) ((*((auth)->ah_ops->ah_destroy))(auth)) #define auth_destroy(auth) ((*((auth)->ah_ops->ah_destroy))(auth)) extern struct opaque_auth _null_auth; /* * These are the various implementations of client side authenticators. */ /* * Unix style authentication * AUTH *authunix_create(machname, uid, gid, len, aup_gids) * char *machname; * int uid; * int gid; * int len; * int *aup_gids; */ extern AUTH* authunix_create(char* __machname, __uid_t __uid, __gid_t __gid, int __len, __gid_t* __aup_gids); extern AUTH* authunix_create_default(void); extern AUTH* authnone_create(void) __THROW; extern AUTH* authdes_create(const char* __servername, u_int __window, struct sockaddr* __syncaddr, des_block* __ckey) __THROW; extern AUTH* authdes_pk_create(const char*, netobj*, u_int, struct sockaddr*, des_block*) __THROW; #define AUTH_NONE 0 /* no authentication */ #define AUTH_NULL 0 /* backward compatibility */ #define AUTH_SYS 1 /* unix style (uid, gids) */ #define AUTH_UNIX AUTH_SYS #define AUTH_SHORT 2 /* short hand unix style */ #define AUTH_DES 3 /* des style (encrypted timestamps) */ #define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */ #define AUTH_KERB 4 /* kerberos style */ /* * Netname manipulating functions * */ extern int getnetname(char*) __THROW; extern int host2netname(char*, const char*, const char*) __THROW; extern int user2netname(char*, const uid_t, const char*) __THROW; extern int netname2user(const char*, uid_t*, gid_t*, int*, gid_t*) __THROW; extern int netname2host(const char*, char*, const int) __THROW; /* * * These routines interface to the keyserv daemon * */ extern int key_decryptsession(char*, des_block*); extern int key_decryptsession_pk(char*, netobj*, des_block*); extern int key_encryptsession(char*, des_block*); extern int key_encryptsession_pk(char*, netobj*, des_block*); extern int key_gendes(des_block*); extern int key_setsecret(char*); extern int key_secretkey_is_set(void); extern int key_get_conv(char*, des_block*); /* * XDR an opaque authentication struct. */ extern bool_t xdr_opaque_auth(XDR*, struct opaque_auth*) __THROW; __END_DECLS #endif /* rpc/auth.h */
33.455882
80
0.68044
0b42b9c0afa91c45c6cd98c4f6431ba7e0dc7d83
288
h
C
WPI Calendar Event Creator/WPITutorialViewController.h
dbogatov/wpi-calendar-event-creator
d626547bd22f23f77ba69bc6445526953e52447f
[ "MIT" ]
null
null
null
WPI Calendar Event Creator/WPITutorialViewController.h
dbogatov/wpi-calendar-event-creator
d626547bd22f23f77ba69bc6445526953e52447f
[ "MIT" ]
null
null
null
WPI Calendar Event Creator/WPITutorialViewController.h
dbogatov/wpi-calendar-event-creator
d626547bd22f23f77ba69bc6445526953e52447f
[ "MIT" ]
null
null
null
// // WPITutorialViewController.h // WPI Calendar Event Creator // // Created by Dmytro Bogatov on 3/26/14. // Copyright (c) 2014 Dima4ka. All rights reserved. // #import <UIKit/UIKit.h> @interface WPITutorialViewController : UIViewController <UIPageViewControllerDataSource> @end
20.571429
88
0.75
72c3b8440284091091fab2e56938cc55765f2967
6,629
h
C
Memories.framework/MiroAutoLayoutClip.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
4
2021-10-06T12:15:26.000Z
2022-02-21T02:26:00.000Z
Memories.framework/MiroAutoLayoutClip.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
null
null
null
Memories.framework/MiroAutoLayoutClip.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
1
2021-10-08T07:40:53.000Z
2021-10-08T07:40:53.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/Memories.framework/Memories */ @interface MiroAutoLayoutClip : NSObject { unsigned long long _altAssignedKBStyle; NSDictionary * _altAssignedTreatmentDict; int _altAssignedTreatmentStyle; int _altRequiredTreatmentStyle; bool _altTransitionAssigned; bool _altTreatmentApplied; unsigned long long _assignedKBStyle; NSDictionary * _assignedTreatmentDict; int _assignedTreatmentStyle; bool _canSupportMultiUp; bool _canSupportPrecedingTransition; int _clipType; bool _couldSupportNUpBase; int _directionOfMovement; bool _durationIsFlexible; int _faceLocation; bool _facesAreClose; bool _isPortrait; bool _isSquare; bool _itemShouldHeroFeaturedPerson; MiroAutoEditKenBurnsController * _kbController; bool _missedRollToBeats; MultiUpClip * _multiUpClip; NSArray * _multiUpPeers; int _numberOfFaces; int _preferredDirection; KonaClip * _projectClip; int _requiredTreatmentStyle; MiroAutoLayoutClip * _selectedPeer; bool _supportsHalf; bool _supportsOneThird; bool _supportsTwoThirds; bool _transitionAssigned; bool _treatmentApplied; bool _zoomToPersonCandidate; } @property (nonatomic) unsigned long long altAssignedKBStyle; @property (nonatomic, retain) NSDictionary *altAssignedTreatmentDict; @property (nonatomic) int altAssignedTreatmentStyle; @property (nonatomic) int altRequiredTreatmentStyle; @property (nonatomic) bool altTransitionAssigned; @property (nonatomic) bool altTreatmentApplied; @property (nonatomic) unsigned long long assignedKBStyle; @property (nonatomic, retain) NSDictionary *assignedTreatmentDict; @property (nonatomic) int assignedTreatmentStyle; @property (nonatomic) bool canSupportMultiUp; @property (nonatomic) bool canSupportPrecedingTransition; @property (nonatomic) int clipType; @property (nonatomic) bool couldSupportNUpBase; @property (nonatomic) int directionOfMovement; @property (nonatomic) bool durationIsFlexible; @property (nonatomic) int faceLocation; @property (nonatomic, readonly) bool facesAreClose; @property (nonatomic, readonly) bool isPortrait; @property (nonatomic, readonly) bool isSquare; @property (nonatomic) bool itemShouldHeroFeaturedPerson; @property (nonatomic, retain) MiroAutoEditKenBurnsController *kbController; @property (nonatomic) bool missedRollToBeats; @property (nonatomic, retain) MultiUpClip *multiUpClip; @property (nonatomic, retain) NSArray *multiUpPeers; @property (nonatomic, readonly) int numberOfFaces; @property (nonatomic) int preferredDirection; @property (nonatomic, retain) KonaClip *projectClip; @property (nonatomic) int requiredTreatmentStyle; @property (nonatomic, retain) MiroAutoLayoutClip *selectedPeer; @property (nonatomic) bool supportsHalf; @property (nonatomic) bool supportsOneThird; @property (nonatomic) bool supportsTwoThirds; @property (nonatomic) bool transitionAssigned; @property (nonatomic) bool treatmentApplied; @property (nonatomic) bool zoomToPersonCandidate; + (bool)assetCanFillProjectFrame:(id)arg1; + (double)clipAspectRatio:(id)arg1; + (bool)clipIsPano:(id)arg1; + (bool)clipIsPortrait:(id)arg1; + (bool)clipIsPortraitOrSquare:(id)arg1; + (bool)clipIsSquare:(id)arg1; - (void).cxx_destruct; - (unsigned long long)altAssignedKBStyle; - (id)altAssignedTreatmentDict; - (int)altAssignedTreatmentStyle; - (int)altRequiredTreatmentStyle; - (bool)altTransitionAssigned; - (bool)altTreatmentApplied; - (void)applyAssignedTreatmentsFromRequired; - (unsigned long long)assignedKBStyle; - (id)assignedTreatmentDict; - (int)assignedTreatmentStyle; - (bool)canSupportMultiUp; - (bool)canSupportPrecedingTransition; - (bool)clipCanZoomCropforAlt:(bool)arg1; - (int)clipType; - (bool)couldSupportNUpBase; - (id)description; - (int)directionOfMovement; - (double)distanceToLayoutClip:(id)arg1; - (bool)durationIsFlexible; - (void)establishCanSupportInEditMultiUp:(id)arg1; - (void)establishCanSupportMultiUp:(id)arg1; - (void)establishCanSupportPrecedingTransition; - (void)establishDurationFlexibility; - (void)establishFaceInfo:(id)arg1; - (void)establishFacesAreClose; - (void)establishIsPortrait; - (void)establishIsSquare; - (void)establishPreferredDirection; - (void)establishProjectClipType; - (int)establishRequiredTreatmentForAspect:(int)arg1 multiDelegate:(id)arg2 polishDelegate:(id)arg3; - (void)establishShotType:(id)arg1; - (int)faceLocation; - (bool)facesAreClose; - (bool)hasMultipleFaces; - (bool)hasSingleFace; - (id)initWithKonaClip:(id)arg1 multiUpDelegate:(id)arg2 polishDelegate:(id)arg3 zoomToPersonCandidate:(bool)arg4; - (bool)isEdited; - (bool)isEqual:(id)arg1; - (bool)isFavorite; - (bool)isPano; - (bool)isPortrait; - (bool)isSquare; - (bool)isTransition; - (bool)isVideo; - (bool)itemMatchesProjectOrientation:(int)arg1; - (bool)itemShouldHeroFeaturedPerson; - (id)kbController; - (id)locationForClip; - (bool)missedRollToBeats; - (id)multiUpClip; - (id)multiUpPeers; - (int)numberOfFaces; - (int)preferredDirection; - (id)projectClip; - (int)requiredTreatmentStyle; - (id)selectedPeer; - (void)setAltAssignedKBStyle:(unsigned long long)arg1; - (void)setAltAssignedTreatmentDict:(id)arg1; - (void)setAltAssignedTreatmentStyle:(int)arg1; - (void)setAltRequiredTreatmentStyle:(int)arg1; - (void)setAltTransitionAssigned:(bool)arg1; - (void)setAltTreatmentApplied:(bool)arg1; - (void)setAssignedKBStyle:(unsigned long long)arg1; - (void)setAssignedTreatmentDict:(id)arg1; - (void)setAssignedTreatmentStyle:(int)arg1; - (void)setCanSupportMultiUp:(bool)arg1; - (void)setCanSupportPrecedingTransition:(bool)arg1; - (void)setClipType:(int)arg1; - (void)setCouldSupportNUpBase:(bool)arg1; - (void)setDirectionOfMovement:(int)arg1; - (void)setDurationIsFlexible:(bool)arg1; - (void)setFaceLocation:(int)arg1; - (void)setItemShouldHeroFeaturedPerson:(bool)arg1; - (void)setKbController:(id)arg1; - (void)setMissedRollToBeats:(bool)arg1; - (void)setMultiUpClip:(id)arg1; - (void)setMultiUpPeers:(id)arg1; - (void)setPreferredDirection:(int)arg1; - (void)setProjectClip:(id)arg1; - (void)setRequiredTreatmentStyle:(int)arg1; - (void)setSelectedPeer:(id)arg1; - (void)setSupportsHalf:(bool)arg1; - (void)setSupportsOneThird:(bool)arg1; - (void)setSupportsTwoThirds:(bool)arg1; - (void)setTransitionAssigned:(bool)arg1; - (void)setTreatmentApplied:(bool)arg1; - (void)setZoomToPersonCandidate:(bool)arg1; - (bool)supportsHalf; - (bool)supportsOneThird; - (bool)supportsTwoThirds; - (bool)transitionAssigned; - (bool)treatmentApplied; - (bool)zoomToPersonCandidate; @end
36.423077
114
0.786846
3cf2df4c3c5c1902f56855fe95bb472b7e230a8c
535
h
C
Player.h
AsgerWJ/Dark-World
90ea58619a1eb64bf09a92d1f6586aa71d99c520
[ "Zlib" ]
null
null
null
Player.h
AsgerWJ/Dark-World
90ea58619a1eb64bf09a92d1f6586aa71d99c520
[ "Zlib" ]
null
null
null
Player.h
AsgerWJ/Dark-World
90ea58619a1eb64bf09a92d1f6586aa71d99c520
[ "Zlib" ]
null
null
null
#ifndef PLAYER_H #define PLAYER_H #include "BaseEntity.h" namespace dw { class Player : public BaseEntity { public: Player(sf::Vector2f spawnPos); void SetMovingDirection(sf::Vector2f movementDir); int Update(const sf::Time &timeFrame); void loadTexture(sf::Texture *texture); protected: sf::VertexArray m_vertices; sf::Vector2f m_movement; private: virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const; }; //end class player };//end namespace dw #endif //PLAYER_H
18.448276
79
0.704673
738813326b2c17f9a6747284be1beff349ef1ba4
377
h
C
Source/App/Core.h
trevortheblack/Physically_Based_Renderer
18fb422c6d8c6de8ed3471c3558b0aa2b5ba4344
[ "MIT" ]
1
2020-09-16T19:42:06.000Z
2020-09-16T19:42:06.000Z
Source/App/Core.h
trevordblack/Physically_Based_Renderer
18fb422c6d8c6de8ed3471c3558b0aa2b5ba4344
[ "MIT" ]
null
null
null
Source/App/Core.h
trevordblack/Physically_Based_Renderer
18fb422c6d8c6de8ed3471c3558b0aa2b5ba4344
[ "MIT" ]
null
null
null
#ifndef CORE_H #define CORE_H #include <stdint.h> namespace Loxodonta { // Core only contains typedefs at the moment using i64 = int64_t; using i32 = int32_t; using i16 = int16_t; using i8 = int8_t; using uint = unsigned int; using u64 = uint64_t; using u32 = uint32_t; using u16 = uint16_t; using u8 = uint8_t; using f32 = float; using f64 = double; } #endif //!CORE_H
13.962963
44
0.713528
4803c6c2e61912e01519cee153035e617d331452
1,198
h
C
src/FSVerticalTabBarController.h
futuresimple/FSVerticalTabBarController
ae38dfb52c43b50836f20f5d1b995f631633fe41
[ "MIT" ]
55
2015-01-30T05:49:58.000Z
2021-10-04T17:52:01.000Z
src/FSVerticalTabBarController.h
pierlis/FSVerticalTabBarController
b40c3d2202893e3ec83f1ccdff9bae823bfe6627
[ "MIT" ]
1
2019-11-20T13:27:35.000Z
2019-11-20T13:27:35.000Z
src/FSVerticalTabBarController.h
pierlis/FSVerticalTabBarController
b40c3d2202893e3ec83f1ccdff9bae823bfe6627
[ "MIT" ]
13
2015-02-09T08:50:25.000Z
2020-02-12T09:25:04.000Z
// // FSVerticalTabBarController.h // iOS-Platform // // Created by Błażej Biesiada on 4/6/12. // Copyright (c) 2012 Future Simple. All rights reserved. // #import <UIKit/UIKit.h> #import "FSVerticalTabBar.h" @class FSVerticalTabBarController, FSVerticalTabBar; @protocol FSTabBarControllerDelegate <NSObject> @optional - (void)tabBarController:(FSVerticalTabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController; - (BOOL)tabBarController:(FSVerticalTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController; @end @interface FSVerticalTabBarController : UIViewController <UITableViewDelegate> @property (nonatomic, readwrite, assign) id<FSTabBarControllerDelegate> delegate; @property (nonatomic, readwrite, strong) FSVerticalTabBar *tabBar; @property (nonatomic, readwrite, copy) NSArray *viewControllers; @property (nonatomic, readwrite, assign) UIViewController *selectedViewController; @property (nonatomic, readwrite, assign) NSUInteger selectedIndex; @property (nonatomic, readwrite, assign) CGFloat tabBarWidth; - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated; @end
31.526316
134
0.808848
212008a66c8df045f76dd56d9b571ab395e82ab1
1,273
h
C
src/hash_table.h
AkashBujju/Data-Oriented-Computer-Simulation
e23661c74207d4a3a1baf7cd6915253b3d8f5d42
[ "BSD-3-Clause" ]
null
null
null
src/hash_table.h
AkashBujju/Data-Oriented-Computer-Simulation
e23661c74207d4a3a1baf7cd6915253b3d8f5d42
[ "BSD-3-Clause" ]
null
null
null
src/hash_table.h
AkashBujju/Data-Oriented-Computer-Simulation
e23661c74207d4a3a1baf7cd6915253b3d8f5d42
[ "BSD-3-Clause" ]
null
null
null
#ifndef HASH_TABLE_H #define HASH_TABLE_H typedef struct Road Road; typedef struct Junction Junction; typedef struct Signal Signal; typedef struct Car Car; typedef struct Model Model; unsigned int compute_hash(const unsigned int id, const unsigned int limit); void put_road(unsigned int *all_ids, Road *roads, unsigned int id, Road *road, unsigned int limit); void put_junction(unsigned int *all_ids, Junction *junctions, unsigned int id, Junction *junction, unsigned int limit); void put_signal(unsigned int *all_ids, Signal *signals, unsigned int id, Signal *signal, unsigned int limit); void put_car(unsigned int *all_ids, Car *cars, unsigned int id, Car *car, unsigned int limit); void put_car_model(unsigned int *all_ids, Model *cars, unsigned int id, Model *car, unsigned int limit); Road* get_road(unsigned int *all_ids, Road *roads, unsigned int id, unsigned int limit); Junction* get_junction(unsigned int *all_ids, Junction *junctions, unsigned int id, unsigned int limit); Signal* get_signal(unsigned int *all_ids, Signal *signals, unsigned int id, unsigned int limit); Car* get_car(unsigned int *all_ids, Car *cars, unsigned int id, unsigned int limit); Model* get_car_model(unsigned int *all_ids, Model *cars, unsigned int id, unsigned int limit); #endif
50.92
119
0.782404
554eecd30f680e252dfa348cc28de35dbe7d0712
3,136
h
C
time_interval.h
dvdvideo1234/LapTimer
88ad9ef06da8b0e02c0e5638bedf16c7c81441aa
[ "Apache-2.0" ]
null
null
null
time_interval.h
dvdvideo1234/LapTimer
88ad9ef06da8b0e02c0e5638bedf16c7c81441aa
[ "Apache-2.0" ]
null
null
null
time_interval.h
dvdvideo1234/LapTimer
88ad9ef06da8b0e02c0e5638bedf16c7c81441aa
[ "Apache-2.0" ]
null
null
null
#if !defined _TIME_INTERVAL_H_ #include <time.h> #define _TIME_INTERVAL_H_ #define TIME_INTERVAL unsigned int typedef class time_interval { protected: TIME_INTERVAL clk; TIME_INTERVAL h; TIME_INTERVAL m; TIME_INTERVAL s; void (*hook)(void); public: char isPassed(void){ return (s==0 && m==0 && h==0); }; class time_interval& Set(class time_interval &o){ s = o.s; m = o.m; h = o.h; return *this; }; class time_interval& Set(class time_interval *o){ if(o != NULL){ s = o->s; m = o->m; h = o->h; } return *this; }; class time_interval& Set(TIME_INTERVAL as, TIME_INTERVAL am, TIME_INTERVAL ah){ s = as; m = am; h = ah; return *this; }; time_interval(TIME_INTERVAL as, TIME_INTERVAL am, TIME_INTERVAL ah){ Set(as,am,ah); clk = CLOCKS_PER_SEC; }; time_interval(TIME_INTERVAL as, TIME_INTERVAL am){ Set(as,am,0); clk = CLOCKS_PER_SEC; }; time_interval(TIME_INTERVAL as){ Set(as,0,0); clk = CLOCKS_PER_SEC; }; time_interval(void){ Set(0,0,0); clk = CLOCKS_PER_SEC; }; ~time_interval(){}; class time_interval& Wait(clock_t next){ while(clock() < next); return *this; }; class time_interval& Reset(){ Set(0,0,0); return *this; } class time_interval& setS(TIME_INTERVAL as){ s = as; return *this; } class time_interval& setM(TIME_INTERVAL am){ m = am; return *this; } class time_interval& setH(TIME_INTERVAL ah){ h = ah; return *this; } TIME_INTERVAL getS(void){ return s; } TIME_INTERVAL getM(void){ return m; } TIME_INTERVAL getH(void){ return h; } class time_interval& setHook(void (*foo)(void)){ hook = foo; return *this; } class time_interval& callHook(void){ if((*hook)){ (*hook)(); } return *this; }; class time_interval& setTickRate(TIME_INTERVAL cy){ clk = cy; return *this; }; class time_interval& deltaTickRate(int dcy); TIME_INTERVAL getTickRate(void){ return clk; }; class time_interval& Normalize(void); class time_interval& Decrement(void){ if(s > 0){ s--; } return *this; } class time_interval& Print(void){ printf("\nTime(%u): %5u, %5u, %5u",clk,s,m,h); return *this; }; class time_interval& Print(char c){ printf("\nTime(%u)[%c]: %5u, %5u, %5u",clk,c,s,m,h); return *this; }; class time_interval& Print(char *str){ printf("\nTime(%u)[%s]: %5u, %5u, %5u",clk,str,s,m,h); return *this; }; class time_interval& TickSecond(void){ return Wait(clock() + CLOCKS_PER_SEC); } class time_interval& TickSecond(TIME_INTERVAL s){ return Wait(clock() + (s * CLOCKS_PER_SEC)); } class time_interval& Tick(void){ return Wait(clock() + clk); } } tmi; tmi& time_interval::Normalize(void) { if(!m && h){ m = 60; h--; } if(!s && m){ s = 60; m--; } return *this; } tmi& time_interval::deltaTickRate(int dcy) { if((dcy > 0) && (clk + dcy) < clk){ return *this; } if((dcy < 0) && (clk + dcy) > clk){ return *this; } return setTickRate(clk + dcy); } #endif
51.409836
127
0.59949
99de427b3ae8468805a4a3fc115bd10ce81555f7
25,268
c
C
src/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c
lastweek/source-freebsd
0821950b0c40cbc891a27964b342e0202a3859ec
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
src/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c
lastweek/source-freebsd
0821950b0c40cbc891a27964b342e0202a3859ec
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
src/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c
lastweek/source-freebsd
0821950b0c40cbc891a27964b342e0202a3859ec
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
/* * Copyright 2008-2012 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Freescale Semiconductor nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * * ALTERNATIVELY, this software may be distributed under the terms of the * GNU General Public License ("GPL") as published by the Free Software * Foundation, either version 2 of that License or (at your option) any * later version. * * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /****************************************************************************** @File fm_rtc.c @Description FM RTC driver implementation. @Cautions None *//***************************************************************************/ #include <linux/math64.h> #include "error_ext.h" #include "debug_ext.h" #include "string_ext.h" #include "part_ext.h" #include "xx_ext.h" #include "ncsw_ext.h" #include "fm_rtc.h" #include "fm_common.h" /*****************************************************************************/ static t_Error CheckInitParameters(t_FmRtc *p_Rtc) { struct rtc_cfg *p_RtcDriverParam = p_Rtc->p_RtcDriverParam; int i; if ((p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL) && (p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_SYSTEM) && (p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR)) RETURN_ERROR(MAJOR, E_INVALID_CLOCK, ("Source clock undefined")); if (p_Rtc->outputClockDivisor == 0) { RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Divisor for output clock (should be positive)")); } for (i=0; i < FM_RTC_NUM_OF_ALARMS; i++) { if ((p_RtcDriverParam->alarm_polarity[i] != E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW) && (p_RtcDriverParam->alarm_polarity[i] != E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH)) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm %d signal polarity", i)); } } for (i=0; i < FM_RTC_NUM_OF_EXT_TRIGGERS; i++) { if ((p_RtcDriverParam->trigger_polarity[i] != E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE) && (p_RtcDriverParam->trigger_polarity[i] != E_FMAN_RTC_TRIGGER_ON_RISING_EDGE)) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Trigger %d signal polarity", i)); } } return E_OK; } /*****************************************************************************/ static void RtcExceptions(t_Handle h_FmRtc) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; struct rtc_regs *p_MemMap; register uint32_t events; ASSERT_COND(p_Rtc); p_MemMap = p_Rtc->p_MemMap; events = fman_rtc_check_and_clear_event(p_MemMap); if (events & FMAN_RTC_TMR_TEVENT_ALM1) { if (p_Rtc->alarmParams[0].clearOnExpiration) { fman_rtc_set_timer_alarm_l(p_MemMap, 0, 0); fman_rtc_disable_interupt(p_MemMap, FMAN_RTC_TMR_TEVENT_ALM1); } ASSERT_COND(p_Rtc->alarmParams[0].f_AlarmCallback); p_Rtc->alarmParams[0].f_AlarmCallback(p_Rtc->h_App, 0); } if (events & FMAN_RTC_TMR_TEVENT_ALM2) { if (p_Rtc->alarmParams[1].clearOnExpiration) { fman_rtc_set_timer_alarm_l(p_MemMap, 1, 0); fman_rtc_disable_interupt(p_MemMap, FMAN_RTC_TMR_TEVENT_ALM2); } ASSERT_COND(p_Rtc->alarmParams[1].f_AlarmCallback); p_Rtc->alarmParams[1].f_AlarmCallback(p_Rtc->h_App, 1); } if (events & FMAN_RTC_TMR_TEVENT_PP1) { ASSERT_COND(p_Rtc->periodicPulseParams[0].f_PeriodicPulseCallback); p_Rtc->periodicPulseParams[0].f_PeriodicPulseCallback(p_Rtc->h_App, 0); } if (events & FMAN_RTC_TMR_TEVENT_PP2) { ASSERT_COND(p_Rtc->periodicPulseParams[1].f_PeriodicPulseCallback); p_Rtc->periodicPulseParams[1].f_PeriodicPulseCallback(p_Rtc->h_App, 1); } if (events & FMAN_RTC_TMR_TEVENT_ETS1) { ASSERT_COND(p_Rtc->externalTriggerParams[0].f_ExternalTriggerCallback); p_Rtc->externalTriggerParams[0].f_ExternalTriggerCallback(p_Rtc->h_App, 0); } if (events & FMAN_RTC_TMR_TEVENT_ETS2) { ASSERT_COND(p_Rtc->externalTriggerParams[1].f_ExternalTriggerCallback); p_Rtc->externalTriggerParams[1].f_ExternalTriggerCallback(p_Rtc->h_App, 1); } } /*****************************************************************************/ t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam) { t_FmRtc *p_Rtc; SANITY_CHECK_RETURN_VALUE(p_FmRtcParam, E_NULL_POINTER, NULL); /* Allocate memory for the FM RTC driver parameters */ p_Rtc = (t_FmRtc *)XX_Malloc(sizeof(t_FmRtc)); if (!p_Rtc) { REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM RTC driver structure")); return NULL; } memset(p_Rtc, 0, sizeof(t_FmRtc)); /* Allocate memory for the FM RTC driver parameters */ p_Rtc->p_RtcDriverParam = (struct rtc_cfg *)XX_Malloc(sizeof(struct rtc_cfg)); if (!p_Rtc->p_RtcDriverParam) { REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM RTC driver parameters")); XX_Free(p_Rtc); return NULL; } memset(p_Rtc->p_RtcDriverParam, 0, sizeof(struct rtc_cfg)); /* Store RTC configuration parameters */ p_Rtc->h_Fm = p_FmRtcParam->h_Fm; /* Set default RTC configuration parameters */ fman_rtc_defconfig(p_Rtc->p_RtcDriverParam); p_Rtc->outputClockDivisor = DEFAULT_OUTPUT_CLOCK_DIVISOR; p_Rtc->p_RtcDriverParam->bypass = DEFAULT_BYPASS; p_Rtc->clockPeriodNanoSec = DEFAULT_CLOCK_PERIOD; /* 1 usec */ /* Store RTC parameters in the RTC control structure */ p_Rtc->p_MemMap = (struct rtc_regs *)UINT_TO_PTR(p_FmRtcParam->baseAddress); p_Rtc->h_App = p_FmRtcParam->h_App; return p_Rtc; } /*****************************************************************************/ t_Error FM_RTC_Init(t_Handle h_FmRtc) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; struct rtc_cfg *p_RtcDriverParam; struct rtc_regs *p_MemMap; uint32_t freqCompensation = 0; uint64_t tmpDouble; bool init_freq_comp = FALSE; p_RtcDriverParam = p_Rtc->p_RtcDriverParam; p_MemMap = p_Rtc->p_MemMap; if (CheckInitParameters(p_Rtc)!=E_OK) RETURN_ERROR(MAJOR, E_CONFLICT, ("Init Parameters are not Valid")); /* TODO check that no timestamping MACs are working in this stage. */ /* find source clock frequency in Mhz */ if (p_Rtc->p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_SYSTEM) p_Rtc->srcClkFreqMhz = p_Rtc->p_RtcDriverParam->ext_src_clk_freq; else p_Rtc->srcClkFreqMhz = (uint32_t)(FmGetMacClockFreq(p_Rtc->h_Fm)); /* if timer in Master mode Initialize TMR_CTRL */ /* We want the counter (TMR_CNT) to count in nano-seconds */ if (!p_RtcDriverParam->timer_slave_mode && p_Rtc->p_RtcDriverParam->bypass) p_Rtc->clockPeriodNanoSec = (1000 / p_Rtc->srcClkFreqMhz); else { /* Initialize TMR_ADD with the initial frequency compensation value: freqCompensation = (2^32 / frequency ratio) */ /* frequency ratio = sorce clock/rtc clock = * (p_Rtc->srcClkFreqMhz*1000000))/ 1/(p_Rtc->clockPeriodNanoSec * 1000000000) */ init_freq_comp = TRUE; freqCompensation = (uint32_t)DIV_CEIL(ACCUMULATOR_OVERFLOW * 1000, p_Rtc->clockPeriodNanoSec * p_Rtc->srcClkFreqMhz); } /* check the legality of the relation between source and destination clocks */ /* should be larger than 1.0001 */ tmpDouble = 10000 * (uint64_t)p_Rtc->clockPeriodNanoSec * (uint64_t)p_Rtc->srcClkFreqMhz; if ((tmpDouble) <= 10001) RETURN_ERROR(MAJOR, E_CONFLICT, ("Invalid relation between source and destination clocks. Should be larger than 1.0001")); fman_rtc_init(p_RtcDriverParam, p_MemMap, FM_RTC_NUM_OF_ALARMS, FM_RTC_NUM_OF_PERIODIC_PULSES, FM_RTC_NUM_OF_EXT_TRIGGERS, init_freq_comp, freqCompensation, p_Rtc->outputClockDivisor); /* Register the FM RTC interrupt */ FmRegisterIntr(p_Rtc->h_Fm, e_FM_MOD_TMR, 0, e_FM_INTR_TYPE_NORMAL, RtcExceptions , p_Rtc); /* Free parameters structures */ XX_Free(p_Rtc->p_RtcDriverParam); p_Rtc->p_RtcDriverParam = NULL; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_Free(t_Handle h_FmRtc) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); if (p_Rtc->p_RtcDriverParam) { XX_Free(p_Rtc->p_RtcDriverParam); } else { FM_RTC_Disable(h_FmRtc); } /* Unregister FM RTC interrupt */ FmUnregisterIntr(p_Rtc->h_Fm, e_FM_MOD_TMR, 0, e_FM_INTR_TYPE_NORMAL); XX_Free(p_Rtc); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigSourceClock(t_Handle h_FmRtc, e_FmSrcClk srcClk, uint32_t freqInMhz) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->p_RtcDriverParam->src_clk = (enum fman_src_clock)srcClk; if (srcClk != e_FM_RTC_SOURCE_CLOCK_SYSTEM) p_Rtc->p_RtcDriverParam->ext_src_clk_freq = freqInMhz; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigPeriod(t_Handle h_FmRtc, uint32_t period) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->clockPeriodNanoSec = period; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigFrequencyBypass(t_Handle h_FmRtc, bool enabled) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->p_RtcDriverParam->bypass = enabled; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigInvertedInputClockPhase(t_Handle h_FmRtc, bool inverted) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->p_RtcDriverParam->invert_input_clk_phase = inverted; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigInvertedOutputClockPhase(t_Handle h_FmRtc, bool inverted) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->p_RtcDriverParam->invert_output_clk_phase = inverted; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigOutputClockDivisor(t_Handle h_FmRtc, uint16_t divisor) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->outputClockDivisor = divisor; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigPulseRealignment(t_Handle h_FmRtc, bool enable) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); p_Rtc->p_RtcDriverParam->pulse_realign = enable; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigAlarmPolarity(t_Handle h_FmRtc, uint8_t alarmId, e_FmRtcAlarmPolarity alarmPolarity) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (alarmId >= FM_RTC_NUM_OF_ALARMS) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm ID")); p_Rtc->p_RtcDriverParam->alarm_polarity[alarmId] = (enum fman_rtc_alarm_polarity)alarmPolarity; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ConfigExternalTriggerPolarity(t_Handle h_FmRtc, uint8_t triggerId, e_FmRtcTriggerPolarity triggerPolarity) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (triggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External trigger ID")); } p_Rtc->p_RtcDriverParam->trigger_polarity[triggerId] = (enum fman_rtc_trigger_polarity)triggerPolarity; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_Enable(t_Handle h_FmRtc, bool resetClock) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); fman_rtc_enable(p_Rtc->p_MemMap, resetClock); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_Disable(t_Handle h_FmRtc) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); /* TODO A check must be added here, that no timestamping MAC's * are working in this stage. */ fman_rtc_disable(p_Rtc->p_MemMap); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_SetClockOffset(t_Handle h_FmRtc, int64_t offset) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); fman_rtc_set_timer_offset(p_Rtc->p_MemMap, offset); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_SetAlarm(t_Handle h_FmRtc, t_FmRtcAlarmParams *p_FmRtcAlarmParams) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; uint64_t tmpAlarm; bool enable = FALSE; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (p_FmRtcAlarmParams->alarmId >= FM_RTC_NUM_OF_ALARMS) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm ID")); } if (p_FmRtcAlarmParams->alarmTime < p_Rtc->clockPeriodNanoSec) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm time must be equal or larger than RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec)); tmpAlarm = p_FmRtcAlarmParams->alarmTime; if (do_div(tmpAlarm, p_Rtc->clockPeriodNanoSec)) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm time must be a multiple of RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec)); if (p_FmRtcAlarmParams->f_AlarmCallback) { p_Rtc->alarmParams[p_FmRtcAlarmParams->alarmId].f_AlarmCallback = p_FmRtcAlarmParams->f_AlarmCallback; p_Rtc->alarmParams[p_FmRtcAlarmParams->alarmId].clearOnExpiration = p_FmRtcAlarmParams->clearOnExpiration; enable = TRUE; } fman_rtc_set_alarm(p_Rtc->p_MemMap, p_FmRtcAlarmParams->alarmId, (unsigned long)tmpAlarm, enable); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_SetPeriodicPulse(t_Handle h_FmRtc, t_FmRtcPeriodicPulseParams *p_FmRtcPeriodicPulseParams) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; bool enable = FALSE; uint64_t tmpFiper; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (p_FmRtcPeriodicPulseParams->periodicPulseId >= FM_RTC_NUM_OF_PERIODIC_PULSES) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse ID")); } if (fman_rtc_is_enabled(p_Rtc->p_MemMap)) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Can't set Periodic pulse when RTC is enabled.")); if (p_FmRtcPeriodicPulseParams->periodicPulsePeriod < p_Rtc->clockPeriodNanoSec) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse must be equal or larger than RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec)); tmpFiper = p_FmRtcPeriodicPulseParams->periodicPulsePeriod; if (do_div(tmpFiper, p_Rtc->clockPeriodNanoSec)) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse must be a multiple of RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec)); if (tmpFiper & 0xffffffff00000000LL) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse/RTC Period must be smaller than 4294967296", p_Rtc->clockPeriodNanoSec)); if (p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback) { p_Rtc->periodicPulseParams[p_FmRtcPeriodicPulseParams->periodicPulseId].f_PeriodicPulseCallback = p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback; enable = TRUE; } fman_rtc_set_periodic_pulse(p_Rtc->p_MemMap, p_FmRtcPeriodicPulseParams->periodicPulseId, (uint32_t)tmpFiper, enable); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (periodicPulseId >= FM_RTC_NUM_OF_PERIODIC_PULSES) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse ID")); } p_Rtc->periodicPulseParams[periodicPulseId].f_PeriodicPulseCallback = NULL; fman_rtc_clear_periodic_pulse(p_Rtc->p_MemMap, periodicPulseId); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams *p_FmRtcExternalTriggerParams) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; bool enable = FALSE; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (p_FmRtcExternalTriggerParams->externalTriggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS) { RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External Trigger ID")); } if (p_FmRtcExternalTriggerParams->f_ExternalTriggerCallback) { p_Rtc->externalTriggerParams[p_FmRtcExternalTriggerParams->externalTriggerId].f_ExternalTriggerCallback = p_FmRtcExternalTriggerParams->f_ExternalTriggerCallback; enable = TRUE; } fman_rtc_set_ext_trigger(p_Rtc->p_MemMap, p_FmRtcExternalTriggerParams->externalTriggerId, enable, p_FmRtcExternalTriggerParams->usePulseAsInput); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_ClearExternalTrigger(t_Handle h_FmRtc, uint8_t externalTriggerId) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (externalTriggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External Trigger ID")); p_Rtc->externalTriggerParams[externalTriggerId].f_ExternalTriggerCallback = NULL; fman_rtc_clear_external_trigger(p_Rtc->p_MemMap, externalTriggerId); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_GetExternalTriggerTimeStamp(t_Handle h_FmRtc, uint8_t triggerId, uint64_t *p_TimeStamp) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); if (triggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS) RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External trigger ID")); *p_TimeStamp = fman_rtc_get_trigger_stamp(p_Rtc->p_MemMap, triggerId)*p_Rtc->clockPeriodNanoSec; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_GetCurrentTime(t_Handle h_FmRtc, uint64_t *p_Ts) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); *p_Ts = fman_rtc_get_timer(p_Rtc->p_MemMap)*p_Rtc->clockPeriodNanoSec; return E_OK; } /*****************************************************************************/ t_Error FM_RTC_SetCurrentTime(t_Handle h_FmRtc, uint64_t ts) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); do_div(ts, p_Rtc->clockPeriodNanoSec); fman_rtc_set_timer(p_Rtc->p_MemMap, (int64_t)ts); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); *p_Compensation = fman_rtc_get_frequency_compensation(p_Rtc->p_MemMap); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_SetFreqCompensation(t_Handle h_FmRtc, uint32_t freqCompensation) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); /* set the new freqCompensation */ fman_rtc_set_frequency_compensation(p_Rtc->p_MemMap, freqCompensation); return E_OK; } #ifdef CONFIG_PTP_1588_CLOCK_DPAA /*****************************************************************************/ t_Error FM_RTC_EnableInterrupt(t_Handle h_FmRtc, uint32_t events) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); /* enable interrupt */ fman_rtc_enable_interupt(p_Rtc->p_MemMap, events); return E_OK; } /*****************************************************************************/ t_Error FM_RTC_DisableInterrupt(t_Handle h_FmRtc, uint32_t events) { t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc; SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE); SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE); /* disable interrupt */ fman_rtc_disable_interupt(p_Rtc->p_MemMap, events); return E_OK; } #endif
36.46176
170
0.634874
9f791b1bb2082c5fe96db4b20d540d54ec332627
490
h
C
www/snapper/include/class/_pCollectionCapabilities.h
lenovo/Snapper
4300739bbdf0b101c7ddd8be09c89f582bf47202
[ "BSD-3-Clause" ]
4
2019-09-04T23:49:58.000Z
2020-08-05T05:46:49.000Z
www/snapper/include/class/_pCollectionCapabilities.h
lenovo/Snapper
4300739bbdf0b101c7ddd8be09c89f582bf47202
[ "BSD-3-Clause" ]
1
2019-09-24T20:42:29.000Z
2019-09-25T00:28:19.000Z
www/snapper/include/class/_pCollectionCapabilities.h
lenovo/Snapper
4300739bbdf0b101c7ddd8be09c89f582bf47202
[ "BSD-3-Clause" ]
null
null
null
//--------------------------------------------------------------------- // <copyright file="_pCollectionCapabilities.h" company="Lenovo"> // Copyright (c) 2018-present, Lenovo. All rights reserved. Licensed under BSD, see COPYING.BSD file for details. // </copyright> //--------------------------------------------------------------------- #pragma once enum UseCase { UseCase_ComputerSystemComposition, UseCase_VolumeCreation, };
32.666667
120
0.455102
195a4daf7aff0f0caad54351eb2dbb4052f9898e
4,103
c
C
examples/Fade.c
flobernd/raspi-apa102
58460640427d0240fdfd63fa3a6f4b051e5a5e48
[ "MIT" ]
1
2019-10-29T14:40:27.000Z
2019-10-29T14:40:27.000Z
examples/Fade.c
flobernd/raspi-apa102
58460640427d0240fdfd63fa3a6f4b051e5a5e48
[ "MIT" ]
1
2020-04-07T14:00:07.000Z
2020-04-07T15:52:03.000Z
examples/Fade.c
flobernd/raspi-apa102
58460640427d0240fdfd63fa3a6f4b051e5a5e48
[ "MIT" ]
null
null
null
/*************************************************************************************************** Raspberry Pi APA102 Library Original Author : Florian Bernd * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. ***************************************************************************************************/ #include <math.h> #include <stdio.h> #include <unistd.h> #include <RaspiAPA102/APA102.h> #include <RaspiAPA102/ColorConversion.h> /* ============================================================================================== */ /* Constants */ /* ============================================================================================== */ #define RASPI_APA102_SPI_SCLK 14 #define RASPI_APA102_SPI_MOSI 15 #define RASPI_APA102_SPI_CS -1 /* ============================================================================================== */ /* Internal Functions */ /* ============================================================================================== */ /* ============================================================================================== */ /* Entry Point */ /* ============================================================================================== */ int main(void) { RaspiAPA102Device device; RaspiAPA102DeviceInitSoftware(&device, RASPI_APA102_SPI_SCLK, RASPI_APA102_SPI_MOSI, RASPI_APA102_SPI_CS); RaspiAPA102RGB lrgb; RaspiAPA102HSV lhsv; // Color 1 (purple) lrgb.r = 255 / 255; lrgb.g = 0 / 255; lrgb.b = 255 / 255; lhsv = RaspiAPA102RGB2HSV(lrgb); printf("RGB: %3.2f, %3.2f, %3.2f, HSV: %3.2f, %3.2f, %3.2f\n", lrgb.r, lrgb.g, lrgb.b, lhsv.h, lhsv.s, lhsv.v); const float h_f = lhsv.h; // Color 2 (green) lrgb.r = 0 / 255; lrgb.g = 255 / 255; lrgb.b = 0 / 255; lhsv = RaspiAPA102RGB2HSV(lrgb); printf("RGB: %3.2f, %3.2f, %3.2f, HSV: %3.2f, %3.2f, %3.2f\n", lrgb.r, lrgb.g, lrgb.b, lhsv.h, lhsv.s, lhsv.v); const float h_t = lhsv.h; usleep(1000 * 1000 * 10); // Delta hue const float h_d = h_t - h_f; // Fade animation for (int i = 0; i <= 100; ++i) { lhsv.h = h_f + h_d * (float)i / 100.0f; lrgb = RaspiAPA102HSV2RGB(lhsv); const uint8_t ar = (uint8_t)floor(255 * lrgb.r); const uint8_t ag = (uint8_t)floor(255 * lrgb.g); const uint8_t ab = (uint8_t)floor(255 * lrgb.b); printf("RGB: %3d, %3d, %3d, Factor: %2.2f\n", ar, ag, ab, (float)i / 100.0f); // Update LED const RaspiAPA102ColorQuad color = RASPI_APA102_COLOR_QUAD_INITIALIZER(ar, ag, ab, 16); RaspiAPA102DeviceUpdate(&device, &color, 1); usleep(1000 * 50); } return 0; } /* ============================================================================================== */
39.07619
100
0.475262
c52dbc091347737972e1d309688e72e7d18c3a34
1,205
h
C
inst.h
trembeczkib/ISA-uProcessor
8c8e6c7363a4f7c8ad89e0a7268de17139a4d68e
[ "MIT" ]
null
null
null
inst.h
trembeczkib/ISA-uProcessor
8c8e6c7363a4f7c8ad89e0a7268de17139a4d68e
[ "MIT" ]
null
null
null
inst.h
trembeczkib/ISA-uProcessor
8c8e6c7363a4f7c8ad89e0a7268de17139a4d68e
[ "MIT" ]
null
null
null
#ifndef H_INST #define H_INST #include <bitset> class instruction { public: instruction(); instruction(const std::bitset<4>& type_code, const std::bitset<4>& destination_code, const std::bitset<4>& oper_a_code, const std::bitset<4>& oper_b_code); instruction::instruction(const int& type_code, const int& destination_code, const int& oper_a_code, const int& oper_b_code); instruction(const instruction& source); void set_type_code(const std::bitset<4>& typecode); void set_destination_code(const std::bitset<4>& destination); void set_oper_a_code(const std::bitset<4>& operand_a); void set_oper_b_code(const std::bitset<4>& operand_b); const std::bitset<4>& get_type_code() const; const std::bitset<4>& get_destination_code() const; const std::bitset<4>& get_oper_a_code() const; const std::bitset<4>& get_oper_b_code() const; void print() const; void operator = (const instruction& other); bool operator == (const instruction& other); std::ostream &operator << (std::ostream &str); private: std::bitset<4> type_code; std::bitset<4> destination_code; std::bitset<4> oper_a_code; std::bitset<4> oper_b_code; }; #endif
31.710526
158
0.706224
27b7905807b1ce659ace16ed29f9209f07f5e424
5,109
h
C
include/blogger/loggers/async_logger.h
8infy/BLogger
e468c22e657d511d6f2ba801689bab73a88f101e
[ "Apache-2.0" ]
27
2019-09-13T18:21:21.000Z
2022-03-01T01:01:13.000Z
include/blogger/loggers/async_logger.h
8infy/BLogger
e468c22e657d511d6f2ba801689bab73a88f101e
[ "Apache-2.0" ]
5
2019-05-24T05:10:41.000Z
2020-06-04T06:54:23.000Z
include/blogger/loggers/async_logger.h
8infy/BLogger
e468c22e657d511d6f2ba801689bab73a88f101e
[ "Apache-2.0" ]
10
2019-10-28T04:52:28.000Z
2020-11-25T00:57:08.000Z
#pragma once #include <thread> #include <mutex> #include <condition_variable> #include <atomic> #include <vector> #include <deque> #include <functional> #include <memory> #include "blogger/core.h" #include "blogger/loggers/logger.h" #include "blogger/sinks/file_sink.h" #include "blogger/sinks/console_sink.h" #include "blogger/sinks/colored_console_sink.h" #include "blogger/log_levels.h" // Probably shouldnt be higher than 4 because the thread_pool // threads will spend most of the time waiting // for the I/O mutex anyway. Unless you're posting your own tasks. #define BLOGGER_THREAD_COUNT std::thread::hardware_concurrency() #define BLOGGER_TASK_LIMIT 10000 namespace bl { // You can make your own tasks // and feed them to the thread_pool // as well. class task { public: virtual void complete() = 0; virtual ~task() = default; }; class bl_task : public task { protected: shared_sinks log_sinks; protected: bl_task(shared_sinks& sinks) : log_sinks(sinks) { } }; class log_task : public bl_task { private: log_message msg; public: log_task( log_message&& msg, shared_sinks& sinks ) : bl_task(sinks), msg(std::move(msg)) { } void complete() override { msg.finalize_format(); for (auto& sink : *log_sinks) { sink->write(msg); } } }; class flush_task : public bl_task { public: flush_task(shared_sinks& sinks) : bl_task(sinks) { } void complete() override { for (auto& sink : *log_sinks) { sink->flush(); } } }; class thread_pool { public: using task_ptr = std::unique_ptr<task>; private: std::vector<std::thread> m_pool; std::deque<task_ptr> m_task_queue; std::mutex m_queue_access; std::condition_variable m_notifier; std::atomic_bool m_running; private: thread_pool(uint16_t thread_count) : m_running(true) { m_pool.reserve(thread_count); for (uint16_t i = 0; i < thread_count; i++) m_pool.emplace_back([this]() { worker(); }); } thread_pool(const thread_pool& other) = delete; thread_pool(thread_pool&& other) = delete; thread_pool& operator=(const thread_pool& other) = delete; thread_pool& operator=(thread_pool&& other) = delete; void worker() { bool did_work = true; std::mutex worker_lock; std::unique_lock<std::mutex> task_waiter(worker_lock); while (m_running || did_work) { if (!did_work) m_notifier.wait_for( task_waiter, std::chrono::seconds(5) ); did_work = do_work(); } } bool do_work() { task_ptr p; { locker lock(m_queue_access); if (!m_task_queue.empty()) { p = std::move(m_task_queue.front()); m_task_queue.pop_front(); } else return false; } p->complete(); return true; } void shutdown() { m_running = false; m_notifier.notify_all(); for (auto& worker : m_pool) worker.join(); } public: static thread_pool& get() { static thread_pool instance( BLOGGER_THREAD_COUNT ); return instance; } void post_task(std::unique_ptr<task> t) { { locker lock(m_queue_access); if (m_task_queue.size() == BLOGGER_TASK_LIMIT) m_task_queue.pop_front(); m_task_queue.emplace_back(std::move(t)); } m_notifier.notify_one(); } ~thread_pool() { shutdown(); } }; class async_logger : public logger { public: async_logger( in_string tag, level lvl, bool default_pattern = true ): logger(tag, lvl, default_pattern) { thread_pool::get(); } void flush() override { thread_pool::get().post_task( std::make_unique<flush_task>(m_sinks) ); } ~async_logger() {} private: void post(log_message&& msg) override { thread_pool::get().post_task( std::make_unique<log_task>(std::move(msg), m_sinks) ); } }; } #undef BLOGGER_THREAD_COUNT #undef BLOGGER_TASK_LIMIT
22.310044
67
0.499511
7eda3b808f225ffa2cb83885fdc467cd2e77adab
3,691
h
C
CGBattle/CGBattle/CGUnit.h
misitegj/CGBattle
17f597ff07ecd3cf661e2a96f69fd4124e08e3fb
[ "MIT" ]
null
null
null
CGBattle/CGBattle/CGUnit.h
misitegj/CGBattle
17f597ff07ecd3cf661e2a96f69fd4124e08e3fb
[ "MIT" ]
null
null
null
CGBattle/CGBattle/CGUnit.h
misitegj/CGBattle
17f597ff07ecd3cf661e2a96f69fd4124e08e3fb
[ "MIT" ]
null
null
null
// // CGBattleUnit.h // CGBattle // // Created by Samuel on 9/20/15. // Copyright (c) 2015 Samuel. All rights reserved. // #import "CGSkill.h" typedef enum { CGActionUnitPrepare, CGActionUnitWillAction, CGActionUnitDidAction, CGActionUnitEndAction, CGActionUnitWillHurt, CGActionUnitDidHurt, } CGActionState; typedef enum : NSUInteger { CGBattleTeamAtker, CGBattleTeamDefer, } CGBattleTeamType; @class CGWorld, CGAction; @interface CGUnit : NSObject <NSCopying> @property (nonatomic, assign) int UID; @property (nonatomic, strong) NSString *originName; // 初始名 @property (nonatomic, strong) NSString *name; // 名字 @property (nonatomic, assign) int charm; // 魅力 @property (nonatomic, assign) BOOL canControl; // 是否能控制, 即是否自己的 @property (nonatomic, assign) int kind; // 种类 人形系 @property (nonatomic, assign) int hurt; // 受伤状态 @property (nonatomic, assign) int soul; // 掉魂 0~-5 @property (nonatomic, assign) int Lv; // 等级 @property (nonatomic, assign) int hp; // 生命 @property (nonatomic, assign) int mp; // 魔法 @property (nonatomic, assign) int atk; // 攻击 @property (nonatomic, assign) int def; // 防御 @property (nonatomic, assign) int agi; // 敏捷 @property (nonatomic, assign) int rep; // 回复 @property (nonatomic, assign) int spr; // 精神 @property (nonatomic, assign) int crystal; // 水晶 @property (nonatomic, strong) NSArray *skills; // 技能 @property (nonatomic, assign) int skillColumnCount; // 技能栏个数 // 5bp @property (nonatomic, assign) int bpRemain; @property (nonatomic, assign) int bpHp; @property (nonatomic, assign) int bpStr; @property (nonatomic, assign) int bpDef; @property (nonatomic, assign) int bpAgi; @property (nonatomic, assign) int bpMp; // 6抗性 @property (nonatomic, assign) int rstPosion; @property (nonatomic, assign) int rstRock; @property (nonatomic, assign) int rstDrunk; @property (nonatomic, assign) int rstSleepy; @property (nonatomic, assign) int rstConfuse; @property (nonatomic, assign) int rstForget; // 4修正 @property (nonatomic, assign) int crtCritical; @property (nonatomic, assign) int crtAccurate; @property (nonatomic, assign) int crtHitBack; @property (nonatomic, assign) int crtDodge; // 3生产数值 @property (nonatomic, assign) int pdDex; // 灵巧 @property (nonatomic, assign) int pdSta; // 耐力 @property (nonatomic, assign) int pdWis; // 智力 // 装备 @property (nonatomic, strong) id equipAcc0; // 饰品0 @property (nonatomic, strong) id equipAcc1; // 饰品1 @property (nonatomic, strong) id equipWeapon; // 武器主手 @property (nonatomic, strong) id equipWeaponAss; // 副手 @property (nonatomic, strong) id equipClothes; // 衣服 @property (nonatomic, strong) id equipShoes; // 鞋子 @property (nonatomic, strong) id equipCrystal; // 水晶 // 战斗 @property (nonatomic, assign) BOOL isActioned; @property (nonatomic, assign) CGBattleTeamType team; // @property (nonatomic, strong) NSMutableSet *buffs; // 增益 @property (nonatomic, assign) int location; // 位置0-9 @property (nonatomic, assign) int isAlive; // 是否存活 - (instancetype)init; - (CGAction *)selectSkillAndTarget:(CGWorld *)world; // 选择技能和目标, 返回CGAction - (NSArray *)doAction:(CGAction *)action world:(CGWorld *)world; - (BOOL)canMeleeHitBack; - (int)attributesWithBuffType:(CGSkillBuffType)type value:(int)value; // 计算buff params 后的战斗属性值 - (void)addBuffParam:(CGSkillBuffParam *)param; - (void)updateBuffParams; // 战斗中得属性值, 加上buff params 后的结果 - (int)battleAtk; - (int)battleDef; - (int)battleAgi; - (int)battleRep; - (int)battleSpr; @end // 宠物 @interface CGPet : CGUnit @property (nonatomic, assign) int loyalty; // 忠诚度 @end @interface CGEnemy : CGUnit @property (nonatomic, strong) NSArray *rootItems; // 掉落物品, 敌方only @end
25.455172
94
0.714441
7d927174e5a74c1ce709f0d6a1edd91113311044
9,751
h
C
schema-util/include/schema-util/Types.h
openenergysolutions/openfmb.adapters
3c95b1c460a8967190bdd9ae16677a4e2a5d9861
[ "Apache-2.0" ]
1
2021-08-20T12:14:11.000Z
2021-08-20T12:14:11.000Z
schema-util/include/schema-util/Types.h
openenergysolutions/openfmb.adapters
3c95b1c460a8967190bdd9ae16677a4e2a5d9861
[ "Apache-2.0" ]
3
2021-06-16T19:25:23.000Z
2021-09-02T14:39:10.000Z
schema-util/include/schema-util/Types.h
openenergysolutions/openfmb.adapters
3c95b1c460a8967190bdd9ae16677a4e2a5d9861
[ "Apache-2.0" ]
null
null
null
// SPDX-FileCopyrightText: 2021 Open Energy Solutions Inc // // SPDX-License-Identifier: Apache-2.0 #ifndef OPENFMB_ADAPTER_SCHEMAUTIL_TYPES_H #define OPENFMB_ADAPTER_SCHEMAUTIL_TYPES_H #include "IProperty.h" #include <memory> #include <utility> #include <vector> #include <map> #include <set> namespace adapter { namespace schema { enum class Required { yes, no }; enum class Default { yes, no }; struct PropertyMetadata { Required required; std::string name; const std::string description; PropertyMetadata( Required required, std::string name, std::string description ) : required(required), name(std::move(name)), description(std::move(description)) {} }; template<class T> struct Bound { Bound(bool valid, T value) : valid(valid), value(value) {} static Bound unused() { return Bound(false, T{}); } static Bound from(T value) { return Bound(true, value); } const bool valid; const T value; }; struct ConstantProperty { const std::string property_name; const std::string value; ConstantProperty(std::string property_name, std::string value) : property_name(std::move(property_name)), value(std::move(value)) {} template <typename Enum> static ConstantProperty from_enum(typename Enum::Value value) { return ConstantProperty(Enum::label, Enum::to_string(value)); } }; class Object; class Variant { public: std::vector<ConstantProperty> constant_values; std::shared_ptr<Object> obj; const Default is_default; Variant(const std::vector<ConstantProperty> &constant_values, const std::initializer_list<property_ptr_t> &required_values, Default is_default = Default::no) : constant_values(constant_values), obj(std::make_shared<Object>(required_values)), is_default(is_default) {} Variant(const std::vector<ConstantProperty> &constant_values, std::shared_ptr<Object> obj, Default is_default = Default::no) : constant_values(constant_values), obj(std::move(obj)), is_default(is_default) {} }; class OneOf { public: std::vector<Variant> variants; OneOf() = default; OneOf(const std::initializer_list<Variant> &variants) : variants(variants) {} }; class ObjectRefName { public: const std::string ref_name; ObjectRefName(std::string ref_name) : ref_name(std::move(ref_name)) {} }; class Object { public: /// Collection of all properties in an object std::vector<property_ptr_t> properties; OneOf one_of; std::shared_ptr<ObjectRefName> ref; explicit Object(std::vector<property_ptr_t> properties) : properties(std::move(properties)) {} Object(std::vector<property_ptr_t> properties, OneOf one_of) : properties(std::move(properties)), one_of(std::move(one_of)) {} static Object create_ref(ObjectRefName ref_name, std::vector<property_ptr_t> properties, OneOf one_of) { auto obj = Object(properties, one_of); obj.ref = std::make_shared<ObjectRefName>(ref_name); return obj; } }; class PropertyBase : public IProperty { PropertyMetadata metadata; public: explicit PropertyBase(PropertyMetadata metadata): metadata(std::move(metadata)) {} const std::string &get_description() const override { return this->metadata.description; } const std::string &get_name() const override { return this->metadata.name; } void set_name(const std::string& name) { this->metadata.name = name; } bool is_required() const override { return this->metadata.required == Required::yes; } void set_required() override { this->metadata.required = Required::yes; } }; class ObjectRef : public PropertyBase { public: const ObjectRefName ref_name; ObjectRef(const PropertyMetadata& metadata, ObjectRefName ref_name) : PropertyBase(metadata), ref_name(std::move(ref_name)) {} void visit(IVisitor& visitor) override; }; class ArrayProperty : public PropertyBase { public: property_ptr_t array_items; ArrayProperty(const PropertyMetadata &metadata, property_ptr_t arrayItems) : PropertyBase(metadata), array_items(std::move(arrayItems)) {} void visit(IVisitor &visitor) override; }; template<class T> class TypedPropertyBase : public PropertyBase { const T default_value; public: TypedPropertyBase(const PropertyMetadata& metadata, T default_value) : PropertyBase(metadata), default_value(std::move(default_value)) {} const T &get_default_value() const { return this->default_value; } }; class BoolProperty : public TypedPropertyBase<bool> { public: BoolProperty(const PropertyMetadata& metadata, bool default_value) : TypedPropertyBase<bool>(metadata, default_value) {} void visit(IVisitor &visitor) override; }; enum class StringFormat { None, IPv4, Uuid, Subject, BitString, MacAddress }; class StringProperty : public TypedPropertyBase<std::string> { public: const StringFormat format; StringProperty(const PropertyMetadata& metadata, const std::string &default_value, StringFormat format) : TypedPropertyBase<std::string>(metadata, default_value), format(format) {} void visit(IVisitor &visitor) override; }; class EnumProperty : public TypedPropertyBase<std::string> { public: const std::vector<std::string> values; EnumProperty(const PropertyMetadata& metadata, const std::string &default_value, std::vector<std::string> values) : TypedPropertyBase<std::string>(metadata, default_value), values(std::move(values)) {} void visit(IVisitor &visitor) override; }; template <class Enum> class TypedEnumProperty: public EnumProperty { public: TypedEnumProperty(const PropertyMetadata& metadata, const std::string &default_value, const std::vector<std::string>& values) : EnumProperty(metadata, default_value, values) {} ConstantProperty when(typename Enum::Value value) { return ConstantProperty(this->get_name(), Enum::to_string(value)); } }; template<class T> class NumericProperty : public TypedPropertyBase<T> { public: const Bound<T> min; const Bound<T> max; NumericProperty(const PropertyMetadata& metadata, const T &default_value, Bound<T> min, Bound<T> max) : TypedPropertyBase<T>(metadata, default_value), min(min), max(max) {} void visit(IVisitor &visitor) override; }; class ObjectProperty : public PropertyBase { public: Object object; ObjectProperty(const PropertyMetadata& metadata, Object object) : PropertyBase(metadata), object(std::move(object)) {} void visit(IVisitor &visitor) override; }; class IVisitor { public: virtual ~IVisitor() = default; virtual void begin(const ObjectProperty &prop) = 0; virtual void on_property(const ObjectRef & ref) = 0; virtual void on_property(const BoolProperty &prop) = 0; virtual void on_property(const StringProperty &prop) = 0; virtual void on_property(const EnumProperty &prop) = 0; virtual void on_property(const ArrayProperty& prop) = 0; virtual void on_property(const NumericProperty<float> &prop) = 0; virtual void on_property(const NumericProperty<double> &prop) = 0; virtual void on_property(const NumericProperty<int64_t> &prop) = 0; virtual void on_property(const NumericProperty<uint16_t> &prop) = 0; virtual void end(const ObjectProperty &prop) = 0; }; template<class T> void NumericProperty<T>::visit(IVisitor &visitor) { visitor.on_property(*this); } } } #endif //OPENFMB_ADAPTER_TYPES_H
29.911043
139
0.551533
47a2d0de0b176cd5695a69dadf2bd90533b0707d
3,408
h
C
src/fltk.h
zot/go-fltk
617fb99069edea4f88c7c27fc051c3edc58360cc
[ "Zlib" ]
16
2016-03-17T05:06:43.000Z
2022-03-12T01:28:26.000Z
src/fltk.h
zot/go-fltk
617fb99069edea4f88c7c27fc051c3edc58360cc
[ "Zlib" ]
1
2021-06-14T14:45:03.000Z
2021-07-01T20:49:16.000Z
src/fltk.h
zot/go-fltk
617fb99069edea4f88c7c27fc051c3edc58360cc
[ "Zlib" ]
8
2015-03-19T04:58:10.000Z
2020-09-29T12:03:30.000Z
#ifdef __cplusplus #define TYPEDEF(type) typedef fltk::type type extern "C" { #else #define TYPEDEF(type) typedef struct type type enum { CTRL = 0x00040000, /*!< Either ctrl key held down */ ALT = 0x00080000, /*!< Either alt key held down */ META = 0x00400000, /*!< "Windows" or the "Apple" keys held down */ #if defined(__APPLE__) ACCELERATOR = CTRL, OPTION = ALT, COMMAND = META #else ACCELERATOR = ALT, //!< ALT on Windows/Linux, CTRL on OS/X, use for menu accelerators COMMAND = CTRL, //!< CTRL on Windows/Linux, META on OS/X, use for menu shortcuts OPTION = ALT|META //!< ALT|META on Windows/Linux, just ALT on OS/X, use as a drag modifier #endif }; #endif TYPEDEF(Box); TYPEDEF(Font); TYPEDEF(LabelType); TYPEDEF(Widget); TYPEDEF(Group); TYPEDEF(PackedGroup); TYPEDEF(Window); TYPEDEF(Input); TYPEDEF(TextEditor); extern Widget *go_fltk_callback_widget; extern int go_fltk_event; extern Widget *go_fltk_event_widget; extern int go_fltk_event_state; extern int go_fltk_event_button; extern int go_fltk_event_clicks; extern int go_fltk_event_dx; extern int go_fltk_event_dy; extern int go_fltk_event_key; extern int go_fltk_event_x; extern int go_fltk_event_y; extern int go_fltk_event_x_root; extern int go_fltk_event_y_root; extern int go_fltk_event_stolen; extern int go_fltk_event_return; extern void free(void *ptr); static inline void free_string(char* s) { free(s); } static inline char* to_char_ptr(void *ptr) {return (char *)ptr;} extern Box *go_fltk_get_UP_BOX(); extern Font *go_fltk_get_HELVETICA_BOLD_ITALIC(); extern LabelType *go_fltk_get_SHADOW_LABEL(); extern Window *go_fltk_new_Window(int w, int h); extern PackedGroup *go_fltk_new_PackedGroup(int x, int y, int w, int h); extern Widget *go_fltk_new_Widget(int x, int y, int w, int h, const char *text); extern Input *go_fltk_new_Input(int x, int y, int w, int h, const char *text); extern TextEditor *go_fltk_new_TextEditor(int x, int y, int w, int h, const char *text); extern void go_fltk_Widget_steal_events(Widget *w, int events); extern void go_fltk_Event_continue(); extern void go_fltk_Group_begin(Group *g); extern void go_fltk_Group_end(Group *g); extern void go_fltk_Group_add(Group *g, Widget *w); extern void go_fltk_Group_resizable(Group *g, Widget *w); extern void go_fltk_Widget_box(Widget *w, Box *box); extern void go_fltk_Widget_labelfont(Widget *w, Font *font); extern void go_fltk_Widget_labelsize(Widget *w, int size); extern void go_fltk_Widget_labeltype(Widget *w, LabelType *type); extern void go_fltk_Widget_callback(Widget *w); extern void go_fltk_Window_destroy(Window *w); extern void go_fltk_Window_show(Window *w, int argc, void *argv); extern void go_fltk_Window_set_label(Window *w, const char *label); extern int go_fltk_Widget_x(Widget *w); extern int go_fltk_Widget_y(Widget *w); extern int go_fltk_Widget_w(Widget *w); extern int go_fltk_Widget_h(Widget *w); extern void go_fltk_Widget_throw_focus(Widget *w); extern const char *go_fltk_Input_get_text(Input *in); extern int go_fltk_Input_set_text(Input *in, const char *text); extern int go_fltk_Input_mouse_position(Input *in); extern int go_fltk_Input_get_position(Input *in); extern int go_fltk_Input_get_mark(Input *in); extern void go_fltk_Input_set_position(Input *in, int p, int m); extern void go_fltk_run(); extern void go_fltk_get_event(); extern void go_fltk_continue_event(int i); #ifdef __cplusplus } #endif
37.043478
92
0.779343
2a25ad5ecfc53128b655ac6524f8eff91304c4ff
1,553
h
C
engines/ep/tests/mock/mock_add_stat_fn.h
BenHuddleston/kv_engine
78123c9aa2c2feb24b7c31eecc862bf2ed6325e4
[ "MIT", "BSD-3-Clause" ]
104
2017-05-22T20:41:57.000Z
2022-03-24T00:18:34.000Z
engines/ep/tests/mock/mock_add_stat_fn.h
BenHuddleston/kv_engine
78123c9aa2c2feb24b7c31eecc862bf2ed6325e4
[ "MIT", "BSD-3-Clause" ]
3
2017-11-14T08:12:46.000Z
2022-03-03T11:14:17.000Z
engines/ep/tests/mock/mock_add_stat_fn.h
BenHuddleston/kv_engine
78123c9aa2c2feb24b7c31eecc862bf2ed6325e4
[ "MIT", "BSD-3-Clause" ]
71
2017-05-22T20:41:59.000Z
2022-03-29T10:34:32.000Z
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2020-Present Couchbase, Inc. * * Use of this software is governed by the Business Source License included * in the file licenses/BSL-Couchbase.txt. As of the Change Date specified * in that file, in accordance with the Business Source License, use of this * software will be governed by the Apache License, Version 2.0, included in * the file licenses/APL2.txt. */ #pragma once #include <folly/portability/GMock.h> #include <memcached/engine_common.h> /** * Mock AddStatFn, implemented using GoogleMock. * * GoogleTest doesn't correctly print std::string_view if an expectation fails, * but does for std::string - therefore define a mock method taking * std::string and then operator() as a trampoline function taking * std::string_view and calling the GoogleMock method with std::string. * * To use, set expectations on the 'stat()' method then use asStdFunction() * to invoke: * * MockAddStat mockAddStat; * EXPECT_CALL(mockAddStat, stat("some_stat_key", "0", cookie)); * ... * someMethodExpectingAddStatFn(..., mockAddStat.asStdFunction()); */ struct MockAddStat { MOCK_CONST_METHOD3(callback, void(std::string, std::string, const void*)); AddStatFn asStdFunction() { return [this](std::string_view key, std::string_view value, const void* cookie) { callback(std::string{key}, std::string{value}, cookie); }; } };
36.116279
79
0.672891
2a6a02ed88b02b3a852ef0519585803045ceb487
1,821
h
C
ScribbleAppQt/QtMessageTickler.h
calgaryscientific/pureweb-cpp-samples
71ba4e501a05f40dc6447a8e8888848c596c4ef5
[ "Apache-2.0" ]
null
null
null
ScribbleAppQt/QtMessageTickler.h
calgaryscientific/pureweb-cpp-samples
71ba4e501a05f40dc6447a8e8888848c596c4ef5
[ "Apache-2.0" ]
null
null
null
ScribbleAppQt/QtMessageTickler.h
calgaryscientific/pureweb-cpp-samples
71ba4e501a05f40dc6447a8e8888848c596c4ef5
[ "Apache-2.0" ]
null
null
null
#ifndef QTMESSAGETICKLER_H #define QTMESSAGETICKLER_H class QtMessageTickler : public QObject, public CSI::PureWeb::Server::IResponseProvider, public CSI::PureWeb::Server::IStateManagerPlugin { private: CSI::Collections::List<CSI::PureWeb::Server::ResponseInfo> m_empty; CSI::PureWeb::Server::StateManager * m_pStateManager; int m_eventCounter; public: QtMessageTickler() { m_eventCounter = 0; } bool event(QEvent * event) { if (event->type() == QEvent::User) { CSI::Threading::Interlocked::Exchange(&m_eventCounter, 0); CSI::Threading::UiDispatcher::PumpMessages(); return true; } return false; } void SessionConnected(CSI::Guid sessionId, CSI::Typeless const& command) { m_pStateManager->SessionManager().AddResponseProvider(sessionId, this); } void SessionDisconnected(CSI::Guid sessionId, CSI::Typeless const& command) { m_pStateManager->SessionManager().RemoveResponseProvider(sessionId, this); } CSI::Collections::List<CSI::PureWeb::Server::ResponseInfo> GetNextResponses(CSI::Guid sessionId) { if (CSI::Threading::Interlocked::CompareExchange(&m_eventCounter, 1, 0)) { QEvent * event = new QEvent(QEvent::User); QApplication::postEvent(this,event); } return m_empty; } void Initialize(CSI::PureWeb::Server::StateManager * pStateManager) { if (pStateManager == NULL) CSI_THROW(CSI::ArgumentNullException, "pStateManager"); m_pStateManager = pStateManager; } void Uninitialize() {} }; #endif // QTMESSAGETICKLER_H
28.904762
138
0.605711
2a71e7c639c17191668341084c83a59a3cb1b2ed
161
h
C
ObjC/Weight/Kilogram.h
materik/unit
f6fa1bd2d6d493d53f60bd3d02adbebfc2c895a7
[ "MIT" ]
3
2016-02-16T13:17:47.000Z
2016-02-18T11:32:48.000Z
ObjC/Weight/Kilogram.h
materik/unit
f6fa1bd2d6d493d53f60bd3d02adbebfc2c895a7
[ "MIT" ]
1
2016-05-11T14:25:04.000Z
2016-05-11T14:25:04.000Z
ObjC/Weight/Kilogram.h
materik/unitility
f6fa1bd2d6d493d53f60bd3d02adbebfc2c895a7
[ "MIT" ]
null
null
null
// // Kilogram.h // Pods // // Created by materik on 16/02/16. // // #import "Unit.h" #import "WeightProtocol.h" @interface Kilogram : Unit <Weight> @end
10.0625
35
0.614907
042bcf56dd74832bfe762c4b14f12a4e5dfb4544
1,751
h
C
lib/memory.h
techno/mist32-demos
601c6c55cb6aec7a4a4dcdfc7de4da631a441f6b
[ "BSD-2-Clause" ]
null
null
null
lib/memory.h
techno/mist32-demos
601c6c55cb6aec7a4a4dcdfc7de4da631a441f6b
[ "BSD-2-Clause" ]
null
null
null
lib/memory.h
techno/mist32-demos
601c6c55cb6aec7a4a4dcdfc7de4da631a441f6b
[ "BSD-2-Clause" ]
1
2022-01-16T15:41:35.000Z
2022-01-16T15:41:35.000Z
#define MEMORY_MAX_ADDR 0x04000000 #define STACK_SIZE 0x100000 /* 1MB */ #define PSR_MMUMOD_MASK 0x3 #define PSR_MMUMOD (PSR & PSR_MMUMOD_MASK) #define PSR_MMUMOD_DIRECT 0x0 #define PSR_MMUMOD_L1 0x1 #define PSR_MMUMOD_L2 0x2 #define PSR_MMUPS_MASK 0x380 #define PSR_MMUPS_OFFSET 7 #define PSR_MMUPS ((PSR & PSR_MMUPS_MASK) >> PSR_MMUPS_OFFSET) #define PSR_MMUPS_4KB 0x1 #define MMU_PAGE_SIZE 4096 #define MMU_PAGE_SIZE_PSE (4096 * 1024) #define MMU_PAGE_INDEX_L1 0xffc00000 #define MMU_PAGE_INDEX_L2 0x003ff000 #define MMU_PAGE_OFFSET 0x0000fff #define MMU_PAGE_OFFSET_PSE 0x003fffff #define MMU_PAGE_NUM 0xfffff000 #define MMU_PTE_VALID 0x001 #define MMU_PTE_R 0x002 #define MMU_PTE_D 0x004 #define MMU_PTE_EX 0x008 #define MMU_PTE_PP 0x030 #define MMU_PTE_PP_RWXX 0x000 #define MMU_PTE_PP_RDXX 0x010 #define MMU_PTE_PP_RWRD 0x020 #define MMU_PTE_PP_RWRW 0x030 #define MMU_PTE_CD 0x040 #define MMU_PTE_G 0x080 #define MMU_PTE_PE 0x100 #define OFFSET(ptr, offset) ((void *)((char *)ptr + offset)) typedef union { struct { unsigned int indexL1 : 10; unsigned int indexL2 : 10; unsigned int flags : 12; }; unsigned int raw; void *ptr; } page_table_entry; void *memcpy_bswap32(void *dest, const void *src, size_t n); static inline void memory_paging_start(void) { unsigned int psr; __asm__("srpsr %0" : "=r"(psr)); psr = (psr & PSR_MMUPS_MASK) | (PSR_MMUPS_4KB << PSR_MMUPS_OFFSET); __asm__("srpsw %0" : : "r"(psr)); __asm__("srmmuw 2"); } static inline void memory_paging_stop(void) { __asm__("srmmuw 0"); } static inline void memory_pdt_set(page_table_entry *pdt) { __asm__("srpdtw %0" : : "r"(pdt)); } static inline void memory_kpdt_set(page_table_entry *pdt) { __asm__("srkpdtw %0" : : "r"(pdt)); }
23.346667
69
0.755568
a490cbe46dae0ecddbf187e7ee3d5d1745a3bcf0
282
h
C
Source/archive/m68k-amigaos/os-include/resources/potgo.h
aGGre55or/darkesthour
2555bf2a328b895669c1ff2e7f1bb642da1b1eca
[ "Unlicense" ]
21
2021-04-04T06:00:44.000Z
2022-01-19T19:12:24.000Z
Source/archive/m68k-amigaos/os-include/resources/potgo.h
aGGre55or/darkesthour
2555bf2a328b895669c1ff2e7f1bb642da1b1eca
[ "Unlicense" ]
null
null
null
Source/archive/m68k-amigaos/os-include/resources/potgo.h
aGGre55or/darkesthour
2555bf2a328b895669c1ff2e7f1bb642da1b1eca
[ "Unlicense" ]
2
2021-10-30T12:59:43.000Z
2021-10-31T09:58:15.000Z
#ifndef RESOURCES_POTGO_H #define RESOURCES_POTGO_H /* ** $VER: potgo.h 36.0 (13.4.1990) ** Includes Release 45.1 ** ** potgo resource name ** ** (C) Copyright 1986-2001 Amiga, Inc. ** All Rights Reserved */ #define POTGONAME "potgo.resource" #endif /* RESOURCES_POTGO_H */
17.625
38
0.684397
d1020cce4018630e371f7832f6e37bbd959ac332
3,838
h
C
physics/tests/vecPhysTests/Common/Hist.h
Geant-RnD/geant
ffff95e23547531f3254ada2857c062a31f33e8f
[ "ECL-2.0", "Apache-2.0" ]
2
2016-10-16T14:37:42.000Z
2018-04-05T15:49:09.000Z
physics/tests/vecPhysTests/Common/Hist.h
Geant-RnD/geant
ffff95e23547531f3254ada2857c062a31f33e8f
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
physics/tests/vecPhysTests/Common/Hist.h
Geant-RnD/geant
ffff95e23547531f3254ada2857c062a31f33e8f
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
#ifndef HIST_H #define HIST_H #include <iostream> #include <cmath> // IT IS JUST FOR TESTING class Hist { public: Hist(double min, double max, int numbin) { fMin = min; fMax = max; fNumBins = numbin; fDelta = (fMax - fMin) / (numbin); fx = new double[fNumBins]; fy = new double[fNumBins]; for (int i = 0; i < fNumBins; ++i) { fx[i] = fMin + i * fDelta; fy[i] = 0.0; } fSum = 0.0; } Hist(double min, double max, double delta) { fMin = min; fMax = max; fDelta = delta; fNumBins = (int)((fMax - fMin) / (delta)) + 1.0; fx = new double[fNumBins]; fy = new double[fNumBins]; for (int i = 0; i < fNumBins; ++i) { fx[i] = fMin + i * fDelta; fy[i] = 0.0; } fSum = 0.0; } void Fill(double x) { int indx = (int)((x - fMin) / fDelta); if (indx < 0) { std::cerr << "\n ***** ERROR in Hist::FILL => x = " << x << " < fMin = " << fMin << std::endl; exit(1); } fy[indx] += 1.0; } void Fill(double x, double w) { int indx = (int)((x - fMin) / fDelta); if (indx < 0) { std::cerr << "\n ***** ERROR in Hist::FILL => x = " << x << " < fMin = " << fMin << std::endl; exit(1); } fy[indx] += 1.0 * w; } int GetNumBins() const { return fNumBins; } double GetDelta() const { return fDelta; } double *GetX() const { return fx; } double *GetY() const { return fy; } Hist operator/(Hist &b) { Hist &a = *this; assert(a.fMax == b.fMax); assert(a.fMin == b.fMin); assert(a.fNumBins = b.fNumBins); Hist res(a.fMin, a.fMax, a.fNumBins); for (int xi = 0; xi < fNumBins; ++xi) { res.fx[xi] = a.fx[xi]; res.fy[xi] = a.fy[xi] / b.fy[xi]; if (a.fy[xi] == 0.0 && b.fy[xi] == 0.0) { res.fy[xi] = 1.0; } res.fy[xi] = (res.fy[xi] - 1.0) * 100.0; } return res; } /* * Compare this histogram with other one, assuming N[bin] ~ Poisson(N_observed[bin]) * Then Mean[ N[bin] ] = N_observed[bin] * Variance[ N[bin] ] = Sqrt[ N_observed[bin] ] * * Sigma of difference N_hist1[bin] - N_hist2[bin] approx. = Sqrt[N_hist1 + N_hist2] * * Reports #bins with difference less than 4 sigma(defined above), and >= 4 sigma */ void Compare(Hist &hist) { int fourSigmaDev = 0, bigDev = 0; Hist &a = *this; Hist &b = hist; assert(a.fMax == b.fMax); assert(a.fMin == b.fMin); assert(a.fNumBins = b.fNumBins); Hist diff(a.fMin, a.fMax, a.fNumBins); Hist diffSigma(a.fMin, a.fMax, a.fNumBins); for (int xi = 0; xi < fNumBins; ++xi) { diff.fx[xi] = a.fx[xi]; diffSigma.fx[xi] = a.fx[xi]; if (a.fy[xi] == 0.0 && b.fy[xi] == 0.0) { diff.fy[xi] = 0.0; diffSigma.fy[xi] = 0.0; } else { diff.fy[xi] = ComputeDiff(a.fy[xi], b.fy[xi]); diffSigma.fy[xi] = ComputeDiffSigma(a.fy[xi], b.fy[xi]); } if (std::abs(diff.fy[xi]) <= 4.0 * diffSigma.fy[xi]) { fourSigmaDev++; } else { Printf("Big deviation in bin x: %f H1: %f H2: %f dev: %f dev_sigma %f", diff.fx[xi], a.fy[xi], b.fy[xi], diff.fy[xi], diffSigma.fy[xi]); bigDev++; } } Printf("4 sigma dev: %d | big dev: %d", fourSigmaDev, bigDev); } void Print() { for (int xi = 0; xi < fNumBins; ++xi) { Printf("%10f -- %10f", fx[xi], fy[xi]); } } private: double ComputeDiff(double a, double b) { assert(a >= 0.0); assert(b >= 0.0); return a - b; } double ComputeDiffSigma(double a, double b) { assert(a >= 0.0); assert(b >= 0.0); return std::sqrt(a + b); } double *fx; double *fy; double fMin; double fMax; double fDelta; double fSum; int fNumBins; }; #endif
24.291139
112
0.506514
01591f61420ac87eb62917df29b327e0cc7708f0
738
h
C
rpi_tph_monitor_sample/lcd/cpp/LCDAQM.h
ono-t01/django-rpi-tph-monitor
30894d937ece11f8c7d087dd735cd79b203f0cf4
[ "MIT" ]
1
2021-01-24T03:06:58.000Z
2021-01-24T03:06:58.000Z
rpi_tph_monitor_sample/lcd/cpp/LCDAQM.h
ono-t01/django-rpi-tph-monitor
30894d937ece11f8c7d087dd735cd79b203f0cf4
[ "MIT" ]
9
2021-03-18T21:47:39.000Z
2021-11-22T23:55:35.000Z
rpi_tph_monitor_sample/lcd/cpp/LCDAQM.h
ono-t01/django-rpi-tph-monitor
30894d937ece11f8c7d087dd735cd79b203f0cf4
[ "MIT" ]
4
2019-11-13T12:32:14.000Z
2020-01-29T12:51:07.000Z
//--------------------------------- // 2016/8/24 #ifndef LCDAQM_H #define LCDAQM_H //--------------------------------- // Constant //--------------------------------- // Class class LCDAQM{ private: //--------------------------------- // Constant static const uint8_t i2cAdr = 0x3E; //--------------------------------- // Variable int i2c; // I2C uint8_t count; // Character count in line uint8_t line; // 1:1st line, 2:2nd line //--------------------------------- // Function void writeData(uint8_t ctrl, uint8_t data); public: //--------------------------------- // Function LCDAQM(); uint8_t init(); void closeI2C(); void printStr(char*str); void clear(); void home(); void secLine(); }; #endif
14.470588
44
0.428184
0076fa1efd75672b8230bd25461fdc97524ac1f5
1,942
h
C
include/kalmanif/impl/covariance_square_root_base.h
LaplaceKorea/kalmanif
5e0f1f2275e22979afa39d8f67782929f21c1072
[ "MIT" ]
208
2021-04-10T17:11:56.000Z
2022-03-31T08:10:24.000Z
include/kalmanif/impl/covariance_square_root_base.h
LaplaceKorea/kalmanif
5e0f1f2275e22979afa39d8f67782929f21c1072
[ "MIT" ]
4
2021-04-13T20:21:17.000Z
2021-04-13T22:14:57.000Z
include/kalmanif/impl/covariance_square_root_base.h
artivis/kalmanif
5e0f1f2275e22979afa39d8f67782929f21c1072
[ "MIT" ]
22
2021-04-12T04:45:36.000Z
2022-03-29T14:01:52.000Z
#ifndef _KALMANIF_KALMANIF_IMPL_COVARIANCE_SQUARE_ROOT_BASE_H_ #define _KALMANIF_KALMANIF_IMPL_COVARIANCE_SQUARE_ROOT_BASE_H_ namespace kalmanif { namespace internal { /** * @brief Base class for objects with Covariance as a square root * * @tparam StateType The state type */ template <typename StateType> struct CovarianceSquareRootBase { public: /** * @brief Get the reconstructed covariance matrix */ Covariance<StateType> getCovariance() const { return S.reconstructedMatrix(); } /** * @brief Set covariance as a covariance matrix * @param [in] covariance The input covariance * @return true if the covariance is successfully decomposed, false otherwise */ bool setCovariance(const Eigen::Ref<const Covariance<StateType>>& covariance) { KALMANIF_ASSERT( // cast to actual type, error: ‘Options’ is not a member of Eigen::Ref isCovariance(Covariance<StateType>(covariance)), "CovarianceSquareRootBase: Not a covariance matrix!" ); S.compute(covariance); return S.info() == Eigen::Success; } /** * @brief Get covariance as square root */ const CovarianceSquareRoot<StateType>& getCovarianceSquareRoot() const { return S; } /** * @brief Set covariance using square root * * @param covariance_square_root Lower triangular matrix * representing the covariance square root (i.e. P = LLˆT). */ bool setCovarianceSquareRoot( const Covariance<StateType>& covariance_square_root ) { CovarianceSquareRoot<StateType> S; S.setL(covariance_square_root); KALMANIF_ASSERT(isCovariance(S.reconstructedMatrix())); return true; } protected: KALMANIF_DEFAULT_CONSTRUCTOR(CovarianceSquareRootBase); //! Covariance square root CovarianceSquareRoot<StateType> S = CovarianceSquareRoot<StateType>::Identity(); }; } // internal } // kalmanif #endif // _KALMANIF_KALMANIF_IMPL_COVARIANCE_SQUARE_ROOT_BASE_H_
25.552632
81
0.730175
2f3e9f7550bbff2f5f11d66b920ea593182f56a2
211
h
C
ios/versioned-react-native/ABI45_0_0/Expo/ExpoKit/Core/UniversalModules/ABI45_0_0EXScopedReactNativeAdapter.h
ryo-rm/expo
0c398d104ae125cc9fbe96826fd5c22802914a86
[ "MIT" ]
null
null
null
ios/versioned-react-native/ABI45_0_0/Expo/ExpoKit/Core/UniversalModules/ABI45_0_0EXScopedReactNativeAdapter.h
ryo-rm/expo
0c398d104ae125cc9fbe96826fd5c22802914a86
[ "MIT" ]
null
null
null
ios/versioned-react-native/ABI45_0_0/Expo/ExpoKit/Core/UniversalModules/ABI45_0_0EXScopedReactNativeAdapter.h
ryo-rm/expo
0c398d104ae125cc9fbe96826fd5c22802914a86
[ "MIT" ]
null
null
null
// Copyright © 2018 650 Industries. All rights reserved. #import <ABI45_0_0ExpoModulesCore/ABI45_0_0EXReactNativeAdapter.h> @interface ABI45_0_0EXScopedReactNativeAdapter : ABI45_0_0EXReactNativeAdapter @end
26.375
78
0.848341
d1b7e639f2cc38fb51784acbc9054012d6ae1bcd
2,764
c
C
GeeksForGeeks/doublylinkiedlist.c
rajatjha28/CPP-Questions-and-Solutions
fc5bae0da3dc7aed69e663e93128cd899b7bb263
[ "MIT" ]
42
2021-09-26T18:02:52.000Z
2022-03-15T01:52:15.000Z
GeeksForGeeks/doublylinkiedlist.c
rajatjha28/CPP-Questions-and-Solutions
fc5bae0da3dc7aed69e663e93128cd899b7bb263
[ "MIT" ]
404
2021-09-24T19:55:10.000Z
2021-11-03T05:47:47.000Z
GeeksForGeeks/doublylinkiedlist.c
rajatjha28/CPP-Questions-and-Solutions
fc5bae0da3dc7aed69e663e93128cd899b7bb263
[ "MIT" ]
140
2021-09-22T20:50:04.000Z
2022-01-22T16:59:09.000Z
/* Enter your question - #Given a doubly-linked list of positive integers. The task is to print the given doubly linked list data in reverse order. Constraints Number of nodes [0, 5000]. -5000 <= Node.val <= 5000 Enter link to the question(if question belongs to any online platform) - https://www.geeksforgeeks.org/print-doubly-linked-list-in-reverse-order/ Tags for the question(eg - Array, Basic, Stack, etc.) - LinkedList, traversal, pointers */ #include<stdlib.h> #include<stdio.h> //node creation struct node{ int data; struct node* prev;//stores address of previous node struct node* next;//stores address of next node }; //assigning head as a global so that it can bes used by all the functions and we dont have to specifically call for it everytime struct node* head; //function to create a new node struct node* getnewNode(int x) { //creating a newnode in the heap and assigning data, prev and next to it struct node* newNode= (struct node*)malloc(sizeof(struct node)); newNode->data=x; newNode->prev=NULL; newNode->next=NULL; return newNode; } // function to enter a new element from the head of the list void insertHead(int x) { struct node* temp=getnewNode(x); //if the list is empty if(head==NULL) { head=temp; return; } head->prev=temp; temp->next=head; head=temp; } // function to enter a new element from the tail of the list void insertTail(int x) { struct node* ptr=getnewNode(x); struct node* temp; //if the list is empty if(head==NULL) { head=ptr; return; } temp = head; while(temp->next!=NULL) { temp = temp->next; } temp->next = ptr; ptr ->prev=temp; ptr->next = NULL; } // forward printing void printforward() { struct node* temp=head; //iterating till the ned of the list and printing the values as we go along while(temp!=NULL) { printf("%d ",temp->data); temp=temp->next; } printf("\n"); } void printreverse() { struct node* temp=head; //for empty list if(temp==NULL) return; //traversing towards the and of the list while(temp->next!=NULL) { temp=temp->next; } // as we reached the last node. we will traverse backwards and print the data as we go along while(temp!=NULL) { printf("%d ",temp->data); temp=temp->prev; } printf("\n"); } //driver code int main() { head=NULL; insertHead(2); insertHead(4); insertHead(1); insertTail(5); insertTail(7); printforward();//1 4 2 5 7 printreverse();//7 5 2 4 1 }
24.245614
129
0.608177
7f441f8ca0d5201f00a1c0b6b572a318ca08e3aa
9,126
c
C
spl/common/printf.c
tao-eternal/d1-nezha-baremeta
896f97a398aa9b59a54283830b7207e376783bc2
[ "Apache-2.0" ]
26
2021-06-29T13:10:01.000Z
2022-03-27T05:29:19.000Z
spl/common/printf.c
tao-eternal/d1-nezha-baremeta
896f97a398aa9b59a54283830b7207e376783bc2
[ "Apache-2.0" ]
2
2022-01-15T13:36:53.000Z
2022-02-03T12:15:50.000Z
spl/common/printf.c
tao-eternal/d1-nezha-baremeta
896f97a398aa9b59a54283830b7207e376783bc2
[ "Apache-2.0" ]
5
2021-12-24T12:03:10.000Z
2022-03-11T08:54:17.000Z
// * SPDX-License-Identifier: GPL-2.0+ #include <common.h> #include <stdarg.h> #include <arch/uart.h> #include <linux/ctype.h> #include <private_toc.h> #include <private_boot0.h> struct printf_info { char *bf; /* Digit buffer */ char zs; /* non-zero if a digit has been written */ char *outstr; /* Next output position for sprintf() */ /* Output a character */ void (*putc)(struct printf_info *info, char ch); }; const unsigned char _ctype[] = { _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ static void out(struct printf_info *info, char c) { *info->bf++ = c; } static void out_dgt(struct printf_info *info, char dgt) { out(info, dgt + (dgt < 10 ? '0' : 'a' - 10)); info->zs = 1; } static void div_out(struct printf_info *info, unsigned long *num, unsigned long div) { unsigned char dgt = 0; while (*num >= div) { *num -= div; dgt++; } if (info->zs || dgt > 0) out_dgt(info, dgt); } #ifdef CONFIG_SPL_NET_SUPPORT static void string(struct printf_info *info, char *s) { char ch; while ((ch = *s++)) out(info, ch); } static const char hex_asc[] = "0123456789abcdef"; #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] static inline char *pack_hex_byte(char *buf, u8 byte) { *buf++ = hex_asc_hi(byte); *buf++ = hex_asc_lo(byte); return buf; } static void mac_address_string(struct printf_info *info, u8 *addr, bool separator) { /* (6 * 2 hex digits), 5 colons and trailing zero */ char mac_addr[6 * 3]; char *p = mac_addr; int i; for (i = 0; i < 6; i++) { p = pack_hex_byte(p, addr[i]); if (separator && i != 5) *p++ = ':'; } *p = '\0'; string(info, mac_addr); } static char *put_dec_trunc(char *buf, unsigned int q) { unsigned int d3, d2, d1, d0; d1 = (q >> 4) & 0xf; d2 = (q >> 8) & 0xf; d3 = (q >> 12); d0 = 6 * (d3 + d2 + d1) + (q & 0xf); q = (d0 * 0xcd) >> 11; d0 = d0 - 10 * q; *buf++ = d0 + '0'; /* least significant digit */ d1 = q + 9 * d3 + 5 * d2 + d1; if (d1 != 0) { q = (d1 * 0xcd) >> 11; d1 = d1 - 10 * q; *buf++ = d1 + '0'; /* next digit */ d2 = q + 2 * d2; if ((d2 != 0) || (d3 != 0)) { q = (d2 * 0xd) >> 7; d2 = d2 - 10 * q; *buf++ = d2 + '0'; /* next digit */ d3 = q + 4 * d3; if (d3 != 0) { q = (d3 * 0xcd) >> 11; d3 = d3 - 10 * q; *buf++ = d3 + '0'; /* next digit */ if (q != 0) *buf++ = q + '0'; /* most sign. digit */ } } } return buf; } static void ip4_addr_string(struct printf_info *info, u8 *addr) { /* (4 * 3 decimal digits), 3 dots and trailing zero */ char ip4_addr[4 * 4]; char temp[3]; /* hold each IP quad in reverse order */ char *p = ip4_addr; int i, digits; for (i = 0; i < 4; i++) { digits = put_dec_trunc(temp, addr[i]) - temp; /* reverse the digits in the quad */ while (digits--) *p++ = temp[digits]; if (i != 3) *p++ = '.'; } *p = '\0'; string(info, ip4_addr); } #endif /* * Show a '%p' thing. A kernel extension is that the '%p' is followed * by an extra set of characters that are extended format * specifiers. * * Right now we handle: * * - 'M' For a 6-byte MAC address, it prints the address in the * usual colon-separated hex notation. * - 'm' Same as above except there is no colon-separator. * - 'I4'for IPv4 addresses printed in the usual way (dot-separated * decimal). */ static void pointer(struct printf_info *info, const char *fmt, void *ptr) { #ifdef DEBUG unsigned long num = (uintptr_t)ptr; unsigned long div; #endif switch (*fmt) { #ifdef DEBUG case 'a': switch (fmt[1]) { case 'p': default: num = *(phys_addr_t *)ptr; break; } break; #endif #ifdef CONFIG_SPL_NET_SUPPORT case 'm': return mac_address_string(info, ptr, false); case 'M': return mac_address_string(info, ptr, true); case 'I': if (fmt[1] == '4') return ip4_addr_string(info, ptr); #endif default: break; } #ifdef DEBUG div = 1UL << (sizeof(long) * 8 - 4); for (; div; div /= 0x10) div_out(info, &num, div); #endif } static int _vprintf(struct printf_info *info, const char *fmt, va_list va) { char ch; char *p; unsigned long num; char buf[12]; unsigned long div; while ((ch = *(fmt++))) { if (ch != '%') { /*for window \r\n*/ if(ch == '\n') info->putc(info, '\r'); info->putc(info, ch); } else { bool lz = false; int width = 0; bool islong = false; ch = *(fmt++); if (ch == '-') ch = *(fmt++); if (ch == '0') { ch = *(fmt++); lz = 1; } if (ch >= '0' && ch <= '9') { width = 0; while (ch >= '0' && ch <= '9') { width = (width * 10) + ch - '0'; ch = *fmt++; } } if (ch == 'l') { ch = *(fmt++); islong = true; } info->bf = buf; p = info->bf; info->zs = 0; switch (ch) { case '\0': goto abort; case 'u': case 'd': div = 1000000000; if (islong) { num = va_arg(va, unsigned long); if (sizeof(long) > 4) div *= div * 10; } else { num = va_arg(va, unsigned int); } if (ch == 'd') { if (islong && (long)num < 0) { num = -(long)num; out(info, '-'); } else if (!islong && (int)num < 0) { num = -(int)num; out(info, '-'); } } if (!num) { out_dgt(info, 0); } else { for (; div; div /= 10) div_out(info, &num, div); } break; case 'x': if (islong) { num = va_arg(va, unsigned long); div = 1UL << (sizeof(long) * 8 - 4); } else { num = va_arg(va, unsigned int); div = 0x10000000; } if (!num) { out_dgt(info, 0); } else { for (; div; div /= 0x10) div_out(info, &num, div); } break; case 'c': out(info, (char)(va_arg(va, int))); break; case 's': p = va_arg(va, char*); break; case 'p': pointer(info, fmt, va_arg(va, void *)); while (isalnum(fmt[0])) fmt++; break; case '%': out(info, '%'); default: break; } *info->bf = 0; info->bf = p; while (*info->bf++ && width > 0) width--; while (width-- > 0) info->putc(info, lz ? '0' : ' '); if (p) { while ((ch = *p++)) info->putc(info, ch); } } } abort: return 0; } static void putc_normal(struct printf_info *info, char ch) { sunxi_serial_putc(ch); } int vprintf(const char *fmt, va_list va) { struct printf_info info; info.putc = putc_normal; return _vprintf(&info, fmt, va); } static u8 debug_mode = 3; int sunxi_set_printf_debug_mode(u8 debug_level) { if (debug_level > 8) { return -1; } else { debug_mode = debug_level; } return 0; } u8 sunxi_get_printf_debug_mode(void) { return debug_mode; } int sprintf(char *buf, const char *fmt, ...); int printf(const char *fmt, ...) { struct printf_info info; va_list va; int ret; char time_stamp[12]; int i; #if defined(CFG_SUNXI_FES) /*fes dont have debug_mode, do nothing*/ #else if (debug_mode == 0) return 0; #endif /* print time stamp as prefix*/ sprintf(time_stamp, "[%d]", get_sys_ticks()); for (i = 0; i < sizeof(time_stamp); i++) { if (time_stamp[i] == 0) break; sunxi_serial_putc(time_stamp[i]); } info.putc = putc_normal; va_start(va, fmt); ret = _vprintf(&info, fmt, va); va_end(va); return ret; } void puts(const char *s) { printf("%s", s); } static void putc_outstr(struct printf_info *info, char ch) { *info->outstr++ = ch; } int sprintf(char *buf, const char *fmt, ...) { struct printf_info info; va_list va; int ret; va_start(va, fmt); info.outstr = buf; info.putc = putc_outstr; ret = _vprintf(&info, fmt, va); va_end(va); *info.outstr = '\0'; return ret; } /* Note that size is ignored */ int snprintf(char *buf, size_t size, const char *fmt, ...) { struct printf_info info; va_list va; int ret; va_start(va, fmt); info.outstr = buf; info.putc = putc_outstr; ret = _vprintf(&info, fmt, va); va_end(va); *info.outstr = '\0'; return ret; } void print_sys_tick(void) { printf("time used:%d\n",get_sys_ticks()); }
20.235033
74
0.557309
d22f498cab2430a0b11d48556ea1608d3f1afa35
294
h
C
include/tml/common.h
bmytnyk/tml
bb753cf776c89f9fc5c70d515bb4cc23d695cd60
[ "MIT" ]
null
null
null
include/tml/common.h
bmytnyk/tml
bb753cf776c89f9fc5c70d515bb4cc23d695cd60
[ "MIT" ]
null
null
null
include/tml/common.h
bmytnyk/tml
bb753cf776c89f9fc5c70d515bb4cc23d695cd60
[ "MIT" ]
null
null
null
#pragma once #include <cstdint> #include <atomic> #include <chrono> #include <string> namespace tml { using operation_id_t = uint64_t; using clock = std::chrono::steady_clock; using time_point = std::chrono::time_point<clock>; using duration = double; };
16.333333
55
0.64966
d25173dbfc552cdb8a5e0950b5b4c09a68a3b043
2,531
h
C
opendnp3/APL/PackingTemplates.h
rahul-sachdev/DNPSimulator
d78f6a3f2fe3b706fe73c163173f06c55af35b1e
[ "ECL-2.0", "Apache-2.0" ]
2
2019-10-28T01:27:21.000Z
2021-05-14T08:06:33.000Z
opendnp3/APL/PackingTemplates.h
rahul-sachdev/DNPSimulator
d78f6a3f2fe3b706fe73c163173f06c55af35b1e
[ "ECL-2.0", "Apache-2.0" ]
1
2019-04-15T06:32:48.000Z
2019-04-15T06:52:33.000Z
opendnp3/APL/PackingTemplates.h
sentient-energy/emsw-opendnp3-mirror
a182a01c15f342fbd498e16b02865fd6d5d5be98
[ "ECL-2.0", "Apache-2.0" ]
1
2016-11-16T15:14:51.000Z
2016-11-16T15:14:51.000Z
// // Licensed to Green Energy Corp (www.greenenergycorp.com) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. Green Enery Corp licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. // #ifndef __PACKING_TEMPLATES_H_ #define __PACKING_TEMPLATES_H_ #include <opendnp3/APL/Types.h> #include <assert.h> namespace apl { template <class T, int U> class Pack { public: typename T::Type Get(const boost::uint8_t* apBuffer) const { return T::Read(apBuffer + U); } void Set(boost::uint8_t* apBuffer, typename T::Type aValue) const { T::Write(apBuffer + U, aValue); } typename T::Type Max() const { return T::Max; } typename T::Type Min() const { return T::Min; } }; template <class T, int U, boost::uint8_t V> class PackOverRange : public Pack<T, U> { public: boost::uint8_t OverRangeMask() const { return V; } }; class BitfieldPacker { public: size_t GetSize(size_t aNumValues) const { size_t ret = (aNumValues >> 3); //integer division by eight if( (aNumValues & 0x07) != 0) ++ret; //if it's not an even multiple of 8 add an extra byte return ret; } void Zero(boost::uint8_t* apPos, size_t aNumValues) const { size_t num_bytes = GetSize(aNumValues); for(size_t i = 0; i < num_bytes; i++) *(apPos++) = 0; } bool Read(const boost::uint8_t* apPos, size_t aStartIndex, size_t aIndex) const { assert(aIndex >= aStartIndex); size_t pos = aIndex - aStartIndex; apPos += (pos >> 3); //figure out which byte you are on and advance the pointer return ((*apPos) & (1 << (pos & 0x07))) != 0; } void Write(boost::uint8_t* apPos, size_t aStartIndex, size_t aIndex, bool aValue) const { assert(aIndex >= aStartIndex); size_t pos = aIndex - aStartIndex; apPos += (pos >> 3); //figure out which byte you are on and advance the pointer size_t bit_mask = 1 << (pos & 0x07); if (aValue) *apPos |= bit_mask; else *apPos &= ~bit_mask; } }; } #endif
26.925532
92
0.697748
cfc6636a9e90a002303c4e963888dc7d296cc254
2,718
c
C
src/crypto/random.c
Skytells/Oxgram
fa42e7d1fc7fe8a809916bf96cd6e9ca476a0d70
[ "MIT" ]
null
null
null
src/crypto/random.c
Skytells/Oxgram
fa42e7d1fc7fe8a809916bf96cd6e9ca476a0d70
[ "MIT" ]
null
null
null
src/crypto/random.c
Skytells/Oxgram
fa42e7d1fc7fe8a809916bf96cd6e9ca476a0d70
[ "MIT" ]
null
null
null
// Copyright (c) 2011-2016 The Skytells developers // Distributed under the MIT/X11 software license, see the accompanying // @license MIT : http://www.opensource.org/licenses/mit-license.php. // @package Oxgram Cryptocurrency by Skytells, Inc. #include <assert.h> #include <stddef.h> #include <string.h> #include "hash-ops.h" #include "initializer.h" #include "random.h" static void generate_system_random_bytes(size_t n, void *result); #if defined(_WIN32) #include <windows.h> #include <wincrypt.h> static void generate_system_random_bytes(size_t n, void *result) { HCRYPTPROV prov; #define must_succeed(x) do if (!(x)) assert(0); while (0) must_succeed(CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)); must_succeed(CryptGenRandom(prov, (DWORD)n, result)); must_succeed(CryptReleaseContext(prov, 0)); #undef must_succeed } #else #include <err.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> static void generate_system_random_bytes(size_t n, void *result) { int fd; if ((fd = open("/dev/urandom", O_RDONLY | O_NOCTTY | O_CLOEXEC)) < 0) { err(EXIT_FAILURE, "open /dev/urandom"); } for (;;) { ssize_t res = read(fd, result, n); if ((size_t) res == n) { break; } if (res < 0) { if (errno != EINTR) { err(EXIT_FAILURE, "read /dev/urandom"); } } else if (res == 0) { errx(EXIT_FAILURE, "read /dev/urandom: end of file"); } else { result = padd(result, (size_t) res); n -= (size_t) res; } } if (close(fd) < 0) { err(EXIT_FAILURE, "close /dev/urandom"); } } #endif static union hash_state state; #if !defined(NDEBUG) static volatile int curstate; /* To catch thread safety problems. */ #endif FINALIZER(deinit_random) { #if !defined(NDEBUG) assert(curstate == 1); curstate = 0; #endif memset(&state, 0, sizeof(union hash_state)); } INITIALIZER(init_random) { generate_system_random_bytes(32, &state); REGISTER_FINALIZER(deinit_random); #if !defined(NDEBUG) assert(curstate == 0); curstate = 1; #endif } void generate_random_bytes(size_t n, void *result) { #if !defined(NDEBUG) assert(curstate == 1); curstate = 2; #endif if (n == 0) { #if !defined(NDEBUG) assert(curstate == 2); curstate = 1; #endif return; } for (;;) { hash_permutation(&state); if (n <= HASH_DATA_AREA) { memcpy(result, &state, n); #if !defined(NDEBUG) assert(curstate == 2); curstate = 1; #endif return; } else { memcpy(result, &state, HASH_DATA_AREA); result = padd(result, HASH_DATA_AREA); n -= HASH_DATA_AREA; } } }
22.840336
106
0.655261
aab77ae9393fc3c5288a874d3572da847d23ce3b
5,973
h
C
pmem-mariadb/storage/tokudb/PerconaFT/xz/src/build_lzma/src/liblzma/lz/lz_decoder.h
wc222/pmdk-examples
64aadc3a70471c469ac8e214eb1e04ff47cf18ff
[ "BSD-3-Clause" ]
11
2017-10-28T08:41:08.000Z
2021-06-24T07:24:21.000Z
pmem-mariadb/storage/tokudb/PerconaFT/xz/src/build_lzma/src/liblzma/lz/lz_decoder.h
WSCWDA/pmdk-examples
c3d079e52cd18b0e14836ef42bad9a995336bf90
[ "BSD-3-Clause" ]
1
2021-02-24T05:26:44.000Z
2021-02-24T05:26:44.000Z
pmem-mariadb/storage/tokudb/PerconaFT/xz/src/build_lzma/src/liblzma/lz/lz_decoder.h
isabella232/pmdk-examples
be7a5a18ba7bb8931e512f6d552eadf820fa2235
[ "BSD-3-Clause" ]
4
2017-09-07T09:33:26.000Z
2021-02-19T07:45:08.000Z
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ // vim: expandtab:ts=8:sw=4:softtabstop=4: /////////////////////////////////////////////////////////////////////////////// // /// \file lz_decoder.h /// \brief LZ out window /// // Authors: Igor Pavlov // Lasse Collin // // This file has been put into the public domain. // You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// #ifndef LZMA_LZ_DECODER_H #define LZMA_LZ_DECODER_H #include "common.h" typedef struct { /// Pointer to the dictionary buffer. It can be an allocated buffer /// internal to liblzma, or it can a be a buffer given by the /// application when in single-call mode (not implemented yet). uint8_t *buf; /// Write position in dictionary. The next byte will be written to /// buf[pos]. size_t pos; /// Indicates how full the dictionary is. This is used by /// dict_is_distance_valid() to detect corrupt files that would /// read beyond the beginning of the dictionary. size_t full; /// Write limit size_t limit; /// Size of the dictionary size_t size; /// True when dictionary should be reset before decoding more data. bool need_reset; } lzma_dict; typedef struct { size_t dict_size; const uint8_t *preset_dict; size_t preset_dict_size; } lzma_lz_options; typedef struct { /// Data specific to the LZ-based decoder lzma_coder *coder; /// Function to decode from in[] to *dict lzma_ret (*code)(lzma_coder *restrict coder, lzma_dict *restrict dict, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size); void (*reset)(lzma_coder *coder, const void *options); /// Set the uncompressed size void (*set_uncompressed)(lzma_coder *coder, lzma_vli uncompressed_size); /// Free allocated resources void (*end)(lzma_coder *coder, lzma_allocator *allocator); } lzma_lz_decoder; #define LZMA_LZ_DECODER_INIT \ (lzma_lz_decoder){ \ .coder = NULL, \ .code = NULL, \ .reset = NULL, \ .set_uncompressed = NULL, \ .end = NULL, \ } extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, const lzma_filter_info *filters, lzma_ret (*lz_init)(lzma_lz_decoder *lz, lzma_allocator *allocator, const void *options, lzma_lz_options *lz_options)); extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size); extern void lzma_lz_decoder_uncompressed( lzma_coder *coder, lzma_vli uncompressed_size); ////////////////////// // Inline functions // ////////////////////// /// Get a byte from the history buffer. static inline uint8_t dict_get(const lzma_dict *const dict, const uint32_t distance) { return dict->buf[dict->pos - distance - 1 + (distance < dict->pos ? 0 : dict->size)]; } /// Test if dictionary is empty. static inline bool dict_is_empty(const lzma_dict *const dict) { return dict->full == 0; } /// Validate the match distance static inline bool dict_is_distance_valid(const lzma_dict *const dict, const size_t distance) { return dict->full > distance; } /// Repeat *len bytes at distance. static inline bool dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len) { // Don't write past the end of the dictionary. const size_t dict_avail = dict->limit - dict->pos; uint32_t left = MIN(dict_avail, *len); *len -= left; // Repeat a block of data from the history. Because memcpy() is faster // than copying byte by byte in a loop, the copying process gets split // into three cases. if (distance < left) { // Source and target areas overlap, thus we can't use // memcpy() nor even memmove() safely. do { dict->buf[dict->pos] = dict_get(dict, distance); ++dict->pos; } while (--left > 0); } else if (distance < dict->pos) { // The easiest and fastest case memcpy(dict->buf + dict->pos, dict->buf + dict->pos - distance - 1, left); dict->pos += left; } else { // The bigger the dictionary, the more rare this // case occurs. We need to "wrap" the dict, thus // we might need two memcpy() to copy all the data. assert(dict->full == dict->size); const uint32_t copy_pos = dict->pos - distance - 1 + dict->size; uint32_t copy_size = dict->size - copy_pos; if (copy_size < left) { memmove(dict->buf + dict->pos, dict->buf + copy_pos, copy_size); dict->pos += copy_size; copy_size = left - copy_size; memcpy(dict->buf + dict->pos, dict->buf, copy_size); dict->pos += copy_size; } else { memmove(dict->buf + dict->pos, dict->buf + copy_pos, left); dict->pos += left; } } // Update how full the dictionary is. if (dict->full < dict->pos) dict->full = dict->pos; return unlikely(*len != 0); } /// Puts one byte into the dictionary. Returns true if the dictionary was /// already full and the byte couldn't be added. static inline bool dict_put(lzma_dict *dict, uint8_t byte) { if (unlikely(dict->pos == dict->limit)) return true; dict->buf[dict->pos++] = byte; if (dict->pos > dict->full) dict->full = dict->pos; return false; } /// Copies arbitrary amount of data into the dictionary. static inline void dict_write(lzma_dict *restrict dict, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, size_t *restrict left) { // NOTE: If we are being given more data than the size of the // dictionary, it could be possible to optimize the LZ decoder // so that not everything needs to go through the dictionary. // This shouldn't be very common thing in practice though, and // the slowdown of one extra memcpy() isn't bad compared to how // much time it would have taken if the data were compressed. if (in_size - *in_pos > *left) in_size = *in_pos + *left; *left -= lzma_bufcpy(in, in_pos, in_size, dict->buf, &dict->pos, dict->limit); if (dict->pos > dict->full) dict->full = dict->pos; return; } static inline void dict_reset(lzma_dict *dict) { dict->need_reset = true; return; } #endif
25.202532
79
0.667504
d2d1285893cffa50adf5fafd0d6c82d4d984b768
3,020
h
C
src/OpenCvSharpExtern/imgproc_Segmentation.h
artheru/opencvsharp
0b88a10f3534e92e75e9d15e07ef32c9768d746b
[ "Apache-2.0" ]
3,886
2015-01-02T15:12:37.000Z
2022-03-31T02:30:51.000Z
src/OpenCvSharpExtern/imgproc_Segmentation.h
artheru/opencvsharp
0b88a10f3534e92e75e9d15e07ef32c9768d746b
[ "Apache-2.0" ]
1,110
2015-01-15T06:18:25.000Z
2022-03-30T14:57:26.000Z
src/OpenCvSharpExtern/imgproc_Segmentation.h
artheru/opencvsharp
0b88a10f3534e92e75e9d15e07ef32c9768d746b
[ "Apache-2.0" ]
1,047
2015-01-08T07:14:48.000Z
2022-03-30T08:54:30.000Z
#pragma once // ReSharper disable IdentifierTypo // ReSharper disable CppInconsistentNaming // ReSharper disable CppNonInlineFunctionDefinitionInHeaderFile #include "include_opencv.h" CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_new( cv::segmentation::IntelligentScissorsMB** returnValue) { BEGIN_WRAP *returnValue = new cv::segmentation::IntelligentScissorsMB(); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_delete( cv::segmentation::IntelligentScissorsMB *obj) { BEGIN_WRAP delete obj; END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_setWeights( cv::segmentation::IntelligentScissorsMB *obj, float weight_non_edge, float weight_gradient_direction, float weight_gradient_magnitude) { BEGIN_WRAP obj->setWeights(weight_non_edge, weight_gradient_direction, weight_gradient_magnitude); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_setGradientMagnitudeMaxLimit( cv::segmentation::IntelligentScissorsMB *obj, float gradient_magnitude_threshold_max) { BEGIN_WRAP obj->setGradientMagnitudeMaxLimit(gradient_magnitude_threshold_max); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_setEdgeFeatureZeroCrossingParameters( cv::segmentation::IntelligentScissorsMB *obj, float gradient_magnitude_min_value) { BEGIN_WRAP obj->setEdgeFeatureZeroCrossingParameters(gradient_magnitude_min_value); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_setEdgeFeatureCannyParameters( cv::segmentation::IntelligentScissorsMB *obj, double threshold1, double threshold2, int apertureSize, int L2gradient) { BEGIN_WRAP obj->setEdgeFeatureCannyParameters(threshold1, threshold2, apertureSize, L2gradient != 0); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_applyImage( cv::segmentation::IntelligentScissorsMB *obj, cv::_InputArray *image) { BEGIN_WRAP obj->applyImage(*image); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_applyImageFeatures( cv::segmentation::IntelligentScissorsMB *obj, cv::_InputArray *non_edge, cv::_InputArray *gradient_direction, cv::_InputArray *gradient_magnitude, cv::_InputArray *image) { BEGIN_WRAP obj->applyImageFeatures(*non_edge, *gradient_direction, *gradient_magnitude, entity(image)); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_buildMap( cv::segmentation::IntelligentScissorsMB *obj, MyCvPoint sourcePt) { BEGIN_WRAP obj->buildMap(cpp(sourcePt)); END_WRAP } CVAPI(ExceptionStatus) imgproc_segmentation_IntelligentScissorsMB_getContour( cv::segmentation::IntelligentScissorsMB *obj, MyCvPoint targetPt, cv::_OutputArray *contour, int backward) { BEGIN_WRAP obj->getContour(cpp(targetPt), *contour, backward != 0); END_WRAP }
29.607843
103
0.796358
960e18e6bb8fe864306af0fe4276565809288cbd
4,212
h
C
include/Elite/Model/Node.h
elite-lang/Elite
f65998863bb13c247c27c781b0cdb4cfc6ba8ae3
[ "MIT" ]
48
2015-12-28T01:42:57.000Z
2022-03-11T02:59:17.000Z
include/Elite/Model/Node.h
elite-lang/Elite
f65998863bb13c247c27c781b0cdb4cfc6ba8ae3
[ "MIT" ]
17
2015-12-16T07:43:52.000Z
2016-04-17T12:30:48.000Z
include/Elite/Model/Node.h
elite-lang/Elite
f65998863bb13c247c27c781b0cdb4cfc6ba8ae3
[ "MIT" ]
14
2015-12-22T06:54:14.000Z
2020-12-02T06:39:45.000Z
/* * @Author: sxf * @Date: 2015-09-22 19:21:10 * @Last Modified by: sxf * @Last Modified time: 2015-12-14 17:03:53 */ #ifndef NODE_H #define NODE_H // #include "Elite/LLCG/lvalue.h" #include <string> namespace Elite { enum NodeType { seq_node_t = 0, list_node_t, block_node_t, int_node_t, float_node_t, char_node_t, id_node_t, string_node_t, type_node_t }; class CodeGenContext; /** * @brief List的基本组成元素,表示一个代码中的基本节点 * @details 编译器后端代码生成时,会构建Node节点串连起来的语法树 * * Node节点的类型一般有如下几种(char 暂未使用): \n * id - 标识符 - 对应NodeType为:id_node_t \n * int - 整型 - 对应NodeType为:int_node_t \n * float - 浮点型 - 对应NodeType为:float_node_t \n * string - 字符串 - 对应NodeType为:string_node_t \n * type - 类型 - 对应NodeType为:type_node_t \n * @see NodeType * * 一般语法解析器在连接这款后端代码生成器时,只需要控制生成Node构造的语法树即可, * 语法树的形状符合RedApple中的定义,即可正确编译为后端代码。 */ class Node { public: /** * @brief 判断当前节点是一个元素, 还是一个链表 * @details 判断当前节点是一个元素, 还是一个链表, * 主要用于getList方法和makeList方法 * 由于构造语法树时,很多情况不知道要添加的是一个节点还是一个链表. * 这个方法可以用来判断.\n * @return 有下一个元素,返回true */ bool hasNext(); /** * @brief 判断当前节点是否有孩子 * @details 判断当前节点是否有孩子, 主要依靠类型判断, 如果是list或block会再检测是否有孩子 * @return 是单一元素返回true, 是链表返回false */ virtual bool hasChild() { return false; } /** * @brief 获取下一个元素 */ virtual Node* getNext() { return next; } /** * @brief 如果是list或block, 取得其孩子的头指针 */ virtual Node* getChild(); // 便捷的构造list的方法 /** * @brief C++语言版的接口, 用来方便地构造一个列表 * @details 用来方便地构造一个列表, make_linked里不定参数如果传入空 * 则认为到达结尾, 使用时请务必注意 * * @param ... 每个是一个 Node* 指针, 使用NULL结尾 * * @return 构造好的列表的首节点指针 */ static Node* make_linked(...); /** * @brief 其他语言的接口, 用来方便地构造一个列表 * @details 用来方便地构造一个列表, 功能和 make_linked 一样 * @see make_linked() * * @param num 参数的个数 * @param plist 一个指针数组 * * @return 构造好的列表的首节点指针 */ static Node* makeLinked(int num, Node* plist[]); /** * @brief 构造一个节点, 并为其添加一个子元素链表 * * @param n 子元素链表, 相当于对空节点添加了孩子 * @return 新构造的节点 */ static Node* CreateList(Node* n); /** * @brief 构造一个节点, 并为其添加一个子元素链表 * * @param n 子元素链表, 相当于对空节点添加了孩子 * @return 新构造的节点 */ static Node* CreateBlock(Node* n); // 全局构造析构 /** * @brief 释放一个节点资源 * @param p 这里是一个指针的引用, 会自动将指针置为NULL */ static void Free(Node*& p); /** * @brief 递归释放节点资源 * @param p 要释放的节点, 这里会递归调用子节点 */ static void FreeAll(Node*& p); // 拷贝函数 virtual Node* copy() = 0; virtual Node* copyAll(); // 节点的替换 // void replaceNext(Node* node); // void replaceChild(Node* node); // void replaceChildFirst(Node* node); /** * @brief 可用于调试的打印指令 * @param k 缩进层次, 首次传0或1皆可 */ void print(int k); /** * @brief 重要的代码生成函数 * @details 重要的代码生成函数, 对于不同的节点, 会有不同的代码生成策略, * 这个函数是多态调用的, 在每个Node的子类中都有相关实现 * Node的代码生成会按照表处理, 将第一个元素视为宏名 * ID会自动去符号表中查找定义, 返回符号表中存储的变量 * Type会自动去符号表中查找, 返回一个类型的定义 * Int会自动构造常量数字 * String会自动构造常量字符串 * * @param context 代码生成上下文类 * @return 返回代码生成的结果指针LValue */ // virtual LValue codeGen(CodeGenContext* context); // 如果是含有字符串的节点,则返回所含字符串,否则将报错 /** * @brief 获取当前节点内存放的字符串 * @details 只有含有字符串的节点该函数有效, 目前ID和String有效 * 如果是普通的节点, 则会报异常 * @return 返回字符串的引用 */ virtual std::string& getStr(); /** * @brief 获取类型名 * @return 节点的名字 */ virtual std::string getTypeName() = 0; /** * @brief 获取节点类型 * @return 节点类型的枚举 */ virtual NodeType getType() = 0; bool isSeq(); bool isList(); bool isBlock(); bool isIntNode(); bool isFloatNode(); bool isIDNode(); bool isStringNode(); bool isCharNode(); bool isTypeNode(); protected: Node(); Node(const Node& other); virtual ~Node(); virtual void printSelf(); Node* next; }; } // Elite #endif // NODE_H
20.446602
61
0.569563
6515507e90bef9affdbcd1690f6e77d25f8053e9
1,092
h
C
APExtension/NSData+APExtension.h
deanyang506/APExtension
7dea52a5be6e4a6870439da6475216ab15d1c8a9
[ "MIT" ]
5
2017-08-10T11:25:35.000Z
2019-06-20T03:33:46.000Z
APExtension/NSData+APExtension.h
idean506/APExtension
7dea52a5be6e4a6870439da6475216ab15d1c8a9
[ "MIT" ]
null
null
null
APExtension/NSData+APExtension.h
idean506/APExtension
7dea52a5be6e4a6870439da6475216ab15d1c8a9
[ "MIT" ]
null
null
null
// // NSData+APExtension.h // Captain Black // // Created by Captain Black on 16/1/23. // Copyright © 2016年 Captain Black. All rights reserved. // #import <Foundation/Foundation.h> static NSString *AESgIv = @"AD8BB59CE350BBC7"; @interface NSData (APExtension) /** * 用十六进制字符串生成NSData * * @param hexString 必须十六进制字符串 * * @return 返回NSData对象 */ + (instancetype)dataWithHexString:(NSString*)hexString NS_AVAILABLE_IOS(2_0); /** * 计算MD5值 * * @return MD5字符串 */ - (NSString *)md5String NS_AVAILABLE_IOS(2_0); /** * 计算SHA1值 * * @return SHA1字符串 */ - (NSString *)sha1String NS_AVAILABLE_IOS(2_0); /** AES128加密 @param key 加密key @param gIv 向量16位字符,或传入默认的AESgIv @return 加密后数据 */ - (NSData *)AES128EncryptWithKey:(NSString *)key gIv:(NSString *)gIv; /** AES128解密 @param key 解密key @param gIv 向量16位字符,或传入默认的AESgIv @return 解密后数据 */ - (NSData *)AES128DecryptWithKey:(NSString *)key gIv:(NSString *)gIv; /** * 把二进制数据转化成十六进制字符串形式 * * @param upperCaseOrNot 是否大写 * * @return 十六进制字符串 */ - (NSString *)hexString:(BOOL)upperCaseOrNot NS_AVAILABLE_IOS(2_0); @end
16.298507
77
0.688645
4565b24a2e728fa7b57d57376a51519541cc0130
854
h
C
Pods/Headers/Typhoon/TyphoonCallStack.h
422053362/Typhoon-example
e164aaa0ae0118063f1a3e756ea25952e88eddcd
[ "Apache-2.0" ]
null
null
null
Pods/Headers/Typhoon/TyphoonCallStack.h
422053362/Typhoon-example
e164aaa0ae0118063f1a3e756ea25952e88eddcd
[ "Apache-2.0" ]
1
2020-03-17T22:53:02.000Z
2020-03-17T22:53:02.000Z
Pods/Headers/Typhoon/TyphoonCallStack.h
422053362/Typhoon-example
e164aaa0ae0118063f1a3e756ea25952e88eddcd
[ "Apache-2.0" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// // // TYPHOON FRAMEWORK // Copyright 2013, Jasper Blues & Contributors // All Rights Reserved. // // NOTICE: The authors permit you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// #import <Foundation/Foundation.h> @class TyphoonStackElement; @class TyphoonRuntimeArguments; @interface TyphoonCallStack : NSObject + (instancetype)stack; - (void)push:(TyphoonStackElement *)stackItem; - (TyphoonStackElement *)pop; - (TyphoonStackElement *)peekForKey:(NSString *)key args:(TyphoonRuntimeArguments *)args; - (BOOL)isResolvingKey:(NSString *)key withArgs:(TyphoonRuntimeArguments *)args; - (BOOL)isEmpty; @end
25.878788
89
0.61007
ca64200d7217b7816b04f223a0f88d25a0dbbc71
3,845
h
C
editor/gui/include/mouseconfig.h
lizardkinger/blacksun
0119948726d2a057c13d208044c7664a8348a1ea
[ "Linux-OpenIB" ]
null
null
null
editor/gui/include/mouseconfig.h
lizardkinger/blacksun
0119948726d2a057c13d208044c7664a8348a1ea
[ "Linux-OpenIB" ]
null
null
null
editor/gui/include/mouseconfig.h
lizardkinger/blacksun
0119948726d2a057c13d208044c7664a8348a1ea
[ "Linux-OpenIB" ]
null
null
null
/*************************************************************************** * Copyright (C) 2006 by Thomas Tischler * ttischl1@fh-landshut.de * * 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. * (See COPYING for details.) **************************************************************************** * * Module: GUI (BlackSun) * File: mouseconfig.h * Created: 13.06.2007 * Author: Thomas Tischler (hunt0r) * **************************************************************************/ /** \file mouseconfig.h * \brief Defines MouseConfig class. * * \author Thomas Tischler. */ #ifndef MOUSECONFIG_H #define MOUSECONFIG_H #include "configinterface.h" #include "mousesettings.h" #include <QtGui> #include "../ui_mouseConfig.h" namespace BSGui { /*! \brief This widget allows to edit the mouse options. */ class MouseConfig : public ConfigInterface { Q_OBJECT public: /*! * \brief The constructor. */ MouseConfig(); /*! * \brief Get the discription of the Config Dialog. * \return The description of the dialog. */ virtual QString getDescription() const ; /*! * \brief Get the Name of the Config Dialog. * \return The name of the dialog. */ virtual QString getShortName() const ; /*! * \brief Get the Icon that is shown in the config Menu. * \return The icon of the dialog. */ virtual QIcon getIcon() const ; /*! * \brief The destructor. */ ~MouseConfig(); private: Ui_mouseConfig ui; /*!< \brief The ui class */ /*! * \brief Fills an QComboBox with the appropriate contents based on its object name. * \param boxToFill The box that should be filled. */ void fillBox(QComboBox* boxToFill); MouseSettings* settings; /*!< \brief The MouseSettings object */ /*! * \brief Converts a QString to a MouseSettings::MouseAction. * \param string The string to convert. */ MouseSettings::MouseAction StringToEnum(QString string); /*! * \brief Converts a objectName to a property name. * \param object The object wich name to read. */ QByteArray objectNameToPropertyName(QObject* object); public slots: /*! * \brief This is called when the Dialog was accepted. */ virtual void dialogAccept(); /*! * \brief This is called when the Dialog was rejected. */ virtual void dialogReject(); /*! * \brief This is called when the User clicked the reset Button. */ virtual void reset(); void checkForChanges(); }; } #endif
30.515873
96
0.520416
1092ec958a27241ddae2236cabad61e7fe9af278
21,628
h
C
src/demos/vnc/include/rfbproto.h
symfund/microwindows
f267e5c368c5e5a49ac6b3907af9527b06a1c67f
[ "X11" ]
1
2020-12-19T13:47:11.000Z
2020-12-19T13:47:11.000Z
src/demos/vnc/include/rfbproto.h
symfund/microwindows
f267e5c368c5e5a49ac6b3907af9527b06a1c67f
[ "X11" ]
null
null
null
src/demos/vnc/include/rfbproto.h
symfund/microwindows
f267e5c368c5e5a49ac6b3907af9527b06a1c67f
[ "X11" ]
null
null
null
/* * Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory * * This 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 software 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 software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * rfbproto.h - header file for the RFB protocol version 3.3 * * Uses types CARD<n> for an n-bit unsigned integer, INT<n> for an n-bit signed * integer (for n = 8, 16 and 32). * * All multiple byte integers are in big endian (network) order (most * significant byte first). Unless noted otherwise there is no special * alignment of protocol structures. * * * Once the initial handshaking is done, all messages start with a type byte, * (usually) followed by message-specific data. The order of definitions in * this file is as follows: * * (1) Structures used in several types of message. * (2) Structures used in the initial handshaking. * (3) Message types. * (4) Encoding types. * (5) For each message type, the form of the data following the type byte. * Sometimes this is defined by a single structure but the more complex * messages have to be explained by comments. */ /* *************************************************************************** * * Structures used in several messages * *****************************************************************************/ /*----------------------------------------------------------------------------- * Structure used to specify a rectangle. This structure is a multiple of 4 * bytes so that it can be interspersed with 32-bit pixel data without * affecting alignment. */ typedef struct { CARD16 x; CARD16 y; CARD16 w; CARD16 h; } rfbRectangle; #define sz_rfbRectangle 8 /*----------------------------------------------------------------------------- * Structure used to specify pixel format. */ typedef struct { CARD8 bitsPerPixel; /* 8,16,32 only */ CARD8 depth; /* 8 to 32 */ CARD8 bigEndian; /* True if multi-byte pixels are interpreted as big endian, or if single-bit-per-pixel has most significant bit of the byte corresponding to first (leftmost) pixel. Of course this is meaningless for 8 bits/pix */ CARD8 trueColour; /* If false then we need a "colour map" to convert pixels to RGB. If true, xxxMax and xxxShift specify bits used for red, green and blue */ /* the following fields are only meaningful if trueColour is true */ CARD16 redMax; /* maximum red value (= 2^n - 1 where n is the number of bits used for red). Note this value is always in big endian order. */ CARD16 greenMax; /* similar for green */ CARD16 blueMax; /* and blue */ CARD8 redShift; /* number of shifts needed to get the red value in a pixel to the least significant bit. To find the red value from a given pixel, do the following: 1) Swap pixel value according to bigEndian (e.g. if bigEndian is false and host byte order is big endian, then swap). 2) Shift right by redShift. 3) AND with redMax (in host byte order). 4) You now have the red value between 0 and redMax. */ CARD8 greenShift; /* similar for green */ CARD8 blueShift; /* and blue */ CARD8 pad1; CARD16 pad2; } rfbPixelFormat; #define sz_rfbPixelFormat 16 /* *************************************************************************** * * Initial handshaking messages * *****************************************************************************/ /*----------------------------------------------------------------------------- * Protocol Version * * The server always sends 12 bytes to start which identifies the latest RFB * protocol version number which it supports. These bytes are interpreted * as a string of 12 ASCII characters in the format "RFB xxx.yyy\n" where * xxx and yyy are the major and minor version numbers (for version 3.3 * this is "RFB 003.003\n"). * * The client then replies with a similar 12-byte message giving the version * number of the protocol which should actually be used (which may be different * to that quoted by the server). * * It is intended that both clients and servers may provide some level of * backwards compatibility by this mechanism. Servers in particular should * attempt to provide backwards compatibility, and even forwards compatibility * to some extent. For example if a client demands version 3.1 of the * protocol, a 3.0 server can probably assume that by ignoring requests for * encoding types it doesn't understand, everything will still work OK. This * will probably not be the case for changes in the major version number. * * The format string below can be used in sprintf or sscanf to generate or * decode the version string respectively. */ #define rfbProtocolVersionFormat "RFB %03d.%03d\n" #define rfbProtocolMajorVersion 3 #define rfbProtocolMinorVersion 3 typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */ #define sz_rfbProtocolVersionMsg 12 /*----------------------------------------------------------------------------- * Authentication * * Once the protocol version has been decided, the server then sends a 32-bit * word indicating whether any authentication is needed on the connection. * The value of this word determines the authentication scheme in use. For * version 3.0 of the protocol this may have one of the following values: */ #define rfbConnFailed 0 #define rfbNoAuth 1 #define rfbVncAuth 2 /* * rfbConnFailed: For some reason the connection failed (e.g. the server * cannot support the desired protocol version). This is * followed by a string describing the reason (where a * string is specified as a 32-bit length followed by that * many ASCII characters). * * rfbNoAuth: No authentication is needed. * * rfbVncAuth: The VNC authentication scheme is to be used. A 16-byte * challenge follows, which the client encrypts as * appropriate using the password and sends the resulting * 16-byte response. If the response is correct, the * server sends the 32-bit word rfbVncAuthOK. If a simple * failure happens, the server sends rfbVncAuthFailed and * closes the connection. If the server decides that too * many failures have occurred, it sends rfbVncAuthTooMany * and closes the connection. In the latter case, the * server should not allow an immediate reconnection by * the client. */ #define rfbVncAuthOK 0 #define rfbVncAuthFailed 1 #define rfbVncAuthTooMany 2 /*----------------------------------------------------------------------------- * Client Initialisation Message * * Once the client and server are sure that they're happy to talk to one * another, the client sends an initialisation message. At present this * message only consists of a boolean indicating whether the server should try * to share the desktop by leaving other clients connected, or give exclusive * access to this client by disconnecting all other clients. */ typedef struct { CARD8 shared; } rfbClientInitMsg; #define sz_rfbClientInitMsg 1 /*----------------------------------------------------------------------------- * Server Initialisation Message * * After the client initialisation message, the server sends one of its own. * This tells the client the width and height of the server's framebuffer, * its pixel format and the name associated with the desktop. */ typedef struct { CARD16 framebufferWidth; CARD16 framebufferHeight; rfbPixelFormat format; /* the server's preferred pixel format */ CARD32 nameLength; /* followed by char name[nameLength] */ } rfbServerInitMsg; #define sz_rfbServerInitMsg (8 + sz_rfbPixelFormat) /* * Following the server initialisation message it's up to the client to send * whichever protocol messages it wants. Typically it will send a * SetPixelFormat message and a SetEncodings message, followed by a * FramebufferUpdateRequest. From then on the server will send * FramebufferUpdate messages in response to the client's * FramebufferUpdateRequest messages. The client should send * FramebufferUpdateRequest messages with incremental set to true when it has * finished processing one FramebufferUpdate and is ready to process another. * With a fast client, the rate at which FramebufferUpdateRequests are sent * should be regulated to avoid hogging the network. */ /* *************************************************************************** * * Message types * *****************************************************************************/ /* server -> client */ #define rfbFramebufferUpdate 0 #define rfbSetColourMapEntries 1 #define rfbBell 2 #define rfbServerCutText 3 /* client -> server */ #define rfbSetPixelFormat 0 #define rfbFixColourMapEntries 1 /* not currently supported */ #define rfbSetEncodings 2 #define rfbFramebufferUpdateRequest 3 #define rfbKeyEvent 4 #define rfbPointerEvent 5 #define rfbClientCutText 6 /* *************************************************************************** * * Encoding types * *****************************************************************************/ #define rfbEncodingRaw 0 #define rfbEncodingCopyRect 1 #define rfbEncodingRRE 2 #define rfbEncodingCoRRE 4 #define rfbEncodingHextile 5 /* *************************************************************************** * * Server -> client message definitions * *****************************************************************************/ /*----------------------------------------------------------------------------- * FramebufferUpdate - a block of rectangles to be copied to the framebuffer. * * This message consists of a header giving the number of rectangles of pixel * data followed by the rectangles themselves. The header is padded so that * together with the type byte it is an exact multiple of 4 bytes (to help * with alignment of 32-bit pixels): */ typedef struct { CARD8 type; /* always rfbFramebufferUpdate */ CARD8 pad; CARD16 nRects; /* followed by nRects rectangles */ } rfbFramebufferUpdateMsg; #define sz_rfbFramebufferUpdateMsg 4 /* * Each rectangle of pixel data consists of a header describing the position * and size of the rectangle and a type word describing the encoding of the * pixel data, followed finally by the pixel data. Note that if the client has * not sent a SetEncodings message then it will only receive raw pixel data. * Also note again that this structure is a multiple of 4 bytes. */ typedef struct { rfbRectangle r; CARD32 encoding; /* one of the encoding types rfbEncoding... */ } rfbFramebufferUpdateRectHeader; #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4) /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Raw Encoding. Pixels are sent in top-to-bottom scanline order, * left-to-right within a scanline with no padding in between. */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CopyRect Encoding. The pixels are specified simply by the x and y position * of the source rectangle. */ typedef struct { CARD16 srcX; CARD16 srcY; } rfbCopyRect; #define sz_rfbCopyRect 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * RRE - Rise-and-Run-length Encoding. We have an rfbRREHeader structure * giving the number of subrectangles following. Finally the data follows in * the form [<bgpixel><subrect><subrect>...] where each <subrect> is * [<pixel><rfbRectangle>]. */ typedef struct { CARD32 nSubrects; } rfbRREHeader; #define sz_rfbRREHeader 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CoRRE - Compact RRE Encoding. We have an rfbRREHeader structure giving * the number of subrectangles following. Finally the data follows in the form * [<bgpixel><subrect><subrect>...] where each <subrect> is * [<pixel><rfbCoRRERectangle>]. This means that * the whole rectangle must be at most 255x255 pixels. */ typedef struct { CARD8 x; CARD8 y; CARD8 w; CARD8 h; } rfbCoRRERectangle; #define sz_rfbCoRRERectangle 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Hextile Encoding. The rectangle is divided up into "tiles" of 16x16 pixels, * starting at the top left going in left-to-right, top-to-bottom order. If * the width of the rectangle is not an exact multiple of 16 then the width of * the last tile in each row will be correspondingly smaller. Similarly if the * height is not an exact multiple of 16 then the height of each tile in the * final row will also be smaller. Each tile begins with a "subencoding" type * byte, which is a mask made up of a number of bits. If the Raw bit is set * then the other bits are irrelevant; w*h pixel values follow (where w and h * are the width and height of the tile). Otherwise the tile is encoded in a * similar way to RRE, except that the position and size of each subrectangle * can be specified in just two bytes. The other bits in the mask are as * follows: * * BackgroundSpecified - if set, a pixel value follows which specifies * the background colour for this tile. The first non-raw tile in a * rectangle must have this bit set. If this bit isn't set then the * background is the same as the last tile. * * ForegroundSpecified - if set, a pixel value follows which specifies * the foreground colour to be used for all subrectangles in this tile. * If this bit is set then the SubrectsColoured bit must be zero. * * AnySubrects - if set, a single byte follows giving the number of * subrectangles following. If not set, there are no subrectangles (i.e. * the whole tile is just solid background colour). * * SubrectsColoured - if set then each subrectangle is preceded by a pixel * value giving the colour of that subrectangle. If not set, all * subrectangles are the same colour, the foreground colour; if the * ForegroundSpecified bit wasn't set then the foreground is the same as * the last tile. * * The position and size of each subrectangle is specified in two bytes. The * Pack macros below can be used to generate the two bytes from x, y, w, h, * and the Extract macros can be used to extract the x, y, w, h values from * the two bytes. */ #define rfbHextileRaw (1 << 0) #define rfbHextileBackgroundSpecified (1 << 1) #define rfbHextileForegroundSpecified (1 << 2) #define rfbHextileAnySubrects (1 << 3) #define rfbHextileSubrectsColoured (1 << 4) #define rfbHextilePackXY(x,y) (((x) << 4) | (y)) #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1)) #define rfbHextileExtractX(byte) ((byte) >> 4) #define rfbHextileExtractY(byte) ((byte) & 0xf) #define rfbHextileExtractW(byte) (((byte) >> 4) + 1) #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1) /*----------------------------------------------------------------------------- * SetColourMapEntries - these messages are only sent if the pixel * format uses a "colour map" (i.e. trueColour false) and the client has not * fixed the entire colour map using FixColourMapEntries. In addition they * will only start being sent after the client has sent its first * FramebufferUpdateRequest. So if the client always tells the server to use * trueColour then it never needs to process this type of message. */ typedef struct { CARD8 type; /* always rfbSetColourMapEntries */ CARD8 pad; CARD16 firstColour; CARD16 nColours; /* Followed by nColours * 3 * CARD16 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ } rfbSetColourMapEntriesMsg; #define sz_rfbSetColourMapEntriesMsg 6 /*----------------------------------------------------------------------------- * Bell - ring a bell on the client if it has one. */ typedef struct { CARD8 type; /* always rfbBell */ } rfbBellMsg; #define sz_rfbBellMsg 1 /*----------------------------------------------------------------------------- * ServerCutText - the server has new text in its cut buffer. */ typedef struct { CARD8 type; /* always rfbServerCutText */ CARD8 pad1; CARD16 pad2; CARD32 length; /* followed by char text[length] */ } rfbServerCutTextMsg; #define sz_rfbServerCutTextMsg 8 /*----------------------------------------------------------------------------- * Union of all server->client messages. */ typedef union { CARD8 type; rfbFramebufferUpdateMsg fu; rfbSetColourMapEntriesMsg scme; rfbBellMsg b; rfbServerCutTextMsg sct; } rfbServerToClientMsg; /* *************************************************************************** * * Message definitions (client -> server) * *****************************************************************************/ /*----------------------------------------------------------------------------- * SetPixelFormat - tell the RFB server the format in which the client wants * pixels sent. */ typedef struct { CARD8 type; /* always rfbSetPixelFormat */ CARD8 pad1; CARD16 pad2; rfbPixelFormat format; } rfbSetPixelFormatMsg; #define sz_rfbSetPixelFormatMsg (sz_rfbPixelFormat + 4) /*----------------------------------------------------------------------------- * FixColourMapEntries - when the pixel format uses a "colour map", fix * read-only colour map entries. * * ***************** NOT CURRENTLY SUPPORTED ***************** */ typedef struct { CARD8 type; /* always rfbFixColourMapEntries */ CARD8 pad; CARD16 firstColour; CARD16 nColours; /* Followed by nColours * 3 * CARD16 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ } rfbFixColourMapEntriesMsg; #define sz_rfbFixColourMapEntriesMsg 6 /*----------------------------------------------------------------------------- * SetEncodings - tell the RFB server which encoding types we accept. Put them * in order of preference, if we have any. We may always receive raw * encoding, even if we don't specify it here. */ typedef struct { CARD8 type; /* always rfbSetEncodings */ CARD8 pad; CARD16 nEncodings; /* followed by nEncodings * CARD32 encoding types */ } rfbSetEncodingsMsg; #define sz_rfbSetEncodingsMsg 4 /*----------------------------------------------------------------------------- * FramebufferUpdateRequest - request for a framebuffer update. If incremental * is true then the client just wants the changes since the last update. If * false then it wants the whole of the specified rectangle. */ typedef struct { CARD8 type; /* always rfbFramebufferUpdateRequest */ CARD8 incremental; CARD16 x; CARD16 y; CARD16 w; CARD16 h; } rfbFramebufferUpdateRequestMsg; #define sz_rfbFramebufferUpdateRequestMsg 10 /*----------------------------------------------------------------------------- * KeyEvent - key press or release * * Keys are specified using the "keysym" values defined by the X Window System. * For most ordinary keys, the keysym is the same as the corresponding ASCII * value. Other common keys are: * * BackSpace 0xff08 * Tab 0xff09 * Return or Enter 0xff0d * Escape 0xff1b * Insert 0xff63 * Delete 0xffff * Home 0xff50 * End 0xff57 * Page Up 0xff55 * Page Down 0xff56 * Left 0xff51 * Up 0xff52 * Right 0xff53 * Down 0xff54 * F1 0xffbe * F2 0xffbf * ... ... * F12 0xffc9 * Shift 0xffe1 * Control 0xffe3 * Meta 0xffe7 * Alt 0xffe9 */ typedef struct { CARD8 type; /* always rfbKeyEvent */ CARD8 down; /* true if down (press), false if up */ CARD16 pad; CARD32 key; /* key is specified as an X keysym */ } rfbKeyEventMsg; #define sz_rfbKeyEventMsg 8 /*----------------------------------------------------------------------------- * PointerEvent - mouse/pen move and/or button press. */ typedef struct { CARD8 type; /* always rfbPointerEvent */ CARD8 buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */ CARD16 x; CARD16 y; } rfbPointerEventMsg; #define rfbButton1Mask 1 #define rfbButton2Mask 2 #define rfbButton3Mask 4 #define sz_rfbPointerEventMsg 6 /*----------------------------------------------------------------------------- * ClientCutText - the client has new text in its cut buffer. */ typedef struct { CARD8 type; /* always rfbClientCutText */ CARD8 pad1; CARD16 pad2; CARD32 length; /* followed by char text[length] */ } rfbClientCutTextMsg; #define sz_rfbClientCutTextMsg 8 /*----------------------------------------------------------------------------- * Union of all client->server messages. */ typedef union { CARD8 type; rfbSetPixelFormatMsg spf; rfbFixColourMapEntriesMsg fcme; rfbSetEncodingsMsg se; rfbFramebufferUpdateRequestMsg fur; rfbKeyEventMsg ke; rfbPointerEventMsg pe; rfbClientCutTextMsg cct; } rfbClientToServerMsg;
32.184524
79
0.621139
a2d6fa90cd9523f588a249eb0d6a4272e8f63175
5,237
h
C
message_services/include/vehicle_status_intent_service.h
usdot-fhwa-stol/carma-streets
1b3a7dc3f74033283c71ecefc2a1878f14574164
[ "Apache-2.0" ]
3
2021-09-04T16:25:47.000Z
2022-03-09T20:24:30.000Z
message_services/include/vehicle_status_intent_service.h
usdot-fhwa-stol/carma-streets
1b3a7dc3f74033283c71ecefc2a1878f14574164
[ "Apache-2.0" ]
85
2021-07-07T16:58:46.000Z
2022-03-31T15:35:26.000Z
message_services/include/vehicle_status_intent_service.h
usdot-fhwa-stol/carma-streets
1b3a7dc3f74033283c71ecefc2a1878f14574164
[ "Apache-2.0" ]
4
2021-05-20T23:12:03.000Z
2021-09-08T15:33:42.000Z
#ifndef VEHICLE_STATUS_INTENT_SERVICE_H #define VEHICLE_STATUS_INTENT_SERVICE_H #include <iostream> #include <thread> #include <vector> #include <map> #include "bsm_worker.h" #include "mobilitypath_worker.h" #include "mobilityoperation_worker.h" #include "vehicle_status_intent_worker.h" #include "vehicle_status_intent.h" #include "kafka_client.h" #include "message_lanelet2_translation.h" namespace message_services { namespace services { typedef struct vsi_message_bucket { models::mobilityoperation mo; models::bsm bsm; models::mobilitypath mp; } vsi_message_bucket_t; class vehicle_status_intent_service { private: std::string bootstrap_server; std::string bsm_group_id; std::string bsm_topic_name; std::string mo_group_id; std::string mo_topic_name; std::string mp_group_id; std::string mp_topic_name; std::string vsi_topic_name; std::shared_ptr<kafka_clients::kafka_producer_worker> _vsi_producer_worker; std::shared_ptr<kafka_clients::kafka_consumer_worker> _mo_consumer_worker; std::shared_ptr<kafka_clients::kafka_consumer_worker> _mp_consumer_worker; std::shared_ptr<kafka_clients::kafka_consumer_worker> _bsm_consumer_worker; std::int64_t vsi_est_path_point_count = 0; //Mapping MobilityOperation and BSM msg_count maximum allowed differences. std::int32_t MOBILITY_OPERATION_BSM_MAX_COUNT_OFFSET = 0; //Mapping MobilityOperation and MobilityPath timestamp duration within 1000 ms. std::int32_t MOBILITY_OPERATION_PATH_MAX_DURATION = 1000; //The duration between the offset points in mobilitypath message. Default duration is MOBILITY_PATH_TRAJECTORY_OFFSET_DURATION * 100 (milliseconds) std::uint32_t MOBILITY_PATH_TRAJECTORY_OFFSET_DURATION = 1; //Publish vehicle status intent thread sleep time. unsigned int VSI_TH_SLEEP_MILLI_SEC = 100; //Expire BSM message from the queue after duration. Default value is 6 seconds unsigned long BSM_MSG_EXPIRE_IN_SEC = 6; //Clean the queue every CLEAN_QUEUE_IN_SECS; std::int32_t CLEAN_QUEUE_IN_SECS = 0; //Tracking last message expired timestamp std::time_t prev_msg_expired_timestamp_ = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); //add lanelet2 translation object std::shared_ptr<message_translations::message_lanelet2_translation> _msg_lanelet2_translate_ptr; public: vehicle_status_intent_service(); ~vehicle_status_intent_service(); /** * @brief configuration file name * **/ const std::string MANIFEST_CONFIG_FILE_PATH = "../manifest.json"; /** * @brief read configuration file and determine the producer and consumer topics, bootstrap server * **/ bool initialize(std::shared_ptr<message_translations::message_lanelet2_translation> msg_translate_ptr); /** * @brief initialize variables and call run() methods to spin up threads. * **/ void start(); /** * @brief Creating and running threads. Each thread is acting as consumer or producer to consume or produce messages to topics * @param pointers to workers that will be used to work on messages that are consumed * **/ void run(std::shared_ptr<message_services::workers::bsm_worker> bsm_w_ptr, std::shared_ptr<message_services::workers::mobilitypath_worker> mp_w_ptr, std::shared_ptr<message_services::workers::mobilityoperation_worker> mo_w_ptr); /** * @brief Generate the vehicle status and intent message based on the latest bsm , MobilityOperation and MobilityPath objects. * @param pointers to object that will store the latest messages * **/ models::vehicle_status_intent compose_vehicle_status_intent(models::bsm &bsm, models::mobilityoperation &mo, models::mobilitypath &mp); /** * @brief Consume a message from particular topic and convert the message as an object. Then append the message to its corresponding worker * @param pointers to object that will store the message consumed. topic from which the message is from. The group id of the consumer * **/ template <class T> void msg_consumer(std::shared_ptr<T> msg_ptr, std::shared_ptr<kafka_clients::kafka_consumer_worker> consumer_worker); /** * @brief Producer a message to a topic * @param pointer to object that will be published, and a topic name * **/ template <typename T> void publish_msg(T msg, std::shared_ptr<kafka_clients::kafka_producer_worker> producer_worker); }; } } #endif
44.381356
191
0.656865
3189f3a0b94a030290b286ea4a78623ddd5ea2e3
1,944
c
C
tests/threads/priority-donate-one.c
Jeffxzj/PintOS-Project1
dcfa3acf4b44885e109b7af87b2bdd70ebd183e8
[ "MIT" ]
40
2015-02-11T23:29:31.000Z
2022-01-26T19:34:02.000Z
pintos-anon-f685123/src/tests/threads/priority-donate-one.c
puffyyy/2021OSLab
61e189fbb676f658002bb1440c89b5b61572cba6
[ "MIT" ]
42
2020-09-27T17:58:34.000Z
2020-11-29T19:58:16.000Z
pintos-anon-f685123/src/tests/threads/priority-donate-one.c
puffyyy/2021OSLab
61e189fbb676f658002bb1440c89b5b61572cba6
[ "MIT" ]
69
2015-01-18T04:36:38.000Z
2021-10-29T21:10:13.000Z
/* The main thread acquires a lock. Then it creates two higher-priority threads that block acquiring the lock, causing them to donate their priorities to the main thread. When the main thread releases the lock, the other threads should acquire it in priority order. Based on a test originally submitted for Stanford's CS 140 in winter 1999 by Matt Franklin <startled@leland.stanford.edu>, Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>. Modified by arens. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/synch.h" #include "threads/thread.h" static thread_func acquire1_thread_func; static thread_func acquire2_thread_func; void test_priority_donate_one (void) { struct lock lock; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); /* Make sure our priority is the default. */ ASSERT (thread_get_priority () == PRI_DEFAULT); lock_init (&lock); lock_acquire (&lock); thread_create ("acquire1", PRI_DEFAULT + 1, acquire1_thread_func, &lock); msg ("This thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 1, thread_get_priority ()); thread_create ("acquire2", PRI_DEFAULT + 2, acquire2_thread_func, &lock); msg ("This thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 2, thread_get_priority ()); lock_release (&lock); msg ("acquire2, acquire1 must already have finished, in that order."); msg ("This should be the last line before finishing this test."); } static void acquire1_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("acquire1: got the lock"); lock_release (lock); msg ("acquire1: done"); } static void acquire2_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("acquire2: got the lock"); lock_release (lock); msg ("acquire2: done"); }
29.454545
75
0.713477
2eeaae5956ea240e84039fff052b1f3caabd4f86
381
h
C
Example/CLBanner/ExampleBanner.h
darkcl/CLBanner
da2eeae4bd718c11054970b7d0a23d3277840cc5
[ "MIT" ]
null
null
null
Example/CLBanner/ExampleBanner.h
darkcl/CLBanner
da2eeae4bd718c11054970b7d0a23d3277840cc5
[ "MIT" ]
null
null
null
Example/CLBanner/ExampleBanner.h
darkcl/CLBanner
da2eeae4bd718c11054970b7d0a23d3277840cc5
[ "MIT" ]
null
null
null
// // ExampleBanner.h // CLBanner // // Created by Yeung Yiu Hung on 8/10/15. // Copyright (c) 2015 Yeung Yiu Hung. All rights reserved. // #import <UIKit/UIKit.h> #import <CLBanner/CLBanner.h> @interface ExampleBanner : UIView<CLBannerDelegate> @property (weak, nonatomic) IBOutlet UILabel *titleLabel; @property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; @end
21.166667
63
0.729659
c82a8ddbddd6175734dba7bfaa79af41caa29ef6
18,503
c
C
sandbox/task.c
chillancezen/Hyrule
79bf1b3e83f4e954fac735c7290093dfb48a0373
[ "BSD-3-Clause" ]
null
null
null
sandbox/task.c
chillancezen/Hyrule
79bf1b3e83f4e954fac735c7290093dfb48a0373
[ "BSD-3-Clause" ]
null
null
null
sandbox/task.c
chillancezen/Hyrule
79bf1b3e83f4e954fac735c7290093dfb48a0373
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2020 Jie Zheng */ #include <task.h> #include <task_sched.h> #include <list.h> #include <vm.h> #include <log.h> #define __USE_GNU #include <sched.h> #include <fcntl.h> #include <unistd.h> #include <uaccess.h> #include <tinyprintf.h> #include <app.h> #include <wait_queue.h> static struct list_elem global_task_list_head; uint8_t * task_state_to_string(enum task_state stat); void raw_task_wake_up(struct hart * task) { log_debug("wake up process:%d current status:%s\n", task->native_vmptr->pid, task_state_to_string(task->state)); switch(task->state) { case TASK_STATE_RUNNING: break; case TASK_STATE_INTERRUPTIBLE: transit_state(task, TASK_STATE_RUNNING); break; case TASK_STATE_UNINTERRUPTIBLE: // In an `TASK_STATE_UNINTERRUPTIBLE` state, the previous // `non_stop_state` must be in `TASK_STATE_INTERRUPTIBLE`, we // restore it to RUNNING state, but do not run the task // immediately. it muust be continued with explicit SIGCONT signal. ASSERT(task->non_stop_state == TASK_STATE_RUNNING || task->non_stop_state == TASK_STATE_INTERRUPTIBLE); task->non_stop_state = TASK_STATE_RUNNING; break; default: log_fatal("current task state:%d\n", task->state); __not_reach(); break; } } void dump_threads(struct hart * hartptr) { struct virtual_machine * vm = hartptr->native_vmptr; log_info("Dump process: %d\n", vm->pid); log_info("\tparent pid: %d\n", vm->ppid); log_info("\tthread group id: %d\n", vm->tgid); log_info("\tflag: CLONE_VM:%d CLONE_FS:%d CLONE_FILES:%d\n", vm->cloned_vm, vm->cloned_fs, vm->cloned_files); log_info("\tthread group members:\n"); struct list_elem * list; LIST_FOREACH_START(&global_task_list_head, list) { struct virtual_machine * _vm = CONTAINER_OF(list, struct virtual_machine, list_node); if (_vm->tgid != vm->tgid) { continue; } log_info("\t thread: %d\n", _vm->pid); } LIST_FOREACH_END(); } static struct virtual_machine * allocate_virtual_machine_descriptor(void) { struct virtual_machine * vm = aligned_alloc(64, sizeof(struct virtual_machine)); ASSERT(vm); memset(vm, 0x0, sizeof(struct virtual_machine)); return vm; } static void task_cpu_init(struct virtual_machine * current_vm, struct virtual_machine * child_vm) { child_vm->hartptr = aligned_alloc(64, sizeof(struct hart)); ASSERT(child_vm->hartptr); hart_init(child_vm->hartptr, 0); child_vm->hartptr->native_vmptr = child_vm; // copy and modify cpu state memcpy(&child_vm->hartptr->registers, &current_vm->hartptr->registers, sizeof(struct integer_register_profile)); child_vm->hartptr->registers.a0 = 0; child_vm->hartptr->pc = current_vm->hartptr->pc + 4; } static void duplicate_virtual_memory(struct virtual_machine * current_vm, struct virtual_machine * child_vm) { int idx = 0; child_vm->nr_pmr_ops = current_vm->nr_pmr_ops; for (idx = 0; idx < current_vm->nr_pmr_ops; idx++) { // XXX: COW semantics are not implemented here for that No single page // tracking is in this emulator memcpy(&child_vm->pmr_ops[idx], &current_vm->pmr_ops[idx], sizeof(struct pm_region_operation)); int pmr_len = child_vm->pmr_ops[idx].addr_high - child_vm->pmr_ops[idx].addr_low; child_vm->pmr_ops[idx].host_base = preallocate_physical_memory(pmr_len); ASSERT(child_vm->pmr_ops[idx].host_base); memcpy(child_vm->pmr_ops[idx].host_base, current_vm->pmr_ops[idx].host_base, pmr_len); if (&current_vm->pmr_ops[idx] == current_vm->vma_heap) { child_vm->vma_heap = &child_vm->pmr_ops[idx]; } if (&current_vm->pmr_ops[idx] == current_vm->vma_stack) { child_vm->vma_stack = &child_vm->pmr_ops[idx]; } } } void reclaim_virtual_memory(struct virtual_machine * vm) { if (vm->cloned_vm) { ASSERT(vm->parent_vm); deference_task(vm->parent_vm); vm->cloned_vm = 0; } else { int idx = 0; for (idx = 0; idx < vm->nr_pmr_ops; idx++) { if (vm->pmr_ops[idx].pmr_reclaim) { vm->pmr_ops[idx].pmr_reclaim(vm->pmr_ops[idx].opaque, vm->hartptr, &vm->pmr_ops[idx]); } } vm->nr_pmr_ops = 0; vm->vma_heap = NULL; vm->vma_stack = NULL; } } static void task_vm_init(struct virtual_machine * current_vm, struct virtual_machine * child_vm, uint32_t flags) { if (flags & CLONE_VM) { // If child process shares virtual machine with parent process, we don't // allocate vma delicated to child process. child_vm->cloned_vm = 1; reference_task(current_vm); } else { // XXX: duplicate everything of virtual memory from parent process. duplicate_virtual_memory(current_vm, child_vm); } } static void task_linkage_init(struct virtual_machine * current_vm, struct virtual_machine * child_vm, uint32_t flags) { child_vm->pid = new_pid(); child_vm->ppid = current_vm->pid; if (flags & CLONE_THREAD) { child_vm->tgid = current_vm->pid; } else { child_vm->tgid = child_vm->pid; } child_vm->parent_vm = current_vm; reference_task(current_vm); } static void task_fs_init(struct virtual_machine * current_vm, struct virtual_machine * child_vm, uint32_t flags) { if (flags & CLONE_FS) { child_vm->cloned_fs = 1; reference_task(current_vm); } else { memcpy(child_vm->root, current_vm->root, sizeof(child_vm->root)); memcpy(child_vm->cwd, current_vm->cwd, sizeof(child_vm->cwd)); } } static void duplicate_files(struct virtual_machine * current_vm, struct virtual_machine * child_vm) { int idx = 0; for (idx = 0; idx < MAX_FILES_NR; idx++) { if (!current_vm->files[idx].valid) { child_vm->files[idx].valid = 0; continue; } child_vm->files[idx].valid = 1; child_vm->files[idx].fd = current_vm->files[idx].fd; if (current_vm->files[idx].host_cpath) { child_vm->files[idx].host_cpath = strdup(current_vm->files[idx].host_cpath); } child_vm->files[idx].clone_blob.file_type = current_vm->files[idx].clone_blob.file_type; child_vm->files[idx].clone_blob.mode = current_vm->files[idx].clone_blob.mode; child_vm->files[idx].clone_blob.flags = current_vm->files[idx].clone_blob.flags; switch(child_vm->files[idx].clone_blob.file_type) { case FILE_TYPE_REGULAR: ASSERT(child_vm->files[idx].host_cpath); child_vm->files[idx].host_fd = open(child_vm->files[idx].host_cpath, child_vm->files[idx].clone_blob.flags, child_vm->files[idx].clone_blob.mode); break; case FILE_TYPE_SOCKET: child_vm->files[idx].host_fd = dup(current_vm->files[idx].host_fd); break; default: __not_reach(); break; } } } static void task_files_init(struct virtual_machine * current_vm, struct virtual_machine * child_vm, uint32_t flags) { if (flags & CLONE_FILES) { child_vm->cloned_files = 1; reference_task(current_vm); } else { duplicate_files(current_vm, child_vm); } } static void task_threads_init(struct virtual_machine * current_vm, struct virtual_machine * child_vm, uint32_t child_stack, uint32_t flags, uint32_t ctid_addr) { if (flags & CLONE_CHILD_SETTID) { child_vm->set_child_tid = ctid_addr; log_debug("clone pid:%d set_child_tid address:0x%x\n", child_vm->pid, child_vm->set_child_tid); } // IF a thread context is created, the stack must be changed to the new one if (flags & CLONE_THREAD) { ASSERT(child_stack); child_vm->hartptr->registers.sp = child_stack; } } #include <translation.h> #include <vmm_sched.h> /* * This will duplicate all information of a task including cpu state information. * it's usually called when creating a process. */ static uint32_t clone_task(struct virtual_machine * current_vm, uint32_t child_stack, uint32_t flags, uint32_t ptid_addr, uint32_t tls_addr, uint32_t ctid_addr) { struct virtual_machine * child_vm = allocate_virtual_machine_descriptor(); task_linkage_init(current_vm, child_vm, flags); task_cpu_init(current_vm, child_vm); task_vm_init(current_vm, child_vm, flags); task_fs_init(current_vm, child_vm, flags); task_files_init(current_vm, child_vm, flags); task_threads_init(current_vm, child_vm, child_stack, flags, ctid_addr); register_task(child_vm); // XXX: now the child process is able to be scheduled. task_vmm_sched_init(child_vm->hartptr, (void (*)(void *))vmresume, child_vm->hartptr); schedule_task(child_vm->hartptr); //yield_cpu(); return child_vm->pid; } void register_task(struct virtual_machine * vm) { list_append(&global_task_list_head, &vm->list_node); log_info("registering task:%d into global tasklist\n", vm->pid); } void unregister_task(struct virtual_machine * vm) { if (element_in_list(&global_task_list_head, &vm->list_node)) { list_delete(&global_task_list_head, &vm->list_node); log_info("unregistering task:%d from global tasklist\n", vm->pid); } } __attribute__((constructor)) static void task_pre_init(void) { list_init(&global_task_list_head); } void do_exit(struct hart * hartptr, uint32_t status) { hartptr->wait_state_exited = 1; wake_up(&hartptr->wq_state_notification); transit_state(hartptr, TASK_STATE_EXITING); yield_cpu(); // This task will never be rescheduled. __not_reach(); } uint32_t call_set_tid_address(struct hart * hartptr, uint32_t tid_address) { struct virtual_machine * vm = hartptr->native_vmptr; vm->set_child_tid = tid_address; log_debug("set_tid_address pid:%d, address:0x%x\n", vm->pid, vm->set_child_tid); return vm->pid; } uint32_t call_set_robust_list(struct hart * hartptr, uint32_t head_addr, uint32_t len) { // FIXME: implement the call body return 0; } // GLIBC: ./sysdeps/unix/sysv/linux/bits/sched.h // ./sysdeps/unix/sysv/linux/riscv/clone.S uint32_t call_clone(struct hart * hartptr, uint32_t flags, uint32_t child_stack_addr, uint32_t ptid_addr, uint32_t tls_addr, uint32_t ctid_addr) { struct virtual_machine * current = hartptr->native_vmptr; log_debug("call_clone:{flags:%x child_stack_addr:%x ptid_addr:%x, " "tls_addr:%x ctid_addr:%x}\n", flags, child_stack_addr, ptid_addr, tls_addr, ctid_addr); return clone_task(current, child_stack_addr, flags, ptid_addr, tls_addr, ctid_addr); } #define MAX_NR_ARGV 128 #define MAX_NR_ENVP 128 uint32_t call_execve(struct hart * hartptr, uint32_t filename_addr, uint32_t argv_addr, uint32_t envp_addr) { // XXX: we only receive binary executable file char * filename = strdup(user_world_pointer(hartptr, filename_addr)); uint32_t * argv = user_world_pointer(hartptr, argv_addr); uint32_t * envp = user_world_pointer(hartptr, envp_addr); __attribute__((unused)) char * host_argv[MAX_NR_ARGV]; __attribute__((unused)) char * host_envp[MAX_NR_ENVP]; int idx = 0; for (idx = 0; idx < MAX_NR_ARGV - 1; idx++) { if (!argv[idx]) { break; } host_argv[idx] = strdup((char *)user_world_pointer(hartptr, argv[idx])); } host_argv[idx] = NULL; for (idx = 0; idx < MAX_NR_ENVP; idx++) { if (!envp[idx]) { break; } host_envp[idx] = strdup((char *)user_world_pointer(hartptr, envp[idx])); } host_envp[idx] = NULL; // Now all paremteres that host can see are all ready // XXX: even execevi() is called in thread context, it works well. struct virtual_machine * vm_vm = get_linked_vm(hartptr->native_vmptr, LINKAGE_HINT_VM); // Now it's safe to release the virtual memory allocated for previous task, // because we do backup all these strings. reclaim_virtual_memory(vm_vm); // canonicalize filename char host_path[MAX_PATH]; char host_cpath[MAX_PATH]; { const char * ptr = filename; for (; *ptr && *ptr == ' '; ptr++); int is_absolute = *ptr == '/'; char guest_cpath[MAX_PATH]; if (is_absolute) { canonicalize_path_name((uint8_t *)guest_cpath, (const uint8_t *)ptr); } else { char guest_path[MAX_PATH]; tfp_sprintf(guest_path, "%s/%s", vm_vm->cwd, ptr); canonicalize_path_name((uint8_t *)guest_cpath, (const uint8_t *)guest_path); } tfp_sprintf(host_path, "%s/%s", vm_vm->root, guest_cpath); canonicalize_path_name((uint8_t *)host_cpath, (const uint8_t *)host_path); } // XXX: MUST flush the translation cache because the instruction stream has // changed. reset_registers(hartptr); flush_translation_cache(hartptr); program_init(vm_vm, host_cpath); env_setup(vm_vm, host_argv, host_envp); free(filename); for (idx = 0; idx < MAX_NR_ARGV && host_argv[idx]; idx++) { free(host_argv[idx]); } for (idx = 0; idx < MAX_NR_ENVP && host_envp[idx]; idx++) { free(host_envp[idx]); } log_debug("execve %s in process:%d\n", host_cpath, hartptr->native_vmptr->pid); // you might yield cpu here, but it's not necessary. yield_cpu(); // note a successful execve() will never return. vmresume(hartptr); return 0; } // wait for the children processes' state changed: // 1) the child is terminated // 2) the child is stoppped by a signal // 3) the child is resumed by a signal // *** wait a child terminated to release all the resources for the child // without wait: the child remains in a 'zombie' state // if child's state has changed: these calls return immediately #define WNOHANG_MASK 0x1 /* Don't block waiting. */ #define WUNTRACED_MASK 0x2 /* Report status of stopped children. */ struct wait_blob { struct virtual_machine * vm; struct wait_queue wait; struct list_elem list_node; }; uint32_t call_wait4(struct hart * hartptr, int32_t pid_hint, uint32_t wstatus_addr, uint32_t options, uint32_t rusage_addr) { int32_t ret = -1; struct virtual_machine * target_vm = NULL; struct virtual_machine * vm = hartptr->native_vmptr; struct list_elem * list; struct list_elem wait_blob_head; list_init(&wait_blob_head); LIST_FOREACH_START(&global_task_list_head, list) { struct virtual_machine * _vm = CONTAINER_OF(list, struct virtual_machine, list_node); if (vm->pid != _vm->ppid || vm->pid == _vm->pid) { continue; } int is_to_wait = 0; if (pid_hint == -1) { // wait for any child process is_to_wait = vm->pid == _vm->ppid; } else if (pid_hint < -1) { // wait if child's tgid is equal to abs(pid_hint) is_to_wait = _vm->tgid == -pid_hint; } else if (!pid_hint) { // wait if child's tgid is equal to the pid of calling process is_to_wait = _vm->tgid == vm->pid; } else { is_to_wait = _vm->pid == pid_hint; } if (!is_to_wait) { continue; } // the child is waitable, adjust the ret value in case WNOHANG is specified ret = 0; // Found one that has exited if (_vm->hartptr->wait_state_exited) { ret = _vm->pid; target_vm = _vm; break; } if (!(options & WNOHANG_MASK)) { // hang until at lease one child state changed. struct wait_blob * _wait_blob = malloc(sizeof(struct wait_blob)); ASSERT(_wait_blob); memset(_wait_blob, 0x0, sizeof(struct wait_blob)); _wait_blob->vm = _vm; initialize_wait_queue_entry(&_wait_blob->wait, hartptr); list_append(&wait_blob_head, &_wait_blob->list_node); add_wait_queue_entry(&_vm->hartptr->wq_state_notification, &_wait_blob->wait); } } LIST_FOREACH_END(); // FIXME: handle pending signals if (!list_empty(&wait_blob_head)) { transit_state(hartptr, TASK_STATE_INTERRUPTIBLE); yield_cpu(); } while ((list = list_fetch(&wait_blob_head))) { struct wait_blob * _wait_blob = CONTAINER_OF(list, struct wait_blob, list_node); if (ret <= 0) { if (_wait_blob->vm->hartptr->wait_state_exited || (options & WUNTRACED_MASK && ( _wait_blob->vm->hartptr->wait_state_continued || _wait_blob->vm->hartptr->wait_state_stopped))) { ret = _wait_blob->vm->pid; target_vm = _wait_blob->vm; } } remove_wait_queue_entry(&_wait_blob->vm->hartptr->wq_state_notification, &_wait_blob->wait); free(_wait_blob); } log_debug("call_wait4, caller's process id: %d result:%d\n", vm->pid, ret); if (ret > 0) { // remove the process entry in case the child becomes a zombie ASSERT(target_vm); unregister_task(target_vm); } return ret; }
32.291449
96
0.611955
0876e26d4821074fa1439def68817c5d7d3dfb25
686
h
C
Engine/inc/EngineFactory.h
sunjinbo/Scallop
d12738f679c5affd5a01db702e90e3db7387da9b
[ "MIT" ]
null
null
null
Engine/inc/EngineFactory.h
sunjinbo/Scallop
d12738f679c5affd5a01db702e90e3db7387da9b
[ "MIT" ]
null
null
null
Engine/inc/EngineFactory.h
sunjinbo/Scallop
d12738f679c5affd5a01db702e90e3db7387da9b
[ "MIT" ]
null
null
null
/* ==================================================================== * File: EngineFactory.h * Created: 08/16/09 * Modified: 08/16/09 * Author: Sun Jinbo * Copyright (c): Tieto, All rights reserved * ==================================================================== */ #ifndef M_ENGINEFACTORY_H #define M_ENGINEFACTORY_H // INCLUDE FILES #include <e32base.h> // FORWARD DECLARATIONS class CEngineBase; class MEngineObserver; // CLASS DECLARATION /** * MEngineFactory class * * @since S60 5.0 */ class MEngineFactory { public: // New functions virtual CEngineBase* ScaEngineL( MEngineObserver& aObserver ) = 0; }; #endif // M_ENGINEFACTORY_H // End of file
20.176471
74
0.561224
bd376e05af5dcbe1a30a974da36df610b5f006c5
3,264
c
C
BibliografiasAEDS1e2/Ziviani-ProjetoDeAlgoritmos/Cap01-Introducao/A4-FuncaoMaximoMinimoOtimizada.c
mariatheresahqs/MaterialSuporteAEDS
6edf3cb4225495024963e0bfc8b53aeaaef40a6c
[ "MIT" ]
1
2019-11-07T01:47:57.000Z
2019-11-07T01:47:57.000Z
BibliografiasAEDS1e2/Ziviani-ProjetoDeAlgoritmos/Cap01-Introducao/A4-FuncaoMaximoMinimoOtimizada.c
mariatheresahqs/MaterialSuporteAEDS
6edf3cb4225495024963e0bfc8b53aeaaef40a6c
[ "MIT" ]
null
null
null
BibliografiasAEDS1e2/Ziviani-ProjetoDeAlgoritmos/Cap01-Introducao/A4-FuncaoMaximoMinimoOtimizada.c
mariatheresahqs/MaterialSuporteAEDS
6edf3cb4225495024963e0bfc8b53aeaaef40a6c
[ "MIT" ]
2
2019-01-22T19:15:40.000Z
2019-10-03T21:48:27.000Z
#include <stdio.h> void MaximoMinimo(int tamanho, int vetor[], int *maximo, int *minimo);//Declaracao da funcao e parametros para encontrar maximos e minimos de um vetor int main() { int tamanho, i;//declaracao da variavel tamanho do vetor e da variavel de iteracao printf("Declare o tamanho do vetor:\n"); scanf("%d", &tamanho);//armazenamento do valor da variavel tamanho int vetor[tamanho], maximo, minimo;//declaracao da variavel vetor com seu tamanho, e das variaveis maximo e minimo printf("Declare os %d valores do vetor:\n", tamanho); for(i=0;i<tamanho;i++){ scanf("%d", &vetor[i]);//declaracao dos valores dos elementos do vetor } printf("Os valores declarados para o vetor são:\n"); for(i=0;i<tamanho;i++){//passagem por iteracao em cada indice dos elementos do vetor printf("%d ", vetor[i]);//exibicao dos valores dos elementos do vetor } MaximoMinimo(tamanho, vetor, &maximo, &minimo);//chamada da funcao para encontrar o maximo e minimo dentre os elementos do vetor printf("\nO valor maximo declarado foi %d, e o valor minimo foi %d.\n", maximo, minimo);//exibicao do valor maximo e minimo do vetor return 0; } void MaximoMinimo(int tamanho, int vetor[], int *maximo, int *minimo)//passagem dos parametros do vetor { int i, FimDoAnel;//declaracao da variavel de iteracao e da variavel FimDoAnel(dependente da variavel tamanho do vetor) if((tamanho & 1)>0){ vetor[tamanho] = vetor[tamanho - 1];//atribui o valor do elemento vetor[tamanho - 1] ao novo elemento criado, vetor[tamanho] FimDoAnel = tamanho;//atribui o valor do tamanho do vetor a variavel FimDoAnel } else{ FimDoAnel = tamanho - 1; } if (vetor[0]>vetor[1]){//compara os valores dos dois primeiros elementos do vetor, conferindo se o primeiro é maior que o segundo *maximo = vetor[0];//designa o valor do primeiro elemento ao ponteiro da variavel maximo *minimo = vetor[1];//designa o valor do segundo elemento ao ponteiro de variavel minimo } else{//caso o primeiro elemento do vetor nao seja maior que o segundo *maximo = vetor[1];//designa o valor do segundo valor ao ponteiro da variavel maximo *minimo = vetor[0];//designa o valor do primeiro valor ao ponteiro da variavel minimo } i = 3;//atribui o valor 3 a variavel de iteracao para que as buscas e comparacoes comecem de um elemento que ainda nao foi analisado while (i <= FimDoAnel) {//estabele iteracao ate o momento em que a variavel indice de comparacao for menor ou igual ao limite de tamanho do vetor if (vetor[i - 1] > vetor[i]) {//compara dois indices de elementos do vetor, indices ainda nao comparados if (vetor[i - 1] > *maximo) { *maximo = vetor[i - 1]; } if (vetor[i] < *minimo) { *minimo = vetor[i]; } } else { if (vetor[i - 1] < *minimo) { *minimo = vetor[i - 1]; } if (vetor[i] > *maximo) { *maximo = vetor[i]; } } i += 2;//Incrementa o indice do vetor em dois, forcando a funcao a analisar dois elementos que ainda nao foram comparados } }
44.108108
150
0.650735
b7f5a37bfa309c35d2c0a4354cc3cc10b81a6137
308
h
C
uMobile/PortletSelectionDelegate.h
aclissold/uMobile-iOS-app
f7419b1c629464e34ed0c878a6a69d1b9e27b3e0
[ "Apache-2.0" ]
null
null
null
uMobile/PortletSelectionDelegate.h
aclissold/uMobile-iOS-app
f7419b1c629464e34ed0c878a6a69d1b9e27b3e0
[ "Apache-2.0" ]
null
null
null
uMobile/PortletSelectionDelegate.h
aclissold/uMobile-iOS-app
f7419b1c629464e34ed0c878a6a69d1b9e27b3e0
[ "Apache-2.0" ]
null
null
null
// // PortletSelectionDelegate.h // uMobile // // Created by Andrew Clissold on 7/2/14. // Copyright (c) 2014 Oakland University. All rights reserved. // #import <Foundation/Foundation.h> @protocol PortletSelectionDelegate <NSObject> @required - (void)selectedPortlet:(NSDictionary *)portletInfo; @end
20.533333
63
0.743506
d3df53c6fd4bbc14e538b0b712556cceaedc273a
3,424
c
C
Codes/aiv2008/length_of_longest_substring/length_of_longest_substring.c
aiv2008/algorithm
ecee5b76af52d9ad55b7fb9cf706be25c76772c1
[ "Apache-2.0" ]
null
null
null
Codes/aiv2008/length_of_longest_substring/length_of_longest_substring.c
aiv2008/algorithm
ecee5b76af52d9ad55b7fb9cf706be25c76772c1
[ "Apache-2.0" ]
null
null
null
Codes/aiv2008/length_of_longest_substring/length_of_longest_substring.c
aiv2008/algorithm
ecee5b76af52d9ad55b7fb9cf706be25c76772c1
[ "Apache-2.0" ]
null
null
null
#include<stdio.h> #include<stdlib.h> #include<string.h> #define HASH_SIZE 29 typedef struct { char val; struct LinkedListNode *pNext; } LinkedListNode; typedef struct { int val; struct LinkedListNode2 *pNext; } LinkedListNode2; typedef struct { struct LinkedListNode **key; struct LinkedListNode2 **val; } HashMap; int h(char key) { return (int)key % HASH_SIZE; } void push(HashMap **ppHashMap, char key, int val) { if(!ppHashMap)return; if(!*ppHashMap) { *ppHashMap = (HashMap*)calloc(1, sizeof(HashMap)); //(*ppHashMap)->size = HASH_SIZE; (*ppHashMap)->key = (LinkedListNode**)calloc(HASH_SIZE, sizeof(LinkedListNode*)); (*ppHashMap)->val = (LinkedListNode2**)calloc(HASH_SIZE, sizeof(LinkedListNode2*)); } int hashCode = h(key); LinkedListNode* pKeyIndex = *((*ppHashMap)->key + hashCode); LinkedListNode2* pValIndex = *((*ppHashMap)->val + hashCode); if(!pKeyIndex) { pKeyIndex = (LinkedListNode*)calloc(1, sizeof(LinkedListNode)); pValIndex = (LinkedListNode2*)calloc(1, sizeof(LinkedListNode2)); pKeyIndex->val = key; pValIndex->val = val; *((*ppHashMap)->key + hashCode) = pKeyIndex; *((*ppHashMap)->val + hashCode) = pValIndex; } else { LinkedListNode* pKeyMove = pKeyIndex; LinkedListNode2* pValMove = pValIndex; int count=0; LinkedListNode *pKeyCur = NULL; LinkedListNode2 *pValCur = NULL; while(pKeyMove) { if(pKeyMove->val == key) { pValMove->val = val; count++; break; } pKeyCur = pKeyMove; pValCur = pValMove; pKeyMove = pKeyMove->pNext; pValMove = pValMove->pNext; } if(!count) { LinkedListNode *pKeyNode = (LinkedListNode*)calloc(1, sizeof(LinkedListNode)); LinkedListNode2 *pValNode = (LinkedListNode*)calloc(1, sizeof(LinkedListNode2)); pKeyNode->val = key; pValNode->val = val; pKeyCur->pNext = pKeyNode; pValCur->pNext = pValNode; pKeyNode = NULL; pValNode = NULL; } pKeyMove = NULL; pValMove = NULL; pKeyCur = NULL; pValCur = NULL; } } int get(HashMap *pHashMap, char key) { if(!pHashMap) return -1; int hashCode = h(key); if(!pHashMap->key) { printf("plinkedlistkey is null\n"); return; } LinkedListNode **ppKeyIndex = pHashMap->key + hashCode; if(!ppKeyIndex) { printf("key is null\n"); return -1; } LinkedListNode *pKeyMove = (*ppKeyIndex); LinkedListNode2 *pValMove = *(pHashMap->val + hashCode); int val = -1; while(pKeyMove) { if(pKeyMove->val == key) { val = pValMove->val; break; } pKeyMove = pKeyMove->pNext; pValMove = pValMove->pNext; } return val; } int lengthOfLongestSubstring(char* s) { if(!s || !strlen(s))return 0; char *pHeader = s; char *pMove = pHeader; HashMap *pHashMap = NULL; int maxLen = 0; int count = 0; int i=0; while((*pMove)!='\0') { int index = get(pHashMap, *pMove); if(index == -1) { count++; push(&pHashMap, *pMove, i); } else { maxLen = (count > maxLen) ? count : maxLen; char *pTail = s + index + 1; char *pMoveJ = pHeader; while(pMoveJ != pTail) { push(&pHashMap, *pMoveJ, -1); pMoveJ++; } pHeader = pTail; push(&pHashMap, *pMove, i); count = pMove - pHeader + 1; } pMove++; i++; } if(count)maxLen = (count > maxLen) ? count : maxLen; return maxLen; } int main(void) { printf("please enter the string:\n"); char str1[30] = {0}; gets(str1); printf("%d\n", lengthOfLongestSubstring(str1)); return 0; }
20.023392
85
0.64486
2366ce90f87a7b7da11ea8e3dc3fa882592e5f02
1,306
h
C
chromeos/components/multidevice/stub_multidevice_util.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chromeos/components/multidevice/stub_multidevice_util.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
chromeos/components/multidevice/stub_multidevice_util.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROMEOS_COMPONENTS_MULTIDEVICE_STUB_MULTIDEVICE_UTIL_H_ #define CHROMEOS_COMPONENTS_MULTIDEVICE_STUB_MULTIDEVICE_UTIL_H_ #include "chromeos/components/multidevice/remote_device.h" namespace chromeos { namespace multidevice { // Returns a fake host phone with all host features enabled. Can be used as a // stub remote device to fake out multidevice features. RemoteDevice CreateStubHostPhone(); // Returns a fake client computer with the client features enabled according to // their corresponding flags. Can be used as a stub remote device to fake out // multidevice features. RemoteDevice CreateStubClientComputer(); // Returns if we should use stubbed implementations of multidevice features, // i.e. when we are running a Linux CrOS build that doesn't support them. bool ShouldUseMultideviceStubs(); } // namespace multidevice } // namespace chromeos // TODO(https://crbug.com/1164001): remove after the migration is finished. namespace ash { namespace multidevice { using ::chromeos::multidevice::ShouldUseMultideviceStubs; } } // namespace ash #endif // CHROMEOS_COMPONENTS_MULTIDEVICE_STUB_MULTIDEVICE_UTIL_H_
33.487179
79
0.799387
c10c86c027660609e9617e82eef813524bf46e17
378
h
C
UnityServices/Monetization/Core/Decision/UMONPlacementContentFactory.h
katoorukavya/unity-ads-ios
52f6e80d00113304e5f52731e6b3a49e202bfc3c
[ "Apache-2.0" ]
4
2017-10-08T10:54:11.000Z
2019-12-10T20:48:31.000Z
UnityServices/Monetization/Core/Decision/UMONPlacementContentFactory.h
katoorukavya/unity-ads-ios
52f6e80d00113304e5f52731e6b3a49e202bfc3c
[ "Apache-2.0" ]
null
null
null
UnityServices/Monetization/Core/Decision/UMONPlacementContentFactory.h
katoorukavya/unity-ads-ios
52f6e80d00113304e5f52731e6b3a49e202bfc3c
[ "Apache-2.0" ]
1
2017-10-08T10:34:56.000Z
2017-10-08T10:34:56.000Z
#import "UMONPlacementContent.h" typedef NS_ENUM(NSInteger, UMONPlacementContentType) { kPlacementContentTypeShowAd, kPlacementContentTypePromoAd, kPlacementContentTypeCustom, kPlacementContentTypeNoFill }; @interface UMONPlacementContentFactory : NSObject +(UMONPlacementContent *)create:(NSString *)placementId withParams:(NSMutableDictionary *)params; @end
29.076923
97
0.820106
c1acfbe4de5a16fbca5e7c39b567cafc3312c628
313
h
C
PXH/PXH/Classes/LifeCircle/View/YSCouponHeaderView.h
louguoquan/cizhuan
d300d1cf8947daf89be5c51f5ede6efe554d2dad
[ "MIT" ]
null
null
null
PXH/PXH/Classes/LifeCircle/View/YSCouponHeaderView.h
louguoquan/cizhuan
d300d1cf8947daf89be5c51f5ede6efe554d2dad
[ "MIT" ]
null
null
null
PXH/PXH/Classes/LifeCircle/View/YSCouponHeaderView.h
louguoquan/cizhuan
d300d1cf8947daf89be5c51f5ede6efe554d2dad
[ "MIT" ]
null
null
null
// // YSCouponHeaderView.h // PXH // // Created by yu on 2017/8/29. // Copyright © 2017年 yu. All rights reserved. // #import <UIKit/UIKit.h> #import "YSProductDetail.h" #import "UIView+YSRecalculate.h" @interface YSCouponHeaderView : UIView @property (nonatomic, strong) YSProductDetail *detail; @end
15.65
56
0.702875
1b2135e95b493d00690edf84a4f986e403cc526a
5,656
h
C
mapleall/maple_be/include/cg/aarch64/aarch64_insn.h
lvyitian/mapleall
1112501c1bcbff5d9388bf46f195d56560c5863a
[ "MulanPSL-1.0" ]
null
null
null
mapleall/maple_be/include/cg/aarch64/aarch64_insn.h
lvyitian/mapleall
1112501c1bcbff5d9388bf46f195d56560c5863a
[ "MulanPSL-1.0" ]
null
null
null
mapleall/maple_be/include/cg/aarch64/aarch64_insn.h
lvyitian/mapleall
1112501c1bcbff5d9388bf46f195d56560c5863a
[ "MulanPSL-1.0" ]
null
null
null
/* * Copyright (c) [2020] Huawei Technologies Co., Ltd. All rights reserved. * * OpenArkCompiler is licensed under the Mulan Permissive Software License v2. * You can use this software according to the terms and conditions of the MulanPSL - 2.0. * You may obtain a copy of MulanPSL - 2.0 at: * * https://opensource.org/licenses/MulanPSL-2.0 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR * FIT FOR A PARTICULAR PURPOSE. * See the MulanPSL - 2.0 for more details. */ #ifndef MAPLEBE_INCLUDE_CG_AARCH64INSN_H #define MAPLEBE_INCLUDE_CG_AARCH64INSN_H #include "aarch64_isa.h" #include "insn.h" #include "aarch64_operand.h" namespace maplebe { class AArch64Insn : public Insn { public: explicit AArch64Insn(MOperator opc, Operand *opnd0 = nullptr, Operand *opnd1 = nullptr, Operand *opnd2 = nullptr, Operand *opnd3 = nullptr, Operand *opnd4 = nullptr) : Insn(opc, opnd0, opnd1, opnd2, opnd3, opnd4) {} AArch64Insn &operator=(const AArch64Insn &p) = default; AArch64Insn(const AArch64Insn &originalInsn) : Insn(originalInsn.mop_, originalInsn.opnds[0], originalInsn.opnds[1], originalInsn.opnds[2], originalInsn.opnds[3], originalInsn.opnds[4]) { prev = originalInsn.prev; next = originalInsn.next; bb = originalInsn.bb; flags = originalInsn.flags; mop_ = originalInsn.mop_; for (int i = 0; i < kMaxOperandNum; i++) { if (originalInsn.opnds[i] == nullptr) { opnds[i] = nullptr; } else { opnds[i] = originalInsn.opnds[i]->Clone(CG::curCgFunc->memPool); } } } ~AArch64Insn() {} bool IsReturn() override { return GetMachineOpcode() == MOP_xret; } bool IsFixedInsn() override { return (GetMachineOpcode() == MOP_clinit || GetMachineOpcode() == MOP_clinit_tail); } bool IsComment() override { return GetMachineOpcode() == MOP_comment; } bool IsImmaterialInsn() override { return (dynamic_cast<mpldbg::DbgInsn *>(this) || GetMachineOpcode() == MOP_comment); } bool IsMachineInstruction() override { MOperator mop = GetMachineOpcode(); return (MOP_undef < mop && mop < MOP_comment); } bool IsPseudoInstruction() override { MOperator mop = GetMachineOpcode(); return (mop >= MOP_pseudo_param_def_x && mop <= MOP_pseudo_eh_def_x); } bool IsEffectiveCopy() override { return CopyOperands() >= 0; } int32_t GetResultNum() override; int32_t GetOpndNum() override; Operand *GetResult(int32_t i) override; Operand *GetOpnd(int32_t i) override; Operand *GetResultMemOpnd() override; Operand *GetMemOpnd() override; void SetOpnd(int32_t i, Operand *opnd) override; int32_t CopyOperands() override; bool IsGlobal() override final { return GetMachineOpcode() == MOP_xadrp || GetMachineOpcode() == MOP_xadrpl12; } bool IsCall() override final; bool IsTailCall() const override final; bool IsClinit() override final; bool CanThrow() override final; bool IsIndirectCall() override final { return GetMachineOpcode() == MOP_xblr; } bool IsCallToFunctionThatNeverReturns() override final; bool MayThrow() override final; bool IsBranch() override final; bool IsMove() override final; bool IsLoad() override final; bool IsLoadStorePair(); bool IsStore() override final; bool IsLoadPair() override final; bool IsStorePair() override final; bool IsLoadAddress() override final; bool IsAtomic() override final; bool IsYieldpoint() override; bool IsVolatile() override; bool IsFallthruCall() override final { return (GetMachineOpcode() == MOP_xblr || GetMachineOpcode() == MOP_xbl); } bool IsMemAccessBar() override; bool IsMemAccess() override; Operand *GetCallTargetOperand() override { CG_ASSERT(IsCall(), ""); return GetOperand(0); } ListOperand *GetCallArgumentOperand() override { CG_ASSERT(IsCall(), ""); CG_ASSERT(GetOperand(1)->IsList(), ""); return static_cast<ListOperand *>(GetOperand(1)); } bool IsDMBInsn() const override; void Emit(CG &, Emitter &) override; void dump() override; bool Check() override; // dfa bool IsDefinition() const override; bool IsDestRegAlsoSrcReg() const override; bool IsUncondBranch() const override; bool IsDataMoveInstruction() const override; bool IsConversionInstruction() const override; bool IsConditionalSet() const override; RegOperand *GetOperandDefined() override; bool IsPartDef() const override; uint32 GetLatencyType() const override; int GetJumpTargetIdx() const override; private: void CheckOpnd(Operand *opnd, OpndProp *mopd); void EmitClinit(CG &, Emitter &); void EmitAdrpLdr(CG &, Emitter &); void EmitClinitTail(CG &, Emitter &); void EmitAdrpLabel(CG &, Emitter &); void EmitCheckThrowPendingException(CG &, Emitter &); }; class AArch64cleancallInsn : public AArch64Insn { public: int ref_skipindex; explicit AArch64cleancallInsn(MOperator opc, Operand *opnd0 = nullptr, Operand *opnd1 = nullptr, Operand *opnd2 = nullptr, Operand *opnd3 = nullptr, Operand *opnd4 = nullptr) : AArch64Insn(opc, opnd0, opnd1, opnd2, opnd3, opnd4), ref_skipindex(-1) {} AArch64cleancallInsn &operator=(const AArch64cleancallInsn &p) = default; AArch64cleancallInsn(const AArch64cleancallInsn &originalInsn) : AArch64Insn(originalInsn) { ref_skipindex = originalInsn.ref_skipindex; } ~AArch64cleancallInsn() {} }; } // namespace maplebe #endif // MAPLEBE_INCLUDE_CG_AARCH64INSN_H
30.245989
115
0.705269
9b2b7017af1a8f2e1417c2aa0ec3148f92147426
608
c
C
tune/blas/level1/NRM2/nrm21_x1.c
kevleyski/math-atlas
cc36aa7e0362c577739ac507378068882834825e
[ "BSD-3-Clause-Clear" ]
19
2015-03-19T10:53:38.000Z
2020-12-17T06:12:32.000Z
tune/blas/level1/NRM2/nrm21_x1.c
kevleyski/math-atlas
cc36aa7e0362c577739ac507378068882834825e
[ "BSD-3-Clause-Clear" ]
1
2018-12-18T17:43:44.000Z
2018-12-18T17:43:44.000Z
tune/blas/level1/NRM2/nrm21_x1.c
kevleyski/math-atlas
cc36aa7e0362c577739ac507378068882834825e
[ "BSD-3-Clause-Clear" ]
47
2015-01-27T06:22:57.000Z
2021-11-11T20:59:04.000Z
#include "atlas_misc.h" #include <math.h> TYPE ATL_UNRM2(const int N, const TYPE *X, const int incX) /* * Only machines like x86 with extended precision (both arithmetic and sqrt) * will be able to use this kernel. On machines with standard 64/32 bit * precision, this will fail the overflow/underflow tests. */ { int i; #if defined(SREAL) || defined(SCPLX) || defined(ATL_OS_WinNT) || \ defined(ATL_OS_Win64) double t0=ATL_rzero; #else #define sqrt sqrtl long double t0=ATL_rzero; #endif for (i=0; i < N; i++) t0 += X[i]*X[i]; t0 = sqrt(t0); return(t0); }
27.636364
76
0.649671
88992c1a94c3e9d6814cce43d09be1dbeddc8560
6,746
c
C
uirc.c
brysonsteck/uirc
50fd2f37c3a438f35e8730327f512891a2c8ae8f
[ "BSD-2-Clause" ]
null
null
null
uirc.c
brysonsteck/uirc
50fd2f37c3a438f35e8730327f512891a2c8ae8f
[ "BSD-2-Clause" ]
null
null
null
uirc.c
brysonsteck/uirc
50fd2f37c3a438f35e8730327f512891a2c8ae8f
[ "BSD-2-Clause" ]
null
null
null
/* uirc: an unnecessary image ratio calculator Created by Bryson Steck (@brysonsteck on GitHub) Free and Open Source Software under the BSD 2-Clause License BSD 2-Clause License Copyright (c) 2022, Bryson Steck All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define STB_IMAGE_IMPLEMENTATION #include <stdio.h> #include <stb/stb_image.h> #include <curl/curl.h> #include <curl/easy.h> #include <unistd.h> const char *VERSION = "0.1.0"; int rFlag = 1; int getBcf(int width, int height) { int *widthFactors, *heightFactors; int bcf; for (int i = 1; i <= width; i++) { for (int j = 1; j <= height; j++) { if (width % i == 0) { if (height % j == 0 && i == j) { bcf = j; } } } } return bcf; } int readFile(char *file, int rFlag, int req, char* url) { int width, height, channels, factor; unsigned char *img = stbi_load(file, &width, &height, &channels, 0); if (img == NULL) { if (req == 0) { printf("FAIL\nuirc: request failed (%s), trying local fs instead\n", url); return 4; } else if (access(file, F_OK) != 0) { printf("uirc: %s: No such file or directory\n", file); exit(6); } else { printf("uirc: could not open file %s: %s\n", file, stbi_failure_reason()); exit(3); } } if (req == 0) printf("ok\n"); factor = getBcf(width, height); stbi_image_free(img); double wuneven = ((float) height) / ((float) width); double huneven = ((float) width) / ((float) height); if (req == 0) { char *token, *next = ""; token = strtok(url, "/"); while (1) { if (next == NULL) { file = token; break; } token = next; next = strtok(NULL, "/"); } } if (factor == 1) { if (width < height) { printf("%s > 1:%.2f (uneven)", file, wuneven); } else { printf("%s > %.2f:1 (uneven)", file, huneven); } } else { printf("%s > %d:%d", file, width / factor, height / factor); } if (rFlag == 0) printf(" [%dx%d]\n", width, height); else printf("\n"); return 0; } // thanks :) https://stackoverflow.com/questions/19404616/c-program-for-downloading-files-with-curl size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t written = fwrite(ptr, size, nmemb, stream); return written; } int download(char *url) { CURL *curl; FILE *fp; CURLcode res; char outfilename[15] = "/tmp/uirc.tmp"; curl = curl_easy_init(); if (curl) { fp = fopen(outfilename,"wb"); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); res = curl_easy_perform(curl); curl_easy_cleanup(curl); fclose(fp); } return 0; } // end of stack overflow snippet int handleArg(char *arg) { int value, complete; char flag, *longFlag, *http, first, firstTwo[3], firstFour[5]; const char *help; help = "USAGE: uirc [OPTIONS] IMAGE1 [IMAGE2] [...]\n\n" "OPTIONS:\n" "informational:\n" " -h, --help \t: Display this message\n" " -l, --license\t: Display the license disclaimer for uirc (BSD 2-Clause)\n" " -v, --version\t: Display the version of uirc\n\n" "functional:\n" " -r, --res \t: Display the resolution of the image (in addition to the ratio)\n\n" "HELP:\n" "For more information on how to use uirc, open the man page uirc(1).\n"; first = arg[0]; firstFour[0] = arg[0]; firstFour[1] = arg[1]; firstFour[2] = arg[2]; firstFour[3] = arg[3]; firstFour[4] = '\0'; firstTwo[0] = arg[0]; firstTwo[1] = arg[1]; firstTwo[2] = '\0'; if (strcmp("--", firstTwo) == 0 || '-' == first) { if (strcmp("--help", arg) == 0 || strcmp("-h", arg) == 0) { printf("an unneccessary image ratio calculator (uirc) v%s\n\n", VERSION); printf("Copyright 2022 Bryson Steck\nFree and Open Source under the BSD 2-Clause License\n\n"); printf("%s\n", help); exit(1); } else if (strcmp("--license", arg) == 0 || strcmp("-l", arg) == 0) { printf("uirc is Free and Open Source Software under the BSD 2-Clause License.\n"); printf("Please read the license regarding copying and distributing uirc.\n"); printf("https://github.com/brysonsteck/uirc/blob/master/LICENSE\n"); exit(1); } else if (strcmp("--res", arg) == 0 || strcmp("-r", arg) == 0) { rFlag = 0; return 0; } else if (strcmp("--version", arg) == 0 || strcmp("-v", arg) == 0) { printf("uirc v%s", VERSION); exit(1); } else { printf("uirc: invalid argument \"%s\"\nType \"uirc --help\" for help with arguments.\n", arg); exit(5); } } if (strcmp("http", firstFour) == 0) { printf("downloading \"%s\"...", arg); fflush(stdout); download(arg); complete = readFile("/tmp/uirc.tmp", rFlag, 0, arg); if (complete != 0) readFile(arg, rFlag, 1, ""); else remove("/tmp/uirc.tmp"); } else { // if no more flags, run ratio calculations return readFile(arg, rFlag, 1, ""); } return 0; } int main(int argc, char *argv[]) { char *i, *a; int runs; if (argc <= 1) { printf("uirc: at least one argument is required\n"); return 1; } for (int i = 1; i < argc; i++) { a = argv[i]; handleArg(a); runs++; } if (runs < 2 && rFlag == 0) { printf("uirc: at least one file/url is required\n"); return 1; } return 0; }
28.584746
103
0.61429
88ea9c9b9bc69308f861ee824e224a4e62527023
2,538
h
C
src/libc/fenv/fenv_impl.h
NuxiNL/CloudLibc
d361c06c3fab3a7814d05b4630abe6da0cc7d757
[ "BSD-2-Clause" ]
298
2015-03-04T13:36:51.000Z
2021-12-19T05:11:58.000Z
src/libc/fenv/fenv_impl.h
NuxiNL/CloudLibc
d361c06c3fab3a7814d05b4630abe6da0cc7d757
[ "BSD-2-Clause" ]
31
2015-07-27T14:51:55.000Z
2020-09-14T15:59:57.000Z
src/libc/fenv/fenv_impl.h
NuxiNL/CloudLibc
d361c06c3fab3a7814d05b4630abe6da0cc7d757
[ "BSD-2-Clause" ]
18
2016-03-27T13:49:22.000Z
2021-09-21T19:02:04.000Z
// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ // // SPDX-License-Identifier: BSD-2-Clause #ifndef FENV_FENV_IMPL_H #define FENV_FENV_IMPL_H #include <fenv.h> #include <stdint.h> #if defined(__aarch64__) // Bits 22 and 23 that determine the rounding. #define ROUNDING_MASK 0xc00000 // Assembly for floating point register manipulation. static inline uint32_t mrs_fpcr(void) { uint64_t cr; asm volatile("mrs %0, fpcr" : "=r"(cr)); return cr; } static inline uint32_t mrs_fpsr(void) { uint64_t sr; asm volatile("mrs %0, fpsr" : "=r"(sr)); return sr; } static inline void msr_fpcr(uint32_t value) { uint64_t cr = value; asm volatile("msr fpcr, %0" : : "r"(cr)); } static inline void msr_fpsr(uint32_t value) { uint64_t sr = value; asm volatile("msr fpsr, %0" : : "r"(sr)); } #elif defined(__arm__) // Bits 22 and 23 that determine the rounding. #define ROUNDING_MASK 0xc00000 // Assembly for floating point register manipulation. static inline uint32_t vmrs_fpscr(void) { uint32_t scr; asm volatile("vmrs %0, fpscr" : "=r"(scr)); return scr; } static inline void vmsr_fpscr(uint32_t value) { asm volatile("vmsr fpscr, %0" : : "r"(value)); } #elif defined(__i386__) || defined(__x86_64__) // Bits 13 and 14 that determine the rounding. #define ROUNDING_MASK 0x6000 // Exception flags in x87 are the same as for SSE, but shifted by seven // bits. #define EXCEPTION_MASK_SHIFT 7 // Assembly for x87 floating point register manipulation. static inline void fldcw(uint16_t cw) { asm volatile("fldcw %0" : : "m"(cw)); } static inline void fldenv(const struct __x87_state *state) { asm volatile("fldenv %0" : : "m"(*state) : "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)"); } static inline uint16_t fnstcw(void) { uint16_t cw; asm volatile("fnstcw %0" : "=m"(cw)); return cw; } static inline uint16_t fnstsw(void) { uint16_t sw; asm volatile("fnstsw %0" : "=m"(sw)); return sw; } static inline void fnstenv(struct __x87_state *state) { asm volatile("fnstenv %0" : "=m"(*state)); } static inline void fnclex(void) { asm volatile("fnclex"); } static inline void fwait(void) { asm volatile("fwait"); } // Assembly for SSE floating point register manipulation. static inline void ldmxcsr(uint32_t mxcsr) { asm volatile("ldmxcsr %0" : : "m"(mxcsr)); } static inline uint32_t stmxcsr(void) { uint32_t mxcsr; asm volatile("stmxcsr %0" : "=m"(mxcsr)); return mxcsr; } #endif #endif
21.327731
76
0.664303
f0532747a2cda7087d66a60b64c3ba0501af8c9d
896
h
C
Pod/Classes/CRRollingLabel.h
Cleveroad/CRRollingLabel
1d43a826b14993fe4e7acbfb54d1cad8fe8fff7e
[ "MIT" ]
34
2016-03-03T14:14:33.000Z
2019-03-03T08:01:11.000Z
Pod/Classes/CRRollingLabel.h
Cleveroad/CRRollingLabel
1d43a826b14993fe4e7acbfb54d1cad8fe8fff7e
[ "MIT" ]
null
null
null
Pod/Classes/CRRollingLabel.h
Cleveroad/CRRollingLabel
1d43a826b14993fe4e7acbfb54d1cad8fe8fff7e
[ "MIT" ]
4
2016-12-03T07:03:24.000Z
2018-09-14T15:57:08.000Z
// // CRRollingLabel.h // CRRollingLabel-iOS // // Created by Prokopiev on 2/18/16. // Copyright © 2016 Cleveroad inc. All rights reserved. // #import <UIKit/UIKit.h> @interface CRRollingLabel : UILabel /** * The numerical value displayed by the label. Animated by default. **/ @property (nonatomic, strong) NSNumber *value; /** * The text displayed by the label, consisting of the numerical values. Non-numeric values are ignored. Animated by default. **/ - (void)setText:(NSString *)text animated:(BOOL)animated; /** * The styled text displayed by the label, consisting of the numerical values. Non-numeric values are ignored. Animated by default. **/ - (void)setAttributedText:(NSAttributedString *)attributedText animated:(BOOL)animated; /** * The numerical value displayed by the label. Animated by default. **/ - (void)setValue:(NSNumber *)value animated:(BOOL)animated; @end
28
131
0.732143
00014664705d36ff8e74f877dfc9c69d3083983e
4,296
c
C
bootloaders/rt1062/user/board_drive_led.c
Seeed-Studio/ArduinoCore-NXP
4dee77110278aed6bc72c02213ccc964690b8523
[ "MIT" ]
9
2019-08-01T02:57:18.000Z
2021-06-07T15:33:31.000Z
bootloaders/rt1062/user/board_drive_led.c
Seeed-Studio/ArduinoCore-NXP
4dee77110278aed6bc72c02213ccc964690b8523
[ "MIT" ]
9
2020-06-03T21:11:44.000Z
2022-01-22T08:46:36.000Z
bootloaders/rt1062/user/board_drive_led.c
Seeed-Studio/ArduinoCore-NXP
4dee77110278aed6bc72c02213ccc964690b8523
[ "MIT" ]
4
2020-01-21T08:42:05.000Z
2021-05-04T07:06:37.000Z
#include "board_drive_led.h" void LED_init(void) { IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 is configured as GPIO1_IO09 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 PAD functional properties : */ 0x10B0U); /* Slew Rate Field: Slow Slew Rate Drive Strength Field: R0/6 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Keeper Pull Up / Down Config. Field: 100K Ohm Pull Down Hyst. Enable Field: Hysteresis Disabled */ gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit(IMXRT_BA_LED_GPIO, IMXRT_BA_LED_GPIO_PIN, &led_config); } void LED_on(void) {GPIO_PinWrite(IMXRT_BA_LED_GPIO, IMXRT_BA_LED_GPIO_PIN, 0U); } void LED_off(void) { GPIO_PinWrite(IMXRT_BA_LED_GPIO, IMXRT_BA_LED_GPIO_PIN, 1U);} void LED_toggle(void) { } void LEDRX_init(void) { IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 is configured as GPIO1_IO10 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 PAD functional properties : */ 0x10B0U); /* Slew Rate Field: Slow Slew Rate Drive Strength Field: R0/6 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Keeper Pull Up / Down Config. Field: 100K Ohm Pull Down Hyst. Enable Field: Hysteresis Disabled */ gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit(IMXRT_BA_LEDRX_GPIO, IMXRT_BA_LEDRX_GPIO_PIN, &led_config); } void LEDRX_on(void) { GPIO_PinWrite(IMXRT_BA_LEDRX_GPIO, IMXRT_BA_LEDRX_GPIO_PIN, 0U); } void LEDRX_off(void) { GPIO_PinWrite(IMXRT_BA_LEDRX_GPIO, IMXRT_BA_LEDRX_GPIO_PIN, 1U); } void LEDRX_toggle(void) { } void LEDTX_init(void) { IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_11_GPIO1_IO11, /* GPIO_AD_B0_11is configured as GPIO1_IO11 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B0_11_GPIO1_IO11, /* GPIO_AD_B0_011 PAD functional properties : */ 0x10B0U); /* Slew Rate Field: Slow Slew Rate Drive Strength Field: R0/6 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Keeper Pull Up / Down Config. Field: 100K Ohm Pull Down Hyst. Enable Field: Hysteresis Disabled */ gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit(IMXRT_BA_LEDTX_GPIO, IMXRT_BA_LEDTX_GPIO_PIN, &led_config); } void LEDTX_on(void) { GPIO_PinWrite(IMXRT_BA_LEDTX_GPIO, IMXRT_BA_LEDTX_GPIO_PIN, 0U); } void LEDTX_off(void) { GPIO_PinWrite(IMXRT_BA_LEDTX_GPIO, IMXRT_BA_LEDTX_GPIO_PIN, 1U);} void LEDTX_toggle(void) { }
61.371429
118
0.546322
767a3b5cd5015322b89f6f05e2f4a0ad76ce9641
15,794
h
C
KDIS/DataTypes/LandPlatformAppearance.h
pelicanmapping/boeing-kdis
ae0d1da99e62a4424b6cd14cd963b5a87a80fb7b
[ "BSD-2-Clause" ]
null
null
null
KDIS/DataTypes/LandPlatformAppearance.h
pelicanmapping/boeing-kdis
ae0d1da99e62a4424b6cd14cd963b5a87a80fb7b
[ "BSD-2-Clause" ]
null
null
null
KDIS/DataTypes/LandPlatformAppearance.h
pelicanmapping/boeing-kdis
ae0d1da99e62a4424b6cd14cd963b5a87a80fb7b
[ "BSD-2-Clause" ]
null
null
null
/********************************************************************* Copyright 2013 KDIS All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. For Further Information Please Contact me at Karljj1@yahoo.com http://p.sf.net/kdis/UserGuide *********************************************************************/ /******************************************************************** class: LandPlatformAppearance created: 22/09/2008 - Updated Feb 2012 author: Karl Jones purpose: Represents the appearance of a land platform. Implemented as struct so as to prevent the size from changing due to RTTI etc. This struct will be part of a union with all appearance values so it is implemented slightly different. No constructors to prevent C2620 error caused by union of classes/structs. size: 32 Bits / 4 Octet *********************************************************************/ #pragma once #include "./../KDefines.h" #include "./Enums/KDISEnums.h" namespace KDIS { namespace DATA_TYPE { using KDIS::DATA_TYPE::ENUMS::EntityPaintScheme; using KDIS::DATA_TYPE::ENUMS::EntityDamage; using KDIS::DATA_TYPE::ENUMS::EntitySmoke; using KDIS::DATA_TYPE::ENUMS::EntityTrailingEffect; using KDIS::DATA_TYPE::ENUMS::EntityHatchState; using KDIS::DATA_TYPE::ENUMS::EntityLights; using DATA_TYPE::ENUMS::EntityCamouflage; struct KDIS_EXPORT LandPlatformAppearance { protected: // Bits KUINT32 m_PaintScheme : 1; // 0 KUINT32 m_MobilityKill : 1; // 1 KUINT32 m_FirePower : 1; // 2 KUINT32 m_Damage : 2; // 3-4 KUINT32 m_Smoke : 2; // 5-6 KUINT32 m_TrailingEffect : 2; // 7-8 KUINT32 m_HatchState : 3; // 9-11 KUINT32 m_HeadLights : 1; // 12 KUINT32 m_TailLights : 1; // 13 KUINT32 m_BrakeLights : 1; // 14 KUINT32 m_FlamingEffectField : 1; // 15 KUINT32 m_Launcher : 1; // 16 KUINT32 m_Camouflage : 2; // 17-18 KUINT32 m_Concealed : 1; // 19 KUINT32 m_Unused : 1; // 20 Unused KUINT32 m_FrozenStatus : 1; // 21 KUINT32 m_PowerPlantStatus : 1; // 22 KUINT32 m_State : 1; // 23 KUINT32 m_Tent : 1; // 24 KUINT32 m_Ramp : 1; // 25 KUINT32 m_BlackoutLights : 1; // 26 KUINT32 m_BlackoutBrakeLights : 1; // 27 KUINT32 m_SpotLights : 1; // 28 KUINT32 m_InteriorLights : 1; // 29 KUINT32 m_SurrenderState : 1; // 30 KUINT32 m_MaskedCloaked : 1; // 31 public: //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityPaintScheme // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntityPaintScheme // Description: Describes the paint scheme of an entity. // Parameter: EntityPaintScheme EPS //************************************ void SetEntityPaintScheme( EntityPaintScheme EPS ); EntityPaintScheme GetEntityPaintScheme() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityMobilityKill // KDIS::DATA_TYPE::LandPlatformAppearance::DoesEntityMobilityKill // Description: Mobility Kill True/False? // Parameter: KBOOL MK //************************************ void SetEntityMobilityKill( KBOOL MK ); KBOOL DoesEntityMobilityKill() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityFirePowerKill // KDIS::DATA_TYPE::LandPlatformAppearance::DoesFirePowerKill // Description: Does Fire Power Kill? // Parameter: KBOOL FP //************************************ void SetEntityFirePower( KBOOL FP ); KBOOL DoesFirePowerKill() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityDamage // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntityDamage // Description: Entity Damage State // Parameter: EntityDamage ED //************************************ void SetEntityDamage( EntityDamage ED ); EntityDamage GetEntityDamage() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntitySmoke, // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntitySmoke // Description: Entity Smoke State // Parameter: EntitySmoke ES //************************************ void SetEntitySmoke( EntitySmoke ES ); EntitySmoke GetEntitySmoke() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityTrailingEffect // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntityTrailingEffect // Description: Describes the size of the dust cloud/trailing effect. // Parameter: EntityTrailingEffect ETE //************************************ void SetEntityTrailingEffect( EntityTrailingEffect ETE ); EntityTrailingEffect GetEntityTrailingEffect() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityHatchState // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntityHatchState // Description: Entity primary hatch state. Open, closed etc. // Parameter: EntityHatchState EHS //************************************ void SetEntityHatchState( EntityHatchState EHS ); EntityHatchState GetEntityHatchState() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityHeadLights // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityHeadLightsOn // Description: Are the vehicles head lights turned on? True = On, False = Off. // Parameter: KBOOL HL //************************************ void SetEntityHeadLights( KBOOL HL ); KBOOL IsEntityHeadLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityHeadLights // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntityLights // Description: Are the vehicles tail lights turned on? True = On, False = Off. // Parameter: KBOOL TL //************************************ void SetEntityTailLights( KBOOL TL ); KBOOL IsEntityTailLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityBrakeLights // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityBrakeLightsOn // Description: Are the vehicles brake lights turned on? True = On, False = Off. // Parameter: KBOOL BL //************************************ void SetEntityBrakeLights( KBOOL BL ); KBOOL IsEntityBrakeLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityFlamingEffect // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityFlaming // Description: Are flames rising from the entity? // Parameter: KBOOL EFE //************************************ void SetEntityFlamingEffect( KBOOL EFE ); KBOOL IsEntityFlaming() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityLauncher // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityLauncherRaised // Description: Set launcher status. False = Not Raised, True = Raised. // Parameter: KBOOL EL //************************************ void SetEntityLauncher( KBOOL EL ); KBOOL IsEntityLauncherRaised() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityCamouflage // KDIS::DATA_TYPE::LandPlatformAppearance::GetEntityCamouflage // Description: camouflage type worn. // Parameter: EntityCamouflage EC //************************************ void SetEntityCamouflage( EntityCamouflage EC ); EntityCamouflage GetEntityCamouflage() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityConcealed // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityConcealed // Description: Is the entity concealed? // False = Not concealed. True = Entity in a prepared concealed // position (with netting, etc.) // Parameter: KBOOL EC //************************************ void SetEntityConcealed( KBOOL EC ); KBOOL IsEntityConcealed() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityFrozenStatus // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityFrozen // Description: Is the entity frozen? // Note: Frozen entities should not be dead-reckoned, they should remain // frozen in place. You would likely freeze entites when your application is // in a paused state. // Parameter: KBOOL EFS //************************************ void SetEntityFrozenStatus( KBOOL EFS ); KBOOL IsEntityFrozen() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityPowerPlantOn // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityPowerPlantOn // Description: Power Plant On/Off. True = On, False = Off. // Parameter: KBOOL EPPS //************************************ void SetEntityPowerPlantOn( KBOOL EPPS ); KBOOL IsEntityPowerPlantOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityStateActive // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityStateActive // Description: True = Active, False = Deactivated. // Parameter: KBOOL ES //************************************ void SetEntityStateActive( KBOOL ES ); KBOOL IsEntityStateActive() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityTentExtended // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityTentExtended // Description: Tent status. True = Not extended, False = Extended. // Parameter: KBOOL ET //************************************ void SetEntityTentExtended( KBOOL ET ); KBOOL IsEntityTentExtended() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityRampDown // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityRampDown // Description: Ramp Status. Up / Down. True = Down, False = Up. // Parameter: KBOOL ER //************************************ void SetEntityRampDown( KBOOL ER ); KBOOL IsEntityRampDown() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityBlackoutLights // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityBlackoutLightsOn // Description: Are the vehicles blackout lights turned on? True = On, False = Off. // Parameter: KBOOL BL //************************************ void SetEntityBlackoutLights( KBOOL BL ); KBOOL IsEntityBlackoutLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityBlackoutBrakeLights // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityBlackoutBrakeLightsOn // Description: Are the vehicles blackout brake lights turned on? True = On, False = Off. // Parameter: KBOOL BBL //************************************ void SetEntityBlackoutBrakeLights( KBOOL BBL ); KBOOL IsEntityBlackoutBrakeLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityBlackoutBrakeLights // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityBlackoutBrakeLightsOn // Description: Are the vehicles spot lights turned on? True = On, False = Off. // Parameter: KBOOL SL //************************************ void SetEntitySpotLights( KBOOL SL ); KBOOL IsEntitySpotLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntityInteriorLights // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityInteriorLightsOn // Description: Are the vehicles interior lights turned on? True = On, False = Off. // Parameter: KBOOL IL //************************************ void SetEntityInteriorLights( KBOOL IL ); KBOOL IsEntityInteriorLightsOn() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntitySurrdenderState // KDIS::DATA_TYPE::LandPlatformAppearance::HasEntitySurrendered // Description: Has the vehicle occupant surrendered? // True = Surrendered, False = Not Surrendered. // Parameter: KBOOL SS //************************************ void SetEntitySurrdenderState( KBOOL SS ); KBOOL HasEntitySurrendered() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::SetEntitySurrdenderState // KDIS::DATA_TYPE::LandPlatformAppearance::IsEntityMaskedCloaked // Description: Is the entity masked/cloaked or not. // True = Masked/Cloaked, False = Not Masked/Cloaked. // Parameter: KBOOL MC //************************************ void SetEntityMaskedCloaked( KBOOL MC ); KBOOL IsEntityMaskedCloaked() const; //************************************ // FullName: KDIS::DATA_TYPE::LandPlatformAppearance::GetAsString // Description: Returns a string representation //************************************ KString GetAsString() const; KBOOL operator == ( const LandPlatformAppearance & Value ) const; KBOOL operator != ( const LandPlatformAppearance & Value ) const; }; }; // END namespace DATA_TYPES }; // END namespace KDIS
46.452941
93
0.580727
b71aced490aec3d24ce2e559bae7f9410ce52b2e
4,815
h
C
xcode/LinkingLibrary.framework/Headers/BLETimer.h
satorupan/engadget-linking
9d481df8f0f1759fce712da1c9d2d146edf0ab42
[ "MIT" ]
null
null
null
xcode/LinkingLibrary.framework/Headers/BLETimer.h
satorupan/engadget-linking
9d481df8f0f1759fce712da1c9d2d146edf0ab42
[ "MIT" ]
null
null
null
xcode/LinkingLibrary.framework/Headers/BLETimer.h
satorupan/engadget-linking
9d481df8f0f1759fce712da1c9d2d146edf0ab42
[ "MIT" ]
null
null
null
/** * Copyright © 2015-2016 NTT DOCOMO, INC. All Rights Reserved. */ #import <Foundation/Foundation.h> #import <CoreBluetooth/CoreBluetooth.h> #import "BLESensorGyroscope.h" #import "BLESensorAccelerometer.h" #import "BLESensorOrientation.h" /** タイマーのデリゲート @warninng 使用されないデリゲートも記載 */ @protocol BLETimerDelegate <NSObject> // 各サービスのレスポンスをアプリ側に返す /** 設定された間隔でのジャイロセンサーの取得を通知 @param peripheral 取得したデバイスのペリフェラル @param sensor 取得したデバイスのセンサーデータ */ - (void)gyroscopeDidUpDateWithInterval:(CBPeripheral *)peripheral gyroscope:(BLESensorGyroscope *)gyroscope; /** 設定された間隔での加速センサーの取得を通知 @param peripheral 取得したデバイスのペリフェラル @param sensor 取得したデバイスのセンサーデータ */ - (void)accelerometerDidUpDateWithInterval:(CBPeripheral *)peripheral accelerometer:(BLESensorAccelerometer *)accelerometer; /** 設定された間隔での方位センサーの取得を通知 @param peripheral 取得したデバイスのペリフェラル @param sensor 取得したデバイスのセンサーデータ */ - (void)orientationDidUpDateWithInterval:(CBPeripheral *)peripheral orientation:(BLESensorOrientation *)orientation; /** 設定時間超過の為,ジャイロセンサーの取得終了を通知 @param peripheral 終了したデバイスのペリフェラル */ - (void)gyroscopeObservationEnded:(CBPeripheral *)peripheral; /** 設定時間超過の為,方位センサーの取得終了を通知 @param peripheral 終了したデバイスのペリフェラル */ - (void)accelerometerObservationEnded:(CBPeripheral *)peripheral; /** ジャイロセンサーの取得を通知 プロファイルNotifyPdSensorInfoの受信を通知 @param peripheral 取得したデバイスのペリフェラル @param sensor 取得したデバイスのセンサーデータ */ - (void)orientationObservationEnded:(CBPeripheral *)peripheral; /**  接続がタイムアウトした場合の通知 @param peripheral タイムアウトしたデバイスのペリフェラル */ - (void)didTimeout:(CBPeripheral *)peripheral; @end /** タイマーを管理しているクラス */ @interface BLETimer : NSObject @property (nonatomic)NSTimer *gyroscopeIntervalTimer; @property (nonatomic)NSTimer *gyroscopeAutoStopTimer; @property (nonatomic)NSTimer *accelerometerIntervalTimer; @property (nonatomic)NSTimer *accelerometerAutoStopTimer; @property (nonatomic)NSTimer *orientationIntervalTimer; @property (nonatomic)NSTimer *orientationAutoStopTimer; @property (nonatomic)NSTimer *disconnectTimer; @property (nonatomic)NSTimer *timeOutTimer; @property (nonatomic)CBPeripheral *gyroscopePeripheral; @property (nonatomic)CBPeripheral *accelerometerPeripheral; @property (nonatomic)CBPeripheral *orientationPeripheral; @property (nonatomic)CBPeripheral *disconnectPeripheral; @property (nonatomic)CBPeripheral *timeOutPeripheral; @property (nonatomic)float gyroscopeInterval; @property (nonatomic)float gyroscopeStopTime; @property (nonatomic)float accelerometerInterval; @property (nonatomic)float accelerometerStopTime; @property (nonatomic)float orientationInterval; @property (nonatomic)float orientationStopTime; @property (nonatomic)float disconnectTime; @property (nonatomic)float timeOutTime; @property (nonatomic, weak) id<BLETimerDelegate> delegate; @property (nonatomic, weak) id<BLETimerDelegate> connecterDelegate; // ジャイロ /** ジャイロセンサーの開始 @param peripheral 開始するデバイスのペリフェラル */ -(void)startGyroscopeIntervalTimer:(CBPeripheral *)peripheral; /** ジャイロセンサーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopGyroscopeIntervalTimer:(CBPeripheral *)peripheral; /** ジャイロセンサーの停止時間を設定 @param peripheral 設定するデバイスのペリフェラル */ -(void)startGyroscopeAutoStopTimer:(CBPeripheral *)peripheral; /** 設定時間超過によるジャイロセンサーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopGyroscopeAutoStopTimer:(CBPeripheral *)peripheral; // 加速 /** 加速センサーの開始 @param peripheral 開始するデバイスのペリフェラル */ -(void)startAccelerometerIntervalTimer:(CBPeripheral *)peripheral; /** 加速センサーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopAccelerometerIntervalTimer:(CBPeripheral *)peripheral; /** 加速センサーの停止時間を設定 @param peripheral 設定するデバイスのペリフェラル */ -(void)startAccelerometerAutoStopTimer:(CBPeripheral *)peripheral; /** 設定時間超過による加速センサーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopAccelerometerAutoStopTimer:(CBPeripheral *)peripheral; // 方位 /** 方位センサーの開始 @param peripheral 開始するデバイスのペリフェラル */ -(void)startOrientationIntervalTimer:(CBPeripheral *)peripheral; /** 方位センサーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopOrientationIntervalTimer:(CBPeripheral *)peripheral; /** 方位センサーの停止時間を設定 @param peripheral 設定するデバイスのペリフェラル */ -(void)startOrientationAutoStopTimer:(CBPeripheral *)peripheral; /** 設定時間超過による方位センサーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopOrientationAutoStopTimer:(CBPeripheral *)peripheral; /** 接続を切断するタイマーの開始 @param peripheral 開始するデバイスのペリフェラル */ -(void)startDisconnectTimer:(CBPeripheral *)peripheral; /** 接続を切断するタイマーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopDisconnectTimer:(CBPeripheral *)peripheral; /** タイムアウトを設定するタイマーの開始 @param peripheral 開始するデバイスのペリフェラル */ -(void)startTimeOutTimer:(CBPeripheral *)peripheral; /** タイムアウトを設定するタイマーの停止 @param peripheral 停止するデバイスのペリフェラル */ -(void)stopTimeOutTimer:(CBPeripheral *)peripheral; @end
25.748663
124
0.803531
bbc2b249272d547df5eb3f2ce59cd2c7feeb7820
221
c
C
share/boilerplate/copyright.c
caqg/linux-home
eed631aae6f5e59e4f46e14f1dff443abca5fa28
[ "Linux-OpenIB" ]
null
null
null
share/boilerplate/copyright.c
caqg/linux-home
eed631aae6f5e59e4f46e14f1dff443abca5fa28
[ "Linux-OpenIB" ]
null
null
null
share/boilerplate/copyright.c
caqg/linux-home
eed631aae6f5e59e4f46e14f1dff443abca5fa28
[ "Linux-OpenIB" ]
null
null
null
/* Copyright (C) 20yy by Cesar A Quiroz, Ph.D. -*- C -*- * 3595 Granada Ave Unit 114 / Santa Clara, CA 95051 / USA * All Rights Reserved Worldwide * mailto:cesar.quiroz@gmail.com */ /* end */
22.1
78
0.574661
eb7b27824ed5edfa9ce508a591c2d547378015d7
133
h
C
inleiding-vision-cpp/opg4_2.h
yorickr/VisionCPP
60eda392d7b4f234afba7d4e29d746d1ae3c8e1c
[ "MIT" ]
null
null
null
inleiding-vision-cpp/opg4_2.h
yorickr/VisionCPP
60eda392d7b4f234afba7d4e29d746d1ae3c8e1c
[ "MIT" ]
null
null
null
inleiding-vision-cpp/opg4_2.h
yorickr/VisionCPP
60eda392d7b4f234afba7d4e29d746d1ae3c8e1c
[ "MIT" ]
null
null
null
#ifndef OPG4_2_H #define OPG4_2_H #include "includes.h" #include "blobdetectionavans.h" int opg4_2(int argc, char** argv); #endif
13.3
34
0.744361
5b784be8f0374da62f231919931cf52603ae503c
363
h
C
drawBrokenLineDemo/drawBrokenLineDemo/LCSelectedBoxModel.h
InnerMongoliaZorro/brokenLineDemo
09065d6ae9fe53d87cd808d15ff25d9b740a214d
[ "Apache-2.0" ]
null
null
null
drawBrokenLineDemo/drawBrokenLineDemo/LCSelectedBoxModel.h
InnerMongoliaZorro/brokenLineDemo
09065d6ae9fe53d87cd808d15ff25d9b740a214d
[ "Apache-2.0" ]
null
null
null
drawBrokenLineDemo/drawBrokenLineDemo/LCSelectedBoxModel.h
InnerMongoliaZorro/brokenLineDemo
09065d6ae9fe53d87cd808d15ff25d9b740a214d
[ "Apache-2.0" ]
null
null
null
// // LCSelectedBoxModel.h // SmartHome // // Created by MoGo on 16/3/30. // Copyright © 2016年 MoGo. All rights reserved. // #import <Foundation/Foundation.h> @interface LCSelectedBoxModel : NSObject @property (nonatomic , strong) NSString *messageString; @property (nonatomic , assign) BOOL copyFrom; @property (nonatomic , strong) NSNumber *weekday; @end
22.6875
55
0.730028
8b0878a34d5184b78771013905464f864a7e8071
337
h
C
Plugins/VoxelPlugin-master/Source/VoxelExamples/Public/VoxelExamplesModule.h
drakelinglabs/breakup
04cc209605082a61399f52a174057eda56b797f2
[ "MIT" ]
3
2020-10-05T18:52:08.000Z
2020-12-01T15:14:36.000Z
Plugins/VoxelPlugin-master/Source/VoxelExamples/Public/VoxelExamplesModule.h
Bluedrake42/breakup
04cc209605082a61399f52a174057eda56b797f2
[ "MIT" ]
null
null
null
Plugins/VoxelPlugin-master/Source/VoxelExamples/Public/VoxelExamplesModule.h
Bluedrake42/breakup
04cc209605082a61399f52a174057eda56b797f2
[ "MIT" ]
2
2020-10-10T20:16:12.000Z
2020-11-01T13:11:40.000Z
// Copyright 2020 Phyronnaz #pragma once #include "CoreMinimal.h" #include "Modules/ModuleInterface.h" #include "VoxelExamplesModule.generated.h" class FVoxelExamples : public IModuleInterface { }; // UBT doesn't like not having any UObject in a module UCLASS() class UVoxelExamplesModuleDummy : public UObject { GENERATED_BODY() };
18.722222
54
0.777448
a0a762d226c0d4933940de7169abc75426722aec
2,143
c
C
sr/lsri/lib/libhgfs/time.c
ducis/operating-system-labs
7df84f3dae792ee96461497b7d47414d24d233ee
[ "MIT" ]
2
2018-03-01T13:45:41.000Z
2018-03-01T14:11:47.000Z
src.clean/lib/libhgfs/time.c
ducis/operating-system-labs
7df84f3dae792ee96461497b7d47414d24d233ee
[ "MIT" ]
null
null
null
src.clean/lib/libhgfs/time.c
ducis/operating-system-labs
7df84f3dae792ee96461497b7d47414d24d233ee
[ "MIT" ]
null
null
null
/* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */ #include "inc.h" PRIVATE u64_t time_offset; /*===========================================================================* * time_init * *===========================================================================*/ PUBLIC void time_init() { /* Initialize the time conversion module. */ /* Generate a 64-bit value for the offset to use in time conversion. The * HGFS time format uses Windows' FILETIME standard, expressing time in * 100ns-units since Jan 1, 1601 UTC. The value that is generated is * 116444736000000000. */ /* FIXME: we currently do not take into account timezones. */ time_offset = make64(3577643008UL, 27111902UL); } /*===========================================================================* * time_put * *===========================================================================*/ PUBLIC void time_put(timep) time_t *timep; { /* Store a UNIX timestamp pointed to by the given pointer onto the RPC buffer, * in HGFS timestamp format. If a NULL pointer is given, store a timestamp of * zero instead. */ u64_t hgfstime; if (timep != NULL) { hgfstime = add64(mul64u(*timep, 10000000), time_offset); RPC_NEXT32 = ex64lo(hgfstime); RPC_NEXT32 = ex64hi(hgfstime); } else { RPC_NEXT32 = 0; RPC_NEXT32 = 0; } } /*===========================================================================* * time_get * *===========================================================================*/ PUBLIC void time_get(timep) time_t *timep; { /* Get a HGFS timestamp from the RPC buffer, convert it into a UNIX timestamp, * and store the result in the given time pointer. If the given pointer is * NULL, however, simply skip over the timestamp in the RPC buffer. */ u64_t hgfstime; u32_t time_lo, time_hi; if (timep != NULL) { time_lo = RPC_NEXT32; time_hi = RPC_NEXT32; hgfstime = make64(time_lo, time_hi); *timep = div64u(sub64(hgfstime, time_offset), 10000000); } else RPC_ADVANCE(sizeof(u32_t) * 2); }
30.614286
80
0.510033
e2577ff8247e2e7fed6ea3dd1e7d67ff3aa1d5b4
10,999
h
C
libsvoxpico/include/picosig2.h
LsquaredTechnologies/pico_tts
7a2ee01c52fa0432b6586e141ecf44bf01b6aa9b
[ "Apache-2.0" ]
108
2015-01-09T17:12:19.000Z
2021-06-08T15:03:12.000Z
src/svox_tts/svoxpico/picosig2.h
u3099811/BaxterTictacToe
967ab0ea8496ca4ce54db41b20c05de68cfe1bb9
[ "Apache-2.0" ]
123
2019-05-28T14:03:04.000Z
2019-07-12T04:23:26.000Z
src/svox_tts/svoxpico/picosig2.h
u3099811/BaxterTictacToe
967ab0ea8496ca4ce54db41b20c05de68cfe1bb9
[ "Apache-2.0" ]
43
2015-01-17T11:51:08.000Z
2021-09-09T02:11:51.000Z
/* * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland * * 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. */ /** * @file picosig2.h * * Signal Generation PU - Internal functions - header file * * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland * All rights reserved. * * History: * - 2009-04-20 -- initial version * */ #ifndef PICOSIG2_H_ #define PICOSIG2_H_ #include "picoos.h" #include "picodsp.h" #ifdef __cplusplus extern "C" { #endif #if 0 } #endif /*---------------------------------------------------------- // Name : sig_innerobj // Function: innerobject definition for the sig processing // Shortcut: sig //---------------------------------------------------------*/ typedef struct sig_innerobj { /*-----------------------Definition of the local storage for this PU--------*/ picoos_int16 *idx_vect1; /*reserved for bit reversal tables*/ picoos_int16 *idx_vect2; /*reserved for table lookup "A" vector*/ picoos_int16 *idx_vect4; /*reserved for max peak index arrax in pchip*/ picoos_int16 *idx_vect5; /*reserved for min index arrax in sigana_singleIMF*/ picoos_int16 *idx_vect6; /*reserved for max index arrax in sigana_singleIMF*/ picoos_int16 *idx_vect7; /*reserved for dispersed phase */ picoos_int16 *idx_vect8; /*reserved for LocV*/ picoos_int16 *idx_vect9; /*reserved for LocU*/ picoos_int32 *int_vec22; /*reserved for normalized hanning window - fixed point */ picoos_int32 *int_vec23; /*reserved for impresp - fixed point */ picoos_int32 *int_vec24; /*reserved for impresp - fixed point */ picoos_int32 *int_vec25; /*reserved for window - fixed point */ picoos_int32 *int_vec26; /*reserved for wavBuf - fixed point */ picoos_int32 *int_vec28; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec29; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec38; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec30; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec31; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec32; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec33; /*reserved for cepstral vectors input - fixed point */ picoos_int32 *int_vec34; /* reserved for sin table- fixed point */ picoos_int32 *int_vec35; /* reserved for cos table - fixed point */ picoos_int32 *int_vec36; /* reserved for currently used sin table- fixed point */ picoos_int32 *int_vec37; /* reserved for currently used cos table - fixed point */ picoos_int32 *int_vec39; /* reserved for ang - fixed point */ picoos_int32 *int_vec40; /* reserved for cos table - fixed point */ picoos_int32 *int_vec41[CEPST_BUFF_SIZE]; /*reserved for phase smoothing - cepstrum buffers */ picoos_int32 *int_vec42[PHASE_BUFF_SIZE]; /*reserved for phase smoothing - phase buffers */ picoos_int16 idx_vect10[CEPST_BUFF_SIZE]; /*reserved for pitch value buffering before phase smoothing*/ picoos_int16 idx_vect11[CEPST_BUFF_SIZE]; /*reserved for phonetic value bufferingid before phase smoothing*/ picoos_int16 idx_vect12[CEPST_BUFF_SIZE]; /*reserved for voicing value bufferingbefore phase smoothing*/ picoos_int16 idx_vect13[CEPST_BUFF_SIZE]; /*reserved for unrectified pitch value bufferingbefore phase smoothing*/ picoos_int16 idx_vect14[PHASE_BUFF_SIZE]; /*reserved for vox_bnd value buffering before phase smoothing*/ picoos_int32 *sig_vec1; picoos_single bvalue1; /*reserved for warp*/ picoos_int32 ibvalue2; /*reserved for voxbnd*/ picoos_int32 ibvalue3; /*reserved for voxbnd2*/ picoos_single bvalue4; /*reserved for E*/ picoos_single bvalue5; /*reserved for F0*/ picoos_single bvalue6; /*reserved for sMod*/ picoos_single bvalue7; /*reserved for voicing*/ picoos_single bvalue8; /*reserved for unrectified pitch*/ picoos_int16 ivalue1; /*reserved for m1,ceporder*/ picoos_int16 ivalue2; /*reserved for m2,fftorder,windowlen*/ picoos_int16 ivalue3; /*reserved for fftorder/2*/ picoos_int16 ivalue4; /*reserved for framelen, displacement*/ picoos_int16 ivalue5; /*reserved for voiced*/ picoos_int16 ivalue6; /*reserved for generic result code*/ picoos_int16 ivalue7; /*reserved for i*/ picoos_int16 ivalue8; /*reserved for j*/ picoos_int16 ivalue9; /*reserved for hop*/ picoos_int16 ivalue10; /*reserved for nextPeak*/ picoos_int16 ivalue11; /*reserved for nFrame*/ picoos_int16 ivalue12; /*reserved for raw*/ picoos_int16 ivalue13; /*reserved for hts engine flag*/ picoos_int16 ivalue14; /*reserved for ph id*/ picoos_int16 ivalue15; /*reserved for Voiced*/ picoos_int16 ivalue16; /*reserved for prevVoiced*/ picoos_int16 ivalue17; /*reserved for nV (size of LocV)*/ picoos_int16 ivalue18; /*reserved for nU (size of LocU)*/ picoos_int16 ivalue19; /*reserved for voicTrans*/ picoos_int16 ivalue20; /*reserved for n_availabe index*/ picoos_int32 lvalue1; /*reserved for sampling rate*/ picoos_int32 lvalue2; /*reserved for VCutoff*/ picoos_int32 lvalue3; /*reserved for UVCutoff*/ picoos_int32 lvalue4; /*reserved for fMax */ picoos_int32 iRand; /*reserved for phase random table poointer ())*/ } sig_innerobj_t; /*------------------------------------------------------------------ Exported (to picosig.c) Service routines : routine name and I/O parameters are to be maintained for PICO compatibility!! ------------------------------------------------------------------*/ extern pico_status_t sigAllocate(picoos_MemoryManager mm, sig_innerobj_t *sig_inObj); extern void sigDeallocate(picoos_MemoryManager mm, sig_innerobj_t *sig_inObj); extern void sigDspInitialize(sig_innerobj_t *sig_inObj, picoos_int32 resetMode); /*------------------------------------------------------------------ Exported (to picosig.c) Processing routines : routine number, name and content can be changed. unique I/O parameter should be "sig" ------------------------------------------------------------------*/ extern void mel_2_lin_init(sig_innerobj_t *sig_inObj); extern void save_transition_frame(sig_innerobj_t *sig_inObj); extern void mel_2_lin_init(sig_innerobj_t *sig_inObj); extern void post_filter_init(sig_innerobj_t *sig_inObj); extern void mel_2_lin_lookup(sig_innerobj_t *sig_inObj, picoos_uint32 mgc); extern void post_filter(sig_innerobj_t *sig_inObj); extern void phase_spec2(sig_innerobj_t *sig_inObj); extern void env_spec(sig_innerobj_t *sig_inObj); extern void save_transition_frame(sig_innerobj_t *sig_inObj); extern void td_psola2(sig_innerobj_t *sig_inObj); extern void impulse_response(sig_innerobj_t *sig_inObj); extern void overlap_add(sig_innerobj_t *sig_inObj); /* ------------------------------------------------------------------- * symbolic vs area assignements * -------------------------------------------------------------------*/ #define WavBuff_p int_vec26 /*output is Wav buffer (2*FFTSize)*/ #define window_p int_vec25 /*window function (hanning) */ #define ImpResp_p int_vec23 /*output step 6*/ #define imp_p int_vec24 /*output step 6*/ #define warp_p bvalue1 /*warp factor */ #define voxbnd_p ibvalue2 /*phase spectra reconstruction noise factor V*/ /* fixed point */ #define voxbnd2_p ibvalue3 /*phase spectra reconstruction noise factor UV */ /* fixed point */ #define E_p bvalue4 /*energy after Envelope spectrum calculation */ #define F0_p bvalue5 /*pitch*/ #define sMod_p bvalue6 /*speaker modification factor*/ #define voicing bvalue7 /*voicing*/ #define Fuv_p bvalue8 /*unrectified pitch (for unvoiced too)*/ #define m1_p ivalue1 /*ceporder(melorder=ceporder-1) */ #define m2_p ivalue2 /*fftorder*/ #define windowLen_p ivalue2 /*same as fftorder*/ #define hfftsize_p ivalue3 /*fftorder/2*/ #define framesz_p ivalue4 /*displacement*/ #define voiced_p ivalue5 /*voicing state*/ #define nRes_p ivalue6 /*generic result*/ #define i_p ivalue7 /*generic counter*/ #define j_p ivalue8 /*generic counter*/ #define hop_p ivalue9 /*hop */ #define nextPeak_p ivalue10 /*nextPeak*/ #define phId_p ivalue14 /*phonetic id*/ #define prevVoiced_p ivalue16 /*previous voicing state (for frame 1)*/ #define nV ivalue17 #define nU ivalue18 #define VoicTrans ivalue19 /* */ #define Fs_p lvalue1 /*Sampling frequency*/ #define VCutoff_p lvalue2 /*voicing cut off frequency in Hz*/ #define UVCutoff_p lvalue3 /*unvoicing cut off frequency in Hz*/ /* Reusable area */ #define wcep_pI int_vec28 /*input step1*/ #define d_p int_vec38 /*output mel_2_lin_init : table lookup vector D*/ #define A_p idx_vect2 /*output mel_2_lin_init : table lookup vector A*/ #define ang_p int_vec39 /*output step4*/ #define EnV int_vec30 #define EnU int_vec31 #define randCosTbl int_vec34 #define randSinTbl int_vec35 #define outCosTbl int_vec36 #define outSinTbl int_vec37 #define cos_table int_vec40 #define norm_window_p int_vec22 /*window function (hanning) */ #define norm_window2_p int_vec27 /*window function (hanning) */ #define F2r_p int_vec32 /*output step 7*/ #define F2i_p int_vec33 /*output step 7*/ #define LocV idx_vect8 /*excitation position voiced pulses*/ #define LocU idx_vect9 /*excitation position unvoiced pulses*/ #define CepBuff int_vec41 /*Buffer for incoming cepstral vector pointers*/ #define PhsBuff int_vec42 /*Buffer for incoming phase vector pointers*/ #define F0Buff idx_vect10 /*Buffer for incoming F0 values*/ #define PhIdBuff idx_vect11 /*Buffer for incoming PhId values*/ #define VoicingBuff idx_vect12 /*Buffer for incoming voicing values*/ #define FuVBuff idx_vect13 /*Buffer for incoming FuV values*/ #define VoxBndBuff idx_vect14 /*Buffer for incoming VoxBnd values*/ #define n_available ivalue20 /*variable for indexing the incoming buffers*/ #ifdef __cplusplus } #endif #endif
47.821739
118
0.677334
e9bc9985289c967156777d725e4abba49dfed469
154
h
C
app/src/main/res/drawable-xdpi.h
273270381/yinshiyun
806a0b8f85ffa9cea58dfda8c11d4c0ca33e19b9
[ "Apache-2.0" ]
null
null
null
app/src/main/res/drawable-xdpi.h
273270381/yinshiyun
806a0b8f85ffa9cea58dfda8c11d4c0ca33e19b9
[ "Apache-2.0" ]
null
null
null
app/src/main/res/drawable-xdpi.h
273270381/yinshiyun
806a0b8f85ffa9cea58dfda8c11d4c0ca33e19b9
[ "Apache-2.0" ]
null
null
null
// // Created by Administrator on 2019/1/29/029. // #ifndef MYEZOPEN_DRAWABLE_XDPI_H #define MYEZOPEN_DRAWABLE_XDPI_H #endif //MYEZOPEN_DRAWABLE_XDPI_H
17.111111
45
0.798701
acb38f06e74e603506f5e0635c8cdc5ac219cb20
551
h
C
ports/multimedia/kodi/dragonfly/patch-xbmc_peripherals_bus_PeripheralBusUSB.h
danielfojt/DeltaPorts
5710b4af4cacca5eb1ac577df304c788c07c4217
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
ports/multimedia/kodi/dragonfly/patch-xbmc_peripherals_bus_PeripheralBusUSB.h
danielfojt/DeltaPorts
5710b4af4cacca5eb1ac577df304c788c07c4217
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
ports/multimedia/kodi/dragonfly/patch-xbmc_peripherals_bus_PeripheralBusUSB.h
danielfojt/DeltaPorts
5710b4af4cacca5eb1ac577df304c788c07c4217
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
--- xbmc/peripherals/bus/PeripheralBusUSB.h.orig 2018-08-04 15:06:41.672876000 +0200 +++ xbmc/peripherals/bus/PeripheralBusUSB.h 2018-08-04 15:07:00.263280000 +0200 @@ -31,6 +31,9 @@ #elif defined(TARGET_FREEBSD) && defined(HAVE_LIBUSB) #define HAVE_PERIPHERAL_BUS_USB 1 #include "linux/PeripheralBusUSBLibUSB.h" +#elif defined(TARGET_DRAGONFLY) && defined(HAVE_LIBUSB) +#define HAVE_PERIPHERAL_BUS_USB 1 +#include "linux/PeripheralBusUSBLibUSB.h" #elif defined(TARGET_DARWIN) #define HAVE_PERIPHERAL_BUS_USB 1 #include "osx/PeripheralBusUSB.h"
42.384615
84
0.785844
5f8fa213457ce593c0c0528d3d29c93c7a3363f5
4,896
c
C
software/firmware/ChibiOS-Contrib/os/hal/ports/NRF5/LLD/hal_rng_lld.c
lowerrandom/DaBomb_dc27_badge
4bba0e58a304671b48755b99113b3d489259760a
[ "Apache-2.0" ]
29
2018-12-13T02:33:42.000Z
2022-02-28T13:26:35.000Z
software/firmware/ChibiOS-Contrib/os/hal/ports/NRF5/LLD/hal_rng_lld.c
lowerrandom/DaBomb_dc27_badge
4bba0e58a304671b48755b99113b3d489259760a
[ "Apache-2.0" ]
47
2019-03-21T05:23:28.000Z
2019-12-07T23:37:44.000Z
software/firmware/ChibiOS-Contrib/os/hal/ports/NRF5/LLD/hal_rng_lld.c
lowerrandom/DaBomb_dc27_badge
4bba0e58a304671b48755b99113b3d489259760a
[ "Apache-2.0" ]
13
2019-01-16T12:06:21.000Z
2020-04-25T02:14:06.000Z
/* RNG for ChibiOS - Copyright (C) 2016 Stephane D'Alu 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. */ /** * @file NRF5/LLD/hal_rng_lld.c * @brief NRF5 RNG subsystem low level driver source. * * @addtogroup RNG * @{ */ #include "hal.h" #if (HAL_USE_RNG == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver local definitions. */ /*===========================================================================*/ /** * @brief RNG default configuration. */ static const RNGConfig default_config = { .digital_error_correction = 1, }; /*===========================================================================*/ /* Driver exported variables. */ /*===========================================================================*/ /** @brief RNGD1 driver identifier.*/ #if NRF5_RNG_USE_RNG0 || defined(__DOXYGEN__) RNGDriver RNGD1; #endif /*===========================================================================*/ /* Driver local variables and types. */ /*===========================================================================*/ /*===========================================================================*/ /* Driver local functions. */ /*===========================================================================*/ /*===========================================================================*/ /* Driver interrupt handlers. */ /*===========================================================================*/ /** * @brief RNG interrupt handler. * * @isr */ OSAL_IRQ_HANDLER(Vector74) { NRF_RNG_Type *rng; rng = RNGD1.rng; OSAL_IRQ_PROLOGUE(); osalSysLockFromISR (); rng->EVENTS_VALRDY = 0; #if CORTEX_MODEL >= 4 (void)rng->EVENTS_VALRDY; #endif osalThreadResumeI (&RNGD1.tr, MSG_OK); osalSysUnlockFromISR (); OSAL_IRQ_EPILOGUE(); return; } /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ /** * @brief Low level RNG driver initialization. * * @notapi */ void rng_lld_init(void) { rngObjectInit(&RNGD1); RNGD1.rng = NRF_RNG; RNGD1.irq = RNG_IRQn; } /** * @brief Configures and activates the RNG peripheral. * * @param[in] rngp pointer to the @p RNGDriver object * * @notapi */ void rng_lld_start(RNGDriver *rngp) { NRF_RNG_Type *rng = rngp->rng; /* If not specified, set default configuration */ if (rngp->config == NULL) rngp->config = &default_config; /* Configure digital error correction */ if (rngp->config->digital_error_correction) rng->CONFIG |= RNG_CONFIG_DERCEN_Msk; else rng->CONFIG &= ~RNG_CONFIG_DERCEN_Msk; /* Enable vector */ nvicEnableVector (RNG_IRQn, NRF5_RNG_RNG0_IRQ_PRIORITY); /* Set interrupt mask */ rng->INTENSET = RNG_INTENSET_VALRDY_Msk; } /** * @brief Deactivates the RNG peripheral. * * @param[in] rngp pointer to the @p RNGDriver object * * @notapi */ void rng_lld_stop(RNGDriver *rngp) { NRF_RNG_Type *rng = rngp->rng; /* Clear interrupt mask */ rng->INTENCLR = RNG_INTENSET_VALRDY_Msk; /* Disable vector */ nvicDisableVector (RNG_IRQn); } /** * @brief Write random bytes; * * @param[in] rngp pointer to the @p RNGDriver object * @param[in] n size of buf in bytes * @param[in] buf @p buffer location * * @notapi */ msg_t rng_lld_write(RNGDriver *rngp, uint8_t *buf, size_t n, systime_t timeout) { NRF_RNG_Type *rng = rngp->rng; msg_t msg; size_t i; if (rngp->state != RNG_READY) return (MSG_TIMEOUT); /* Start */ rng->TASKS_START = 1; for (i = 0; i < n; i++) { msg = osalThreadSuspendTimeoutS (&rngp->tr, timeout); if (msg != MSG_OK) break; /* Read byte */ buf[i] = (char)rng->VALUE; } /* Stop */ rng->TASKS_STOP = 1; /* Mark as read */ rng->EVENTS_VALRDY = 0; #if CORTEX_MODEL >= 4 (void)rng->EVENTS_VALRDY; #endif return (msg); } #endif /* HAL_USE_RNG */ /** @} */
25.237113
79
0.487949
5c4c484eec9a7518a2fc39c397c73c4d663624ee
5,184
h
C
src/hardware/startup/lib/public/arm/psci.h
luuhuuquyet/Rock64_QNX700_BSP
9e834ed73aaa83357e5f1c724a4de22f55ce81af
[ "Apache-2.0" ]
null
null
null
src/hardware/startup/lib/public/arm/psci.h
luuhuuquyet/Rock64_QNX700_BSP
9e834ed73aaa83357e5f1c724a4de22f55ce81af
[ "Apache-2.0" ]
null
null
null
src/hardware/startup/lib/public/arm/psci.h
luuhuuquyet/Rock64_QNX700_BSP
9e834ed73aaa83357e5f1c724a4de22f55ce81af
[ "Apache-2.0" ]
null
null
null
/* * $QNXLicenseC: * Copyright 2016, QNX Software Systems. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not reproduce, modify or distribute this software 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 OF ANY KIND, either express or implied. * * This file may contain contributions from others, either as * contributors under the License or as licensors under other terms. * Please review this entire file for other proprietary rights or license * notices, as well as the QNX Development Suite License Guide at * http://licensing.qnx.com/license-guide/ for other information. * $ */ /* * ARM Power State Co-ordination Interface. * Based on PSCI-1.0 (ARM DEN0022C). */ #ifndef __ARM_PSCI_H_INCLUDED #define __ARM_PSCI_H_INCLUDED #include <inttypes.h> /* * Function IDs */ #define PSCI_VERSION 0x84000000U #define PSCI_CPU_SUSPEND 0x84000001U #define PSCI_CPU_OFF 0x84000002U #define PSCI_CPU_ON 0x84000003U #define PSCI_AFFINITY_INFO 0x84000004U #define PSCI_MIGRATE 0x84000005U #define PSCI_MIGRATE_INFO_TYPE 0x84000006U #define PSCI_MIGRATE_INFO_UP_CPU 0x84000007U #define PSCI_SYSTEM_OFF 0x84000008U #define PSCI_SYSTEM_RESET 0x84000009U #define PSCI_FEATURES 0x8400000aU #define PSCI_CPU_FREEZE 0x8400000bU #define PSCI_CPU_DEFAULT_SUSPEND 0x8400000cU #define PSCI_NODE_HW_STATE 0x8400000dU #define PSCI_SYSTEM_SUSPEND 0x8400000eU #define PSCI_SET_SUSPEND_MODE 0x8400000fU #define PSCI_STAT_RESIDENCY 0x84000010U #define PSCI_STAT_COUNT 0x84000011U /* * Error codes. */ #define PSCI_SUCCESS (0) #define PSCI_NOT_SUPPORTED (-1) #define PSCI_INVALID_PARAMETERS (-2) #define PSCI_DENIED (-3) #define PSCI_ALREADY_ON (-4) #define PSCI_ON_PENDING (-5) #define PSCI_INTERNAL_FAILURE (-6) #define PSCI_NOT_PRESENT (-7) #define PSCI_DISABLED (-8) #define PSCI_INVALID_ADDRESS (-9) /* * Invocation mechanism is determined at runtime: psci_hvc or psci_svc */ extern uint32_t (*psci_call)(uint32_t __x0, uint32_t __x1, uint32_t __x2, uint32_t __x3); extern uint32_t psci_hvc(uint32_t __x0, uint32_t __x1, uint32_t __x2, uint32_t __x3); extern uint32_t psci_smc(uint32_t __x0, uint32_t __x1, uint32_t __x2, uint32_t __x3); static inline uint32_t psci_version(void) { return (uint32_t)psci_call(PSCI_VERSION, 0, 0, 0); } static inline int32_t psci_cpu_suspend(uint32_t power_state, uint32_t entry_point, uint32_t context_id) { return (int32_t)psci_call(PSCI_CPU_SUSPEND, power_state, entry_point, context_id); } static inline int32_t psci_cpu_off(void) { return (int32_t)psci_call(PSCI_CPU_OFF, 0, 0, 0); } static inline int32_t psci_cpu_on(uint64_t target_cpu, uint32_t entry_point, uint32_t context_id) { return (int32_t)psci_call(PSCI_CPU_ON, target_cpu, entry_point, context_id); } static inline int32_t psci_affinity_info(uint32_t target_affinity, uint32_t lowest_affinity) { return (int32_t)psci_call(PSCI_AFFINITY_INFO, target_affinity, lowest_affinity, 0); } static inline int32_t psci_migrate(uint32_t target_cpu) { return (int32_t)psci_call(PSCI_MIGRATE, target_cpu, 0, 0); } static inline int32_t psci_migrate_info_type(void) { return (int32_t)psci_call(PSCI_MIGRATE_INFO_TYPE, 0, 0, 0); } static inline uint32_t psci_migrate_info_up_cpu(void) { return psci_call(PSCI_MIGRATE_INFO_UP_CPU, 0, 0, 0); } static inline void psci_system_off(void) { psci_call(PSCI_SYSTEM_OFF, 0, 0, 0); } static inline void psci_system_reset(void) { psci_call(PSCI_SYSTEM_RESET, 0, 0, 0); } static inline int32_t psci_features(uint32_t func_id) { return (int32_t)psci_call(PSCI_FEATURES, func_id, 0, 0); } static inline int32_t psci_cpu_freeze(void) { return (int32_t)psci_call(PSCI_CPU_FREEZE, 0, 0, 0); } static inline int32_t psci_cpu_default_suspend(uint32_t target_cpu, uint32_t entry_point, uint32_t context_id) { return (int32_t)psci_call(PSCI_CPU_DEFAULT_SUSPEND, target_cpu, entry_point, context_id); } static inline int32_t psci_node_hw_state(uint32_t target_cpu, uint32_t power_level) { return (int32_t)psci_call(PSCI_NODE_HW_STATE, target_cpu, power_level, 0); } static inline int32_t psci_system_suspend(uint32_t entry_point, uint32_t context_id) { return (int32_t)psci_call(PSCI_SYSTEM_SUSPEND, entry_point, context_id, 0); } static inline int32_t psci_set_suspend_mode(uint32_t mode) { return (int32_t)psci_call(PSCI_SET_SUSPEND_MODE, mode, 0, 0); } static inline uint64_t psci_stat_residency(uint32_t target_cpu, uint32_t power_state) { return psci_call(PSCI_STAT_RESIDENCY, target_cpu, power_state, 0); } static inline uint64_t psci_stat_count(uint32_t target_cpu, uint32_t power_state) { return psci_call(PSCI_STAT_COUNT, 0, 0, 0); } #endif /* __AARCH64_PSCI_H_INCLUDED */ #if defined(__QNXNTO__) && defined(__USESRCVERSION) #include <sys/srcversion.h> __SRCVERSION("$URL: http://svn.ott.qnx.com/product/branches/7.0.0/trunk/hardware/startup/lib/public/arm/psci.h $ $Rev: 805440 $") #endif
27.428571
129
0.786844
5c5866664bc9121bbde2eecc71a91abcffc0d734
815
h
C
msr.h
scott-walker-llnl/turbo-fs
20fe5592823567bf5bc5cbc884b2ff4853befe2d
[ "Intel" ]
null
null
null
msr.h
scott-walker-llnl/turbo-fs
20fe5592823567bf5bc5cbc884b2ff4853befe2d
[ "Intel" ]
null
null
null
msr.h
scott-walker-llnl/turbo-fs
20fe5592823567bf5bc5cbc884b2ff4853befe2d
[ "Intel" ]
null
null
null
#include "master.h" #include "msr_core.h" #define MSR_TURBO_RATIO_LIMIT 0x1AD #define MSR_TURBO_RATIO_LIMIT_CORES 0x1AE void read_turbo_limit(); void set_turbo_limit(unsigned long limit); void set_all_turbo_limit(uint64_t limit); unsigned long get_turbo_limit(); void enable_turbo(const unsigned tid); void disable_turbo(const unsigned tid); void get_rapl_units(double *power_unit, double *seconds_unit); void set_rapl(unsigned sec, double watts, double pu, double su, unsigned affinity); void set_rapl2(unsigned sec, double watts, double pu, double su, unsigned affinity); void set_perf(const unsigned freq, const unsigned numcores); void dump_rapl(); //inline void disable_rapl(); void dump_perf_limit(); void dump_platform_rapl(); unsigned long get_turbo_limit1(); void set_all_turbo_limit1(uint64_t limit);
32.6
84
0.809816
d4cce505522d984a300e551c29c148188d2cd207
1,187
c
C
src/list.c
LanskovNV/calc
5bffc3b558bc44f58850ef457168d4820f4d1fd7
[ "MIT" ]
null
null
null
src/list.c
LanskovNV/calc
5bffc3b558bc44f58850ef457168d4820f4d1fd7
[ "MIT" ]
null
null
null
src/list.c
LanskovNV/calc
5bffc3b558bc44f58850ef457168d4820f4d1fd7
[ "MIT" ]
null
null
null
/* leins, 26.03.2017 */ #include <stdio.h> #include <stdlib.h> #include "error.h" #include "list.h" #include "calculate.h" void ClearList(LIST **L) { LIST *tmp; while (*L != NULL) { tmp = *L; *L = (*L)->Next; free(tmp); } }/* OK */ int Push(STACK *S, TOKEN T) { LIST *NewL; if ((NewL = malloc(sizeof(LIST))) == NULL) return 0; NewL->t = T; NewL->Next = S->Top; S->Top = NewL; return 1; }/* OK */ int Pop(STACK *S, TOKEN *T) { LIST *tmp = NULL; if (S->Top == NULL) return 0; if (T != NULL) { *T = S->Top->t; tmp = S->Top; } else { return 0; } S->Top = S->Top->Next; free(tmp); return 1; }/* OK */ int Put(QUEUE *Q, TOKEN T) { LIST *NewL; if ((NewL = malloc(sizeof(LIST))) == NULL) return 0; NewL->t = T; NewL->Next = NULL; if (Q->Head == NULL) Q->Head = Q->Tail = NewL; else { Q->Tail->Next = NewL; Q->Tail = NewL; } return 1; }/* OK */ int Get(QUEUE *Q, TOKEN *T) { LIST* tmp = NULL; if (Q->Head == NULL) return 0; if (T != NULL) { *T = Q->Head->t; tmp = Q->Head; } else { return 0; } Q->Head = Q->Head->Next; free(tmp); return 1; }/* OK */
12.763441
44
0.491154
cebe1be56fb3008d0f2b606ea49bf622f823449b
380
h
C
src/menus/battle_menu/summon_view/battle_summon_callbacks.h
Kor-Hal/SisterRay
4e8482525a5d7f77dee186f438ddb16523a61e7e
[ "BSD-3-Clause" ]
null
null
null
src/menus/battle_menu/summon_view/battle_summon_callbacks.h
Kor-Hal/SisterRay
4e8482525a5d7f77dee186f438ddb16523a61e7e
[ "BSD-3-Clause" ]
null
null
null
src/menus/battle_menu/summon_view/battle_summon_callbacks.h
Kor-Hal/SisterRay
4e8482525a5d7f77dee186f438ddb16523a61e7e
[ "BSD-3-Clause" ]
null
null
null
#ifndef BATTLE_SUMMON_CALLBACKS_H #define BATTLE_SUMMON_CALLBACKS_H #include <SisterRay/types.h> #include <SisterRay/SisterRay.h> #include "battle_summon_init_callbacks.h" #include "battle_summon_input_callbacks.h" #include "battle_summon_draw_callbacks.h" #include "../battle_menu_widget_names.h" void initializeBattleSummonMenu(); void registerSummonViewListeners(); #endif
23.75
42
0.834211
ceeb28ceea58eb4c6e445d51877e27354fd2aa8a
3,886
h
C
Tempest/DataDefinitions/AudioDatabase_generated.h
Alekssasho/TempoEngine
60e23e4ef743f8a9f44f8c576457a5feb27f70b9
[ "MIT" ]
7
2020-08-02T10:51:09.000Z
2021-08-03T17:04:56.000Z
Tempest/DataDefinitions/AudioDatabase_generated.h
Alekssasho/TempoEngine
60e23e4ef743f8a9f44f8c576457a5feb27f70b9
[ "MIT" ]
null
null
null
Tempest/DataDefinitions/AudioDatabase_generated.h
Alekssasho/TempoEngine
60e23e4ef743f8a9f44f8c576457a5feb27f70b9
[ "MIT" ]
null
null
null
// automatically generated by the FlatBuffers compiler, do not modify #ifndef FLATBUFFERS_GENERATED_AUDIODATABASE_TEMPEST_DEFINITION_H_ #define FLATBUFFERS_GENERATED_AUDIODATABASE_TEMPEST_DEFINITION_H_ #include "flatbuffers/flatbuffers.h" namespace Tempest { namespace Definition { struct AudioDatabase; struct AudioDatabaseBuilder; struct AudioDatabase FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef AudioDatabaseBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_BACKGROUND_MUSIC = 4 }; const flatbuffers::Vector<uint8_t> *background_music() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_BACKGROUND_MUSIC); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_BACKGROUND_MUSIC) && verifier.VerifyVector(background_music()) && verifier.EndTable(); } }; struct AudioDatabaseBuilder { typedef AudioDatabase Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_background_music(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> background_music) { fbb_.AddOffset(AudioDatabase::VT_BACKGROUND_MUSIC, background_music); } explicit AudioDatabaseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } flatbuffers::Offset<AudioDatabase> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<AudioDatabase>(end); return o; } }; inline flatbuffers::Offset<AudioDatabase> CreateAudioDatabase( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> background_music = 0) { AudioDatabaseBuilder builder_(_fbb); builder_.add_background_music(background_music); return builder_.Finish(); } inline flatbuffers::Offset<AudioDatabase> CreateAudioDatabaseDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<uint8_t> *background_music = nullptr) { auto background_music__ = background_music ? _fbb.CreateVector<uint8_t>(*background_music) : 0; return Tempest::Definition::CreateAudioDatabase( _fbb, background_music__); } inline const Tempest::Definition::AudioDatabase *GetAudioDatabase(const void *buf) { return flatbuffers::GetRoot<Tempest::Definition::AudioDatabase>(buf); } inline const Tempest::Definition::AudioDatabase *GetSizePrefixedAudioDatabase(const void *buf) { return flatbuffers::GetSizePrefixedRoot<Tempest::Definition::AudioDatabase>(buf); } inline const char *AudioDatabaseIdentifier() { return "TADB"; } inline bool AudioDatabaseBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier( buf, AudioDatabaseIdentifier()); } inline bool VerifyAudioDatabaseBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<Tempest::Definition::AudioDatabase>(AudioDatabaseIdentifier()); } inline bool VerifySizePrefixedAudioDatabaseBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifySizePrefixedBuffer<Tempest::Definition::AudioDatabase>(AudioDatabaseIdentifier()); } inline const char *AudioDatabaseExtension() { return "tab"; } inline void FinishAudioDatabaseBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Tempest::Definition::AudioDatabase> root) { fbb.Finish(root, AudioDatabaseIdentifier()); } inline void FinishSizePrefixedAudioDatabaseBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Tempest::Definition::AudioDatabase> root) { fbb.FinishSizePrefixed(root, AudioDatabaseIdentifier()); } } // namespace Definition } // namespace Tempest #endif // FLATBUFFERS_GENERATED_AUDIODATABASE_TEMPEST_DEFINITION_H_
34.389381
107
0.756305
3006626bfebd6c770a428df317944427638d1782
137
c
C
misc/assert.c
kaitoii11/c-misc
afe11509b15d0504ba68360b88f895de53d31567
[ "MIT" ]
null
null
null
misc/assert.c
kaitoii11/c-misc
afe11509b15d0504ba68360b88f895de53d31567
[ "MIT" ]
null
null
null
misc/assert.c
kaitoii11/c-misc
afe11509b15d0504ba68360b88f895de53d31567
[ "MIT" ]
null
null
null
#include <stdio.h> #include <assert.h> int main(int argc, char **argv){ int i = 10; assert(i ==10); assert(i ==9); return 0; }
12.454545
32
0.576642
cda96d5deef87a769858e793643b10cdf7c213e9
2,127
h
C
include/std.h
ckurtz22/SkylinePluginTemplate
8d6eded4a09bc088d46e8b17fa8b19e806d7a655
[ "MIT" ]
1
2020-08-07T05:54:29.000Z
2020-08-07T05:54:29.000Z
include/std.h
ckurtz22/SkylinePluginTemplate
8d6eded4a09bc088d46e8b17fa8b19e806d7a655
[ "MIT" ]
null
null
null
include/std.h
ckurtz22/SkylinePluginTemplate
8d6eded4a09bc088d46e8b17fa8b19e806d7a655
[ "MIT" ]
1
2020-09-30T05:27:19.000Z
2020-09-30T05:27:19.000Z
/** * @file std.h * @brief Classes that are a part of the standard library (std) */ #pragma once #include "types.h" #include "operator.h" #include <string> namespace std { struct nothrow_t; struct __va_list; namespace __l { template<typename T, typename T2> class __tree_node; template<typename T, typename T2> class list { public: list(T const &); }; template<typename T, typename T2> class pair { public: ~pair(); }; template<typename T, typename T2> class vector { public: void reserve(u64); void __push_back_slow_path(T const &); }; template<typename T, typename T2, typename T3> class __tree { public: void destroy(std::__l::__tree_node<T, void *> *); }; template<typename T, typename T2> void __sort(T2, T2, T2, T); template<typename T, typename T2> void __sort3(T2, T2, T); template<typename T, typename T2> void __sort5(T2, T2, T2, T2, T2, T); template<typename T, typename T2> void __insertion_sort_incomplete(T2, T2, T); }; namespace __1 { class locale { class facet { ~facet(); void __on_zero_shared(); }; class id { void __init(); void __get(); }; public: static locale global(locale const&); static locale __global(); static const locale& classic(); locale(); locale(locale const&); locale(locale const&, locale const&, int); locale(locale const&, std::string const&, int); locale(std::string const&); std::string name() const; bool has_facet(locale::id const&); int operator=(locale const&); void operator==(locale const&); ~locale(); }; }; };
21.704082
63
0.490362
e09149d201c4a38854161ee2446ef0d44ac33a40
12,126
c
C
render.c
ArthurWalraven/c_sandbox
184102a24bbefa0e4b62c9f82746dc3cb7b04441
[ "MIT" ]
2
2020-08-24T01:48:53.000Z
2020-08-24T17:01:45.000Z
render.c
ArthurWalraven/c_sandbox
184102a24bbefa0e4b62c9f82746dc3cb7b04441
[ "MIT" ]
null
null
null
render.c
ArthurWalraven/c_sandbox
184102a24bbefa0e4b62c9f82746dc3cb7b04441
[ "MIT" ]
null
null
null
#include "render.h" #if BYTE_ORDER == BIG_ENDIAN #define to_little_endian16(x) __builtin_bswap16((uint16_t) (x)) #else #define to_little_endian16(x) (x) #endif #define FRAMES_DIRECTORY_PATH "frames/" #define FRAME_FILE_NAME_PREFIX FRAMES_DIRECTORY_PATH "frame_" #define WITCH_CONSTANT 6.f #define RENDER_RADIUS (15.93738f / WITCH_CONSTANT) // See https://en.wikipedia.org/wiki/Witch_of_Agnesi static inline float witch_of_Agnesi(const vec v) { return 1/(1 + sq(WITCH_CONSTANT) * norm_sq(v)); } static inline void colour_pixel(uint8_t * restrict p, const vec r) { if unlikely(norm_sq(r) < RENDER_RADIUS) { *p = (uint8_t) fminf(127.f, *p + 127.f * witch_of_Agnesi(r)); } } static void to_BMP(const int W, const int H, const uint8_t canvas[][W]) { assert(!(W & 0b11) && "Not implemented: canvas width is not a multiple of 4"); static int frame_counter = -1; ++frame_counter; // TODO: Make endian independent struct BMP_Header { // From https://en.wikipedia.org/wiki/BMP_file_format char BM[2]; // Used to identify the BMP file uint32_t file_size; // In bytes unsigned : 16; unsigned : 16; uint32_t offset; // Offset to image data in bytes from beginning of file (54 bytes) uint32_t dib_header_size; // DIB Header size in bytes (40 bytes) int32_t width_px; int32_t height_px; uint16_t num_planes; // Must be 1 uint16_t bits_per_pixel; uint32_t compression_type; uint32_t image_size_bytes; // Image size in bytes signed : 32; signed : 32; uint32_t num_colours; unsigned : 32; } __attribute__((packed)) header = { .BM = {'B', 'M'}, .file_size = sizeof(struct BMP_Header) + (256 * 4 * 1) + (W * H * 1), .offset = sizeof(struct BMP_Header) + (256 * 4 * 1), .dib_header_size = 40, .width_px = W, .height_px = H, .num_planes = 1, .bits_per_pixel = 8, // Grayscale .compression_type = 0, .image_size_bytes = W * H * 1, .num_colours = 1 << 8 }; assert(sizeof(header) == 54 && "BMP header has proper size"); static char file_name[] = FRAME_FILE_NAME_PREFIX "000000.bmp"; assert(frame_counter <= 999999 && "Frame number can be represented within 6 decimal digits"); sprintf(file_name + sizeof(FRAME_FILE_NAME_PREFIX) - 1, "%06d.bmp", frame_counter); FILE *fp = fopen(file_name, "wb"); if (!fp) { perror("Error on file creation"); exit(EXIT_FAILURE); } fwrite(&header, 1, sizeof(header), fp); uint8_t shades_of_gray[256][4]; for (int i = 0; i < 256; ++i) { shades_of_gray[i][0] = i; shades_of_gray[i][1] = i; shades_of_gray[i][2] = i; shades_of_gray[i][3] = 0; } fwrite(shades_of_gray, 4, 256, fp); fwrite(canvas, 1, W * H, fp); fclose(fp); } static void to_GIF(const int W, const int H, const int T, const uint8_t frame[][H][W], const float FPS, const char * filename) { assert(W > 0); assert(H > 0); assert(T > 0); assert(FPS > 0); if (roundf(100.f / FPS) < 2) { puts("Warning: high fps GIFs are not widely supported."); } // Uncompressed GIF file // See https://en.wikipedia.org/wiki/GIF#Uncompressed_GIF for reference and // https://en.wikipedia.org/wiki/File:Quilt_design_as_46x46_uncompressed_GIF.gif for an example // In order to keep one byte per pixel // NOTE: Used macros to keep GCC happy #define BIT_DEPTH 7 #define NUMBER_OF_COLOURS (1 << BIT_DEPTH) struct __attribute__((packed)) GIF_Header { // From https://www.w3.org/Graphics/GIF/spec-gif89a.txt char signature[3]; char version[3]; uint16_t width_px; uint16_t height_px; unsigned global_colour_table_size : 3; unsigned _sort : 1; unsigned colour_resolution : 3; unsigned global_colour_table : 1; uint8_t background_colour_index; uint8_t _aspect_ratio; uint8_t colour_table[NUMBER_OF_COLOURS][3]; } header = { .signature = {'G', 'I', 'F'}, .version = {'8', '9', 'a'}, .width_px = to_little_endian16(W), .height_px = to_little_endian16(H), .global_colour_table_size = BIT_DEPTH - 1, .colour_resolution = 8 - 1, .global_colour_table = true, .background_colour_index = 0, // Unused fields ._sort = 0, ._aspect_ratio = 0 }; // Grayscale (128 colours) for (int i = 0; i < NUMBER_OF_COLOURS; ++i) { header.colour_table[i][0] = i * 2; header.colour_table[i][1] = i * 2; header.colour_table[i][2] = i * 2; } struct __attribute__((packed)) Application_Extension { // From https://en.wikipedia.org/wiki/GIF#Animated_GIF uint8_t extension_introducer; uint8_t application_label; uint8_t block_size; char application_identifier[8]; char application_authentication_code[3]; } const netscape_application_block = { .extension_introducer = '!', .application_label = 0xFF, .block_size = 11, .application_identifier = {'N', 'E', 'T', 'S', 'C', 'A', 'P', 'E'}, .application_authentication_code = {'2', '.', '0'} }; struct __attribute__((packed)) Netscape_Data_Subblock { // From https://en.wikipedia.org/wiki/GIF#Animated_GIF uint8_t block_size; uint8_t subblock_index; uint16_t number_of_repetitions; uint8_t block_terminator; } const netscape_subblock = { .block_size = 3, .subblock_index = 1, .number_of_repetitions = to_little_endian16(0), .block_terminator = 0 }; struct __attribute__((packed)) Graphics_Control_Extension { // From https://www.w3.org/Graphics/GIF/spec-gif89a.txt char extension_introducer; char graphic_control_label; uint8_t block_size; unsigned transparency : 1; unsigned wait_for_user_input : 1; unsigned diposal_method : 3; unsigned _reserved: 3; uint16_t delay; uint8_t transparent_colour_index; uint8_t block_terminator; } GCE = { .extension_introducer = '!', .graphic_control_label = 0xF9, .block_size = 4, .transparency = false, .wait_for_user_input = false, .diposal_method = 0, .delay = to_little_endian16((uint16_t) roundf(100.f / FPS)), .transparent_colour_index = 0, .block_terminator = 0, // Unused fields ._reserved = 0 }; struct __attribute__((packed)) Image_Descriptor { // From https://www.w3.org/Graphics/GIF/spec-gif89a.txt char image_separator; uint16_t left; uint16_t top; uint16_t width; uint16_t height; unsigned _local_colour_table_size : 3; unsigned _reserved : 2; unsigned _sort : 1; unsigned _interlace : 1; unsigned local_colour_table : 1; } const image_descriptor = { .image_separator = ',', .left = to_little_endian16(0), .top = to_little_endian16(0), .width = to_little_endian16(W), .height = to_little_endian16(H), .local_colour_table = false, // Unused fields ._local_colour_table_size = 0, ._reserved = 0, ._sort = 0, ._interlace = 0 }; const uint8_t LZW_minimum_code_size = BIT_DEPTH; const char GIF_file_terminator = ';'; FILE *fp = fopen(filename, "wb"); if (!fp) { perror("Error on file creation"); exit(EXIT_FAILURE); } fwrite(&header, 1, sizeof(header), fp); fwrite(&netscape_application_block, 1, sizeof(netscape_application_block), fp); fwrite(&netscape_subblock, 1, sizeof(netscape_subblock), fp); for (int t = 0; t < T; ++t) { // GCE.delay = (t+1 < T) ? GCE.delay : 1.0f * 100; fwrite(&GCE, 1, sizeof(GCE), fp); fwrite(&image_descriptor, 1, sizeof(image_descriptor), fp); fwrite(&LZW_minimum_code_size, 1, sizeof(LZW_minimum_code_size), fp); // One byte will be used to store the length and another for the 'CLEAR' code const uint8_t data_block_length = (0b1 << BIT_DEPTH) - 2; const uint8_t CLEAR = 0b1 << BIT_DEPTH; int i; for (i = 0; i < W * H - data_block_length; i += data_block_length) { fwrite((uint8_t []) {data_block_length+1, CLEAR}, 2, sizeof(uint8_t), fp); fwrite(&frame[t][0][0] + i, data_block_length, sizeof(uint8_t), fp); } fwrite((uint8_t []) {W * H - i + 1, CLEAR}, 2, sizeof(uint8_t), fp); fwrite(&frame[t][0][0] + i, W * H - i, sizeof(uint8_t), fp); const uint8_t STOP = CLEAR + 1; fwrite((char []) {1, STOP, 0}, 3, sizeof(char), fp); } fwrite((char *) &GIF_file_terminator, 1, sizeof(char), fp); if (fclose(fp)) { perror("Error while closing file"); exit(EXIT_FAILURE); } #undef NUMBER_OF_COLOURS #undef BIT_DEPTH } void render__frames(const int n, vec positions[][n], const int n_frames, const int W, const int H, uint8_t frame[][H][W], const float box_radius) { const vec canvas_origin = { .x = W / 2.f, .y = H / 2.f }; #pragma omp parallel for schedule(auto) for (int f = 0; f < n_frames; ++f) { int s = 0; int t = 0; for (int i = 0; i < H; ++i) { vec v = {.y = -(i - canvas_origin.y) * box_radius / (W / 2.f)}; while ((s < n) && (positions[f][s].y - RENDER_RADIUS > v.y)) { ++s; } while ((t < n) && (positions[f][t].y + RENDER_RADIUS > v.y)) { ++t; } for (int j = 0; j < W; ++j) { v.x = (j - canvas_origin.x) * box_radius / (W / 2.f); for (int k = s; k < t; ++k) { vec r = sub(v, positions[f][k]); #ifdef PBC r = physics__periodic_boundary_shift(r, box_radius); #endif colour_pixel(&frame[f][i][j], r); } #ifdef PBC if unlikely(v.y > box_radius - RENDER_RADIUS) { for (int k = n-1; k >= 0; --k) { if (positions[f][k].y + 2 * box_radius - RENDER_RADIUS > v.y) { break; } vec r = sub(v, to_vec(positions[f][k].x, positions[f][k].y + 2 * box_radius)); r = physics__periodic_boundary_shift(r, box_radius); colour_pixel(&frame[f][i][j], r); } } else if unlikely(v.y < -box_radius + RENDER_RADIUS) { for (int k = 0; k < n; ++k) { if (positions[f][k].y - 2 * box_radius + RENDER_RADIUS < v.y) { break; } vec r = sub(v, to_vec(positions[f][k].x, positions[f][k].y - 2 * box_radius)); r = physics__periodic_boundary_shift(r, box_radius); colour_pixel(&frame[f][i][j], r); } } #endif } } } } void render__animation(const int W, const int H, const int T, const uint8_t frame[][H][W], const float FPS, const char * filename) { // system("convert -delay 2 " FRAME_FILE_NAME_PREFIX "*.bmp animation.gif"); to_GIF(W, H, T, frame, FPS, filename); } inline void render__test_BMP() { const int N = 1 << 11; uint8_t (*canvas)[N] = malloc(N*N); if (!canvas) { perror("Error on frame creation"); exit(EXIT_FAILURE); } for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { canvas[i][j] = roundf(((i ^ j) & (N-1)) * 256.f / N); } } to_BMP(N, N, canvas); free(canvas); }
33.040872
147
0.559871
ef3e9f13cd69b5d31544e5857da96fa7e67136cd
218
c
C
189_rotate_array.c
wuzhouhui/leetcode
80ae1f9209681ed12adf2f4a2783af8d1f9917e2
[ "MIT" ]
1
2019-09-24T14:23:42.000Z
2019-09-24T14:23:42.000Z
189_rotate_array.c
wuzhouhui/leetcode
80ae1f9209681ed12adf2f4a2783af8d1f9917e2
[ "MIT" ]
null
null
null
189_rotate_array.c
wuzhouhui/leetcode
80ae1f9209681ed12adf2f4a2783af8d1f9917e2
[ "MIT" ]
4
2017-03-18T11:31:08.000Z
2021-12-12T03:28:44.000Z
#include <string.h> void rotate(int nums[], int n, int k) { if (!nums || !n || n == 1) return; int tmp[n]; int i; for (i = 0; i < n; i++) tmp[(i + k) % n] = nums[i]; memcpy(nums, tmp, n * sizeof(int)); }
12.823529
37
0.490826
d48501b18b8e310006e39e5f2a9f1dad4d729f52
1,824
c
C
misc.c
Seclabs-htc/slip39
a831455a47850b0402aee1ac0fab166e6731717d
[ "MIT" ]
6
2019-06-25T02:45:58.000Z
2019-09-03T14:52:35.000Z
misc.c
Seclabs-htc/slip39
a831455a47850b0402aee1ac0fab166e6731717d
[ "MIT" ]
null
null
null
misc.c
Seclabs-htc/slip39
a831455a47850b0402aee1ac0fab166e6731717d
[ "MIT" ]
1
2019-06-25T02:46:30.000Z
2019-06-25T02:46:30.000Z
#include <stdio.h> #include <string.h> #include <stdint.h> #include <stdlib.h> #include <inttypes.h> int fromhex(uint8_t *buf, uint32_t *buf_len, const char *str) { size_t i, len = strlen(str) / 2; if (len > *buf_len) return -1; for (i = 0; i < len; i++) { uint8_t c = 0; if (str[i * 2] >= '0' && str[i*2] <= '9') c += (str[i * 2] - '0') << 4; if ((str[i * 2] & ~0x20) >= 'A' && (str[i*2] & ~0x20) <= 'F') c += (10 + (str[i * 2] & ~0x20) - 'A') << 4; if (str[i * 2 + 1] >= '0' && str[i * 2 + 1] <= '9') c += (str[i * 2 + 1] - '0'); if ((str[i * 2 + 1] & ~0x20) >= 'A' && (str[i * 2 + 1] & ~0x20) <= 'F') c += (10 + (str[i * 2 + 1] & ~0x20) - 'A'); buf[i] = c; } *buf_len = len; return 0; } static char hex_table[] = "0123456789abcdef"; void dumphex(uint8_t *b, int l) { int i, c; char obuf[32 * 2 + 1]; if (b == NULL) return; while (l >= 32) { memset(obuf, 0, sizeof(obuf)); for (i = 0; i < 32; i++) { int c0, c1; c = *b++; l--; c0 = (c >> 4) & 0xf; c1 = c & 0x0f; obuf[i*2] = hex_table[c0]; obuf[i*2+1] = hex_table[c1]; obuf[i*2+2] = 0; } printf("%s\n", obuf); } if (l > 0) { memset(obuf, 0, sizeof(obuf)); for (i = 0; i < l; i++) { int c0, c1; c = *b++; c0 = (c >> 4) & 0xf; c1 = c & 0x0f; obuf[i*2] = hex_table[c0]; obuf[i*2+1] = hex_table[c1]; obuf[i*2+2] = 0; } printf("%s\n", obuf); } } size_t memscpy(void *d, size_t ds, const void *s, size_t ss) { size_t cs; cs = (ds < ss) ? ds : ss; memcpy(d, s, cs); return cs; }
23.088608
123
0.391447
3335bf377abfd479b644f7db1920dc1abc683f9a
286
c
C
sdl_render.c
tanishq-dubey/sen3.14
5cf0957fb81c38ffede15cf3bd04ec3bf0185a6d
[ "Apache-2.0" ]
2
2016-11-18T18:16:52.000Z
2016-11-22T05:07:54.000Z
sdl_render.c
tanishq-dubey/sen3.14
5cf0957fb81c38ffede15cf3bd04ec3bf0185a6d
[ "Apache-2.0" ]
null
null
null
sdl_render.c
tanishq-dubey/sen3.14
5cf0957fb81c38ffede15cf3bd04ec3bf0185a6d
[ "Apache-2.0" ]
null
null
null
#include "sdl_render.h" void init_renderer() { if (SDL_Init(SDL_INIT_VIDEO) < 0) { debug_print("%s", "Could not initalize SDL renderer!"); exit(-1); } int width = SCREEN_W; int height = SCREEN_H; int bpp = SCREEN_C; int flags = SDL_HWSURFACE; }
22
63
0.604895
ded0bdb42d190e2fec14298c7b3ccab7843c43c0
2,576
h
C
Unreal/CtaCpp/Runtime/Scripts/Terrain/IGeoPositionSystem.h
areilly711/CtaApi
8c7a80c48f2a6d02fb6680a5d8f62e6ff7da8d4c
[ "MIT" ]
3
2021-06-02T16:44:02.000Z
2022-01-24T20:20:10.000Z
Unreal/CtaCpp/Runtime/Scripts/Terrain/IGeoPositionSystem.h
areilly711/CtaApi
8c7a80c48f2a6d02fb6680a5d8f62e6ff7da8d4c
[ "MIT" ]
null
null
null
Unreal/CtaCpp/Runtime/Scripts/Terrain/IGeoPositionSystem.h
areilly711/CtaApi
8c7a80c48f2a6d02fb6680a5d8f62e6ff7da8d4c
[ "MIT" ]
null
null
null
#pragma once #include "../Core/IBaseSystem.h" #include "../Math/Vector3d.h" #include "../Math/GcsUtils.h" /* The MIT License (MIT) Copyright 2021 Adam Reilly, Call to Action Software LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using namespace Cta::Math; namespace Cta::Terrain { /// <summary> /// Interface for systems that work for geographic locations /// </summary> class IGeoPositionSystem : public IBaseSystem { /// <summary> /// Gets the latitude, longitude, and height specified as the origin of the scenario /// </summary> /// <returns>The Latitude (X), Longitude (Y), and height (Z) of the scenario origin</returns> public: virtual Vector3d GetLatLonHeightOrigin() = 0; /// <summary> /// Converts a left-handed coordinate system with y-axis pointing up (Unity) position to an /// earth-centered earth-fixed position /// </summary> /// <param name="pos">the lhs y up position</param> /// <returns>The earth-centered earth-fixed location in meters</returns> //Vector3d LhsYUpToEcef(Vector3 pos); /// <summary> /// Convets a position in one coordinate system to another /// </summary> /// <param name="input">The coordinate system that the inputPos is in</param> /// <param name="inputPos">The input position to convert</param> /// <param name="output">The coordinate system that you want the inputPos to be converted to</param> /// <returns>The converted position to the output coordinate system</returns> virtual Vector3d ConvertSystem(GlobalCoordinateSystem input, Vector3d inputPos, GlobalCoordinateSystem output) = 0; }; }
49.538462
460
0.748835
a67f12cb60735e9b098c3b51562f63b03ef9603f
926
h
C
examples/OS/Keystone/include/OS/Keystone/V2/Model/Access.h
jxx-project/JXXRS
0d788e3aba5231ec1782699c9d397b9d81fdb1fd
[ "BSL-1.0" ]
null
null
null
examples/OS/Keystone/include/OS/Keystone/V2/Model/Access.h
jxx-project/JXXRS
0d788e3aba5231ec1782699c9d397b9d81fdb1fd
[ "BSL-1.0" ]
null
null
null
examples/OS/Keystone/include/OS/Keystone/V2/Model/Access.h
jxx-project/JXXRS
0d788e3aba5231ec1782699c9d397b9d81fdb1fd
[ "BSL-1.0" ]
null
null
null
// // Copyright (C) 2018 Dr. Michael Steffens // // SPDX-License-Identifier: BSL-1.0 // #ifndef OS_Keystone_V2_Model_Access_INCLUDED #define OS_Keystone_V2_Model_Access_INCLUDED #include "OS/Keystone/V2/Model/Metadata.h" #include "OS/Keystone/V2/Model/Service.h" #include "OS/Keystone/V2/Model/Token.h" #include "OS/Keystone/V2/Model/Trust.h" #include "OS/Keystone/V2/Model/User.h" #include <JXXON/List.h> #include <JXXON/Serializable.h> namespace OS { namespace Keystone { namespace V2 { namespace Model { struct Access : public JXXON::Serializable { Access(); Access(const JXXON::Json& json); virtual JXXON::Json toJson() const override; std::shared_ptr<Token> token; std::shared_ptr<JXXON::List<Service>> serviceCatalog; std::shared_ptr<User> user; std::shared_ptr<Metadata> metadata; std::shared_ptr<Trust> trust; }; }}}} // namespace OS::Keystone::V2::Model #endif // OS_Keystone_V2_Model_Access_INCLUDED
25.027027
68
0.75162
b841c53a16593d7e8bbbabcaaa72c3afb51978f2
489
h
C
assignment4/stdlibQueueImplementation/TellerEvent.h
matticoli/CS2303
5399fa2c8bdfcd0620793356dba108ba92f36da3
[ "Apache-2.0" ]
null
null
null
assignment4/stdlibQueueImplementation/TellerEvent.h
matticoli/CS2303
5399fa2c8bdfcd0620793356dba108ba92f36da3
[ "Apache-2.0" ]
null
null
null
assignment4/stdlibQueueImplementation/TellerEvent.h
matticoli/CS2303
5399fa2c8bdfcd0620793356dba108ba92f36da3
[ "Apache-2.0" ]
null
null
null
// // Created by Mikel Matticoli on 2/15/18. // #ifndef ASSIGNMENT4_TELLEREVENT_H #define ASSIGNMENT4_TELLEREVENT_H #include "Event.h" #include "TellerQueue.h" class TellerEvent : public Event { public: /** * TellerQueue to serve customers from */ TellerQueue *queue; TellerEvent(double startTime, TellerQueue *queue); void retask(double startTime); std::string getType() override; }; #endif //ASSIGNMENT4_TELLEREVENT_H
18.807692
58
0.664622
8ed0e575a4b9c9665db3742bbdbad65050f95aca
336
h
C
Simulator/maze.h
ElonaKhoshaba/Micromouse-Floodfill
d94385a9f50b0ee80ecde0d9b00b6a870793372d
[ "MIT" ]
null
null
null
Simulator/maze.h
ElonaKhoshaba/Micromouse-Floodfill
d94385a9f50b0ee80ecde0d9b00b6a870793372d
[ "MIT" ]
2
2021-02-16T10:14:20.000Z
2021-02-16T23:54:22.000Z
Simulator/maze.h
ElonaKhoshaba/Micromouse-Floodfill
d94385a9f50b0ee80ecde0d9b00b6a870793372d
[ "MIT" ]
2
2021-03-22T00:30:06.000Z
2021-04-24T20:08:15.000Z
#ifndef MAZE_H #define MAZE_H #include <SDL2/SDL.h> typedef struct { char name[64]; int size; SDL_Texture* mazeTexture; int hWalls [17][16]; int vWalls [16][17]; } Maze; int loadMaze(Maze* maze, const char *path); SDL_Texture* createMazeTexture(Maze *maze); int renderMaze(Maze *maze); #endif
16.8
44
0.639881
119c21db2be4af2b951a8d1dbcd938005f036413
142
h
C
Example/Pods/Target Support Files/AWGeometry/AWGeometry-umbrella.h
tomwey/AWGeometry
994050a24fa837fd2daef64d106624d6653a706d
[ "MIT" ]
null
null
null
Example/Pods/Target Support Files/AWGeometry/AWGeometry-umbrella.h
tomwey/AWGeometry
994050a24fa837fd2daef64d106624d6653a706d
[ "MIT" ]
null
null
null
Example/Pods/Target Support Files/AWGeometry/AWGeometry-umbrella.h
tomwey/AWGeometry
994050a24fa837fd2daef64d106624d6653a706d
[ "MIT" ]
null
null
null
#import <UIKit/UIKit.h> FOUNDATION_EXPORT double AWGeometryVersionNumber; FOUNDATION_EXPORT const unsigned char AWGeometryVersionString[];
20.285714
64
0.84507
f9cbdee97221e82b16f297ec9a9bb30782b1e953
1,829
c
C
xp/protocols/gg_protocols.c
vladcorneci/golden-gate
fab6e11c4df942c6a915328d805d3265f9ccc8e0
[ "Apache-2.0" ]
262
2020-05-05T21:25:17.000Z
2022-03-22T09:11:15.000Z
xp/protocols/gg_protocols.c
vladcorneci/golden-gate
fab6e11c4df942c6a915328d805d3265f9ccc8e0
[ "Apache-2.0" ]
22
2020-05-07T21:20:42.000Z
2022-02-25T02:44:50.000Z
xp/protocols/gg_protocols.c
vladcorneci/golden-gate
fab6e11c4df942c6a915328d805d3265f9ccc8e0
[ "Apache-2.0" ]
18
2020-05-06T07:21:43.000Z
2022-02-08T09:49:23.000Z
/** * * @file * * @copyright * Copyright 2017-2020 Fitbit, Inc * SPDX-License-Identifier: Apache-2.0 * * @author Gilles Boccon-Gibod * * @date 2017-11-21 * * @details * Misc protocol parsers and helpers */ /*---------------------------------------------------------------------- | includes +---------------------------------------------------------------------*/ #include <string.h> #include "xp/common/gg_port.h" #include "xp/common/gg_types.h" #include "xp/common/gg_utils.h" #include "gg_protocols.h" /*---------------------------------------------------------------------- | thunks +---------------------------------------------------------------------*/ //---------------------------------------------------------------------- void GG_FrameAssembler_GetFeedBuffer(GG_FrameAssembler* self, uint8_t** buffer, size_t* buffer_size) { GG_ASSERT(self); GG_INTERFACE(self)->GetFeedBuffer(self, buffer, buffer_size); } //---------------------------------------------------------------------- GG_Result GG_FrameAssembler_Feed(GG_FrameAssembler* self, size_t* data_size, GG_Buffer**frame) { GG_ASSERT(self); return GG_INTERFACE(self)->Feed(self, data_size, frame); } //---------------------------------------------------------------------- void GG_FrameAssembler_Reset(GG_FrameAssembler* self) { GG_ASSERT(self); GG_INTERFACE(self)->Reset(self); } //---------------------------------------------------------------------- GG_Result GG_FrameSerializer_SerializeFrame(GG_FrameSerializer* self, const uint8_t* frame, size_t frame_size, GG_RingBuffer* output) { GG_ASSERT(self); return GG_INTERFACE(self)->SerializeFrame(self, frame, frame_size, output); }
28.138462
95
0.448879
f9d6f363b8b32c29c760d1059e26a4b3f25a65ab
774
h
C
Twitter/Tweet.h
src-code/Tweeter
6e9e93439faf5c905a2cc743798e1e14ad70d260
[ "Apache-2.0" ]
null
null
null
Twitter/Tweet.h
src-code/Tweeter
6e9e93439faf5c905a2cc743798e1e14ad70d260
[ "Apache-2.0" ]
1
2017-02-18T09:06:48.000Z
2017-02-18T09:06:48.000Z
Twitter/Tweet.h
src-code/Tweeter
6e9e93439faf5c905a2cc743798e1e14ad70d260
[ "Apache-2.0" ]
null
null
null
// // Tweet.h // Twitter // // Created by Steve Carlson (Media Engineering) on 1/30/17. // Copyright © 2017 Steve Carlson. All rights reserved. // #import <Foundation/Foundation.h> #import "User.h" @interface Tweet : NSObject @property (nonatomic, strong) NSString *tweetId; @property (nonatomic, strong) NSString *text; @property (nonatomic, strong) NSDate *createdAt; @property (nonatomic, assign) bool retweeted; @property (nonatomic, strong) NSNumber *retweetCount; @property (nonatomic, assign) bool favorited; @property (nonatomic, strong) NSNumber *favoriteCount; @property (nonatomic, strong) User *user; @property (nonatomic, strong) Tweet *retweet; - (id)initWithDictionary:(NSDictionary *)dictionary; + (NSArray *)tweetsWithArray:(NSArray *)array; @end
27.642857
61
0.741602
fbb0f9d3d06002c0cc0f408a55474a2c13e754d6
488
c
C
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/powerpc/pr82112.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
7
2020-05-02T17:34:05.000Z
2021-10-17T10:15:18.000Z
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/powerpc/pr82112.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
null
null
null
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/powerpc/pr82112.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
2
2020-07-27T00:22:36.000Z
2021-04-01T09:41:02.000Z
/* PR target/82112 */ /* { dg-do compile } */ /* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -std=gnu90" } */ #include <altivec.h> struct __attribute__((aligned (16))) S { unsigned char c[64]; } bar (void); vector unsigned char v; void foo (void) { vec_ld (0, bar ().c); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */ vec_st (v, 0, bar ().c); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */ }
28.705882
99
0.647541