blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
268
content_id
stringlengths
40
40
detected_licenses
listlengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
5
118
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
816 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
2.31k
677M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
151 values
src_encoding
stringclasses
33 values
language
stringclasses
1 value
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
3
10.3M
extension
stringclasses
119 values
content
stringlengths
3
10.3M
authors
listlengths
1
1
author_id
stringlengths
0
228
7a49ba6d24713f0b3fc9bc0903da7ab02fff0767
cd249ff43ba2813809810f32f616f9c044430f6a
/LabOS01/Docker/charcount.c
b8894014f0cc296b5887c4c10d6eaa6d12162f16
[]
no_license
bottarocarlo/SistemiOperativi
bec2f493eadda0a1b98634b66e8f2214aa0c8487
5be888a6d8f5138887edeebbb3cdf1e2f077c0e8
refs/heads/master
2023-08-23T01:30:32.547307
2021-10-12T07:39:42
2021-10-12T07:39:42
372,231,278
0
1
null
null
null
null
UTF-8
C
false
false
561
c
#include <stdio.h> //(f)printf #include <string.h> //string #include <stdlib.h> //exit #include <unistd.h>//fork #include <fcntl.h> //open #include <sys/wait.h> //wait int main(int argc,char ** argv){ if (argc<2){ fprintf(stderr,"usage\n"); exit(-1); } int cont=0; char cr; while((cr=getchar())!=EOF){ if(cr==argv[1][0]){ printf("\033[0;31m%c\033[0;0m",cr); cont++; }else{ printf("%c",cr); } } printf("\n\nCI SONO %d %c",cont,argv[1][0]); return 0; }
[ "29379533+bottarocarloo@users.noreply.github.com" ]
29379533+bottarocarloo@users.noreply.github.com
356d91612767b977ec4a09da2768f04581e120b4
ee8080008b949af2a8ce14b75821704fb6d225f1
/learn_c/algorithm/bitwise/basic/swap_three_variables.c
24e5111331c82b3c9b8c1a5d1cbedbb4941b902d
[]
no_license
nguyenatan/learn-c
a54701b36edde99d8188e4263b6819a2d84c9182
894d800cebcc7b2e5ce979d3d326806ddac94585
refs/heads/master
2021-05-26T05:27:32.414119
2020-11-01T16:24:10
2020-11-01T16:24:10
127,598,777
0
0
null
null
null
null
UTF-8
C
false
false
272
c
#include <stdio.h> void swap_three(unsigned *a, unsigned *b, unsigned *c) { *a ^= *b ^ *c; *b ^= *a ^ *c; *c ^= *a ^ *b; *a ^= *b ^ *c; } int main(void) { int a = 2, b = 3, c = 1; swap_three(&a, &b, &c); printf("%d %d %d\n", a, b, c); // 1 2 3 return 0; }
[ "noreply@github.com" ]
nguyenatan.noreply@github.com
7759fe9404693e46acabfaa2eade5630465009a7
ad02a89fad35fd043edfe6690f5af0b12d7cff75
/ft_memccpy.c
50d30062997091233aa85c40fcd4649d912c2dac
[]
no_license
Nyastor/libft
7fbcf8b9693416cf4320dbf1c872e23ce84fd79e
284e0ffe9e1e474bd502814029891791ab4cc904
refs/heads/master
2023-04-10T12:46:25.096565
2021-04-22T19:32:08
2021-04-22T19:32:08
360,660,238
0
0
null
null
null
null
UTF-8
C
false
false
1,234
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memccpy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bswarm <bswarm@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/04/19 15:32:45 by bswarm #+# #+# */ /* Updated: 2021/04/21 11:22:19 by bswarm ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void *ft_memccpy(void *dst, const void *src, int ch, size_t n) { size_t i; if (!dst || !src) return (0); i = 0; while (i < n) { *(unsigned char *)(dst + i) = *(unsigned char *)(src + i); if (*(unsigned char *)(src + i) == (unsigned char)ch) return ((unsigned char *)(dst + i + 1)); i++; } return (0); }
[ "bswarm@student" ]
bswarm@student
d4f67eda3a22218002a9682267db94d4d55333d2
371f47f30e6663228eb11f3e6bcff9fbf4383973
/include/p64_buckring.h
1881d12feb66ddf7a799938cfcca1a08161f512b
[ "BSD-3-Clause" ]
permissive
ARM-software/progress64
8bad5b69251e05ca2dc0204292f403e70280444f
1930f44519d8ff3ad5843e67f8af14d5a6d636ee
refs/heads/master
2023-09-02T00:13:41.327286
2023-03-07T23:03:32
2023-03-07T23:15:09
138,292,902
82
18
BSD-3-Clause
2019-06-25T10:20:25
2018-06-22T11:05:35
C
UTF-8
C
false
false
1,015
h
//Copyright (c) 2019, ARM Limited. All rights reserved. // //SPDX-License-Identifier: BSD-3-Clause // //Non-blocking ring buffer using pass-the-buck algorithm #ifndef P64_BUCKRING_H #define P64_BUCKRING_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif typedef struct p64_buckring p64_buckring_t; //Allocate a buck ring buffer with space for at least 'nelems' elements //'nelems' != 0 and 'nelems' <= 0x80000000 p64_buckring_t * p64_buckring_alloc(uint32_t nelems, uint32_t flags); //Free a buck ring buffer //The ring buffer must be empty void p64_buckring_free(p64_buckring_t *rb); //Enqueue elements on a buck ring buffer //Return the number of actually enqueued elements uint32_t p64_buckring_enqueue(p64_buckring_t *rb, void *const ev[], uint32_t num); //Dequeue elements from a buck ring buffer //Return the number of actually dequeued elements uint32_t p64_buckring_dequeue(p64_buckring_t *rb, void *ev[], uint32_t num, uint32_t *index); #ifdef __cplusplus } #endif #endif
[ "ola.liljedahl@arm.com" ]
ola.liljedahl@arm.com
3ca5c21e7dd876c086a99cda233be7f5f9c7e9a5
0407dbf8b72cb521c0dd45efea2fd3f500bb539d
/ElectrolyteAnalyzer/Generated_Code/PE_LDD.c
ec9bf996cad9ae08097ca134b7fdac5e0d60f92a
[]
no_license
nvhien1992/CW_FRDM-KE06Z
f361394473788741fb351cf56b02c2e820af3dc1
b57cbf58f1c83b3efd95a12af719fc439ef137e2
refs/heads/master
2020-04-26T11:42:21.710169
2015-08-31T03:17:15
2015-08-31T03:17:15
29,116,883
0
1
null
null
null
null
UTF-8
C
false
false
7,490
c
/** ################################################################### ** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT. ** Filename : PE_LDD.c ** Project : ElectrolyteAnalyzer ** Processor : MKE06Z64VLK4 ** Version : Component 01.011, Driver 01.00, CPU db: 3.00.000 ** Compiler : GNU C Compiler ** Date/Time : 2015-08-23, 11:46, # CodeGen: 39 ** ** Copyright : 1997 - 2014 Freescale Semiconductor, Inc. ** All Rights Reserved. ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: ** ** o Redistributions of source code must retain the above copyright notice, this list ** of conditions and the following disclaimer. ** ** o 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. ** ** o Neither the name of Freescale Semiconductor, 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. ** ** http: www.freescale.com ** mail: support@freescale.com ** ###################################################################*/ /*! ** @file PE_LDD.c ** @version 01.00 */ /*! ** @addtogroup PE_LDD_module PE_LDD module documentation ** @{ */ /* MODULE PE_LDD. */ /* MQX Lite include files */ #include "mqxlite.h" #include "mqxlite_prv.h" #include "PE_LDD.h" #include "Cpu.h" /*lint -esym(765,PE_PeripheralUsed,LDD_SetClockConfiguration,PE_CpuClockConfigurations,PE_FillMemory) Disable MISRA rule (8.10) checking for symbols (PE_PeripheralUsed,LDD_SetClockConfiguration,PE_CpuClockConfigurations,PE_FillMemory). */ /* ** =========================================================================== ** Array of initialized device structures of LDD components. ** =========================================================================== */ LDD_TDeviceData *PE_LDD_DeviceDataList[13] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /* ** =========================================================================== ** The array of clock frequencies in configured clock configurations. ** =========================================================================== */ /*! The array of clock configurations (frequencies) configured in configured clock configurations of the CPU component. */ const TCpuClockConfiguration PE_CpuClockConfigurations[CPU_CLOCK_CONFIG_NUMBER] = { /* Clock configuration 0 */ { CPU_CORE_CLK_HZ_CONFIG_0, /*!< Core clock frequency in clock configuration 0 */ CPU_BUS_CLK_HZ_CONFIG_0, /*!< Bus clock frequency in clock configuration 0 */ CPU_FLEXBUS_CLK_HZ_CONFIG_0, /*!< Flexbus clock frequency in clock configuration 0 */ CPU_FLASH_CLK_HZ_CONFIG_0, /*!< FLASH clock frequency in clock configuration 0 */ CPU_USB_CLK_HZ_CONFIG_0, /*!< USB clock frequency in clock configuration 0 */ CPU_PLL_FLL_CLK_HZ_CONFIG_0, /*!< PLL/FLL clock frequency in clock configuration 0 */ CPU_MCGIR_CLK_HZ_CONFIG_0, /*!< MCG internal reference clock frequency in clock configuration 0 */ CPU_OSCER_CLK_HZ_CONFIG_0, /*!< System OSC external reference clock frequency in clock configuration 0 */ CPU_ERCLK32K_CLK_HZ_CONFIG_0, /*!< External reference clock 32k frequency in clock configuration 0 */ CPU_MCGFF_CLK_HZ_CONFIG_0 /*!< MCG fixed frequency clock */ } }; /* ** =================================================================== ** Method : Cpu_PE_FillMemory (component MKE06Z128LK4) */ /*! ** @brief ** Fills a memory area block by a specified value. ** @param ** SourceAddressPtr - Source address pointer. ** @param ** c - A value used to fill a memory block. ** @param ** len - Length of a memory block to fill. */ /* ===================================================================*/ void PE_FillMemory(register void* SourceAddressPtr, register uint8_t c, register uint32_t len) { register uint8_t *ptr = (uint8_t*)SourceAddressPtr; if (len > 0U) { while (len--) { *ptr++ = c; } } } /* ** =================================================================== ** Method : Cpu_PE_PeripheralUsed (component MKE06Z128LK4) */ /*! ** @brief ** Returns information whether a peripheral is allocated by PEx ** or not. ** @param ** PrphBaseAddress - Base address of a peripheral. ** @return ** TRUE if a peripheral is used by PEx or FALSE if it isn't used. */ /* ===================================================================*/ bool PE_PeripheralUsed(uint32_t PrphBaseAddress) { bool result = FALSE; switch (PrphBaseAddress) { /* Base address allocated by peripheral(s) SysTick */ case 0xE000E010UL: /* Base address allocated by peripheral(s) GPIOA */ case 0x400FF000UL: /* Base address allocated by peripheral(s) GPIOB */ case 0x400FF040UL: /* Base address allocated by peripheral(s) FTM0 */ case 0x40038000UL: /* Base address allocated by peripheral(s) UART1 */ case 0x4006B000UL: result = TRUE; break; default: break; } return result; } /* ** =================================================================== ** Method : Cpu_LDD_SetClockConfiguration (component MKE06Z128LK4) */ /*! ** @brief ** Changes the clock configuration of all LDD components in a ** project. ** @param ** ClockConfiguration - New CPU clock configuration changed by CPU SetClockConfiguration method. */ /* ===================================================================*/ void LDD_SetClockConfiguration(LDD_TClockConfiguration ClockConfiguration) { (void)ClockConfiguration; /*!< Parameter is not used, suppress unused argument warning */ /* Just one clock configuration defined in CPU component. */ } /* END PE_LDD. */ /*! ** @} */ /* ** ################################################################### ** ** This file was created by Processor Expert 10.3 [05.09] ** for the Freescale Kinetis series of microcontrollers. ** ** ################################################################### */
[ "nvhien1992@gmail.com" ]
nvhien1992@gmail.com
c4feff31addd26ea582d2cc41d9a7a7616d20cee
76fd3f6e89f8b086f5f31c4b9f7c58ad0f4b4026
/handlers/map_handlers.c
7967f210d3e050afde6e7617aeba5d4aea478202
[]
no_license
jordanbonaldi/Wolf3D
65eff59f3cd235ef77354dc64a2d6e9aa9a10993
ebbff9a27d04a781aac72214059752c00a895ad8
refs/heads/master
2020-03-27T15:28:52.477397
2018-08-30T08:40:01
2018-08-30T08:40:01
146,720,924
0
0
null
null
null
null
UTF-8
C
false
false
1,022
c
/* ** map_handlers.c for wolf in /home/Neferett/wolf3d ** ** Made by Bonaldi Jordan ** Login <Neferett@epitech.net> ** ** Started on Sun Jan 1 21:38:18 2017 Bonaldi Jordan ** Last update Sun Jan 15 21:36:02 2017 root */ # include "project.h" static int get_len_line(char *file, int line) { int j; int i; i = 0; j = 0; while (i < line) { if (file[j] == '\n') i++; j++; } i = 0; j--; while (file[++j] != '\n' && ++i); return (i); } int **convert_map(t_wolf *wolf) { int **map; int i; int j; int k; i = -1; j = -1; if (!(map = malloc(sizeof(int *) * nb_of(wolf->buf, '\n')))) wolf->stop = 1; while (++i < nb_of(wolf->buf, '\n') && !wolf->stop) { if (!(map[i] = malloc(sizeof(int) * get_len_line(wolf->buf, i)))) wolf->stop = 1; k = -1; while (wolf->buf[++j] != '\n') map[i][++k] = ((int)wolf->buf[j]) - 48; } if (!wolf->stop) wolf->size = set_vector(i - 1, j / i); return (map); }
[ "jordanbonaldi@me.com" ]
jordanbonaldi@me.com
c78a254f86d9306fe5fde07cbce7501a2f439613
b6a6a6f45a9ed0cfd86bddcb140855ca0cfc9540
/Operating Systems/2018OSD - Threads, Userprog, Virtual memory/thread_internal.h
3ba3af54d53f3a020e1b3789d825762d44678cd6
[]
no_license
acuraulm/Miscellaneous
366e9810833dcc6eedcb95d3c7d3d14e538a6393
d80b3140f89cf17d41bc582d70e86bd134b63860
refs/heads/master
2020-05-03T12:24:29.893156
2019-03-31T02:20:44
2019-03-31T02:20:44
178,625,293
0
0
null
null
null
null
UTF-8
C
false
false
10,581
h
#pragma once #include "list.h" #include "ref_cnt.h" #include "ex_event.h" #include "thread.h" typedef enum _THREAD_STATE { // currently executing on a CPU ThreadStateRunning, // in ready list, i.e. it is ready to be executed // when it will be scheduled ThreadStateReady, // it is waiting for a resource (mutex, ex event, ex timer) // and cannot be scheduled until it is unblocked by another // thread ThreadStateBlocked, // the thread has already executed its last quanta - it will // be destroyed before the next thread in the ready list resumes // execution ThreadStateDying, ThreadStateReserved = ThreadStateDying + 1 } THREAD_STATE; typedef DWORD THREAD_FLAGS; #define THREAD_FLAG_FORCE_TERMINATE_PENDING 0x1 #define THREAD_FLAG_FORCE_TERMINATED 0x2 typedef struct _THREAD { REF_COUNT RefCnt; TID Id; char* Name; QWORD creationTime; PTHREAD Parent; // Currently the thread priority is not used for anything THREAD_PRIORITY Priority; THREAD_STATE State; // valid only if State == ThreadStateTerminated STATUS ExitStatus; EX_EVENT TerminationEvt; volatile THREAD_FLAGS Flags; // Lock which ensures there are no race conditions between a thread that // blocks and a thread on another CPU which wants to unblock it LOCK BlockLock; // List of all the threads in the system (including those blocked or dying) LIST_ENTRY AllList; LIST_ENTRY OrderedList; // List of the threads ready to run LIST_ENTRY ReadyList; // List of the threads in the same process LIST_ENTRY ProcessList; // Incremented on each clock tick for the running thread QWORD TickCountCompleted; // Counts the number of ticks the thread has currently run without being // de-scheduled, i.e. if the thread yields the CPU to another thread the // count will be reset to 0, else if the thread yields, but it will // scheduled again the value will be incremented. QWORD UninterruptedTicks; // Incremented if the thread yields the CPU before the clock // ticks, i.e. by yielding or by blocking QWORD TickCountEarly; // The highest valid address for the kernel stack (its initial value) PVOID InitialStackBase; // The size of the kernel stack DWORD StackSize; // The current kernel stack pointer (it gets updated on each thread switch, // its used when resuming thread execution) PVOID Stack; // MUST be non-NULL for all threads which belong to user-mode processes PVOID UserStack; struct _PROCESS* Process; } THREAD, *PTHREAD; //****************************************************************************** // Function: ThreadSystemPreinit // Description: Basic global initialization. Initializes the all threads list, // the ready list and all the locks protecting the global // structures. // Returns: void // Parameter: void //****************************************************************************** void _No_competing_thread_ ThreadSystemPreinit( void ); //****************************************************************************** // Function: ThreadSystemInitMainForCurrentCPU // Description: Call by each CPU to initialize the main execution thread. Has a // different flow than any other thread creation because some of // the thread information already exists and it is currently // running. // Returns: STATUS // Parameter: void //****************************************************************************** STATUS ThreadSystemInitMainForCurrentCPU( void ); //****************************************************************************** // Function: ThreadSystemInitIdleForCurrentCPU // Description: Called by each CPU to spawn the idle thread. Execution will not // continue until after the idle thread is first scheduled on the // CPU. This function is also responsible for enabling interrupts // on the processor. // Returns: STATUS // Parameter: void //****************************************************************************** STATUS ThreadSystemInitIdleForCurrentCPU( void ); //****************************************************************************** // Function: ThreadCreateEx // Description: Same as ThreadCreate except it also takes an additional // parameter, the process to which the thread should belong. This // function must be called for creating user-mode threads. // Returns: STATUS // Parameter: IN_Z char * Name // Parameter: IN THREAD_PRIORITY Priority // Parameter: IN PFUNC_ThreadStart Function // Parameter: IN_OPT PVOID Context // Parameter: OUT_PTR PTHREAD * Thread // Parameter: INOUT struct _PROCESS * Process //****************************************************************************** STATUS ThreadCreateEx( IN_Z char* Name, IN THREAD_PRIORITY Priority, IN PFUNC_ThreadStart Function, IN_OPT PVOID Context, OUT_PTR PTHREAD* Thread, INOUT struct _PROCESS* Process ); //****************************************************************************** // Function: ThreadTick // Description: Called by the timer interrupt at each timer tick. It keeps // track of thread statistics and triggers the scheduler when a // time slice expires. // Returns: void // Parameter: void //****************************************************************************** void ThreadTick( void ); //****************************************************************************** // Function: ThreadBlock // Description: Transitions the running thread into the blocked state. The // thread will not run again until it is unblocked (ThreadUnblock) // Returns: void // Parameter: void //****************************************************************************** void ThreadBlock( void ); //****************************************************************************** // Function: ThreadUnblock // Description: Transitions thread, which must be in the blocked state, to the // ready state, allowing it to resume running. This is called when // the resource on which the thread is waiting for becomes // available. // Returns: void // Parameter: IN PTHREAD Thread //****************************************************************************** void ThreadUnblock( IN PTHREAD Thread ); //****************************************************************************** // Function: ThreadYieldOnInterrupt // Description: Returns TRUE if the thread must yield the CPU at the end of // this interrupt. FALSE otherwise. // Returns: BOOLEAN // Parameter: void //****************************************************************************** BOOLEAN ThreadYieldOnInterrupt( void ); //****************************************************************************** // Function: ThreadTerminate // Description: Signals a thread to terminate. // Returns: void // Parameter: INOUT PTHREAD Thread // NOTE: This function does not cause the thread to instantly terminate, // if you want to wait for the thread to terminate use // ThreadWaitForTermination. // NOTE: This function should be used only in EXTREME cases because it // will not free the resources acquired by the thread. //****************************************************************************** void ThreadTerminate( INOUT PTHREAD Thread ); //****************************************************************************** // Function: ThreadTakeBlockLock // Description: Takes the block lock for the executing thread. This is required // to avoid a race condition which would happen if a thread is // unblocked while in the process of being blocked (thus still // running on the CPU). // Returns: void // Parameter: void //****************************************************************************** void ThreadTakeBlockLock( void ); //****************************************************************************** // Function: ThreadExecuteForEachThreadEntry // Description: Iterates over the all threads list and invokes Function on each // entry passing an additional optional Context parameter. // Returns: STATUS // Parameter: IN PFUNC_ListFunction Function // Parameter: IN_OPT PVOID Context //****************************************************************************** STATUS ThreadExecuteForEachThreadEntry( IN PFUNC_ListFunction Function, IN_OPT PVOID Context ); //****************************************************************************** // Function: GetCurrentThread // Description: Returns the running thread. // Returns: void //****************************************************************************** #define GetCurrentThread() ((THREAD*)__readmsr(IA32_FS_BASE_MSR)) //****************************************************************************** // Function: SetCurrentThread // Description: Sets the current running thread. // Returns: void // Parameter: IN PTHREAD Thread //****************************************************************************** void SetCurrentThread( IN PTHREAD Thread ); //****************************************************************************** // Function: ThreadSetPriority // Description: Sets the thread's priority to new priority. If the // current thread no longer has the highest priority, yields. // Returns: void // Parameter: IN THREAD_PRIORITY NewPriority //****************************************************************************** void ThreadSetPriority( IN THREAD_PRIORITY NewPriority );
[ "acuraulm@gmail.com" ]
acuraulm@gmail.com
9dd9a5b26a4233c6998f5a14de486c951eb97137
2c78de0b151238b1c0c26e6a4d1a36c7fa09268c
/common/components/rtl/external/Embarcadero/DelphiBerlin/cpprtl/Source/dinkumware/source/xcostate.c
9096368d52359e5dbbccaa1319deb76d77902faa
[]
no_license
bravesoftdz/realwork
05a3b308cef59bed8a9efda4212849c391b4b267
19b446ce8ad2adf82ab8ce7988bc003221accad2
refs/heads/master
2021-06-07T23:57:22.429896
2016-11-01T18:30:21
2016-11-01T18:30:21
null
0
0
null
null
null
null
UTF-8
C
false
false
428
c
/* _Costate table */ #include "xlocale.h" #include "xtls.h" #include "xwchar.h" _STD_BEGIN _TLS_DATA_DEF(_IMPLICIT_EXTERN, _Statab, _Costate, {{0}}); /* 0: 1-to-1 inline */ _Statab *_Getpcostate() { /* get pointer to _Costate */ return (_TLS_DATA_PTR(_Costate)); } _STD_END /* * Copyright (c) 1992-2006 by P.J. Plauger. ALL RIGHTS RESERVED. * Consult your license regarding permissions and restrictions. V5.01:1422 */
[ "lulinalex@gmail.com" ]
lulinalex@gmail.com
f0d94f4403e6aa0c706d73063517e2aedfca5b0a
5c255f911786e984286b1f7a4e6091a68419d049
/vulnerable_code/7aad4892-a729-4a3e-85c5-316b71b90586.c
feced8d36467dbebb21d8e0f8416177d5d9114c5
[]
no_license
nmharmon8/Deep-Buffer-Overflow-Detection
70fe02c8dc75d12e91f5bc4468cf260e490af1a4
e0c86210c86afb07c8d4abcc957c7f1b252b4eb2
refs/heads/master
2021-09-11T19:09:59.944740
2018-04-06T16:26:34
2018-04-06T16:26:34
125,521,331
0
0
null
null
null
null
UTF-8
C
false
false
567
c
#include <string.h> #include <stdio.h> int main() { int i=0; int j=14; int k; int l; j = 53; l = 64; k = i/j; l = i/j; l = l/j; l = i%j; l = l+j; k = k-k*k; //variables /* START VULNERABILITY */ int a; long b[26]; long c[7]; a = 0; while (b[a] != 0) { /* START BUFFER SET */ *((long *)c + a) = *((long *)b + a); /* END BUFFER SET */ //random a++; } /* END VULNERABILITY */ //random printf("%d%d\n",k,l); return 0; }
[ "nharmon8@gmail.com" ]
nharmon8@gmail.com
e0bae1de10847053d28947c3dae5924f1cd770df
fefac5716839ed8765f8a2b421bc1bf40900f64f
/rushes/rush02/ex00/src-rush-00/rush01.c
12021160789e4b669deee67c804cbd463f5ba926
[]
no_license
luizakhachatryan/42
b883472b972234bddbd04d5252bcfae5af76916a
352bcc9f192d1af7cc4f8aa3093265d039e2237f
refs/heads/master
2022-12-13T04:56:04.589325
2020-09-17T16:51:20
2020-09-17T16:51:20
null
0
0
null
null
null
null
UTF-8
C
false
false
1,564
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rush01.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/12 15:17:07 by gtertysh #+# #+# */ /* Updated: 2016/11/12 15:17:18 by gtertysh ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft.h" void rush_print(int x, int y, int i, int j) { if (j > 1 && j < x && i > 1 && i < y) ft_putchar(' '); else if (j == 1 && i == 1) ft_putchar('/'); else if (j == x && i == 1) ft_putchar('\\'); else if (j == 1 && i == y) ft_putchar('\\'); else if (j == x && i == y) ft_putchar('/'); else if ((j > 1 && j < x) && (i == 1 || i == y)) ft_putchar('*'); else ft_putchar('*'); } int rush(int x, int y) { int i; int j; i = 1; j = 1; if (x < 0 || y < 0) return (1); if (x == 0 || y == 0) return (0); while (i <= y) { while (j <= x) { rush_print(x, y, i, j); j++; } ft_putchar('\n'); i++; j = 1; } return (0); }
[ "fotonmoton@yandex.ua" ]
fotonmoton@yandex.ua
2461342911ae33e2cce24bb092b55c20961c5b91
138c849d97f084224d7a83916e3824cdcddca3bb
/c6run_0_98_03_03/build/gpp_libs/ipc/dsplink/.svn/text-base/rpc_ipc.c.svn-base
65c152f0443b5d372d7b1c75f13fb2f5422e59f9
[]
no_license
lab85-ru/ti-dvsdk_omapl138-evm_04_03_00_06
7210a0324d9b520aa4e17879fe1bb84af98b1178
350e68dd99669e46c6f679e91216e22412ee50c5
refs/heads/master
2022-07-29T11:31:20.816254
2020-05-17T18:09:02
2020-05-17T18:09:02
264,720,283
1
0
null
null
null
null
UTF-8
C
false
false
11,317
/* * rpc_ipc.c */ /* * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* ----------------------------------- Standard C Headers */ #include <stdint.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <time.h> /* ----------------------------------- OS Specific Headers */ #include <fcntl.h> #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> #include <unistd.h> #include <pthread.h> #include <semaphore.h> /* ----------------------------------- DSP/BIOS Link */ #include <dsplink.h> /* ----------------------------------- DSP/BIOS LINK API */ #include <proc.h> #include <procdefs.h> #include <msgq.h> #include <pool.h> #include <loaderdefs.h> /* ----------------------------------- Application Headers */ #include "c6run.h" #include "debug_common.h" #include "C6Run_common.h" /* ----------------------------------- IPC Specific Headers */ #include "dsplink/ipc_common.h" /* ----------------------------------- This module's header */ #include "rpc_ipc.h" /************************************************************ * Explicit External Declarations * ************************************************************/ /************************************************************ * Local Macro Declarations * ************************************************************/ // Size of the buffer passed in RPC messages. #define RPC_BUFSZ (RPC_MSG_TOTALSIZE - sizeof(MSGQ_MsgHeader) - sizeof(intptr_t)) /************************************************************ * Local Typedef Declarations * ************************************************************/ // Message structure for RPC messages struct RPC_Msg { MSGQ_MsgHeader header; intptr_t pSyncStruct; volatile unsigned char buffer[RPC_BUFSZ]; }; /************************************************************ * Local Function Declarations * ************************************************************/ /************************************************************ * Local Variable Definitions * ************************************************************/ static sem_t RPC_IPC_msgSemObj; static bool LOCAL_isModuleInitialized = false; /************************************************************ * Global Variable Definitions * ************************************************************/ pthread_t RPC_IPC_recvThread; // Global CONTROL MSGQ Objects for Tx and Rx MSGQ_Queue MSGQ_rpcFromGPP = (uint32_t) MSGQ_INVALIDMSGQ; MSGQ_Queue MSGQ_rpcToGPP = (uint32_t) MSGQ_INVALIDMSGQ; /************************************************************ * Global Function Definitions * ************************************************************/ void *RPC_IPC_receiver( void *ptr ) { DSP_STATUS status = DSP_SOK; RPC_Msg *msg; RPC_SyncStruct *pSync; uint16_t msgId; while(1) { status = MSGQ_get(MSGQ_rpcToGPP, WAIT_FOREVER, (MsgqMsg *) &msg); if (DSP_FAILED(status)) { REPORT_STATUS("MSGQ_get"); break; } msgId = MSGQ_getMsgId((MsgqMsg) msg); if (RPC_TERMINATE == msgId) { // If we got the terminate message, then the DSP has been told to shut down // So free the message and then quit receiving stuff (kill this thread) RPC_IPC_freeMsg(msg); break; } else { pSync = (RPC_SyncStruct *) msg->pSyncStruct; // Fill in the message pointer pSync->msg = msg; // Notify the calling thread that the function call has returned sem_post(&(pSync->sem)); } } pthread_exit(NULL); } int32_t RPC_IPC_init( void ) { DSP_STATUS status = DSP_SOK; if (LOCAL_isModuleInitialized) { return C6RUN_SUCCESS; } VERBOSE_PRINT0("Entered RPC_IPC_init()\n"); // Open the RPC TO GPP message queue if (DSP_SUCCEEDED(status)) { status = MSGQ_open(RPC_TO_GPP_MSGQNAME, &MSGQ_rpcToGPP, NULL); if (DSP_FAILED(status)) { REPORT_STATUS("MSGQ_open"); return C6RUN_FAIL; } } // Connect to the remote sending message queue if (DSP_SUCCEEDED(status)) { MSGQ_LocateAttrs syncLocateAttrs; syncLocateAttrs.timeout = WAIT_FOREVER; status = DSP_ENOTFOUND; while ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY)) { status = MSGQ_locate(RPC_FROM_GPP_MSGQNAME, &MSGQ_rpcFromGPP, &syncLocateAttrs); if ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY)) { VERBOSE_PRINT0("RPC MSGQ_locate() failed! Will retry.\n"); usleep(10000); } else if (DSP_FAILED(status)) { REPORT_STATUS("MSGQ_locate"); return C6RUN_FAIL; } } } // Setup a counting semaphore to limit the in-flight messages if( sem_init(&RPC_IPC_msgSemObj,0,RPC_MSG_CNT) < 0 ) { printf("sem_init() failed"); exit(0); } // Start the RPC return receive thread if (pthread_create(&RPC_IPC_recvThread, NULL, RPC_IPC_receiver, NULL) != 0) { printf("Aborting...pthread_create() for RPC receiver failed!\n"); exit(1); } VERBOSE_PRINT0("pthread_create() passed!\n"); LOCAL_isModuleInitialized = true; VERBOSE_PRINT0("Leaving RPC_IPC_init()\n"); return C6RUN_SUCCESS; } void RPC_IPC_exit( void ) { DSP_STATUS status = DSP_SOK; DSP_STATUS tmpStatus = DSP_SOK; if (!LOCAL_isModuleInitialized) { return; } VERBOSE_PRINT0("Entered RPC_IPC_exit()\n"); // Wait for RPC_IPC_receiver to shutdown pthread_join(RPC_IPC_recvThread, NULL); VERBOSE_PRINT0("Completed shutdown of RPC_IPC_receiver thread.\n"); if( sem_destroy(&RPC_IPC_msgSemObj) < 0 ) { printf("sem_destroy() failed"); exit(0); } // Release the remote message queue status = MSGQ_release(MSGQ_rpcFromGPP); if (DSP_FAILED(status)) { REPORT_STATUS("MSGQ_release"); } else { VERBOSE_PRINT0("MSGQ_release() passed.\n"); } // Close the GPP's RPC message queue tmpStatus = MSGQ_close(MSGQ_rpcToGPP); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; REPORT_STATUS("MSGQ_close"); } else { VERBOSE_PRINT0("MSGQ_close() passed.\n"); } LOCAL_isModuleInitialized = false; VERBOSE_PRINT0("Leaving RPC_IPC_exit()\n"); } void RPC_IPC_sendMsg( RPC_Msg *msg, uint16_t msgId, RPC_SyncStruct **pSyncPtr ) { DSP_STATUS status; RPC_SyncStruct *pSync; VERBOSE_PRINT0("Entering RPC_IPC_sendMsg()\n"); MSGQ_setMsgId((MsgqMsg)msg, msgId); // Create a sync structure, local to this thread. pSync = (RPC_SyncStruct *) malloc(sizeof(RPC_SyncStruct)); *pSyncPtr = pSync; // Init the semaphore (part of the sync struct) that the receive // thread can post to, and that the sending thread (the one calling // this function) can block on. Initial count should be zero. sem_init(&(pSync->sem),0,0); // Put the pointer to the sync structure in the message to be sent. // This pointer will come back with the return message so that the // receiving thread can use it to fill in the return message and notify // the calling thread (the one calling this function). msg->pSyncStruct = (intptr_t) pSync; // Send the message status = MSGQ_put(MSGQ_rpcFromGPP, (MsgqMsg) msg); if (DSP_FAILED(status)) { MSGQ_free((MsgqMsg) msg); REPORT_STATUS("MSGQ_put"); } VERBOSE_PRINT0("Exiting RPC_IPC_sendMsg()\n"); } bool RPC_IPC_hasReceivedMsg( RPC_SyncStruct *pSync ) { int result = sem_trywait(&(pSync->sem)); if ( result < 0) { return false; } else { // Post the semaphore again so that the recvMsg call will get it sem_post(&(pSync->sem)); return true; } } uint16_t RPC_IPC_recvMsg( RPC_Msg **msg, RPC_SyncStruct *pSync) { uint16_t msgId; VERBOSE_PRINT0("Entering RPC_IPC_recvMsg()\n"); // Wait for the receive thread to post the semaphore, then destroy it sem_wait(&(pSync->sem)); sem_destroy(&(pSync->sem)); if (NULL == pSync->msg) { return RPC_NULL; } *msg = pSync->msg; msgId = MSGQ_getMsgId((MsgqMsg) (*msg)); // Free the sync structure now we are done with it free(pSync); VERBOSE_PRINT0("Exiting RPC_IPC_recvMsg()\n"); return msgId; } void RPC_IPC_allocMsg( RPC_Msg **msg ) { VERBOSE_PRINT0("Entering RPC_IPC_allocMsg()\n"); // Semaphore wait on an available message sem_wait(&RPC_IPC_msgSemObj); { DSP_STATUS status = DSP_SOK; // Do MSGQ alloc for a remote procedure call status = MSGQ_alloc(COMMON_POOL_ID, sizeof(RPC_Msg), (MSGQ_Msg *) msg ); if (DSP_FAILED(status)) { REPORT_STATUS("MSGQ_alloc"); *msg = NULL; } } VERBOSE_PRINT0("Exiting RPC_IPC_allocMsg()\n"); } void RPC_IPC_freeMsg( RPC_Msg *msg ) { VERBOSE_PRINT0("Entering RPC_IPC_freeMsg()\n"); MSGQ_free((MSGQ_Msg) msg); sem_post(&RPC_IPC_msgSemObj); VERBOSE_PRINT0("Exiting RPC_IPC_freeMsg()\n"); } void *RPC_IPC_getMsgBuffer( RPC_Msg *msg ) { return (void *) (msg->buffer); } uint32_t RPC_IPC_getMsgBufferSize ( void ) { return RPC_BUFSZ; } /*********************************************************** * Local Function Definitions * ***********************************************************/ /*********************************************************** * End file * ***********************************************************/
[ "info@lab85.ru" ]
info@lab85.ru
c07ac499f5cbc63f12e40a788de8c1edaea6de33
c9f4a6afd95b2a01e2f9176919fab3374499f8c5
/main.c
562103b3f2cc0c73563a82f96a54d300fc4cdad8
[]
no_license
TheFwGuy/magclock
6f65e79f6b39ebca35edcbdc4c1cc3df9b1740a1
59f14a173ebb742018a705b9b83fbf738736540f
refs/heads/master
2021-04-27T07:45:37.786353
2018-02-23T15:28:10
2018-02-23T15:28:10
122,638,333
0
0
null
null
null
null
UTF-8
C
false
false
2,375
c
/* * magdriver - * Copyright (c) 2013 - Stefano Bodini * * This code is designed to drive three coils with a 1 sec pulse each using an LaunchPad board. * The board is a LaunchPad board, using a MSP430F2012 and the code is compiled using MSPGCC 4.4.3 * using the -mmcu=msp430x2012 parameter */ //#include <io.h> #include<msp430.h> #include <signal.h> /* * Defines for I/O * P1.0 -> Coil1 (OUTPUT - red LED) * P1.1 -> Coil2 (OUTPUT) * P1.2 -> Coil3 (OUTPUT) * P1.3 -> not used - input * P1.4 -> not used - input * P1.5 -> not used - input * P1.6 -> not used - input * P1.7 -> not used - input */ #define COIL_PORT P1OUT #define MASK_CLEAN 0xF8 /* Filter out only outputs */ #define MASK1 0x01 /* Coil 1 ON, Coil 2 OFF, Coil 3 OFF */ #define MASK2 0x02 /* Coil 1 OFF, Coil 2 ON, Coil 3 OFF */ #define MASK3 0x04 /* Coil 1 OFF, Coil 2 OFF, Coil 3 ON */ /* * Global variables */ unsigned char Coil; /* Coil index */ int main(void) { WDTCTL = WDTPW + WDTHOLD; /* Stop WDT */ BCSCTL1 |= DIVA_3; /* ACLK/8 */ BCSCTL3 |= XCAP_3; /* 12.5pF cap- setting for 32768Hz crystal */ P1DIR |= BIT0 + BIT1 + BIT2; /* set P1.0, P1.1 and P1.2 as output */ P1OUT &= MASK_CLEAN; /* Force low coils */ Coil = MASK1; /* Start from the first coil */ CCTL0 = CCIE; /* CCR0 interrupt enabled */ CCR0 = 512; /* 512 -> 1 sec, 30720 -> 1 min */ TACTL = TASSEL_1 + ID_3 + MC_1; /* ACLK, /8, upmode */ _BIS_SR(LPM3_bits + GIE); /* Enter LPM3 w/ interrupt */ /* Main goes to die - only interrupt is working */ for(;;); } /* * Timer interrupt - every second */ __attribute__((__interrupt__(TIMERA0_VECTOR))) void Timer_A (void) { unsigned char shadow = COIL_PORT & MASK_CLEAN; /* Read current content and force to zero last 3 bits */ shadow |= Coil; /* Load current mask */ COIL_PORT = shadow; /* Put out signal */ switch(Coil) /* Update mask for next interrupt */ { case MASK1: Coil = MASK2; break; case MASK2: Coil = MASK3; break; case MASK3: default: Coil = MASK1; break; } }
[ "stefano.bodini@elyxor.com" ]
stefano.bodini@elyxor.com
e580764c6c1995e61286fe7bcfe3b7a463ea1cb5
dea3ced165d3b0b00be2a707908d904eb406a9d2
/gbdk/include/asm/z80/provides.h
69b20f0f4074067bd02212472249e03ddebc0fab
[ "MIT" ]
permissive
gbdkjs/gbdkjs
f7e22bd307195028367f1337782b56e21aa5f54f
f0a9c2e666c70276af8274b12c26e61f2bb36b2e
refs/heads/master
2022-12-13T15:23:24.041692
2020-02-27T13:14:44
2020-02-27T13:14:44
120,190,941
52
2
MIT
2022-12-09T13:41:59
2018-02-04T14:15:17
JavaScript
UTF-8
C
false
false
60
h
#undef USE_C_MEMCPY #undef USE_C_STRCPY #undef USE_C_STRCMP
[ "chris.maltby@gmail.com" ]
chris.maltby@gmail.com
601e3621e1b79d381edb005e5b690ca6f1c925a7
47d48a3de5bcc5ff83fa6735c9dde962cb221e25
/libft/ft_printf_funct/ft_storechar.c
6b095a33ee0a78d859a2a0cf3598273871d380f9
[]
no_license
Bumbieris31/push_swap
1596ef3ef3c3a2ded76c6257bab2efe726b347ff
d1748e3832939c631600f798c8187a5a7f357589
refs/heads/master
2020-09-11T17:37:26.116440
2019-11-16T18:16:11
2019-11-16T18:16:11
222,140,558
0
0
null
null
null
null
UTF-8
C
false
false
1,192
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_storechar.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: abumbier <abumbier@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/04 14:19:25 by abumbier #+# #+# */ /* Updated: 2019/06/15 14:28:33 by abumbier ### ########.fr */ /* */ /* ************************************************************************** */ #include "../ft_printf.h" void ft_store_char(t_sbox *sb) { char *str; str = 0; while (sb->str[sb->ind] && sb->str[sb->ind] != '%') { str = ft_strcadd(str, sb->str[sb->ind]); sb->ind++; } if (str != 0) { ft_put_ret_str(str); sb->ret_len += ft_strlen(str); } if (str) free(str); }
[ "abumbier@f1r2s21.codam.nl" ]
abumbier@f1r2s21.codam.nl
2b7ff42c2a0c8a5114cb5203554394778c5d2ff1
1f8040b376144cb648910df9d5e87750b987fac4
/resources.c
ef115bb61c7829cf3f72b746b5067b938cfc1b6e
[]
no_license
ch3rc/OSP5
1f3cdc95db31b7fa4eaa46052d5c6fb3767cf697
bb161d364c5398981f2f655ed6cd4400334abe32
refs/heads/master
2021-05-21T05:18:13.600144
2020-04-19T00:55:20
2020-04-19T00:55:20
252,560,601
0
0
null
null
null
null
UTF-8
C
false
false
6,291
c
//===================================================================== //Date: April 10,2020 //Author: Cody Hawkins //Class: CS4760 //Program: Assignment 5 //File: resources.c //===================================================================== #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <error.h> #include <sys/wait.h> #include <signal.h> #include <sys/time.h> #include <sys/msg.h> #include <semaphore.h> #include "share.h" int availMatrix[MAX_RESOURCES]; int resMatrix[MAX_RESOURCES]; int reqMatrix[MAX_PROCESSES][MAX_RESOURCES]; int allocMatrix[MAX_PROCESSES][MAX_RESOURCES]; int written; int verbose; FILE *fp; struct Queue *queue; //move clock and give it a little leeway with //unsigned integer. 4.3 x 10^9 void tickClock(Clock *clock, unsigned int nanos) { unsigned int nano = clock->nano + nanos; while(nano >= 1000000000) { nano -= 1000000000; clock->seconds++; } clock->nano = nano; } int compare(Clock *time, Clock* newtime) { long time1 = (long)time->seconds * 1000000000 + (long)time->nano; long time2 = (long)newtime->seconds * 1000000000 + (long)newtime->nano; if(time1 > time2) return 1; else return 0; } //initialize matrix with all zeros void initMatrix(int arr[MAX_PROCESSES][MAX_RESOURCES]) { int i, j; for(i = 0; i < MAX_PROCESSES; i++) { for(j = 0; j < MAX_RESOURCES; j++) { arr[i][j] = 0; } } } //initialize vector with all zeros void initVec(int arr[MAX_RESOURCES]) { int i; for(i = 0; i < MAX_RESOURCES; i++) { arr[i] = 0; } } //get position of filled descriptor int getPos(Descriptor* req, int pid) { int i; for(i = 0; i < MAX_PROCESSES; i++) { if(req->pid[i] == pid) { return i; } } return -1; } //find open spot in empty descriptor int findSpot() { int i; for(i = 0; i < MAX_PROCESSES; i++) { if(req->pid[i] == -1) { return i; } } return -1; } //initialize descriptor with allocation //instances (1 - 10) inclusive void initDescriptor(Descriptor* req) { srand(time(0)); int i, j; for(i = 0; i < MAX_PROCESSES; i++) { req->pid[i] = -1; req->rpid[i] = 0; for(j = 0; j < MAX_RESOURCES; j++) { req->curAlloc[i][j] = (rand() % 10) + 1; req->release[i][j] = 0; req->request[i][j] = 0; } //zero is not shared, 1 is shared req->shared[i] = (((rand() % 100) + 1) < 20) ? 1 : 0; } } //fill request and allocation static tables //also fill max requests for descriptors //allocation + request table values. void fillTables(Descriptor* req, int alloc[MAX_PROCESSES][MAX_RESOURCES],int avail[MAX_RESOURCES]) { int i, j; for(i = 0; i < MAX_PROCESSES; i++) { for(j = 0; j < MAX_RESOURCES; j++) { avail[i] = (rand() % 20) + 1;//available matrix alloc[i][j] = req->curAlloc[i][j];//allocation matrix } } } //update request matrix with latest requests void updateRequest(Descriptor *req, int array[MAX_PROCESSES][MAX_RESOURCES]) { int i, j; for(i = 0; i < MAX_PROCESSES; i++) { for(j = 0; j < MAX_RESOURCES; j++) { array[i][j] += req->request[i][j]; } } } //terminate pid and release allocations back //to available. void offThePid(Descriptor *req, int pid) { int i = getPos(req, pid); if(written < 100000 && verbose == 1) { fprintf(fp, "OSS Terminating P%d at time %d:%d\n",i, clock->seconds, clock->nano); written++; } //naturalDeath++; int k; for(k = 0; k < MAX_RESOURCES; k++) { availMatrix[k] += req->curAlloc[i][k]; } updatePid(i); } //after terminating a pid, update allocations //and request table void updatePid(int pos) { srand(time(0)); int i, j; for(i = 0; i < MAX_PROCESSES; i++) { if(req->pid[i] == pos) { req->pid[i] = -1; req->rpid[i] = 0; for(j = 0; j < MAX_RESOURCES; j++) { req->curAlloc[i][j] = (rand()% 10) + 1; allocMatrix[i][j] = req->curAlloc[i][j]; req->release[i][j] = 0; req->request[i][j] = 0; } } req->shared[i] = (((rand() % 100) + 1) < 20) ? 1 : 0; } } void releaseResource(Descriptor *req, int pid) { if(written < 100000 && verbose == 1) { fprintf(fp, "OSS has acknowledged process P%d requesting to release resources at time %d:%d\n", pid, clock->seconds, clock->nano); written++; } int i, j; for(i = 0; i < MAX_PROCESSES; i++) { if(req->pid[i] == pid) { for(j = 0; j < MAX_RESOURCES; j++) { if(req->release[i][j] != 0) { req->curAlloc[i][j] -= req->release[i][j]; allocMatrix[i][j] = req->curAlloc[i][j]; availMatrix[j] += req->release[i][j]; req->release[i][j] = 0; } } } break; } } //test print to make sure that descriptors //are being allocated correctly void printDescriptor(Descriptor* req) { int i, j, k, e, g; for(i = 0; i < MAX_PROCESSES; i++) { printf("P%d Pid %d", i, req->pid[i]); printf("\n"); for(j = 0; j < MAX_RESOURCES; j++) { printf("%d ", req->curAlloc[i][j]); } printf("\n"); for(k = 0; k < MAX_RESOURCES; k++) { printf("%d ", req->release[i][k]); } printf("\n"); for(e = 0; e < MAX_RESOURCES; e++) { printf("%d ", req->request[i][e]); } printf("\n"); printf("%d\n", req->shared[i]); printf("\n"); } } //currently test but will be used for verbose printout void printMatrix(int arr[MAX_PROCESSES][MAX_RESOURCES]) { int i,j; if(written < 100000 && verbose == 1) { fprintf(fp, "\n line count = %d", written); written++; } for(i = 0; i < MAX_RESOURCES; i++) { if(written < 100000 && verbose == 1) { fprintf(fp, "\tR%d", i); written++; } } if(written < 100000 && verbose == 1) { fprintf(fp, "\n"); written++; } for(i = 0; i < MAX_PROCESSES; i++) { if(written < 100000 && verbose == 1) { fprintf(fp, "P%d ", i); written++; } for(j = 0; j < MAX_RESOURCES; j++) { if(written < 100000 && verbose == 1) { fprintf(fp," %d\t", arr[i][j]); written++; } } if(written < 100000 && verbose == 1) { fprintf(fp, "\n"); written++; } } } //initialize everything and also test printouts for now void allAtOnce() { initMatrix(reqMatrix); initMatrix(allocMatrix); initVec(availMatrix); initVec(resMatrix); initDescriptor(req); fillTables(req, allocMatrix, availMatrix); }
[ "hawkins@hoare7.cs.umsl.edu" ]
hawkins@hoare7.cs.umsl.edu
2199cab23e27d5a8e6c32e1f915061d81ce8ac11
fe692881320e10c55962cebd165d478c1434c359
/skill/06/06101.c
25bbf2377b0d10c33bfd54a6b9eeb4075dcafb43
[]
no_license
anho9339/chienquoc
130602c90c43053bbc99dfbfbc877de0b2d81dd7
cb5157d5eabcb4bb2ff71c292cfbdd5dc5fbb221
refs/heads/master
2021-07-04T07:51:49.408023
2021-02-01T15:15:58
2021-02-01T15:15:58
222,929,950
1
0
null
null
null
null
UTF-8
C
false
false
366
c
inherit SKILL; // 函数:构造处理 void create() { set_number(0610); set_name( "Đầu Bếp" ); } // 函数:能否特殊技 void can_perform( object me ) { send_user( me, "%c%c%w%w%c%w%w%s", 0x60, 3, 610, 6101, 0, 0, 0, "Tửu Thực chế tác" ); send_user( me, "%c%c%w%w%s", 0x60, 4, get_number(), 1, "Tửu Thực chế tác" ); }
[ "hothienan1993@gmail.com" ]
hothienan1993@gmail.com
5d6c2c4a029d26535a2ec26498e944da86795dc8
c551afe0e7d94cc76375bc034523336f1dcef639
/Part II/Train++/Train_plus_plus/haberman_survival_train_test.h
1f4d0b1433fce054ef36372602bb5a707cdff9f1
[ "MIT" ]
permissive
bharathsudharsan/ECML-Tutorial-ML-Meets-IoT
cdd2e49d5fa9c25bfa19e3589b3dff3ea947dc08
7928e517598c91778c5de648ad630585d9fc89eb
refs/heads/main
2023-08-02T14:53:23.484715
2021-09-16T21:01:08
2021-09-16T21:01:08
382,620,596
6
0
null
null
null
null
UTF-8
C
false
false
4,740
h
#define FEATURES_DIMEN 3 #define DATASET_ROWS 306 float X[DATASET_ROWS][FEATURES_DIMEN] = { //1. Age of patient at time of operation (numerical) //2. Patient's year of operation (year - 1900, numerical) //3. Number of positive axillary nodes detected (numerical) {30,64,1}, {30,62,3}, {30,65,0}, {31,59,2}, {31,65,4}, {33,58,10}, {33,60,0}, {34,59,0}, {34,66,9}, {34,58,30}, {34,60,1}, {34,61,10}, {34,67,7}, {34,60,0}, {35,64,13}, {35,63,0}, {36,60,1}, {36,69,0}, {37,60,0}, {37,63,0}, {37,58,0}, {37,59,6}, {37,60,15}, {37,63,0}, {38,69,21}, {38,59,2}, {38,60,0}, {38,60,0}, {38,62,3}, {38,64,1}, {38,66,0}, {38,66,11}, {38,60,1}, {38,67,5}, {39,66,0}, {39,63,0}, {39,67,0}, {39,58,0}, {39,59,2}, {39,63,4}, {40,58,2}, {40,58,0}, {40,65,0}, {41,60,23}, {41,64,0}, {41,67,0}, {41,58,0}, {41,59,8}, {41,59,0}, {41,64,0}, {41,69,8}, {41,65,0}, {41,65,0}, {42,69,1}, {42,59,0}, {42,58,0}, {42,60,1}, {42,59,2}, {42,61,4}, {42,62,20}, {42,65,0}, {42,63,1}, {43,58,52}, {43,59,2}, {43,64,0}, {43,64,0}, {43,63,14}, {43,64,2}, {43,64,3}, {43,60,0}, {43,63,2}, {43,65,0}, {43,66,4}, {44,64,6}, {44,58,9}, {44,63,19}, {44,61,0}, {44,63,1}, {44,61,0}, {44,67,16}, {45,65,6}, {45,66,0}, {45,67,1}, {45,60,0}, {45,67,0}, {45,59,14}, {45,64,0}, {45,68,0}, {45,67,1}, {46,58,2}, {46,69,3}, {46,62,5}, {46,65,20}, {46,62,0}, {46,58,3}, {46,63,0}, {47,63,23}, {47,62,0}, {47,65,0}, {47,61,0}, {47,63,6}, {47,66,0}, {47,67,0}, {47,58,3}, {47,60,4}, {47,68,4}, {47,66,12}, {48,58,11}, {48,58,11}, {48,67,7}, {48,61,8}, {48,62,2}, {48,64,0}, {48,66,0}, {49,63,0}, {49,64,10}, {49,61,1}, {49,62,0}, {49,66,0}, {49,60,1}, {49,62,1}, {49,63,3}, {49,61,0}, {49,67,1}, {50,63,13}, {50,64,0}, {50,59,0}, {50,61,6}, {50,61,0}, {50,63,1}, {50,58,1}, {50,59,2}, {50,61,0}, {50,64,0}, {50,65,4}, {50,66,1}, {51,59,13}, {51,59,3}, {51,64,7}, {51,59,1}, {51,65,0}, {51,66,1}, {52,69,3}, {52,59,2}, {52,62,3}, {52,66,4}, {52,61,0}, {52,63,4}, {52,69,0}, {52,60,4}, {52,60,5}, {52,62,0}, {52,62,1}, {52,64,0}, {52,65,0}, {52,68,0}, {53,58,4}, {53,65,1}, {53,59,3}, {53,60,9}, {53,63,24}, {53,65,12}, {53,58,1}, {53,60,1}, {53,60,2}, {53,61,1}, {53,63,0}, {54,60,11}, {54,65,23}, {54,65,5}, {54,68,7}, {54,59,7}, {54,60,3}, {54,66,0}, {54,67,46}, {54,62,0}, {54,69,7}, {54,63,19}, {54,58,1}, {54,62,0}, {55,63,6}, {55,68,15}, {55,58,1}, {55,58,0}, {55,58,1}, {55,66,18}, {55,66,0}, {55,69,3}, {55,69,22}, {55,67,1}, {56,65,9}, {56,66,3}, {56,60,0}, {56,66,2}, {56,66,1}, {56,67,0}, {56,60,0}, {57,61,5}, {57,62,14}, {57,64,1}, {57,64,9}, {57,69,0}, {57,61,0}, {57,62,0}, {57,63,0}, {57,64,0}, {57,64,0}, {57,67,0}, {58,59,0}, {58,60,3}, {58,61,1}, {58,67,0}, {58,58,0}, {58,58,3}, {58,61,2}, {59,62,35}, {59,60,0}, {59,63,0}, {59,64,1}, {59,64,4}, {59,64,0}, {59,64,7}, {59,67,3}, {60,59,17}, {60,65,0}, {60,61,1}, {60,67,2}, {60,61,25}, {60,64,0}, {61,62,5}, {61,65,0}, {61,68,1}, {61,59,0}, {61,59,0}, {61,64,0}, {61,65,8}, {61,68,0}, {61,59,0}, {62,59,13}, {62,58,0}, {62,65,19}, {62,62,6}, {62,66,0}, {62,66,0}, {62,58,0}, {63,60,1}, {63,61,0}, {63,62,0}, {63,63,0}, {63,63,0}, {63,66,0}, {63,61,9}, {63,61,28}, {64,58,0}, {64,65,22}, {64,66,0}, {64,61,0}, {64,68,0}, {65,58,0}, {65,61,2}, {65,62,22}, {65,66,15}, {65,58,0}, {65,64,0}, {65,67,0}, {65,59,2}, {65,64,0}, {65,67,1}, {66,58,0}, {66,61,13}, {66,58,0}, {66,58,1}, {66,68,0}, {67,64,8}, {67,63,1}, {67,66,0}, {67,66,0}, {67,61,0}, {67,65,0}, {68,67,0}, {68,68,0}, {69,67,8}, {69,60,0}, {69,65,0}, {69,66,0}, {70,58,0}, {70,58,4}, {70,66,14}, {70,67,0}, {70,68,0}, {70,59,8}, {70,63,0}, {71,68,2}, {72,63,0}, {72,58,0}, {72,64,0}, {72,67,3}, {73,62,0}, {73,68,0}, {74,65,3}, {74,63,0}, {75,62,1}, {76,67,0}, {77,65,3}, {78,65,1}, {83,58,2}, }; //4. Survival status (class attribute) //1 = the patient survived 5 years or longer //2 = the patient died within 5 year int y[DATASET_ROWS] = { 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2};
[ "bhasud@ie.deri.local" ]
bhasud@ie.deri.local
36c25ce843328e152c6df6e90d9b97bc0c6b88de
9e668585ada8d94bb7e43f3021e0a014ee7c39f9
/src/main.c
3b38e1c0c20fc2ef13d88da9b1d405b9bee6f46e
[ "Apache-2.0" ]
permissive
Appudo/libxdelta3
00169db7eb8074a79ddc8fdac46fc44f755529be
3237b63c78528c82098e90daefe20197200dbebb
refs/heads/master
2020-12-30T10:23:49.753551
2017-07-31T08:40:01
2017-07-31T08:40:01
66,492,805
0
0
null
null
null
null
UTF-8
C
false
false
781
c
/* xdelta3 - delta compression tools and library * * Copyright (C) 2014 * 543699f52901235482e5b2c38ffc606366c05ce2c371043aecdbeff00215914a source@appudo.com * * 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. */ #define NOT_MAIN 1 #include "xdelta3.c"
[ "pending@appudo.com" ]
pending@appudo.com
c9d17958eb90729425558999cc3f87f6bd69e996
8ff87173dfab346d52b515f9460278411dab8607
/2_23之管道/pipe2_4/pipe3.c
dfe8217c2ead8b5544856fa0d6da2acd6a083a6c
[]
no_license
hj605635529/linux
75b5c59f33eb10089d85bf7e3bbe39c6ecb9088b
d7cfd806b7eafc4bc6da90ead854dea8fdd18107
refs/heads/master
2020-03-20T13:40:19.277655
2018-06-15T08:51:52
2018-06-15T08:51:52
137,462,707
0
0
null
null
null
null
UTF-8
C
false
false
1,309
c
/************************************************************************* > File Name: pipe.c > Author: huangjia > Mail: 605635529@qq.com > Created Time: Wed 22 Feb 2017 11:46:32 PM PST ************************************************************************/ #include<stdio.h> #include<unistd.h> #include<string.h> #include<stdlib.h> //匿名管道 单向的,只能用于有血缘关系的,常用于父子进程。 //5.写端一直写,读端一直不读取,就可以测出管道的大小了。 int main() { int pipefd[2] = {0,0}; if (pipe(pipefd) < 0)//int pipe(int pipefd[2]) 通过调用从pipe中拿出两个管道文件描述符,0表示读,1表示写。 成功的时候返回0,失败的时候返回-1. { perror("pipe"); return 1; } pid_t id = fork(); if(id < 0) { perror("fork"); return 2; } else if (id == 0) {//child -> writer close(pipefd[0]); //关闭读端 const char *msg = "h"; int count = 0; while (1) { write(pipefd[1],msg,strlen(msg)); //往管道中写,所以是pipefd[1], count++; printf("count = %d\n",count); } close(pipefd[1]); //写完关闭写端 exit(0); } else {//father -> read close(pipefd[1]); //关闭写端 while (1) { ; } close(pipefd[0]);//读完,关闭读端 } return 0; }
[ "root@localhost.localdomain" ]
root@localhost.localdomain
f4d0fb17a64fc5c8b6003627496daf5670a0d3e5
c456b05cf1fe1b74c9ac16fad776cd174e566e66
/src/engine/math/vecs/vec4f.h
95c47c792281ae648e8b9750abc2fb19f328e6ae
[]
no_license
Nedusat/MurderEngine
d4a50d7768e12dcdaa2335a0ae24fc1dd268050e
f8d5ddbac21e9e4af93c2539963bcb219d355220
refs/heads/master
2021-05-17T15:53:58.949585
2020-03-28T16:38:51
2020-03-28T16:38:51
null
0
0
null
null
null
null
UTF-8
C
false
false
395
h
#ifndef VEC_4F_H #define VEC_4F_H me::vec4f::vec4f(float x, float y, float z, float w) { this->x = x; this->y = y; this->z = z; this->w = w; } void me::vec4f::add(me::vec4f &vec) { this->x+=vec.x; this->y+=vec.y; this->z+=vec.z; this->w+=vec.w; } void me::vec4f::sub(me::vec4f &vec) { } void me::vec4f::mul(me::vec4f &vec) { } void me::vec4f::div(me::vec4f &vec) { } #endif
[ "spelfanta2@gmail.com" ]
spelfanta2@gmail.com
0327073b230ab402982cb65c6ea22ce78306239b
ace26cc33ebc9fa02199b0627699999adfba2164
/kernel/linux-5.4.152/net/ipv4/ip_vti.mod.c
23466733a14f1eff35f2eebb9d89e295ce13e087
[]
no_license
YJbonobono/linux-design
936d5b9880e2aac4d86c07c3ca6c260d90b3e135
1684b19645bcd523d51fe2d12805d0bbcdea6599
refs/heads/main
2023-08-07T21:55:30.484704
2021-10-12T17:01:04
2021-10-12T17:01:04
413,645,550
0
0
null
2021-10-05T02:34:49
2021-10-05T02:15:12
Shell
UTF-8
C
false
false
2,624
c
#include <linux/build-salt.h> #include <linux/module.h> #include <linux/vermagic.h> #include <linux/compiler.h> BUILD_SALT; MODULE_INFO(vermagic, VERMAGIC_STRING); MODULE_INFO(name, KBUILD_MODNAME); __visible struct module __this_module __section(.gnu.linkonce.this_module) = { .name = KBUILD_MODNAME, .init = init_module, #ifdef CONFIG_MODULE_UNLOAD .exit = cleanup_module, #endif .arch = MODULE_ARCH_INIT, }; MODULE_INFO(intree, "Y"); #ifdef CONFIG_RETPOLINE MODULE_INFO(retpoline, "Y"); #endif static const struct modversion_info ____versions[] __used __section(__versions) = { { 0xf6b02092, "module_layout" }, { 0x6027f55b, "ip_tunnel_get_link_net" }, { 0x68dc74b4, "ip_tunnel_dellink" }, { 0xc5ec3e50, "ip_tunnel_get_iflink" }, { 0xd362bb6, "ip_tunnel_get_stats64" }, { 0xe309304c, "ip_tunnel_change_mtu" }, { 0x7a0e172c, "ip_tunnel_uninit" }, { 0xf06e306f, "rtnl_link_unregister" }, { 0x3d117aa8, "unregister_pernet_device" }, { 0xb803929f, "xfrm4_protocol_deregister" }, { 0x27c733b8, "xfrm4_tunnel_deregister" }, { 0xcd60e37c, "rtnl_link_register" }, { 0xa6822a08, "xfrm4_tunnel_register" }, { 0x9e32247, "xfrm4_protocol_register" }, { 0xcf4b0f2, "register_pernet_device" }, { 0xc5850110, "printk" }, { 0x95e63e22, "ip_tunnel_rcv" }, { 0x2b2e880, "__iptunnel_pull_header" }, { 0xb68bab54, "xfrm_input" }, { 0xa7277679, "__xfrm_policy_check" }, { 0x17193a3a, "__icmp_send" }, { 0x53569707, "this_cpu_off" }, { 0x4a2b1256, "skb_scrub_packet" }, { 0x4db0ba1, "icmp6_send" }, { 0xdf566a59, "__x86_indirect_thunk_r9" }, { 0x47e7fcaa, "__pskb_pull_tail" }, { 0xc34540f0, "ip_route_output_key_hash" }, { 0xfb2b900, "kfree_skb" }, { 0x2ea2c95c, "__x86_indirect_thunk_rax" }, { 0xb0704523, "dst_release" }, { 0x7d7dbcc3, "xfrm_lookup" }, { 0xa290dc85, "ip6_route_output_flags" }, { 0x3b13bffb, "__xfrm_decode_session" }, { 0x32bab770, "ip_tunnel_init_net" }, { 0x51a63c94, "ip_tunnel_delete_nets" }, { 0x11b6a754, "ipv4_update_pmtu" }, { 0x556d02be, "__xfrm_state_destroy" }, { 0x165b145c, "ex_handler_refcount" }, { 0xaf5f9ff4, "ipv4_redirect" }, { 0xc65b49bb, "xfrm_state_lookup" }, { 0x9c9e3fa0, "ip_tunnel_lookup" }, { 0x59b757d9, "ip_tunnel_init" }, { 0x6b10bee1, "_copy_to_user" }, { 0xae108feb, "ip_tunnel_ioctl" }, { 0x13c49cc2, "_copy_from_user" }, { 0xf6661793, "ip_tunnel_setup" }, { 0x32bb3048, "ip_tunnel_newlink" }, { 0xf67a501f, "ip_tunnel_changelink" }, { 0xdecd0b29, "__stack_chk_fail" }, { 0x839e2ef7, "nla_put" }, { 0xbdfb6dbb, "__fentry__" }, }; MODULE_INFO(depends, "ip_tunnel,tunnel4"); MODULE_INFO(srcversion, "E0011F03B3DE39875F93978");
[ "1004anny1@naver.com" ]
1004anny1@naver.com
8c8b80a0dc04ad3f8505761a42a97a2fd27a692c
6099b15457d72898872a708113cc6cae715f050b
/3rdparty/musl/libc-test/src/regression/strverscmp.c
a4daa26a6f4865c722c5d550b21fb7e3afbb3be0
[ "BSD-3-Clause", "LicenseRef-scancode-mit-nagy", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "MIT", "GPL-1.0-or-later", "OpenSSL", "Apache-2.0" ]
permissive
BRMcLaren/openenclave
277d5bd5258ea3d62b25b10db8edd339673776dd
0002b1c22c10bf3de818e5b76d012e02e3b464de
refs/heads/master
2021-07-02T00:03:22.821481
2021-01-26T17:21:13
2021-01-26T17:21:13
226,914,136
1
0
MIT
2021-03-31T21:06:41
2019-12-09T16:16:38
C
UTF-8
C
false
false
785
c
// leading zero handling according to the manual #define _GNU_SOURCE #include <string.h> #include "test.h" #define ASSERT(x) ((x) || (t_error(#x " failed\n"),0)) int main() { ASSERT(strverscmp("", "") == 0); ASSERT(strverscmp("a", "a") == 0); ASSERT(strverscmp("a", "b") < 0); ASSERT(strverscmp("b", "a") > 0); ASSERT(strverscmp("000", "00") < 0); ASSERT(strverscmp("00", "000") > 0); ASSERT(strverscmp("a0", "a") > 0); ASSERT(strverscmp("00", "01") < 0); ASSERT(strverscmp("01", "010") < 0); ASSERT(strverscmp("010", "09") < 0); ASSERT(strverscmp("09", "0") < 0); ASSERT(strverscmp("9", "10") < 0); ASSERT(strverscmp("0a", "0") > 0); ASSERT(strverscmp("foobar-1.1.2", "foobar-1.1.3") < 0); ASSERT(strverscmp("foobar-1.1.2", "foobar-1.01.3") > 0); return t_status; }
[ "jloeser@microsoft.com" ]
jloeser@microsoft.com
c43dee20ad2814f46eb8abc6ccc438a5c6af408c
81f40a39848f12e5b07e958cf2b4fda999cea4b6
/board/board.h
0128ad7a703f0096d7cee6a4d13ff2b19c51b9f1
[]
no_license
yanchunqing2010/rtt-bsp-pandora_wifi_support
a797ea0dccf3d2425aa5a42004e82d39e3636c12
ad66a0a72da8e73186d98e22baedc0cae5bc3df3
refs/heads/master
2020-06-30T08:52:55.151156
2019-08-05T07:59:38
2019-08-05T09:52:16
null
0
0
null
null
null
null
UTF-8
C
false
false
1,686
h
/* * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-11-5 SummerGift first version */ #ifndef __BOARD_H__ #define __BOARD_H__ #include <rtthread.h> #include <stm32l4xx.h> #include "drv_common.h" #include "drv_gpio.h" #ifdef __cplusplus extern "C" { #endif #ifdef __ICCARM__ // Use *.icf ram symbal, to avoid hardcode. extern char __ICFEDIT_region_IRAM1_end__; #define STM32_SRAM_END &__ICFEDIT_region_IRAM1_end__ #else #define STM32_SRAM_SIZE 96 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) #endif #ifdef __CC_ARM extern int Image$$RW_IRAM1$$ZI$$Limit; #define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) #elif __ICCARM__ #pragma section="HEAP" #define HEAP_BEGIN (__segment_end("HEAP")) #else extern int __bss_end; #define HEAP_BEGIN (&__bss_end) #endif #define HEAP_END STM32_SRAM_END #define STM32_SRAM2_SIZE 32 #define STM32_SRAM2_BEGIN (0x10000000u) #define STM32_SRAM2_END (0x10000000 + STM32_SRAM2_SIZE * 1024) #define STM32_SRAM2_HEAP_SIZE ((uint32_t)STM32_SRAM2_END - (uint32_t)STM32_SRAM2_BEGIN) #define STM32_FLASH_START_ADRESS ((uint32_t)0x08000000) #define STM32_FLASH_SIZE (512 * 1024) #define STM32_FLASH_END_ADDRESS ((uint32_t)(STM32_FLASH_START_ADRESS + STM32_FLASH_SIZE)) void SystemClock_Config(void); void SystemClock_MSI_ON(void); void SystemClock_MSI_OFF(void); void SystemClock_80M(void); void SystemClock_24M(void); void SystemClock_2M(void); void SystemClock_ReConfig(uint8_t mode); #ifdef __cplusplus } #endif #endif
[ "sogwyms@gmail.com" ]
sogwyms@gmail.com
95c02d4d64db08fee33a552d2015786cb2d4a6a4
70bdbf7bd66268a66af7169d284fa5821478a486
/easyflash/src/ef_env.c
26830f007ee83a7a85e92ddb745e1d86e798603d
[ "MIT" ]
permissive
pushuang/EasyFlash
83dbfaf79d9639a93ca86ec8b0e3951a078da2ed
9c3000739e1b0ba2b2e01ad2dc39658f2c79bc0c
refs/heads/master
2020-12-31T06:22:51.246572
2015-07-11T02:17:51
2015-07-11T02:17:51
null
0
0
null
null
null
null
UTF-8
C
false
false
21,800
c
/* * This file is part of the EasyFlash Library. * * Copyright (c) 2014, Armink, <armink.ztl@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * 'Software'), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Function: Environment variables operating interface. (normal mode) * Created on: 2014-10-06 */ #include "easyflash.h" #include <string.h> #include <stdlib.h> #ifdef EF_USING_ENV #ifdef EF_ENV_USING_NORMAL_MODE /** * ENV area has 2 sections * 1. System section * It storage ENV parameters. (Units: Word) * 2. Data section * It storage all ENV. Storage format is key=value\0. * All ENV must be 4 bytes alignment. The remaining part must fill '\0'. * * @note Word = 4 Bytes in this file * @note It will has two ENV areas(Area0, Area1) when used power fail safeguard mode. */ /* flash ENV parameters index and size in system section */ enum { /* data section ENV end address index in system section */ ENV_PARAM_INDEX_END_ADDR = 0, #ifdef EF_ENV_USING_PFS_MODE /* saved count for ENV area */ ENV_PARAM_INDEX_SAVED_COUNT, #endif /* data section CRC32 code index in system section */ ENV_PARAM_INDEX_DATA_CRC, /* flash ENV parameters word size */ ENV_PARAM_WORD_SIZE, /* flash ENV parameters byte size */ ENV_PARAM_BYTE_SIZE = ENV_PARAM_WORD_SIZE * 4, }; /* default ENV set, must be initialized by user */ static ef_env const *default_env_set = NULL; /* default ENV set size, must be initialized by user */ static size_t default_env_set_size = NULL; /* flash ENV all section total size */ static size_t env_total_size = NULL; /* ENV RAM cache */ static uint32_t env_cache[EF_USER_SETTING_ENV_SIZE / 4] = { 0 }; /* ENV start address in flash */ static uint32_t env_start_addr = NULL; #ifdef EF_ENV_USING_PFS_MODE /* current load ENV area address */ static uint32_t cur_load_area_addr = NULL; /* next save ENV area address */ static uint32_t next_save_area_addr = NULL; #endif static uint32_t get_env_system_addr(void); static uint32_t get_env_data_addr(void); static uint32_t get_env_end_addr(void); static void set_env_end_addr(uint32_t end_addr); static EfErrCode write_env(const char *key, const char *value); static uint32_t *find_env(const char *key); static EfErrCode del_env(const char *key); static size_t get_env_data_size(void); static EfErrCode create_env(const char *key, const char *value); static uint32_t calc_env_crc(void); static bool env_crc_is_ok(void); /** * Flash ENV initialize. * * @param start_addr ENV start address in flash * @param total_size ENV section total size (@note must be word alignment) * @param erase_min_size the minimum size of flash erasure. it isn't be used in normal mode. * @param default_env default ENV set for user * @param default_env_size default ENV set size * * @note user_size must equal with total_size in normal mode * * @return result */ EfErrCode ef_env_init(uint32_t start_addr, size_t total_size, size_t erase_min_size, ef_env const *default_env, size_t default_env_size) { EfErrCode result = EF_NO_ERR; EF_ASSERT(start_addr); EF_ASSERT(total_size); EF_ASSERT(default_env); EF_ASSERT(default_env_size < total_size); /* must be word alignment for ENV */ EF_ASSERT(total_size % 4 == 0); #ifndef EF_ENV_USING_PFS_MODE /* total_size must be aligned with erase_min_size */ if (EF_USER_SETTING_ENV_SIZE % erase_min_size == 0) { EF_ASSERT(EF_USER_SETTING_ENV_SIZE == total_size); } else { EF_ASSERT((EF_USER_SETTING_ENV_SIZE/erase_min_size + 1)*erase_min_size == total_size); } #else /* total_size must be aligned with erase_min_size */ if (EF_USER_SETTING_ENV_SIZE % erase_min_size == 0) { /* it has double area when used power fail safeguard mode */ EF_ASSERT(2*EF_USER_SETTING_ENV_SIZE == total_size); } else { /* it has double area when used power fail safeguard mode */ EF_ASSERT(2*(EF_USER_SETTING_ENV_SIZE/erase_min_size + 1)*erase_min_size == total_size); } #endif env_start_addr = start_addr; env_total_size = total_size; default_env_set = default_env; default_env_set_size = default_env_size; EF_DEBUG("ENV start address is 0x%08X, size is %d bytes.\n", start_addr, total_size); ef_load_env(); return result; } /** * ENV set default. * * @return result */ EfErrCode ef_env_set_default(void){ EfErrCode result = EF_NO_ERR; size_t i; EF_ASSERT(default_env_set); EF_ASSERT(default_env_set_size); /* lock the ENV cache */ ef_port_env_lock(); /* set environment end address is at data section start address */ set_env_end_addr(get_env_data_addr()); #ifdef EF_ENV_USING_PFS_MODE /* set saved count to default 0 */ env_cache[ENV_PARAM_INDEX_SAVED_COUNT] = 0; #endif /* create default ENV */ for (i = 0; i < default_env_set_size; i++) { create_env(default_env_set[i].key, default_env_set[i].value); } /* unlock the ENV cache */ ef_port_env_unlock(); ef_save_env(); return result; } /** * Get ENV system section start address. * * @return system section start address */ static uint32_t get_env_system_addr(void) { #ifndef EF_ENV_USING_PFS_MODE EF_ASSERT(env_start_addr); return env_start_addr; #else EF_ASSERT(cur_load_area_addr); return cur_load_area_addr; #endif } /** * Get ENV data section start address. * * @return data section start address */ static uint32_t get_env_data_addr(void) { return get_env_system_addr() + ENV_PARAM_BYTE_SIZE; } /** * Get ENV end address. * It's the first word in ENV. * * @return ENV end address */ static uint32_t get_env_end_addr(void) { /* it is the first word */ return env_cache[ENV_PARAM_INDEX_END_ADDR]; } /** * Set ENV end address. * It's the first word in ENV. * * @param end_addr ENV end address */ static void set_env_end_addr(uint32_t end_addr) { env_cache[ENV_PARAM_INDEX_END_ADDR] = end_addr; } /** * Get current ENV data section size. * * @return size */ static size_t get_env_data_size(void) { return get_env_end_addr() - get_env_data_addr(); } /** * Get current ENV section total size. * * @return size */ size_t ef_get_env_total_size(void) { return env_total_size; } /** * Get current ENV already write bytes. * * @return write bytes */ size_t ef_get_env_write_bytes(void) { #ifndef EF_ENV_USING_PFS_MODE return get_env_end_addr() - env_start_addr; #else /* It has two ENV areas(Area0, Area1) on used power fail safeguard mode */ return 2 * (get_env_end_addr() - get_env_system_addr()); #endif } /** * Write an ENV at the end of cache. * * @param key ENV name * @param value ENV value * * @return result */ static EfErrCode write_env(const char *key, const char *value) { EfErrCode result = EF_NO_ERR; size_t ker_len = strlen(key), value_len = strlen(value), env_str_len; char *env_cache_bak = (char *)env_cache; /* calculate ENV storage length, contain '=' and '\0'. */ env_str_len = ker_len + value_len + 2; if (env_str_len % 4 != 0) { env_str_len = (env_str_len / 4 + 1) * 4; } /* check capacity of ENV */ if (env_str_len + get_env_data_size() >= EF_USER_SETTING_ENV_SIZE) { return EF_ENV_FULL; } /* calculate current ENV ram cache end address */ env_cache_bak += get_env_end_addr() - get_env_system_addr(); /* copy key name */ memcpy(env_cache_bak, key, ker_len); env_cache_bak += ker_len; /* copy equal sign */ *env_cache_bak = '='; env_cache_bak++; /* copy value */ memcpy(env_cache_bak, value, value_len); env_cache_bak += value_len; /* fill '\0' for string end sign */ *env_cache_bak = '\0'; env_cache_bak ++; /* fill '\0' for word alignment */ memset(env_cache_bak, 0, env_str_len - (ker_len + value_len + 2)); set_env_end_addr(get_env_end_addr() + env_str_len); return result; } /** * Find ENV. * * @param key ENV name * * @return index of ENV in ram cache */ static uint32_t *find_env(const char *key) { uint32_t *env_cache_addr = NULL; char *env_start, *env_end, *env; size_t key_len = strlen(key), env_len; EF_ASSERT(env_start_addr); if (*key == NULL) { EF_INFO("Flash ENV name must be not empty!\n"); return NULL; } /* from data section start to data section end */ env_start = (char *) ((char *) env_cache + ENV_PARAM_BYTE_SIZE); env_end = (char *) ((char *) env_cache + (get_env_end_addr() - get_env_system_addr())); /* ENV is null */ if (env_start == env_end) { return NULL; } env = env_start; while (env < env_end) { /* the key length must be equal */ if (!strncmp(env, key, key_len) && (env[key_len] == '=')) { env_cache_addr = (uint32_t *) env; break; } else { /* calculate ENV length, contain '\0'. */ env_len = strlen(env) + 1; /* next ENV and word alignment */ if (env_len % 4 == 0) { env += env_len; } else { env += (env_len / 4 + 1) * 4; } } } return env_cache_addr; } /** * If the ENV is not exist, create it. * @see flash_write_env * * @param key ENV name * @param value ENV value * * @return result */ static EfErrCode create_env(const char *key, const char *value) { EfErrCode result = EF_NO_ERR; EF_ASSERT(key); EF_ASSERT(value); if (*key == NULL) { EF_INFO("Flash ENV name must be not empty!\n"); return EF_ENV_NAME_ERR; } if (strchr(key, '=')) { EF_INFO("Flash ENV name can't contain '='.\n"); return EF_ENV_NAME_ERR; } /* find ENV */ if (find_env(key)) { EF_INFO("The name of \"%s\" is already exist.\n", key); return EF_ENV_NAME_EXIST; } /* write ENV at the end of cache */ result = write_env(key, value); return result; } /** * Delete an ENV in cache. * * @param key ENV name * * @return result */ static EfErrCode del_env(const char *key){ EfErrCode result = EF_NO_ERR; char *del_env_str = NULL; size_t del_env_length, remain_env_length; EF_ASSERT(key); if (*key == NULL) { EF_INFO("Flash ENV name must be not NULL!\n"); return EF_ENV_NAME_ERR; } if (strchr(key, '=')) { EF_INFO("Flash ENV name or value can't contain '='.\n"); return EF_ENV_NAME_ERR; } /* find ENV */ del_env_str = (char *) find_env(key); if (!del_env_str) { EF_INFO("Not find \"%s\" in ENV.\n", key); return EF_ENV_NAME_ERR; } del_env_length = strlen(del_env_str); /* '\0' also must be as ENV length */ del_env_length ++; /* the address must multiple of 4 */ if (del_env_length % 4 != 0) { del_env_length = (del_env_length / 4 + 1) * 4; } /* calculate remain ENV length */ remain_env_length = get_env_data_size() - (((uint32_t) del_env_str + del_env_length) - ((uint32_t) env_cache + ENV_PARAM_BYTE_SIZE)); /* remain ENV move forward */ memcpy(del_env_str, del_env_str + del_env_length, remain_env_length); /* reset ENV end address */ set_env_end_addr(get_env_end_addr() - del_env_length); return result; } /** * Set an ENV. If it value is empty, delete it. * If not find it in ENV table, then create it. * * @param key ENV name * @param value ENV value * * @return result */ EfErrCode ef_set_env(const char *key, const char *value) { EfErrCode result = EF_NO_ERR; /* lock the ENV cache */ ef_port_env_lock(); /* if ENV value is empty, delete it */ if (*value == NULL) { result = del_env(key); } else { /* if find this ENV, then delete it and recreate it */ if (find_env(key)) { result = del_env(key); } if (result == EF_NO_ERR) { result = create_env(key, value); } } /* unlock the ENV cache */ ef_port_env_unlock(); return result; } /** * Get an ENV value by key name. * * @param key ENV name * * @return value */ char *ef_get_env(const char *key) { uint32_t *env_cache_addr = NULL; char *value = NULL; /* find ENV */ env_cache_addr = find_env(key); if (env_cache_addr == NULL) { return NULL; } /* get value address */ value = strchr((char *) env_cache_addr, '='); if (value != NULL) { /* the equal sign next character is value */ value++; } return value; } /** * Print ENV. */ void ef_print_env(void) { uint32_t *env_cache_data_addr = env_cache + ENV_PARAM_WORD_SIZE, *env_cache_end_addr = (uint32_t *) (env_cache + ENV_PARAM_WORD_SIZE + get_env_data_size() / 4); uint8_t j; char c; for (; env_cache_data_addr < env_cache_end_addr; env_cache_data_addr += 1) { for (j = 0; j < 4; j++) { c = (*env_cache_data_addr) >> (8 * j); ef_print("%c", c); if (c == NULL) { ef_print("\n"); break; } } } #ifndef EF_ENV_USING_PFS_MODE ef_print("\nENV size: %ld/%ld bytes.\n", ef_get_env_write_bytes(), ef_get_env_total_size()); #else ef_print("\nENV size: %ld/%ld bytes, saved count: %ld, mode: power fail safeguard.\n", ef_get_env_write_bytes(), ef_get_env_total_size(), env_cache[ENV_PARAM_INDEX_SAVED_COUNT]); #endif } /** * Load flash ENV to ram. */ #ifndef EF_ENV_USING_PFS_MODE void ef_load_env(void) { uint32_t *env_cache_bak, env_end_addr; /* read ENV end address from flash */ ef_port_read(get_env_system_addr() + ENV_PARAM_INDEX_END_ADDR * 4, &env_end_addr, 4); /* if ENV is not initialize or flash has dirty data, set default for it */ if ((env_end_addr == 0xFFFFFFFF) || (env_end_addr < env_start_addr) || (env_end_addr > env_start_addr + EF_USER_SETTING_ENV_SIZE)) { ef_env_set_default(); } else { /* set ENV end address */ set_env_end_addr(env_end_addr); env_cache_bak = env_cache + ENV_PARAM_WORD_SIZE; /* read all ENV from flash */ ef_port_read(get_env_data_addr(), env_cache_bak, get_env_data_size()); /* read ENV CRC code from flash */ ef_port_read(get_env_system_addr() + ENV_PARAM_INDEX_DATA_CRC * 4, &env_cache[ENV_PARAM_INDEX_DATA_CRC] , 4); /* if ENV CRC32 check is fault, set default for it */ if (!env_crc_is_ok()) { EF_INFO("Warning: ENV CRC check failed. Set it to default.\n"); ef_env_set_default(); } } } #else void ef_load_env(void) { uint32_t area0_start_address = env_start_addr, area1_start_address = env_start_addr + env_total_size / 2; uint32_t area0_end_addr, area1_end_addr, area0_crc, area1_crc, area0_saved_count, area1_saved_count; bool area0_is_valid = true, area1_is_valid = true; /* read ENV area end address from flash */ ef_port_read(area0_start_address + ENV_PARAM_INDEX_END_ADDR * 4, &area0_end_addr, 4); ef_port_read(area1_start_address + ENV_PARAM_INDEX_END_ADDR * 4, &area1_end_addr, 4); if ((area0_end_addr == 0xFFFFFFFF) || (area0_end_addr < area0_start_address) || (area0_end_addr > area0_start_address + EF_USER_SETTING_ENV_SIZE)) { area0_is_valid = false; } if ((area1_end_addr == 0xFFFFFFFF) || (area1_end_addr < area1_start_address) || (area1_end_addr > area1_start_address + EF_USER_SETTING_ENV_SIZE)) { area1_is_valid = false; } /* check area0 CRC when it is valid */ if (area0_is_valid) { /* read ENV area0 crc32 code from flash */ ef_port_read(area0_start_address + ENV_PARAM_INDEX_DATA_CRC * 4, &area0_crc, 4); /* read ENV from ENV area0 */ ef_port_read(area0_start_address, env_cache, area0_end_addr - area0_start_address); /* current load ENV area address is area0 start address */ cur_load_area_addr = area0_start_address; if (!env_crc_is_ok()) { area0_is_valid = false; } } /* check area1 CRC when it is valid */ if (area1_is_valid) { /* read ENV area1 crc32 code from flash */ ef_port_read(area1_start_address + ENV_PARAM_INDEX_DATA_CRC * 4, &area1_crc, 4); /* read ENV from ENV area1 */ ef_port_read(area1_start_address, env_cache, area1_end_addr - area1_start_address); /* current load ENV area address is area1 start address */ cur_load_area_addr = area1_start_address; if (!env_crc_is_ok()) { area1_is_valid = false; } } /* all ENV area CRC is OK then compare saved count */ if (area0_is_valid && area1_is_valid) { /* read ENV area saved count from flash */ ef_port_read(area0_start_address + ENV_PARAM_INDEX_SAVED_COUNT * 4, &area0_saved_count, 4); ef_port_read(area1_start_address + ENV_PARAM_INDEX_SAVED_COUNT * 4, &area1_saved_count, 4); /* the bigger saved count area is valid */ if ((area0_saved_count > area1_saved_count)||((area0_saved_count == 0)&&(area1_saved_count == 0xFFFFFFFF))) { area1_is_valid = false; } else { area0_is_valid = false; } } if (area0_is_valid) { /* current load ENV area address is area0 start address */ cur_load_area_addr = area0_start_address; /* next save ENV area address is area1 start address */ next_save_area_addr = area1_start_address; /* read all ENV from area0 */ ef_port_read(area0_start_address, env_cache, area0_end_addr - area0_start_address); } else if (area1_is_valid) { /* next save ENV area address is area0 start address */ next_save_area_addr = area0_start_address; } else { /* current load ENV area address is area1 start address */ cur_load_area_addr = area1_start_address; /* next save ENV area address is area0 start address */ next_save_area_addr = area0_start_address; /* set the ENV to default */ ef_env_set_default(); } } #endif /** * Save ENV to flash. */ EfErrCode ef_save_env(void) { EfErrCode result = EF_NO_ERR; uint32_t write_addr, write_size; #ifndef EF_ENV_USING_PFS_MODE write_addr = get_env_system_addr(); write_size = get_env_end_addr() - get_env_system_addr(); /* calculate and cache CRC32 code */ env_cache[ENV_PARAM_INDEX_DATA_CRC] = calc_env_crc(); #else write_addr = next_save_area_addr; write_size = get_env_end_addr() - get_env_system_addr(); /* replace next_save_area_addr with cur_load_area_addr */ next_save_area_addr = cur_load_area_addr; cur_load_area_addr = write_addr; /* change the ENV end address to next save area address */ set_env_end_addr(write_addr + write_size); /* ENV area saved count +1 */ env_cache[ENV_PARAM_INDEX_SAVED_COUNT]++; /* calculate and cache CRC32 code */ env_cache[ENV_PARAM_INDEX_DATA_CRC] = calc_env_crc(); #endif /* erase ENV */ result = ef_port_erase(write_addr, write_size); switch (result) { case EF_NO_ERR: { EF_INFO("Erased ENV OK.\n"); break; } case EF_ERASE_ERR: { EF_INFO("Warning: Erased ENV fault!\n"); /* will return when erase fault */ return result; } } /* write ENV to flash */ result = ef_port_write(write_addr, env_cache, write_size); switch (result) { case EF_NO_ERR: { EF_INFO("Saved ENV OK.\n"); break; } case EF_WRITE_ERR: { EF_INFO("Warning: Saved ENV fault!\n"); break; } } return result; } /** * Calculate the cached ENV CRC32 value. * * @return CRC32 value */ static uint32_t calc_env_crc(void) { uint32_t crc32 = 0; /* Calculate the ENV end address CRC32. The 4 is ENV end address bytes size. */ crc32 = ef_calc_crc32(crc32, &env_cache[ENV_PARAM_INDEX_END_ADDR], 4); #ifdef EF_ENV_USING_PFS_MODE /* Calculate the ENV area saved count CRC32. */ crc32 = ef_calc_crc32(crc32, &env_cache[ENV_PARAM_INDEX_SAVED_COUNT], 4); #endif /* Calculate the all ENV data CRC32. */ crc32 = ef_calc_crc32(crc32, &env_cache[ENV_PARAM_WORD_SIZE], get_env_data_size()); EF_DEBUG("Calculate ENV CRC32 number is 0x%08X.\n", crc32); return crc32; } /** * Check the ENV CRC32 * * @return true is ok */ static bool env_crc_is_ok(void) { if (calc_env_crc() == env_cache[ENV_PARAM_INDEX_DATA_CRC]) { EF_DEBUG("Verify ENV CRC32 result is OK.\n"); return true; } else { return false; } } #endif /* EF_ENV_USING_NORMAL_MODE */ #endif /* EF_USING_ENV */
[ "armink.ztl@gmail.com" ]
armink.ztl@gmail.com
85da5555ff323ffc690c07a6fc7565ae7e2c63e5
d106bab43506c1d7af6ca4697ccfcc1eb614d62a
/mult.c
2a8d422e4d1556b17277c57a49f4d241355aa737
[]
no_license
sagar123agrawal/evenset
dd2b89c7a7ac48ef6cb7953d12dd1de5f9bd391e
655fa7eb52b620f35eef55cac2b7773ebbb1ee2e
refs/heads/master
2020-03-10T16:51:30.005622
2018-05-22T19:33:42
2018-05-22T19:33:42
129,484,634
0
0
null
null
null
null
UTF-8
C
false
false
125
c
#include<stdio.h> void main() { int n,m; scanf("%d%d",&n,&m); if((n*m)%2==0) printf("even"); else printf("odd"); }
[ "noreply@github.com" ]
sagar123agrawal.noreply@github.com
5b79ae81292fbf3ed8c755e0247cfe051853cb89
c8e6dfe5d2d4511f6ba1413b278932a2ab10a9c1
/lib/am335x_sdk/ti/osal/soc/am572x/osal_soc.h
692aff112692d556979e908cd97529b653ed0ee6
[ "MIT" ]
permissive
brandonbraun653/Apollo
61d4a81871ac10b2a2c74c238be817daeee40bb6
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
refs/heads/main
2023-04-08T19:13:45.705310
2021-04-17T22:02:02
2021-04-17T22:02:02
319,139,363
4
0
null
null
null
null
UTF-8
C
false
false
3,121
h
/* * Copyright (c) 2015-2016, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** ============================================================================ * @file osal_soc.h * * @brief SOC specific includes for Osal * * * ============================================================================ */ #ifndef ti_osal_soc_am572x_include #define ti_osal_soc_am572x_include #ifdef __cplusplus extern "C" { #endif #include <stdint.h> #undef TimerP_numTimerDevices #undef TIMERP_ANY_MASK #define TimerP_numTimerDevices ((uint32_t) 16 ) #define TIMERP_ANY_MASK ((uint32_t) 0xFFFF) #define EXTERNAL_CLOCK_KHZ_DEFAULT (24000) #undef TIMERP_TIMER_FREQ_LO #undef TIMERP_TIMER_FREQ_HI #define TIMERP_TIMER_FREQ_LO ((int32_t) 19200000) #define TIMERP_TIMER_FREQ_HI ((int32_t) 0) #if defined (_TMS320C6X) #define TIMERP_AVAILABLE_MASK ((uint32_t)(0x0030)) #elif defined (__TI_ARM_V7M4__) #define TIMERP_AVAILABLE_MASK ((uint32_t)(0x050C)) #else #define TIMERP_AVAILABLE_MASK ((uint32_t)(0xFFFF)) #endif /* Max number of semaphores for NonOs */ #define OSAL_NONOS_MAX_SEMAPHOREP_PER_SOC ((uint32_t) 80U) #define OSAL_NONOS_MAX_HWIP_PER_SOC ((uint32_t) 40U) #define OSAL_NONOS_MAX_TIMERP_PER_SOC (TimerP_numTimerDevices) #define OSAL_TIRTOS_MAX_SEMAPHOREP_PER_SOC ((uint32_t) 80U) #define OSAL_TIRTOS_MAX_HWIP_PER_SOC ((uint32_t) 40U) #define OSAL_TIRTOS_MAX_TIMERP_PER_SOC (TimerP_numTimerDevices) #ifdef __cplusplus } #endif #endif /* nothing past this point */
[ "brandonbraun653@gmail.com" ]
brandonbraun653@gmail.com
0525dfa93586b25252d81c5ebc29245084b615f0
46979906b331cc10c7f0f009a158ce0996f14097
/dynchk/libs/libgio-2.0/g_memory_output_stream_get_size.c
a003a5e2b6f1f7f1ef24aac24f56ecd31d5b4690
[]
no_license
mwichmann/lsb-checkers
2f6a9674c9a23e39d69d35e8d2457c7a5b3881dc
1170e4486085731b129cbb060c693e7e6ebca027
refs/heads/master
2020-06-11T00:07:56.105656
2016-12-08T19:30:39
2016-12-08T19:30:39
75,857,254
3
3
null
null
null
null
UTF-8
C
false
false
1,184
c
// Generated by gen_lib.pl #include "../../tests/type_tests.h" #include "../../misc/lsb_output.h" #include "stdlib.h" #include <glib-2.0/gio/giotypes.h> #include <glib-2.0/gio/gmemoryoutputstream.h> #undef g_memory_output_stream_get_size static gsize(*funcptr) (GMemoryOutputStream * ) = 0; extern int __lsb_check_params; gsize g_memory_output_stream_get_size (GMemoryOutputStream * arg0 ) { int reset_flag = __lsb_check_params; gsize ret_value ; __lsb_output(4, "Invoking wrapper for g_memory_output_stream_get_size()"); if(!funcptr) funcptr = dlsym(RTLD_NEXT, "g_memory_output_stream_get_size"); if(!funcptr) { __lsb_output(-1, "Failed to load g_memory_output_stream_get_size. Probably the library was loaded using dlopen, we don't support this at the moment."); exit(1); } if(__lsb_check_params) { __lsb_check_params=0; __lsb_output(4, "g_memory_output_stream_get_size() - validating"); if( arg0 ) { validate_RWaddress( arg0, "g_memory_output_stream_get_size - arg0 (ostream)"); } validate_NULL_TYPETYPE( arg0, "g_memory_output_stream_get_size - arg0 (ostream)"); } ret_value = funcptr(arg0); __lsb_check_params = reset_flag; return ret_value; }
[ "mats@linuxfoundation.org" ]
mats@linuxfoundation.org
ba0a575b5edbeddb494fe6e53def3cb178178c5e
8099bbef8b4dcf25798029959fb90044b167ebec
/unit7/exer6.c
e2019c0c2037e9d1b03ee6a93d9dbe6f83fdd290
[]
no_license
ILoveFryingPan/LearnCPrimerPlus
3ffddf723ddc240fe7c023326f4e5f12ced9d26f
2abe7fea84a7c1e70fe7de02d24663d4dccb622f
refs/heads/master
2023-06-29T09:32:04.024962
2021-07-21T08:40:11
2021-07-21T08:40:11
296,826,304
0
0
null
null
null
null
UTF-8
C
false
false
262
c
/*第七章 编程练习 第六题*/ #include<stdio.h> int main(void) { char ch, lastch = '\0'; int count = 0; while((ch = getchar()) != '#') { if(lastch == 'e' && ch == 'i') count++; lastch = ch; } printf("the time is %d.\n", count); return 0; }
[ "2669206166@qq.com" ]
2669206166@qq.com
6dd1fb32dd9e55218dbce685bd694fac8f7b4956
70236f3b5ad523952572810c5d85a66276773603
/代码阅读方法与实践/随书光盘/XFree86-3.3/xc/config/util/mkdirhier.c
02a7fbb3ee8805fe91a3dfe9a7935dffef5704a5
[]
no_license
near2see/read-book-notes
adc0878d614ca163334fa8c7c26d64c260c0c836
f10a0e40520f518cd6852e8f6fd497d763b277f9
refs/heads/master
2020-09-28T15:37:25.344285
2019-10-18T01:05:36
2019-10-18T01:05:36
null
0
0
null
null
null
null
UTF-8
C
false
false
2,179
c
/* $XConsortium: mkdirhier.c /main/1 1996/11/13 14:43:34 lehors $ */ /* Copyright (C) 1996 X Consortium 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 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 X CONSORTIUM 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. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ /* * Simple mkdirhier program for Windows NT */ #include <sys/types.h> #include <sys/stat.h> #include <direct.h> #include <stdlib.h> #include <string.h> char * next_sep(char *path) { while (*path) if (*path == '/' || *path == '\\') return path; else path++; return NULL; } int main(int argc, char *argv[]) { char *dirname, *next, *prev; char buf[1024]; struct _stat sb; if (argc < 2) exit(1); dirname = argv[1]; prev = dirname; while (next = next_sep(prev)) { strncpy(buf, dirname, next - dirname); buf[next - dirname] = '\0'; /* if parent dir doesn't exist yet create it */ if (_stat(buf, &sb)) _mkdir(buf); /* no error checking to avoid barfing on C: */ prev = next + 1; } if (!_mkdir(dirname)) { perror("mkdirhier failed"); exit(1); } exit(0); }
[ "collinxz@163.com" ]
collinxz@163.com
ec8ac44711e20e0ea35012774cb79c45ac3a03e2
25ba673dae94a65d02989d8b72aa4ebda00b0652
/예제3-7.c
e1cd08870dab16e56c6c30d992f4a26e68cdf3f6
[]
no_license
mykid7/C
3c72d2414ba4a9ae889d57702468ccbfea19796a
23d1de46d313521a53cb957014f492e3165cff17
refs/heads/master
2020-07-21T16:58:10.378238
2019-11-10T15:20:47
2019-11-10T15:20:47
206,925,648
0
0
null
null
null
null
UTF-8
C
false
false
389
c
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> // 문자열을 다룰 수 있는 string.h 헤더 파일 포함 int main() { char fruit[20] = "strawberry"; // strawberry로 초기화 printf("%s\n", fruit); // strawberry 출력 strcpy(fruit, "banana"); // fruit에 banana 복사 printf("%s\n", fruit); // banana 출력 return 0; }
[ "noreply@github.com" ]
mykid7.noreply@github.com
cb77cadd8d9210b2243a62b07e3ad07a746b1e67
85fa095a971560cbf86cf03fdf47d5a19599ae6b
/src/pager.c
f8f6f3047093e20260ae47702b1697120d337d66
[]
no_license
moon-chilled/nethackbrass
aa8572ad04dc4700441686147d5efff1542c2afa
8268d4cf7a11bfd38fea5f783be1cbb49170cef4
refs/heads/master
2021-06-13T10:24:27.619676
2017-03-10T17:20:32
2017-03-10T17:20:32
null
0
0
null
null
null
null
UTF-8
C
false
false
28,249
c
/* SCCS Id: @(#)pager.c 3.4 2003/08/13 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ /* This file contains the command routines dowhatis() and dohelp() and */ /* a few other help related facilities */ #include "hack.h" #include "dlb.h" STATIC_DCL boolean FDECL(is_swallow_sym, (int)); STATIC_DCL int FDECL(append_str, (char *, const char *)); STATIC_DCL struct permonst * FDECL(lookat, (int, int, char *, char *)); STATIC_DCL void FDECL(checkfile, (char *,struct permonst *,BOOLEAN_P,BOOLEAN_P)); STATIC_DCL int FDECL(do_look, (BOOLEAN_P)); STATIC_DCL boolean FDECL(help_menu, (int *)); #ifdef PORT_HELP extern void NDECL(port_help); #endif /* Returns "true" for characters that could represent a monster's stomach. */ STATIC_OVL boolean is_swallow_sym(c) int c; { int i; for (i = S_sw_tl; i <= S_sw_br; i++) if ((int)showsyms[i] == c) return TRUE; return FALSE; } /* * Append new_str to the end of buf if new_str doesn't already exist as * a substring of buf. Return 1 if the string was appended, 0 otherwise. * It is expected that buf is of size BUFSZ. */ STATIC_OVL int append_str(buf, new_str) char *buf; const char *new_str; { int space_left; /* space remaining in buf */ if (strstri(buf, new_str)) return 0; space_left = BUFSZ - strlen(buf) - 1; (void) strncat(buf, " or ", space_left); (void) strncat(buf, new_str, space_left - 4); return 1; } /* * Return the name of the glyph found at (x,y). * If not hallucinating and the glyph is a monster, also monster data. */ STATIC_OVL struct permonst * lookat(x, y, buf, monbuf) int x, y; char *buf, *monbuf; { register struct monst *mtmp = (struct monst *) 0; struct permonst *pm = (struct permonst *) 0; int glyph; buf[0] = monbuf[0] = 0; glyph = glyph_at(x,y); if (u.ux == x && u.uy == y && senseself()) { char race[QBUFSZ]; /* if not polymorphed, show both the role and the race */ race[0] = 0; if (!Upolyd) { Sprintf(race, "%s ", urace.adj); } Sprintf(buf, "%s%s%s called %s", Invis ? "invisible " : "", race, mons[u.umonnum].mname, plname); /* file lookup can't distinguish between "gnomish wizard" monster and correspondingly named player character, always picking the former; force it to find the general "wizard" entry instead */ if (Role_if(PM_WIZARD) && Race_if(PM_GNOME) && !Upolyd) pm = &mons[PM_WIZARD]; #ifdef STEED if (u.usteed) { char steedbuf[BUFSZ]; Sprintf(steedbuf, ", mounted on %s", y_monnam(u.usteed)); /* assert((sizeof buf >= strlen(buf)+strlen(steedbuf)+1); */ Strcat(buf, steedbuf); } #endif /* When you see yourself normally, no explanation is appended (even if you could also see yourself via other means). Sensing self while blind or swallowed is treated as if it were by normal vision (cf canseeself()). */ if ((Invisible || u.uundetected) && !Blind && !u.uswallow) { unsigned how = 0; if (Infravision) how |= 1; if (Unblind_telepat) how |= 2; if (Detect_monsters) how |= 4; if (how) Sprintf(eos(buf), " [seen: %s%s%s%s%s]", (how & 1) ? "infravision" : "", /* add comma if telep and infrav */ ((how & 3) > 2) ? ", " : "", (how & 2) ? "telepathy" : "", /* add comma if detect and (infrav or telep or both) */ ((how & 7) > 4) ? ", " : "", (how & 4) ? "monster detection" : ""); } } else if (u.uswallow) { /* all locations when swallowed other than the hero are the monster */ Sprintf(buf, "interior of %s", Blind ? "a monster" : a_monnam(u.ustuck)); pm = u.ustuck->data; } else if (glyph_is_monster(glyph)) { bhitpos.x = x; bhitpos.y = y; mtmp = m_at(x,y); if (mtmp != (struct monst *) 0) { char *name, monnambuf[BUFSZ]; boolean accurate = !Hallucination; #ifdef MONSTEED if (accurate) mtmp = mrider_or_msteed(mtmp, !canspotmon(mtmp)); #endif /*MONSTEED*/ if (mtmp->data == &mons[PM_COYOTE] && accurate) name = coyotename(mtmp, monnambuf); else name = distant_monnam(mtmp, ARTICLE_NONE, monnambuf); pm = mtmp->data; Sprintf(buf, "%s%s%s", (mtmp->mx != x || mtmp->my != y) ? ((mtmp->isshk && accurate) ? "tail of " : "tail of a ") : "", (mtmp->mtame && accurate) ? "tame " : (mtmp->mpeaceful && accurate) ? "peaceful " : "", name); #ifdef MONSTEED if (mtmp->mriding) Sprintf(eos(buf), " riding on %s", canspotmon(mtmp->mchild) ? x_monnam(mtmp->mchild, ARTICLE_A, (char *)0, SUPPRESS_SADDLE, TRUE) : something); #endif /*MONSTEED*/ if (u.ustuck == mtmp) Strcat(buf, (Upolyd && sticks(youmonst.data)) ? ", being held" : ", holding you"); if (mtmp->mleashed) Strcat(buf, ", leashed to you"); if (mtmp->mtrapped && cansee(mtmp->mx, mtmp->my)) { struct trap *t = t_at(mtmp->mx, mtmp->my); int tt = t ? t->ttyp : NO_TRAP; /* newsym lets you know of the trap, so mention it here */ if (tt == BEAR_TRAP || tt == PIT || tt == SPIKED_PIT || tt == WEB) Sprintf(eos(buf), ", trapped in %s", an(defsyms[trap_to_defsym(tt)].explanation)); } { int ways_seen = 0, normal = 0, xraydist; boolean useemon = (boolean) canseemon(mtmp); xraydist = (u.xray_range<0) ? -1 : u.xray_range * u.xray_range; /* normal vision */ if ((mtmp->wormno ? worm_known(mtmp) : cansee(mtmp->mx, mtmp->my)) && mon_visible(mtmp) && !mtmp->minvis) { ways_seen++; normal++; } /* see invisible */ if (useemon && mtmp->minvis) ways_seen++; /* infravision */ if ((!mtmp->minvis || See_invisible) && see_with_infrared(mtmp)) ways_seen++; /* telepathy */ if (tp_sensemon(mtmp)) ways_seen++; /* xray */ if (useemon && xraydist > 0 && distu(mtmp->mx, mtmp->my) <= xraydist) ways_seen++; if (Detect_monsters) ways_seen++; if (MATCH_WARN_OF_MON(mtmp)) ways_seen++; if (ways_seen > 1 || !normal) { if (normal) { Strcat(monbuf, "normal vision"); /* can't actually be 1 yet here */ if (ways_seen-- > 1) Strcat(monbuf, ", "); } if (useemon && mtmp->minvis) { Strcat(monbuf, "see invisible"); if (ways_seen-- > 1) Strcat(monbuf, ", "); } if ((!mtmp->minvis || See_invisible) && see_with_infrared(mtmp)) { Strcat(monbuf, "infravision"); if (ways_seen-- > 1) Strcat(monbuf, ", "); } if (tp_sensemon(mtmp)) { Strcat(monbuf, "telepathy"); if (ways_seen-- > 1) Strcat(monbuf, ", "); } if (useemon && xraydist > 0 && distu(mtmp->mx, mtmp->my) <= xraydist) { /* Eyes of the Overworld */ Strcat(monbuf, "astral vision"); if (ways_seen-- > 1) Strcat(monbuf, ", "); } if (Detect_monsters) { Strcat(monbuf, "monster detection"); if (ways_seen-- > 1) Strcat(monbuf, ", "); } if (MATCH_WARN_OF_MON(mtmp)) { char wbuf[BUFSZ]; if (Hallucination) Strcat(monbuf, "paranoid delusion"); else { Sprintf(wbuf, "warned of %s", makeplural(mtmp->data->mname)); Strcat(monbuf, wbuf); } if (ways_seen-- > 1) Strcat(monbuf, ", "); } } } } } else if (glyph_is_object(glyph)) { struct obj *otmp = vobj_at(x,y); if (!otmp || otmp->otyp != glyph_to_obj(glyph)) { if (glyph_to_obj(glyph) != STRANGE_OBJECT) { otmp = mksobj(glyph_to_obj(glyph), FALSE, FALSE); if (otmp->oclass == COIN_CLASS) otmp->quan = 2L; /* to force pluralization */ else if (otmp->otyp == SLIME_MOLD) otmp->spe = current_fruit; /* give the fruit a type */ Strcpy(buf, distant_name(otmp, xname)); dealloc_obj(otmp); } } else Strcpy(buf, distant_name(otmp, xname)); if (levl[x][y].typ == STONE || levl[x][y].typ == SCORR) Strcat(buf, " embedded in stone"); else if (IS_WALL(levl[x][y].typ) || levl[x][y].typ == SDOOR) Strcat(buf, " embedded in a wall"); else if (closed_door(x,y)) Strcat(buf, " embedded in a door"); else if (is_pool(x,y)) Strcat(buf, " in water"); else if (is_lava(x,y)) Strcat(buf, " in molten lava"); /* [can this ever happen?] */ } else if (glyph_is_trap(glyph)) { int tnum = what_trap(glyph_to_trap(glyph)); Strcpy(buf, defsyms[trap_to_defsym(tnum)].explanation); } else if (glyph_is_warning(glyph)) { Strcpy(buf, def_warnsyms[glyph - GLYPH_WARNING_OFF].explanation); } else if(!glyph_is_cmap(glyph)) { Strcpy(buf,"dark part of a room"); } else switch(glyph_to_cmap(glyph)) { case S_altar: if(!In_endgame(&u.uz)) Sprintf(buf, "%s altar", align_str(Amask2align(levl[x][y].altarmask & ~AM_SHRINE))); else Sprintf(buf, "aligned altar"); break; case S_ndoor: if (is_drawbridge_wall(x, y) >= 0) Strcpy(buf,"open drawbridge portcullis"); else if ((levl[x][y].doormask & ~D_TRAPPED) == D_BROKEN) Strcpy(buf,"broken door"); else Strcpy(buf,"doorway"); break; case S_cloud: Strcpy(buf, Is_airlevel(&u.uz) ? "cloudy area" : "fog/vapor cloud"); break; default: Strcpy(buf,defsyms[glyph_to_cmap(glyph)].explanation); break; } return ((pm && !Hallucination) ? pm : (struct permonst *) 0); } /* * Look in the "data" file for more info. Called if the user typed in the * whole name (user_typed_name == TRUE), or we've found a possible match * with a character/glyph and flags.help is TRUE. * * NOTE: when (user_typed_name == FALSE), inp is considered read-only and * must not be changed directly, e.g. via lcase(). We want to force * lcase() for data.base lookup so that we can have a clean key. * Therefore, we create a copy of inp _just_ for data.base lookup. */ STATIC_OVL void checkfile(inp, pm, user_typed_name, without_asking) char *inp; struct permonst *pm; boolean user_typed_name, without_asking; { dlb *fp; char buf[BUFSZ], newstr[BUFSZ]; char *ep, *dbase_str; long txt_offset; int chk_skip; boolean found_in_file = FALSE, skipping_entry = FALSE; fp = dlb_fopen(DATAFILE, "r"); if (!fp) { pline("Cannot open data file!"); return; } /* To prevent the need for entries in data.base like *ngel to account * for Angel and angel, make the lookup string the same for both * user_typed_name and picked name. */ if (pm != (struct permonst *) 0 && !user_typed_name) dbase_str = strcpy(newstr, pm->mname); else dbase_str = strcpy(newstr, inp); (void) lcase(dbase_str); if (!strncmp(dbase_str, "interior of ", 12)) dbase_str += 12; if (!strncmp(dbase_str, "a ", 2)) dbase_str += 2; else if (!strncmp(dbase_str, "an ", 3)) dbase_str += 3; else if (!strncmp(dbase_str, "the ", 4)) dbase_str += 4; if (!strncmp(dbase_str, "tame ", 5)) dbase_str += 5; else if (!strncmp(dbase_str, "peaceful ", 9)) dbase_str += 9; if (!strncmp(dbase_str, "invisible ", 10)) dbase_str += 10; if (!strncmp(dbase_str, "statue of ", 10)) dbase_str[6] = '\0'; else if (!strncmp(dbase_str, "figurine of ", 12)) dbase_str[8] = '\0'; /* Make sure the name is non-empty. */ if (*dbase_str) { /* adjust the input to remove "named " and convert to lower case */ char *alt = 0; /* alternate description */ if ((ep = strstri(dbase_str, " named ")) != 0) alt = ep + 7; else ep = strstri(dbase_str, " called "); if (!ep) ep = strstri(dbase_str, ", "); if (ep && ep > dbase_str) *ep = '\0'; /* * If the object is named, then the name is the alternate description; * otherwise, the result of makesingular() applied to the name is. This * isn't strictly optimal, but named objects of interest to the user * will usually be found under their name, rather than under their * object type, so looking for a singular form is pointless. */ if (!alt) alt = makesingular(dbase_str); else if (user_typed_name) (void) lcase(alt); /* skip first record; read second */ txt_offset = 0L; if (!dlb_fgets(buf, BUFSZ, fp) || !dlb_fgets(buf, BUFSZ, fp)) { impossible("can't read 'data' file"); (void) dlb_fclose(fp); return; } else if (sscanf(buf, "%8lx\n", &txt_offset) < 1 || txt_offset <= 0) goto bad_data_file; /* look for the appropriate entry */ while (dlb_fgets(buf,BUFSZ,fp)) { if (*buf == '.') break; /* we passed last entry without success */ if (digit(*buf)) { /* a number indicates the end of current entry */ skipping_entry = FALSE; } else if (!skipping_entry) { if (!(ep = index(buf, '\n'))) goto bad_data_file; *ep = 0; /* if we match a key that begins with "~", skip this entry */ chk_skip = (*buf == '~') ? 1 : 0; if (pmatch(&buf[chk_skip], dbase_str) || (alt && pmatch(&buf[chk_skip], alt))) { if (chk_skip) { skipping_entry = TRUE; continue; } else { found_in_file = TRUE; break; } } } } } if(found_in_file) { long entry_offset; int entry_count; int i; /* skip over other possible matches for the info */ do { if (!dlb_fgets(buf, BUFSZ, fp)) goto bad_data_file; } while (!digit(*buf)); if (sscanf(buf, "%ld,%d\n", &entry_offset, &entry_count) < 2) { bad_data_file: impossible("'data' file in wrong format"); (void) dlb_fclose(fp); return; } if (user_typed_name || without_asking || yn("More info?") == 'y') { winid datawin; if (dlb_fseek(fp, txt_offset + entry_offset, SEEK_SET) < 0) { pline("? Seek error on 'data' file!"); (void) dlb_fclose(fp); return; } datawin = create_nhwindow(NHW_MENU); for (i = 0; i < entry_count; i++) { if (!dlb_fgets(buf, BUFSZ, fp)) goto bad_data_file; if ((ep = index(buf, '\n')) != 0) *ep = 0; if (index(buf+1, '\t') != 0) (void) tabexpand(buf+1); putstr(datawin, 0, buf+1); } display_nhwindow(datawin, FALSE); destroy_nhwindow(datawin); } } else if (user_typed_name) pline("I don't have any information on those things."); (void) dlb_fclose(fp); } /* getpos() return values */ #define LOOK_TRADITIONAL 0 /* '.' -- ask about "more info?" */ #define LOOK_QUICK 1 /* ',' -- skip "more info?" */ #define LOOK_ONCE 2 /* ';' -- skip and stop looping */ #define LOOK_VERBOSE 3 /* ':' -- show more info w/o asking */ /* also used by getpos hack in do_name.c */ const char what_is_an_unknown_object[] = "an unknown object"; STATIC_OVL int do_look(quick) boolean quick; /* use cursor && don't search for "more info" */ { char out_str[BUFSZ], look_buf[BUFSZ]; const char *x_str, *firstmatch = 0; struct permonst *pm = 0; int i, ans = 0; int sym; /* typed symbol or converted glyph */ int found; /* count of matching syms found */ coord cc; /* screen pos of unknown glyph */ boolean save_verbose; /* saved value of flags.verbose */ boolean from_screen; /* question from the screen */ boolean need_to_look; /* need to get explan. from glyph */ boolean hit_trap; /* true if found trap explanation */ int skipped_venom; /* non-zero if we ignored "splash of venom" */ static const char *mon_interior = "the interior of a monster"; if (quick) { from_screen = TRUE; /* yes, we want to use the cursor */ } else { i = ynq("Specify unknown object by cursor?"); if (i == 'q') return 0; from_screen = (i == 'y'); } if (from_screen) { cc.x = u.ux; cc.y = u.uy; sym = 0; /* gcc -Wall lint */ } else { getlin("Specify what? (type the word)", out_str); if (out_str[0] == '\0' || out_str[0] == '\033') return 0; if (out_str[1]) { /* user typed in a complete string */ checkfile(out_str, pm, TRUE, TRUE); return 0; } sym = out_str[0]; } /* Save the verbose flag, we change it later. */ save_verbose = flags.verbose; flags.verbose = flags.verbose && !quick; /* * The user typed one letter, or we're identifying from the screen. */ do { /* Reset some variables. */ need_to_look = FALSE; pm = (struct permonst *)0; skipped_venom = 0; found = 0; out_str[0] = '\0'; if (from_screen) { int glyph; /* glyph at selected position */ if (flags.verbose) pline("Please move the cursor to %s.", what_is_an_unknown_object); else pline("Pick an object."); ans = getpos(&cc, quick, what_is_an_unknown_object); if (ans < 0 || cc.x < 0) { flags.verbose = save_verbose; return 0; /* done */ } flags.verbose = FALSE; /* only print long question once */ /* Convert the glyph at the selected position to a symbol. */ glyph = glyph_at(cc.x,cc.y); if (glyph_is_cmap(glyph)) { sym = showsyms[glyph_to_cmap(glyph)]; } else if (glyph_is_trap(glyph)) { sym = showsyms[trap_to_defsym(glyph_to_trap(glyph))]; } else if (glyph_is_object(glyph)) { sym = oc_syms[(int)objects[glyph_to_obj(glyph)].oc_class]; if (sym == '`' && iflags.bouldersym && (int)glyph_to_obj(glyph) == BOULDER) sym = iflags.bouldersym; } else if (glyph_is_monster(glyph)) { /* takes care of pets, detected, ridden, and regular mons */ sym = monsyms[(int)mons[glyph_to_mon(glyph)].mlet]; } else if (glyph_is_swallow(glyph)) { sym = showsyms[glyph_to_swallow(glyph)+S_sw_tl]; } else if (glyph_is_invisible(glyph)) { sym = DEF_INVISIBLE; } else if (glyph_is_warning(glyph)) { sym = glyph_to_warning(glyph); sym = warnsyms[sym]; } else { impossible("do_look: bad glyph %d at (%d,%d)", glyph, (int)cc.x, (int)cc.y); sym = ' '; } } /* * Check all the possibilities, saving all explanations in a buffer. * When all have been checked then the string is printed. */ /* Check for monsters */ for (i = 0; i < MAXMCLASSES; i++) { if (sym == (from_screen ? monsyms[i] : def_monsyms[i]) && monexplain[i]) { need_to_look = TRUE; if (!found) { Sprintf(out_str, "%c %s", sym, an(monexplain[i])); firstmatch = monexplain[i]; found++; } else { found += append_str(out_str, an(monexplain[i])); } } } /* handle '@' as a special case if it refers to you and you're playing a character which isn't normally displayed by that symbol; firstmatch is assumed to already be set for '@' */ if ((from_screen ? (sym == monsyms[S_HUMAN] && cc.x == u.ux && cc.y == u.uy) : (sym == def_monsyms[S_HUMAN] && !iflags.showrace)) && !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd) found += append_str(out_str, "you"); /* tack on "or you" */ /* * Special case: if identifying from the screen, and we're swallowed, * and looking at something other than our own symbol, then just say * "the interior of a monster". */ if (u.uswallow && from_screen && is_swallow_sym(sym)) { if (!found) { Sprintf(out_str, "%c %s", sym, mon_interior); firstmatch = mon_interior; } else { found += append_str(out_str, mon_interior); } need_to_look = TRUE; } /* Now check for objects */ for (i = 1; i < MAXOCLASSES; i++) { if (sym == (from_screen ? oc_syms[i] : def_oc_syms[i])) { need_to_look = TRUE; if (from_screen && i == VENOM_CLASS) { skipped_venom++; continue; } if (!found) { Sprintf(out_str, "%c %s", sym, an(objexplain[i])); firstmatch = objexplain[i]; found++; } else { found += append_str(out_str, an(objexplain[i])); } } } if (sym == DEF_INVISIBLE) { if (!found) { Sprintf(out_str, "%c %s", sym, an(invisexplain)); firstmatch = invisexplain; found++; } else { found += append_str(out_str, an(invisexplain)); } } #define is_cmap_trap(i) ((i) >= S_arrow_trap && (i) <= S_polymorph_trap) #define is_cmap_drawbridge(i) ((i) >= S_vodbridge && (i) <= S_hcdbridge) /* Now check for graphics symbols */ for (hit_trap = FALSE, i = 0; i < MAXPCHARS; i++) { x_str = defsyms[i].explanation; if (sym == (from_screen ? showsyms[i] : defsyms[i].sym) && *x_str) { /* avoid "an air", "a water", or "a floor of a room" */ int article = (i == S_room) ? 2 : /* 2=>"the" */ !(strcmp(x_str, "air") == 0 || /* 1=>"an" */ strcmp(x_str, "water") == 0); /* 0=>(none)*/ if (!found) { if (is_cmap_trap(i)) { Sprintf(out_str, "%c a trap", sym); hit_trap = TRUE; } else { Sprintf(out_str, "%c %s", sym, article == 2 ? the(x_str) : article == 1 ? an(x_str) : x_str); } firstmatch = x_str; found++; } else if (!u.uswallow && !(hit_trap && is_cmap_trap(i)) && !(found >= 3 && is_cmap_drawbridge(i))) { found += append_str(out_str, article == 2 ? the(x_str) : article == 1 ? an(x_str) : x_str); if (is_cmap_trap(i)) hit_trap = TRUE; } if (i == S_altar || is_cmap_trap(i)) need_to_look = TRUE; } } /* Now check for warning symbols */ for (i = 0; i < WARNCOUNT; i++) { x_str = def_warnsyms[i].explanation; if (sym == (from_screen ? warnsyms[i] : def_warnsyms[i].sym)) { if (!found) { Sprintf(out_str, "%c %s", sym, def_warnsyms[i].explanation); firstmatch = def_warnsyms[i].explanation; found++; } else { found += append_str(out_str, def_warnsyms[i].explanation); } /* Kludge: warning trumps boulders on the display. Reveal the boulder too or player can get confused */ if (from_screen && sobj_at(BOULDER, cc.x, cc.y)) Strcat(out_str, " co-located with a boulder"); break; /* out of for loop*/ } } /* if we ignored venom and list turned out to be short, put it back */ if (skipped_venom && found < 2) { x_str = objexplain[VENOM_CLASS]; if (!found) { Sprintf(out_str, "%c %s", sym, an(x_str)); firstmatch = x_str; found++; } else { found += append_str(out_str, an(x_str)); } } /* handle optional boulder symbol as a special case */ if (iflags.bouldersym && sym == iflags.bouldersym) { x_str = "boulder"; if (!found) { Sprintf(out_str, "%c %s", sym, an(x_str)); firstmatch = x_str; found++; } else { found += append_str(out_str, x_str); } } /* * If we are looking at the screen, follow multiple possibilities or * an ambiguous explanation by something more detailed. */ if (from_screen) { if (found > 1 || need_to_look) { char monbuf[BUFSZ]; char temp_buf[BUFSZ]; pm = lookat(cc.x, cc.y, look_buf, monbuf); firstmatch = look_buf; if (*firstmatch) { Sprintf(temp_buf, " (%s)", firstmatch); (void)strncat(out_str, temp_buf, BUFSZ-strlen(out_str)-1); found = 1; /* we have something to look up */ } if (monbuf[0]) { Sprintf(temp_buf, " [seen: %s]", monbuf); (void)strncat(out_str, temp_buf, BUFSZ-strlen(out_str)-1); } } } /* Finally, print out our explanation. */ if (found) { pline("%s", out_str); /* check the data file for information about this thing */ if (found == 1 && ans != LOOK_QUICK && ans != LOOK_ONCE && (ans == LOOK_VERBOSE || (flags.help && !quick))) { char temp_buf[BUFSZ]; Strcpy(temp_buf, firstmatch); checkfile(temp_buf, pm, FALSE, (boolean)(ans == LOOK_VERBOSE)); } } else { pline("I've never heard of such things."); } } while (from_screen && !quick && ans != LOOK_ONCE); flags.verbose = save_verbose; return 0; } int dowhatis() { return do_look(FALSE); } int doquickwhatis() { struct monst *mtmp; bhitpos.x = bhitpos.y = 0; do_look(TRUE); if (bhitpos.x != 0 && !Hallucination) { mtmp = m_at(bhitpos.x, bhitpos.y); if (mtmp && canseemon(mtmp) && /* keep consistency with display_minventory() */ mon_has_worn_wield_items(mtmp)) { display_minventory(mtmp, MINV_NOLET, (char *)0); } } return 0; } int doidtrap() { register struct trap *trap; int x, y, tt; if (!getdir("^")) return 0; x = u.ux + u.dx; y = u.uy + u.dy; for (trap = ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y) { if (!trap->tseen) break; tt = trap->ttyp; if (u.dz) { if (u.dz < 0 ? (tt == TRAPDOOR || tt == HOLE) : tt == ROCKTRAP) break; } tt = what_trap(tt); pline("That is %s%s%s.", an(defsyms[trap_to_defsym(tt)].explanation), !trap->madeby_u ? "" : (tt == WEB) ? " woven" : /* trap doors & spiked pits can't be made by player, and should be considered at least as much "set" as "dug" anyway */ (tt == HOLE || tt == PIT) ? " dug" : " set", !trap->madeby_u ? "" : " by you"); return 0; } pline("I can't see a trap there."); return 0; } char * dowhatdoes_core(q, cbuf) char q; char *cbuf; { dlb *fp; char bufr[BUFSZ]; register char *buf = &bufr[6], *ep, ctrl, meta; fp = dlb_fopen(CMDHELPFILE, "r"); if (!fp) { pline("Cannot open data file!"); return 0; } ctrl = ((q <= '\033') ? (q - 1 + 'A') : 0); meta = ((0x80 & q) ? (0x7f & q) : 0); while(dlb_fgets(buf,BUFSZ-6,fp)) { if ((ctrl && *buf=='^' && *(buf+1)==ctrl) || (meta && *buf=='M' && *(buf+1)=='-' && *(buf+2)==meta) || *buf==q) { ep = index(buf, '\n'); if(ep) *ep = 0; if (ctrl && buf[2] == '\t'){ buf = bufr + 1; (void) strncpy(buf, "^? ", 8); buf[1] = ctrl; } else if (meta && buf[3] == '\t'){ buf = bufr + 2; (void) strncpy(buf, "M-? ", 8); buf[2] = meta; } else if(buf[1] == '\t'){ buf = bufr; buf[0] = q; (void) strncpy(buf+1, " ", 7); } (void) dlb_fclose(fp); Strcpy(cbuf, buf); return cbuf; } } (void) dlb_fclose(fp); return (char *)0; } int dowhatdoes() { char bufr[BUFSZ]; char q, *reslt; #if defined(UNIX) || defined(VMS) introff(); #endif q = yn_function("What command?", (char *)0, '\0'); #if defined(UNIX) || defined(VMS) intron(); #endif reslt = dowhatdoes_core(q, bufr); if (reslt) pline("%s", reslt); else pline("I've never heard of such commands."); return 0; } /* data for help_menu() */ static const char *help_menu_items[] = { /* 0*/ "Long description of the game and commands.", /* 1*/ "List of game commands.", /* 2*/ "Concise history of NetHack.", /* 3*/ "Info on a character in the game display.", /* 4*/ "Info on what a given key does.", /* 5*/ "List of game options.", /* 6*/ "Longer explanation of game options.", /* 7*/ "List of extended commands.", /* 8*/ "The NetHack license.", #ifdef PORT_HELP "%s-specific help and commands.", #define PORT_HELP_ID 100 #define WIZHLP_SLOT 10 #else #define WIZHLP_SLOT 9 #endif #ifdef WIZARD "List of wizard-mode commands.", #endif "", (char *)0 }; STATIC_OVL boolean help_menu(sel) int *sel; { winid tmpwin = create_nhwindow(NHW_MENU); #ifdef PORT_HELP char helpbuf[QBUFSZ]; #endif int i, n; menu_item *selected; anything any; any.a_void = 0; /* zero all bits */ start_menu(tmpwin); #ifdef WIZARD if (!wizard) help_menu_items[WIZHLP_SLOT] = "", help_menu_items[WIZHLP_SLOT+1] = (char *)0; #endif for (i = 0; help_menu_items[i]; i++) #ifdef PORT_HELP /* port-specific line has a %s in it for the PORT_ID */ if (help_menu_items[i][0] == '%') { Sprintf(helpbuf, help_menu_items[i], PORT_ID); any.a_int = PORT_HELP_ID + 1; add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, helpbuf, MENU_UNSELECTED); } else #endif { any.a_int = (*help_menu_items[i]) ? i+1 : 0; add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, help_menu_items[i], MENU_UNSELECTED); } end_menu(tmpwin, "Select one item:"); n = select_menu(tmpwin, PICK_ONE, &selected); destroy_nhwindow(tmpwin); if (n > 0) { *sel = selected[0].item.a_int - 1; free((genericptr_t)selected); return TRUE; } return FALSE; } int dohelp() { int sel = 0; if (help_menu(&sel)) { switch (sel) { case 0: display_file(HELP, TRUE); break; case 1: display_file(SHELP, TRUE); break; case 2: (void) dohistory(); break; case 3: (void) dowhatis(); break; case 4: (void) dowhatdoes(); break; case 5: option_help(); break; case 6: display_file(OPTIONFILE, TRUE); break; case 7: (void) doextlist(); break; case 8: display_file(LICENSE, TRUE); break; #ifdef WIZARD /* handle slot 9 or 10 */ default: display_file(DEBUGHELP, TRUE); break; #endif #ifdef PORT_HELP case PORT_HELP_ID: port_help(); break; #endif } } return 0; } int dohistory() { display_file(HISTORY, TRUE); return 0; } /*pager.c*/
[ "elronnd@slashem.me" ]
elronnd@slashem.me
a4eae97aaef974bae7019abd99bc8665317fb4f5
3b826329c0197ebe2650f13443c7700c68bcbb09
/includes/i8259A_emu.h
51456ecd58134db44c9b0e55232068707c70dd42
[ "MIT" ]
permissive
vookimedlo/tinyos
1fac59e925b2d09e48b4249ebe95b331d1d3dc71
02c534f2ad4af6d3f44f515eb17bdf3b72c1c7b3
refs/heads/master
2020-04-18T15:54:07.319810
2013-08-06T00:49:02
2013-08-06T00:49:02
null
0
0
null
null
null
null
UTF-8
C
false
false
513
h
#ifndef i8259A_emuH #define i8259A_emuH #include "kernel.h" #include "resource.h" void init_i8259A_emu(void); /* 0x20 */ void i8259A_master_out_port_A(BYTE value); BYTE i8259A_master_in_port_A(void); /* 0x21 */ void i8259A_master_out_port_B(BYTE value); BYTE i8259A_master_in_port_B(void); /* 0xA0 */ void i8259A_slave_out_port_A(BYTE value); BYTE i8259A_slave_in_port_A(void); /* 0xA1 */ void i8259A_slave_out_port_B(BYTE value); BYTE i8259A_slave_in_port_B(void); #endif
[ "kazushi@rvm.jp" ]
kazushi@rvm.jp
4fd05af13127131a437d5c10236c02db50e9b163
cdd8a53dd491e2cbc61aa5c87ed142c495626780
/segel.c
42321814081d578683d207da088561e2f0781505
[]
no_license
assaflovton/234123-OperatingSystemsHW3
955a2848d2ece0e18eed5b72c70bf0089b029580
c7c95ef9975f152362738295d452fc0ee8e36ad0
refs/heads/main
2023-08-04T15:50:06.984861
2021-09-11T19:39:45
2021-09-11T19:39:45
405,467,902
0
1
null
null
null
null
UTF-8
C
false
false
13,644
c
#include "segel.h" /************************** * Error-handling functions **************************/ /* $begin errorfuns */ /* $begin unixerror */ void unix_error(char *msg) /* unix-style error */ { fprintf(stderr, "%s: %s\n", msg, strerror(errno)); exit(0); } /* $end unixerror */ void posix_error(int code, char *msg) /* posix-style error */ { fprintf(stderr, "%s: %s\n", msg, strerror(code)); exit(0); } void dns_error(char *msg) /* dns-style error */ { fprintf(stderr, "%s: DNS error %d\n", msg, h_errno); exit(0); } void app_error(char *msg) /* application error */ { fprintf(stderr, "%s\n", msg); exit(0); } /* $end errorfuns */ int Gethostname(char *name, size_t len) { int rc; if ((rc = gethostname(name, len)) < 0) unix_error("Setenv error"); return rc; } int Setenv(const char *name, const char *value, int overwrite) { int rc; if ((rc = setenv(name, value, overwrite)) < 0) unix_error("Setenv error"); return rc; } /********************************************* * Wrappers for Unix process control functions ********************************************/ /* $begin forkwrapper */ pid_t Fork(void) { pid_t pid; if ((pid = fork()) < 0) unix_error("Fork error"); return pid; } /* $end forkwrapper */ void Execve(const char *filename, char *const argv[], char *const envp[]) { if (execve(filename, argv, envp) < 0) unix_error("Execve error"); } /* $begin wait */ pid_t Wait(int *status) { pid_t pid; if ((pid = wait(status)) < 0) unix_error("Wait error"); return pid; } /* $end wait */ pid_t WaitPid(pid_t pid,int* status,int options) { if ((pid = waitpid(pid,status,options)) < 0) unix_error("Wait error"); return pid; } /******************************** * Wrappers for Unix I/O routines ********************************/ int Open(const char *pathname, int flags, mode_t mode) { int rc; if ((rc = open(pathname, flags, mode)) < 0) unix_error("Open error"); return rc; } ssize_t Read(int fd, void *buf, size_t count) { ssize_t rc; if ((rc = read(fd, buf, count)) < 0) unix_error("Read error"); return rc; } ssize_t Write(int fd, const void *buf, size_t count) { ssize_t rc; if ((rc = write(fd, buf, count)) < 0) unix_error("Write error"); return rc; } off_t Lseek(int fildes, off_t offset, int whence) { off_t rc; if ((rc = lseek(fildes, offset, whence)) < 0) unix_error("Lseek error"); return rc; } void Close(int fd) { int rc; if ((rc = close(fd)) < 0) unix_error("Close error"); } int Select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { int rc; if ((rc = select(n, readfds, writefds, exceptfds, timeout)) < 0) unix_error("Select error"); return rc; } int Dup2(int fd1, int fd2) { int rc; if ((rc = dup2(fd1, fd2)) < 0) unix_error("Dup2 error"); return rc; } void Stat(const char *filename, struct stat *buf) { if (stat(filename, buf) < 0) unix_error("Stat error"); } void Fstat(int fd, struct stat *buf) { if (fstat(fd, buf) < 0) unix_error("Fstat error"); } /*************************************** * Wrappers for memory mapping functions ***************************************/ void *Mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) { void *ptr; if ((ptr = mmap(addr, len, prot, flags, fd, offset)) == ((void *) -1)) unix_error("mmap error"); return(ptr); } void Munmap(void *start, size_t length) { if (munmap(start, length) < 0) unix_error("munmap error"); } /**************************** * Sockets interface wrappers ****************************/ int Socket(int domain, int type, int protocol) { int rc; if ((rc = socket(domain, type, protocol)) < 0) unix_error("Socket error"); return rc; } void Setsockopt(int s, int level, int optname, const void *optval, int optlen) { int rc; if ((rc = setsockopt(s, level, optname, optval, optlen)) < 0) unix_error("Setsockopt error"); } void Bind(int sockfd, struct sockaddr *my_addr, int addrlen) { int rc; if ((rc = bind(sockfd, my_addr, addrlen)) < 0) unix_error("Bind error"); } void Listen(int s, int backlog) { int rc; if ((rc = listen(s, backlog)) < 0) unix_error("Listen error"); } int Accept(int s, struct sockaddr *addr, socklen_t *addrlen) { int rc; if ((rc = accept(s, addr, addrlen)) < 0) unix_error("Accept error"); return rc; } void Connect(int sockfd, struct sockaddr *serv_addr, int addrlen) { int rc; if ((rc = connect(sockfd, serv_addr, addrlen)) < 0) unix_error("Connect error"); } /************************ * DNS interface wrappers ***********************/ /* $begin gethostbyname */ struct hostent *Gethostbyname(const char *name) { struct hostent *p; if ((p = gethostbyname(name)) == NULL) dns_error("Gethostbyname error"); return p; } /* $end gethostbyname */ struct hostent *Gethostbyaddr(const char *addr, int len, int type) { struct hostent *p; if ((p = gethostbyaddr(addr, len, type)) == NULL) dns_error("Gethostbyaddr error"); return p; } /********************************************************************* * The Rio package - robust I/O functions **********************************************************************/ /* * rio_readn - robustly read n bytes (unbuffered) */ /* $begin rio_readn */ ssize_t rio_readn(int fd, void *usrbuf, size_t n) { size_t nleft = n; ssize_t nread; char *bufp = usrbuf; while (nleft > 0) { if ((nread = read(fd, bufp, nleft)) < 0) { if (errno == EINTR) /* interrupted by sig handler return */ nread = 0; /* and call read() again */ else return -1; /* errno set by read() */ } else if (nread == 0) break; /* EOF */ nleft -= nread; bufp += nread; } return (n - nleft); /* return >= 0 */ } /* $end rio_readn */ /* * rio_writen - robustly write n bytes (unbuffered) */ /* $begin rio_writen */ ssize_t rio_writen(int fd, void *usrbuf, size_t n) { size_t nleft = n; ssize_t nwritten; char *bufp = usrbuf; while (nleft > 0) { if ((nwritten = write(fd, bufp, nleft)) <= 0) { if (errno == EINTR) /* interrupted by sig handler return */ nwritten = 0; /* and call write() again */ else return -1; /* errorno set by write() */ } nleft -= nwritten; bufp += nwritten; } return n; } /* $end rio_writen */ /* * rio_read - This is a wrapper for the Unix read() function that * transfers min(n, rio_cnt) bytes from an internal buffer to a user * buffer, where n is the number of bytes requested by the user and * rio_cnt is the number of unread bytes in the internal buffer. On * entry, rio_read() refills the internal buffer via a call to * read() if the internal buffer is empty. */ /* $begin rio_read */ static ssize_t rio_read(rio_t *rp, char *usrbuf, size_t n) { int cnt; while (rp->rio_cnt <= 0) { /* refill if buf is empty */ rp->rio_cnt = read(rp->rio_fd, rp->rio_buf, sizeof(rp->rio_buf)); if (rp->rio_cnt < 0) { if (errno != EINTR) /* interrupted by sig handler return */ return -1; } else if (rp->rio_cnt == 0) /* EOF */ return 0; else rp->rio_bufptr = rp->rio_buf; /* reset buffer ptr */ } /* Copy min(n, rp->rio_cnt) bytes from internal buf to user buf */ cnt = n; if (rp->rio_cnt < n) cnt = rp->rio_cnt; memcpy(usrbuf, rp->rio_bufptr, cnt); rp->rio_bufptr += cnt; rp->rio_cnt -= cnt; return cnt; } /* $end rio_read */ /* * rio_readinitb - Associate a descriptor with a read buffer and reset buffer */ /* $begin rio_readinitb */ void rio_readinitb(rio_t *rp, int fd) { rp->rio_fd = fd; rp->rio_cnt = 0; rp->rio_bufptr = rp->rio_buf; } /* $end rio_readinitb */ /* * rio_readnb - Robustly read n bytes (buffered) */ /* $begin rio_readnb */ ssize_t rio_readnb(rio_t *rp, void *usrbuf, size_t n) { size_t nleft = n; ssize_t nread; char *bufp = usrbuf; while (nleft > 0) { if ((nread = rio_read(rp, bufp, nleft)) < 0) { if (errno == EINTR) /* interrupted by sig handler return */ nread = 0; /* call read() again */ else return -1; /* errno set by read() */ } else if (nread == 0) break; /* EOF */ nleft -= nread; bufp += nread; } return (n - nleft); /* return >= 0 */ } /* $end rio_readnb */ /* * rio_readlineb - robustly read a text line (buffered) */ /* $begin rio_readlineb */ ssize_t rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen) { int n, rc; char c, *bufp = usrbuf; for (n = 1; n < maxlen; n++) { if ((rc = rio_read(rp, &c, 1)) == 1) { *bufp++ = c; if (c == '\n') break; } else if (rc == 0) { if (n == 1) return 0; /* EOF, no data read */ else break; /* EOF, some data was read */ } else return -1; /* error */ } *bufp = 0; return n; } /* $end rio_readlineb */ /********************************** * Wrappers for robust I/O routines **********************************/ ssize_t Rio_readn(int fd, void *ptr, size_t nbytes) { ssize_t n; if ((n = rio_readn(fd, ptr, nbytes)) < 0) unix_error("Rio_readn error"); return n; } void Rio_writen(int fd, void *usrbuf, size_t n) { if (rio_writen(fd, usrbuf, n) != n) unix_error("Rio_writen error"); } void Rio_readinitb(rio_t *rp, int fd) { rio_readinitb(rp, fd); } ssize_t Rio_readnb(rio_t *rp, void *usrbuf, size_t n) { ssize_t rc; if ((rc = rio_readnb(rp, usrbuf, n)) < 0) unix_error("Rio_readnb error"); return rc; } ssize_t Rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen) { ssize_t rc; if ((rc = rio_readlineb(rp, usrbuf, maxlen)) < 0) unix_error("Rio_readlineb error"); return rc; } /******************************** * Client/server helper functions ********************************/ /* * open_clientfd - open connection to server at <hostname, port> * and return a socket descriptor ready for reading and writing. * Returns -1 and sets errno on Unix error. * Returns -2 and sets h_errno on DNS (gethostbyname) error. */ /* $begin open_clientfd */ int open_clientfd(char *hostname, int port) { int clientfd; struct hostent *hp; struct sockaddr_in serveraddr; if ((clientfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return -1; /* check errno for cause of error */ /* Fill in the server's IP address and port */ if ((hp = gethostbyname(hostname)) == NULL) return -2; /* check h_errno for cause of error */ bzero((char *) &serveraddr, sizeof(serveraddr)); serveraddr.sin_family = AF_INET; bcopy((char *)hp->h_addr, (char *)&serveraddr.sin_addr.s_addr, hp->h_length); serveraddr.sin_port = htons(port); /* Establish a connection with the server */ if (connect(clientfd, (SA *) &serveraddr, sizeof(serveraddr)) < 0) return -1; return clientfd; } /* $end open_clientfd */ /* * open_listenfd - open and return a listening socket on port * Returns -1 and sets errno on Unix error. */ /* $begin open_listenfd */ int open_listenfd(int port) { int listenfd, optval=1; struct sockaddr_in serveraddr; /* Create a socket descriptor */ if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "socket failed\n"); return -1; } /* Eliminates "Address already in use" error from bind. */ if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval , sizeof(int)) < 0) { fprintf(stderr, "setsockopt failed\n"); return -1; } /* Listenfd will be an endpoint for all requests to port on any IP address for this host */ bzero((char *) &serveraddr, sizeof(serveraddr)); serveraddr.sin_family = AF_INET; serveraddr.sin_addr.s_addr = htonl(INADDR_ANY); serveraddr.sin_port = htons((unsigned short)port); if (bind(listenfd, (SA *)&serveraddr, sizeof(serveraddr)) < 0) { fprintf(stderr, "bind failed\n"); return -1; } /* Make it a listening socket ready to accept connection requests */ if (listen(listenfd, LISTENQ) < 0) { fprintf(stderr, "listen failed\n"); return -1; } return listenfd; } /* $end open_listenfd */ /****************************************** * Wrappers for the client/server helper routines ******************************************/ int Open_clientfd(char *hostname, int port) { int rc; if ((rc = open_clientfd(hostname, port)) < 0) { if (rc == -1) unix_error("Open_clientfd Unix error"); else dns_error("Open_clientfd DNS error"); } return rc; } int Open_listenfd(int port) { int rc; if ((rc = open_listenfd(port)) < 0) unix_error("Open_listenfd error"); return rc; }
[ "62953134+assaflovton@users.noreply.github.com" ]
62953134+assaflovton@users.noreply.github.com
16c467b514372527be11850f6e1e7c7776dee8f5
d7f5957df7e30aa03fb327fe904ffda91a1345c2
/Initiation_C/racinecarre.c
d6e53dba2bee5e373591ad9f8e79e4276f48dc63
[]
no_license
MaelVe/C
9e1b2cc155b66c4b5277d71604a518b8c4581270
4b62f5cd2184831638becf23541ca1b735d324b6
refs/heads/master
2020-07-23T06:35:29.417131
2017-06-14T16:57:33
2017-06-14T16:57:33
94,353,813
0
0
null
null
null
null
ISO-8859-1
C
false
false
378
c
/* Ce programme permet de saisir un caractere et d'affiche sa racine carrée Mael VERON septembre 2015 */ #include <stdio.h> #include <conio.h> int main (void) { float a,r; puts ("saisir un nombre x"); scanf("%f",&a); // a <- lire le clavier r=sqrt(a); // calculer racine de a printf("La racine carree de %f est %f",a,r); system("pause"); }
[ "noreply@github.com" ]
MaelVe.noreply@github.com
321f8b46dbcfc1b05ed76483614518b1dbd3ff2f
c9fd937f94041713d707a5c7ef720fc10c2b3664
/macros.h
129d32651401a9b58d634967150c100db65069b2
[]
no_license
shawqy/SmartHome_ARM
b9843f4d72e2b4ecb4b0ad45e0210855d27ebef5
74cdb347baf881186f989055a1c5d9c0037275c4
refs/heads/master
2020-05-09T13:42:13.804811
2019-05-16T18:16:15
2019-05-16T18:16:15
181,164,208
1
2
null
null
null
null
UTF-8
C
false
false
1,049
h
/* * Module: Macros. * * File Name: macros.h * * Disc: commonly used macros * * Created on: ------ * * Author: Samir Mossad Ibrahim */ #ifndef MACROS_H_ #define MACROS_H_ /*Check if specific bit is set in any register*/ #define BIT_IS_SET(REG,BIT_NUM) ((REG)&(1<<BIT_NUM)) /*Check if specific bit is clear in any register*/ #define BIT_IS_CLEAR(REG,BIT_NUM) (!((REG)&(1<<BIT_NUM))) /*Set a certain bit inside a any register*/ #define SET_BIT(REG,BIT_NUM) ((REG)=(REG)|(1<<BIT_NUM)) /*Reset a certain bit inside a any register*/ #define RESET_BIT(REG,BIT_NUM) ((REG)=(REG)&(~(1<<BIT_NUM))) /*Toggle a certain bit inside a any register*/ #define TOGGLE_BIT(REG,BIT_NUM) ((REG)=(REG)^(1<<BIT_NUM)) /*Rotate right the register with specific no of rotates*/ #define ROTATE_RIGHT(REG,BIT_NUM) ((REG>>BIT_NUM)|(REG>>((sizeof(REG)*8)-BIT_NUM))) /*Rotate left the register with specific no of rotates*/ #define ROTATE_LEFT(REG,BIT_NUM) ((REG<<BIT_NUM)|(REG<<>((sizeof(REG)*8)-BIT_NUM))) #endif /* MACROS_H_ */
[ "samirmossad6@gmail.com" ]
samirmossad6@gmail.com
ccdda8c5a414ac8fc8eeda9c781ffccfb5950a52
be3167504c0e32d7708e7d13725c2dbc9232f2cb
/mameppk/src/lib/formats/smx_dsk.c
bebbffbeb776e4712757c3998ac1fa2b66c24ec9
[]
no_license
sysfce2/MAME-Plus-Plus-Kaillera
83b52085dda65045d9f5e8a0b6f3977d75179e78
9692743849af5a808e217470abc46e813c9068a5
refs/heads/master
2023-08-10T06:12:47.451039
2016-08-01T09:44:21
2016-08-01T09:44:21
null
0
0
null
null
null
null
UTF-8
C
false
false
1,114
c
// license:BSD-3-Clause // copyright-holders:Olivier Galibert /********************************************************************* formats/smx_dsk.c Specialist MX format *********************************************************************/ #include <assert.h> #include "formats/smx_dsk.h" smx_format::smx_format() : wd177x_format(formats) { } const char *smx_format::name() const { return "smx"; } const char *smx_format::description() const { return "Specialist MX/Orion/B2M disk image"; } const char *smx_format::extensions() const { return "odi,cpm,img"; } // Unverified gap sizes const smx_format::format smx_format::formats[] = { { // Specialist MX/Orion/B2M disk image floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM, 2000, 5, 80, 2, 1024, {}, 1, {}, 100, 22, 20 }, { // Lucksian Key Orion disk image floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM, 2000, 9, 80, 2, 512, {}, 1, {}, 100, 22, 20 }, {} }; const floppy_format_type FLOPPY_SMX_FORMAT = &floppy_image_format_creator<smx_format>;
[ "mameppk@199a702f-54f1-4ac0-8451-560dfe28270b" ]
mameppk@199a702f-54f1-4ac0-8451-560dfe28270b
40e74b1a32a731291bdb2b3c0c4910baf4ffac1e
2cd986dee35becd91cbd93ba7b35414e80e33f4f
/venv/include/python3.7m/enumobject.h
12c6e18f902ee22bdd6bd355ac73d84245e90a29
[]
no_license
HernanG234/sensors_async_sim
95ccb4e4fd188b8fc5be206bae3af4302f23e3e2
fce3701e2a0865198c0977ede5f42da77b8a7853
refs/heads/master
2020-05-07T09:43:57.354059
2019-05-11T19:07:23
2019-05-11T19:07:23
180,387,282
0
1
null
2019-04-29T15:42:53
2019-04-09T14:37:38
Python
UTF-8
C
false
false
42
h
/usr/local/include/python3.7m/enumobject.h
[ "hernan.gonzalez@incluit.com" ]
hernan.gonzalez@incluit.com
25484d86aab403ea81335886ae9a9c93aecdedb9
c673f57337bfeac930a81e2bf54239768808bf5f
/src/tasks/audio.c
5beae08a39f08f1865e1a016cae36b1ec7c7c87a
[ "BSD-3-Clause", "MIT" ]
permissive
juimonen/sof
e5ea4110917280abb258c7314b26a1fb57c62a5d
ef4fc532c59d3bad59e64ef2e1b89459511039a9
refs/heads/master
2023-08-02T21:34:43.500209
2018-08-02T03:44:48
2018-08-02T03:44:48
143,250,507
0
0
NOASSERTION
2019-06-14T08:30:43
2018-08-02T06:14:23
C
UTF-8
C
false
false
3,020
c
/* * Copyright (c) 2016, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Intel Corporation nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> * * Generic audio task. */ #include <sof/task.h> #include <sof/wait.h> #include <sof/debug.h> #include <sof/timer.h> #include <sof/interrupt.h> #include <sof/ipc.h> #include <sof/agent.h> #include <platform/interrupt.h> #include <platform/shim.h> #include <sof/audio/pipeline.h> #include <sof/work.h> #include <sof/debug.h> #include <sof/trace.h> #include <stdint.h> #include <stdlib.h> #include <errno.h> struct audio_data { struct pipeline *p; }; int do_task(struct sof *sof) { #ifdef STATIC_PIPE struct audio_data pdata; #endif /* init default audio components */ sys_comp_init(); sys_comp_dai_init(); sys_comp_host_init(); sys_comp_mixer_init(); sys_comp_mux_init(); sys_comp_switch_init(); sys_comp_volume_init(); sys_comp_src_init(); sys_comp_tone_init(); sys_comp_eq_iir_init(); sys_comp_eq_fir_init(); #if STATIC_PIPE /* init static pipeline */ pdata.p = init_static_pipeline(); if (pdata.p == NULL) panic(SOF_IPC_PANIC_TASK); #endif /* let host know DSP boot is complete */ platform_boot_complete(0); /* main audio IPC processing loop */ while (1) { /* sleep until next IPC or DMA */ sa_enter_idle(sof); wait_for_interrupt(0); /* now process any IPC messages from host */ ipc_process_msg_queue(); /* schedule any idle tasks */ schedule(); } /* something bad happened */ return -EIO; }
[ "liam.r.girdwood@linux.intel.com" ]
liam.r.girdwood@linux.intel.com
5f82ac9d76e012cfa01af07d6bb654f9033fb998
46ddf59ca3d1a4468f1e82fa632457283d630a5b
/TPs-Laboratorio-I/TP_3_Cascara/TP_3_Cascara/movies.h
1813feac0b1c0f06c8f43f26c13cc33d36bbac80
[]
no_license
mguelpa/Programacion-Laboratorio-I
7361e0dfe47f87540991b08bef34934acd0898fc
a5bb25e52f385aa424fc71676ba12df6787023a5
refs/heads/master
2021-01-22T18:07:04.359774
2018-04-02T02:41:09
2018-04-02T02:41:09
119,440,237
1
0
null
null
null
null
UTF-8
C
false
false
4,126
h
#ifndef MOVIES_H_INCLUDED #define MOVIES_H_INCLUDED #define MAX_REINGRESOS 3 #define MAX_CHARS_HTML 2048 #define MAX_CHARS_TITULOS 50 #define MAX_CHARS_GENEROS 50 #define MAX_CHARS_DESCRIPCIONES 500 #define MAX_CHARS_LINKS 500 #define MOVIE_EMPTY 0 #define MOVIE_TAKEN 1 #define MOVIE_DOWN -1 typedef struct{ int emov_slot; int emov_code; char titulo[MAX_CHARS_TITULOS +1]; char genero[MAX_CHARS_GENEROS +1]; int duracion; char descripcion[MAX_CHARS_DESCRIPCIONES +1]; int puntaje; char linkImagen[MAX_CHARS_LINKS +1]; //2KBytes length }EMovie; #endif // MOVIES_H_INCLUDED /******************************************************** * \brief funcion utilizada para inicializar el array. * * \param 1. se pasa nombre del array a inicializar. * \param 2. se pasa el limite del array. * * \return ( 0) = inicializacion correcta. * \return (-1) = error en la inicializacion. */ int emov_arrayInit (EMovie* nombre_array, int length); /********************************************************** * \brief funcion utilizada para imprimir datos cargados. * * \param 1. se pasa nombre del array a inicializar. * \param 2. se pasa el limite del array. * * \return ( 0) = impresion correcta. * \return (-1) = error en la impresion. */ int emov_arrayRecords (EMovie* nombre_array, int length); /************************************************************** * \brief funcion utilizada para buscar un indice en el array. * * \param 1. se pasa nombre del array a buscar. * \param 2. se pasa el limite del array. * \param 3. se pasa el buffer donde guardar el codigo generado. * * \return ( 0) = codigo generado correctamente. * \return (-1) = error en la generacion del codigo. */ int emov_searchIndexByID (EMovie* nombre_array, int length, int* code); /************************************************************ * \brief funcion utilizada para cargar los datos validados. * * \param 1. se pasa nombre del array a cargar. * \param 2. se pasa indice donde cargar. * \param 3. se pasa el buffer de datos validos. * \param 4. se pasa el buffer de datos validos. * \param 5. se pasa el buffer de datos validos. * \param 6. se pasa el buffer de datos validos. * \param 7. se pasa el buffer de datos validos. * \param 8. se pasa el buffer de datos validos. * * \return ( 0) = carga correcta. * \return (-1) = error en la carga. */ int emov_loadData (EMovie* nombre_array, int index, char* data1, char* data2, int* data3, char* data4, int* data5, char* data6); /************************************************************** * \brief funcion utilizada para modificar los datos validados. * * \param 1. se pasa nombre del array a modificar. * \param 2. se pasa indice donde cargar. * \param 3. se pasa el buffer de datos validos. * \param 4. se pasa el buffer de datos validos. * \param 5. se pasa el buffer de datos validos. * \param 6. se pasa el buffer de datos validos. * \param 7. se pasa el buffer de datos validos. * \param 8. se pasa el buffer de datos validos. * * \return ( 0) = carga correcta. * \return (-1) = error en la carga. */ int emov_modifyData (EMovie* nombre_array, int index, char* data1, char* data2, int* data3, char* data4, int* data5, char* data6); /********************************************************************* * \brief Funcion utilizada para realizar una baja logica de manera * que los datos permanezcan guardados, busca un indice y * cambia el estado por baja (STATUS_DOWN) * * \param 1. Puntero al array a modificar. * \param 2. indice del dato a dar de baja. */ int emov_downData (EMovie* nombre_array, int index); /******************************************************** * \brief funcion utilizada para harcodear datos en el * array de manera que sea mas facil testear. * * \param 1. se pasa nombre del array a inicializar. */ void emov_cheater (EMovie* nombre_array1);
[ "mguelpa@gmail.com" ]
mguelpa@gmail.com
59194b71cac9d50fe053e0454f9059bc8591cd65
5d417f03f724f4e23000f28cd629c92bc9297a23
/common/services/usb/class/cdc/device/example2/sam4s16c_sam4s_ek/iar/asf.h
87dbb58c24e865e388baf9d2e100a0a61dbb5ffc
[]
no_license
siliconunited/atmel-asf
5ac78a123cb0f5026ffb9a0ba66b75abcccb788f
19e02800a6cc33d203f5d12f7dfca0c39195d879
refs/heads/master
2021-01-22T21:34:10.563981
2017-03-19T04:45:30
2017-03-19T04:45:30
85,439,630
6
3
null
2020-03-08T01:34:35
2017-03-18T23:56:24
C
UTF-8
C
false
false
3,469
h
/** * \file * * \brief Autogenerated API include file for the Atmel Software Framework (ASF) * * Copyright (c) 2012 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * \asf_license_stop * */ #ifndef ASF_H #define ASF_H /* * This file includes all API header files for the selected drivers from ASF. * Note: There might be duplicate includes required by more than one driver. * * The file is automatically generated and will be re-written when * running the ASF driver selector tool. Any changes will be discarded. */ // From module: Common SAM compiler driver #include <compiler.h> #include <status_codes.h> // From module: GPIO - General purpose Input/Output #include <gpio.h> // From module: Generic board support #include <board.h> // From module: IOPORT - General purpose I/O service #include <ioport.h> // From module: Interrupt management - SAM implementation #include <interrupt.h> // From module: MATRIX - Bus Matrix #include <matrix.h> // From module: PIO - Parallel Input/Output Controller #include <pio.h> // From module: PMC - Power Management Controller #include <pmc.h> #include <sleep.h> // From module: Part identification macros #include <parts.h> // From module: SAM4S EK LED support enabled #include <led.h> // From module: Sleep manager - SAM implementation #include <sam/sleepmgr.h> #include <sleepmgr.h> // From module: System Clock Control - SAM4S implementation #include <sysclk.h> // From module: USART - Univ. Syn Async Rec/Trans #include <usart.h> // From module: USB CDC Protocol #include <usb_protocol_cdc.h> // From module: USB Device CDC (Single Interface Device) #include <udi_cdc.h> // From module: USB Device Stack Core (Common API) #include <udc.h> #include <udd.h> // From module: pio_handler support enabled #include <pio_handler.h> #endif // ASF_H
[ "robksawyer@gmail.com" ]
robksawyer@gmail.com
3a1a3d5c185aec97d855e25283856a1a775abc55
711e5c8b643dd2a93fbcbada982d7ad489fb0169
/XPSP1/NT/ds/security/services/ca/ocmsetup/regd.h
a784b932903b101da591943ad7dd88618dea344c
[]
no_license
aurantst/windows-XP-SP1
629a7763c082fd04d3b881e0d32a1cfbd523b5ce
d521b6360fcff4294ae6c5651c539f1b9a6cbb49
refs/heads/master
2023-03-21T01:08:39.870106
2020-09-28T08:10:11
2020-09-28T08:10:11
null
0
0
null
null
null
null
UTF-8
C
false
false
921
h
//+-------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1996 - 1999 // // File: regd.h // // Contents: Helper functions registering and unregistering a component. // // History: July-97 xtan created // //--------------------------------------------------------------------------- #ifndef __Regd_H__ #define __Regd_H__ // This function will register a component in the Registry. HRESULT RegisterDcomServer( const CLSID& clsid, const WCHAR *szFriendlyName, const WCHAR *szVerIndProgID, const WCHAR *szProgID); // This function will unregister a component HRESULT UnregisterDcomServer( const CLSID& clsid, const WCHAR *szVerIndProgID, const WCHAR *szProgID); HRESULT RegisterDcomApp( const CLSID& clsid); VOID UnregisterDcomApp(VOID); #endif
[ "112426112@qq.com" ]
112426112@qq.com
2612b93afcfe27ac9e198851afe6d2108c18b270
be1aa238ce2655abaf35b4375bd4bb1a12a72404
/cpp/part2.c
78c329af72ab51b5506932d1dfff91af5b3c6b4e
[]
no_license
imnxllet/CSC443
3dd66350165eb2648fd4d0f7d83863de67679cef
2db795765868ab156327ccbb070e6634a7dbd183
refs/heads/master
2021-03-24T14:07:08.707900
2018-02-21T03:15:08
2018-02-21T03:15:08
121,722,402
0
0
null
null
null
null
UTF-8
C
false
false
9,082
c
#include "part2.h" #include <time.h> #include <sys/timeb.h> #include <stdlib.h> #include <stdio.h> #include <strings.h> #include <cstring> /* Compute the number of bytes required to serialize record.*/ int fixed_len_sizeof(Record *record){ /* number of items inside the vector */ /*Record::iterator it; // declare an iterator to a vector of strings int size = 0; int i = 0; for(it = record->begin(); it != record->end(); it++) { size += sizeof(char) * std::strlen((char *)*it); printf("This value has strlen %d\n", std::strlen((char *) *it)); printf("Get valuye %s\n", (char *)*it); i++; } printf("This record has %d attributes...\n", record->size());*/ return record->size() * ATTRIBUTE_SIZE; //return size; } /*Serialize the record to a byte array to be stored in buf*/ void fixed_len_write(Record *record, void *buf){ /* Write the bytes in the buf */ Record::iterator it; // declare an iterator to a vector of strings //int size = 0; int index = 0; for(it = record->begin(); it != record->end(); it++) { std::memcpy((char*)buf + index, *it, ATTRIBUTE_SIZE); index += ATTRIBUTE_SIZE; } } /** * Deserializes `size` bytes from the buffer, `buf`, and * stores the data in `record`. */ void fixed_len_read(void *buf, int size, Record *record){ /* Value is of 10 bytes long(ATTRIBUTE_SIZE) for each attribute. */ printf("buffer size is %d\n", size); int values_count = size / (ATTRIBUTE_SIZE + 1); //=100 //printf("The buf has %d attributes.\n", values_count); int index = 0; for (int i = 0; i < values_count; i++) { char value[ATTRIBUTE_SIZE]; //std::memcpy(value, (char*)buf + index, (ATTRIBUTE_SIZE + 1)); std::memcpy(value, (char*)buf + index, (ATTRIBUTE_SIZE)); //value[ATTRIBUTE_SIZE] = '\0'; //printf("Get valuye %s\n", value); index += ATTRIBUTE_SIZE + 1; //attribute[ATTRIBUTE_SIZE] = '\0'; //printf("pushing record %d\n", i); record->push_back(value); printf("Value is %.*s", ATTRIBUTE_SIZE, value); /*if (strlen(value) > 0) { record->push_back(attribute); }*/ } } /*Part2.2: Page layout typedef struct{ void *data; int page_size; int slot_size; int free_slots; int used_slots; } Page; */ /*Initializes a page using the given slot size. */ void init_fixed_len_page(Page *page, int page_size, int slot_size){ page->slot_size = slot_size; page->page_size = page_size; page->total_slot = fixed_len_page_capacity(page); page->free_slots = fixed_len_page_capacity(page); page->used_slots = 0; page->data = malloc(page_size); page->slot_bitmap_size = (page->total_slot)/8 + ((page->total_slot) % 8 != 0); std::memset ((char*)page->data, 0, page_size); std::memset((int*)page->data, page->free_slots, sizeof(int)); printf("new page has %d for slot suze\n", page->slot_size); printf("new page has %d free slots\n", page->free_slots); printf("new page has %d bytes reserve for bitmap\n", page->slot_bitmap_size); } /* Calculates the maximal number of records that fit in a page. */ int fixed_len_page_capacity(Page *page){ /*Page size = M*slot_size + 2 or 1 (to store M) + M/8 (M bits)*/ int num_slots_M = (page->page_size - sizeof(int)) / ((1/8) + page->slot_size); return num_slots_M; } /* Calculate the free space (number of free slots) in the page */ int fixed_len_page_freelots(Page *page){ return page->free_slots; } /* Add a record to the page *Return: * record slot offset if successful, * -1 if unsuccessful (page full) Page size = M*slot_size + 2 or 1 (to store M) + M/8 (M bits) */ int add_fixed_len_page(Page *page, Record *r){ /* To-do: should we check slot size fit record r..??*/ printf("Record size: %d, slot size %d\n", fixed_len_sizeof(r), page->slot_size); if (fixed_len_sizeof(r) <= page->slot_size){ int slot_id = find_FreeSlot(page); printf("Free slot id is: %d\n", slot_id); if(slot_id != -1){ printf("start writing record...\n"); write_fixed_len_page(page, slot_id, r); return 0; } } return -1; } /* Write a record into a given slot. */ void write_fixed_len_page(Page *page, int slot, Record *r){ printf("start writing record#2...\n"); char* next_free_slot = (char *)((char *)page->data + sizeof(int) + page->slot_bitmap_size + ((slot - 1) * page->slot_size)); togglePageBitmap(page, slot, 1); fixed_len_write(r, (void *)next_free_slot); } /* Read from a page's slot and store it to Record r. */ void read_fixed_len_page(Page *page, int slot, Record *r){ char* record_slot = (char *)((char *)page->data + sizeof(int) + page->slot_bitmap_size + ((slot - 1) * page->slot_size)); // serialize the data at the dataslot and store in r //fixed_len_read((void *)record_slot, page->slot_size, r); int values_count = page->slot_size / (ATTRIBUTE_SIZE); //=100 //printf("The buf has %d attributes.\n", values_count); int index = 0; for (int i = 0; i < values_count; i++) { char value[ATTRIBUTE_SIZE]; //std::memcpy(value, (char*)buf + index, (ATTRIBUTE_SIZE + 1)); std::memcpy(value, (char*)record_slot + index, ATTRIBUTE_SIZE); //value[ATTRIBUTE_SIZE] = '\0'; //printf("Get valuye %s\n", value); index += ATTRIBUTE_SIZE; // //printf("pushing record %d\n", i); printf("Value is %.*s", ATTRIBUTE_SIZE, value); value[ATTRIBUTE_SIZE -1] = '\0'; printf("Value1 is %s", value); r->push_back(value); /*if (strlen(value) > 0) { record->push_back(attribute); }*/ } } /*Helper function for exercise to print bitmap.*/ void printBit(unsigned char *byte){ printf(" "); for(int i = 0; i < 8; i++){ int bit = *byte & 1 << i; //check bit 1 or 0 if(bit) printf("1"); else printf("0"); } } /*Find next free node from bitmap*/ int find_FreeSlot(Page *page){ unsigned char *slot_bitmap = (unsigned char *)page->data + sizeof(int); int num_slots = fixed_len_page_capacity(page); printf("# of slots is: %data\n", num_slots); int counter = 0; //unsigned char *inode_bitmap = index(disk, group->bg_inode_bitmap); //printf("\nInode bitmap:"); for (int i =0; i < ((float)num_slots / (float)8); i++){ printf("checking byte...\n"); unsigned char *byte = slot_bitmap + i; printBit(byte); for(int j = 0; j < 8; j++){ //printf("checking bit...\n"); counter++; int bit = *byte & 1 << j; //check bit 1 or 0 if(bit){ continue; }else{ return counter; } } } //No Free Inode found. return -1; } int checkValue(Page *page, int slot_id){ //Toggle to 1 //struct ext2_group_desc *group = (struct ext2_group_desc *)(disk + 2048); //int num_slots = fixed_len_page_capacity(page); int counter = 0; unsigned char *page_bitmap = (unsigned char *)page->data + sizeof(int); //printf("\nInode bitmap:"); for (int i =0; i < (float)page->total_slot / (float)8; i++){ unsigned char *byte = page_bitmap + i; for(int j = 0; j < 8; j++){ counter++; if(counter == slot_id){ int bit = *byte & 1 << j; if(bit){//Set high return 1; }else{ return 0; } } } } //error return -1; } /*Update inode with id in inode bitmap to value. Adjust sb,group descriptor accordingly.*/ int togglePageBitmap(Page *page, int slot_id, int value){ //Toggle to 1 //struct ext2_group_desc *group = (struct ext2_group_desc *)(disk + 2048); //int num_slots = fixed_len_page_capacity(page); int counter = 0; unsigned char *page_bitmap = (unsigned char *)page->data + sizeof(int); //printf("\nInode bitmap:"); for (int i =0; i < (float)page->total_slot / (float)8; i++){ unsigned char *byte = page_bitmap + i; for(int j = 0; j < 8; j++){ counter++; //set bit if(counter == slot_id){ if(value == 1){//Set high page->free_slots--; page->used_slots++; *byte |= (1 << j); return 0; }else{ page->free_slots++; page->used_slots--; *byte &= ~(1 << j); return 0; } } } } //error return -1; }
[ "chrislu0126@hotmail.com" ]
chrislu0126@hotmail.com
b137180b613b250994730113a29c55390024d04c
c3ac6a59aa7560f6c59b6cc8f46ce923e1b0af35
/src/clan.c
643a963693f63cae34bab237ca2c33a94fef356b
[]
no_license
cbagg/aagnor
88c33c36ac0d92dcedd9cc3b5e988235a805e9b0
8f8523b6ca26fcf1a3514c1b896ecd9747e6b9cf
refs/heads/main
2023-04-24T04:46:54.476766
2021-05-08T00:17:49
2021-05-08T00:17:49
365,369,812
1
1
null
null
null
null
UTF-8
C
false
false
29,993
c
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <memory.h> #include "merc.h" #include "clan.h" /***************************************************************/ /*Following are army orientanted routines for Forsaken Lands */ /*mud created by Virigoth circa Apr 2004. Copyrighted for Forsaken*/ /*Lands mud Apr 04, 2004. Do not use or copy without explicit */ /*permission of author. (Voytek Plawny aka Virigoth) */ /***************************************************************/ /* GLOBALS */ static CLAN_DATA clan_list[MAX_CLANS]; /* PROTOTYPES */ char* ClanFixName( char* name ); /* PRIVATE */ //zero the clan list void Reset(){ memset( clan_list, 0, sizeof( CLAN_DATA ) * MAX_CLANS); } //convert a clan name to handle, 0 on not found int ClanNameToHandle( char* name ){ int clan; for ( clan = 0; clan < MAX_CLANS; clan++){ if (IS_NULLSTR(clan_list[clan].name) || str_cmp(name, clan_list[clan].name)) continue; else return ( clan + 1); } return 0; } //convert handle to name, NULL on not found char* ClanHandleToName( int handle ){ static char* nul = ""; if (handle < 1 || handle > MAX_CLANS || IS_NULLSTR(clan_list[handle - 1].name)) return nul; else return clan_list[handle - 1].name; } //returns clan data based on handle CLAN_DATA* GetClanData( int handle ){ if (handle < 1 || handle > MAX_CLANS) return NULL; return ( &clan_list[handle - 1]); } int ClanInsertMember( int handle, CLAN_MEMBER* pCmd ){ CLAN_DATA* pClan = GetClanData( handle ); CLAN_MEMBER* prev, *new; if (pClan == NULL || pCmd == NULL){ return 0; } else if ( (new = GetClanMember( handle, pCmd->name)) != NULL){ return handle; } /* search for the end of the member list */ for (prev = &pClan->members; prev->next; prev = prev->next); /* attach the new member */ new = alloc_mem( sizeof( *new )); memset( new, 0, sizeof( *new )); new->name = str_dup( pCmd->name ); new->class = pCmd->class; new->race = pCmd->race; new->level = pCmd->level; new->rank = pCmd->rank; new->pts = pCmd->pts; new->last_logon = pCmd->last_logon; new->joined = pCmd->joined; new->allowed = pCmd->allowed; new->next = NULL; prev->next = new; pClan->max++; return handle; } //adds a member to a clan int ClanAddMember( int handle, CHAR_DATA* ch){ CLAN_MEMBER tmp; if (handle < 1 || handle > MAX_CLANS || ch == NULL) return 0; tmp.name = ch->name; tmp.class = ch->class; tmp.race = ch->race; tmp.level = ch->race; tmp.rank = 0; tmp.last_logon = ch->logoff; tmp.joined = mud_data.current_time; tmp.allowed = 0; tmp.pts = ch->pcdata->clan_points + mud_data.mudport == TEST_PORT ? 1 : 0; return (ClanInsertMember( handle, &tmp )); } //removes a given member from a clan bool ClanRemMember( int handle, char* name ){ CLAN_DATA* pClan = GetClanData( handle ); CLAN_MEMBER* prev, *tmp = NULL; if (pClan == NULL || IS_NULLSTR( name )){ return FALSE; } /* search members untill we find target name */ for (prev = &pClan->members; prev->next; prev = prev->next){ if (!str_cmp(prev->next->name, name)){ tmp = prev->next; break; } } if (tmp == NULL){ bug("clan.c>ClanRemMember: name not found.", 0); return FALSE; } /* unlink the member */ prev->next = tmp->next; /* free strings */ free_string( tmp->name ); /* free the member */ free_mem( tmp, sizeof( *tmp )); pClan->max--; return TRUE; } //adds a clan to the list of clans, returns handle int ClanAdd( CLAN_DATA* pClan){ int handle; if (pClan == NULL || IS_NULLSTR(pClan->name)) return 0; else if ( (handle = ClanNameToHandle( pClan->name )) > 0){ return (handle); } else{ /* try to find an empty spot */ for (handle = 0; handle < MAX_CLANS; handle++){ if (IS_NULLSTR(clan_list[handle].name)){ memcpy(&clan_list[handle], pClan, sizeof( *pClan )); clan_list[handle].name = str_dup( pClan->name ); return (handle + 1); } } return 0; } } //removes a clan from the list bool ClanRem( int handle ){ CLAN_DATA* pClan = GetClanData( handle ); char path[MIL]; if (pClan == NULL){ bug("clan.c>ClanRem: Could not find clan %d", handle ); return FALSE; } /* free members */ while (pClan->members.next) ClanRemMember( handle, pClan->members.next->name ); /* unlink save file */ sprintf( path, "%s%s", CLAN_DIR, ClanFixName( pClan->name ) ); unlink( path ); /* free strings */ free_string( pClan->name ); pClan->name = NULL; pClan->max = 0; return TRUE; } //lists all the clans loaded void ListClans( CHAR_DATA* ch ){ int clan; for (clan = 0; clan < MAX_CLANS; clan++){ if (IS_NULLSTR(clan_list[clan].name)) continue; sendf(ch, "%-25.25s (%-3d)\n\r", clan_list[clan].name, clan_list[clan].max ); } } //returns a string with clan data for one member char* PrintMemberData( CLAN_MEMBER* pCmd, bool fImm ){ static char out[MIL]; out[0] = 0; /* IMM info */ if (fImm){ if (pCmd == NULL){ sprintf( out, "Name Race Class Rank Lvl Sen Log Pts \n\r"\ "----------------------------------------------------------------------"); } else{ sprintf( out, "%-15.15s %-10.10s %-10.10s %-10.10s %-2d %-3ld %-3ld %-3d", pCmd->name, pc_race_table[pCmd->race].name, class_table[pCmd->class].name, clanr_table[pCmd->rank][1], pCmd->level, (mud_data.current_time - pCmd->joined) / 86400, (mud_data.current_time - pCmd->last_logon) / 86400, pCmd->pts); } } /* NORMAL */ else{ if (pCmd == NULL){ sprintf( out, "Name Rank Lvl Days Ago\n\r"\ "----------------------------------------"); } else{ sprintf( out, "%-15.15s %-10.10s %-2d %-3ld", pCmd->name, clanr_table[pCmd->rank][1], pCmd->level, (mud_data.current_time - pCmd->last_logon) / 86400); } } return ( out ); } //lists members of a given clan //types are: seniority, rank, pts (default) void ListMembers( CHAR_DATA* ch, int handle, bool fImm, char* type ){ CLAN_DATA* pClan; CLAN_MEMBER* pCmd; const int max_search = 128; const int max_show = 16; CLAN_MEMBER* members[max_search]; int max_member = 0, i, j; bool fRank = FALSE, fSen = FALSE; if ( (pClan = GetClanData( handle )) == NULL) return; for (pCmd = pClan->members.next; pCmd; pCmd = pCmd->next){ if ((mud_data.current_time - pCmd->last_logon) > MAX_INACTIVE) continue; /* Viri: Lets see for now if this pruning is really necessary else if (pCmd->rank < RANK_ELDER && pCmd->pts < 1) continue; */ if (max_member < max_search) members[max_member++] = pCmd; } if (!str_prefix(type, "rank")) fRank = TRUE; if (!str_prefix(type, "seniority")) fSen = TRUE; /* sort */ if (fRank){ for (i = 0; i < max_member; i++){ pCmd = members[i]; for (j = i; j > 0 && members[j - 1]->rank < pCmd->rank; j--){ members[j] = members[j - 1]; } members[j] = pCmd; } } else if (fSen){ for (i = 0; i < max_member; i++){ pCmd = members[i]; for (j = i; j > 0 && members[j - 1]->joined > pCmd->joined; j--){ members[j] = members[j - 1]; } members[j] = pCmd; } } else{ for (i = 0; i < max_member; i++){ pCmd = members[i]; for (j = i; j > 0 && members[j - 1]->pts < pCmd->pts; j--){ members[j] = members[j - 1]; } members[j] = pCmd; } } /* show */ sendf( ch, "%s\n\r", PrintMemberData( NULL, fImm ) ); for (i = 0; i < max_member && i < max_show; i++){ sendf( ch, "%s\n\r", PrintMemberData( members[i], fImm ) ); } } //fixes a clan name to be ok for a filename char* ClanFixName( char* name ){ static char out[MIL]; char* ptr = out; *ptr = 0; while (*name ){ switch( *name ){ default: if (isalpha( *name )) *ptr = *name; else *ptr = '_'; break; case ' ': *ptr = '_'; break; } ptr++; name++; } *ptr = 0; return out; } //writes a single clan's data to file void fWriteClan( FILE *fp, CLAN_DATA* pClan ){ CLAN_MEMBER* pCmd; //start the file off with the name fprintf( fp, "CLAN %s~\n", pClan->name ); for (pCmd = pClan->members.next; pCmd; pCmd = pCmd->next){ fprintf( fp, "MEMBER %s~\n"\ "RACE %d CLASS %d LEVEL %d\n"\ "RANK %d PTS %d\n"\ "JOIN %ld LAST %ld ALLOWED %ld\n"\ "MEMBER_END\n", pCmd->name, pCmd->race, pCmd->class, pCmd->level, pCmd->rank, pCmd->pts, pCmd->joined, pCmd->last_logon, pCmd->allowed); } fprintf( fp, "END\n\n"); } //reads a single clan's data and loads the clan void fReadClan( FILE* fp ){ CLAN_DATA clan; CLAN_MEMBER member; char* word; int handle; bool fMatch; if ( (word = fread_word( fp )) == NULL){ bug("clan.c>fReadClan: Error accessing file.\n\r", 0); return; } else if (str_cmp(word, "CLAN")){ bug("can.c>fReadClan: Expected CLAN not found.", 0); return; } memset( &clan, 0, sizeof( CLAN_DATA )); //get name first clan.name = fread_string( fp ); if ( (handle = ClanAdd( &clan )) < 1){ bug("clan.c>fReadClan: Could not get a handle for clan.", 0); return; } //reset the name data for use memset( &member, 0, sizeof( CLAN_MEMBER )); for (;;){ fMatch = FALSE; if (feof( fp) || (word = fread_word( fp )) == NULL) word = "END"; switch( UPPER(word[0])){ case 'A': KEY( "ALLOWED", member.allowed, fread_number( fp )); break; case 'C': KEY( "CLASS", member.class, fread_number( fp )); break; case 'E': if (!str_cmp(word, "END")){ fMatch = TRUE; return; } break; case 'J': KEY( "JOIN", member.joined, fread_number( fp )); break; case 'L': KEY( "LEVEL", member.level, fread_number( fp )); KEY( "LAST", member.last_logon, fread_number( fp )); break; case 'M': KEYS( "MEMBER", member.name, fread_string( fp )); if (!str_cmp(word, "MEMBER_END")){ if (ClanInsertMember( handle, &member) < 1){ nlogf("[*****] BUG: clan.c>fReadClan: Could not insert member %s", member.name); continue; } fMatch = TRUE; break; } break; case 'P': KEY( "PTS", member.pts, fread_number( fp )); break; case 'R': KEY( "RACE", member.race, fread_number( fp )); KEY( "RANK", member.rank, fread_number( fp )); break; } if (!fMatch){ nlogf("[*****] BUG: clan.c>fReadClan: Can't match \"%s\"", word); } } } /* INTERFACE */ void LoadClans(){ FILE* fp; DIR *directory; //Directory struct dirent *dir_ent; //Directory entry struct stat Stat; //File statistics char path[MIL]; //Current file name Reset(); /* Open dir, get first entry */ if ( (directory = opendir(CLAN_DIR)) == NULL){ bug("clan.c>LoadClans: Could not access CLAN_DIR", 0); return; } else if ( (dir_ent = readdir(directory)) == NULL){ bug("clan.c>LoadClans: Could not access first directory entry.", 0); closedir( directory ); return; } fclose( fpReserve ); while( dir_ent != NULL){ sprintf( path, "%s%s", CLAN_DIR, dir_ent->d_name ); if ( -1 == stat( path, &Stat)){ dir_ent = readdir( directory ); continue; } else if(!S_ISREG(Stat.st_mode)){ dir_ent = readdir( directory ); continue; } nlogf("Loading clan %s", dir_ent->d_name ); if ( (fp = fopen( path, "r")) == NULL){ perror( path ); dir_ent = readdir( directory ); continue; } fReadClan( fp ); fclose( fp ); dir_ent = readdir( directory ); } closedir( directory ); fpReserve = fopen( NULL_FILE, "r" ); } //saves a single clan void ClanSave( int handle ){ CLAN_DATA* pClan = GetClanData( handle ); FILE* fp; char path[MIL], buf[MIL]; if (pClan == NULL){ bug("clan.c>ClanSave: Could not get pointer to clan %d", handle ); return; } sprintf( path, "%s%s", CLAN_DIR, CLAN_TMP_FILE ); if ( (fp = fopen( path, "w")) == NULL){ perror( path ); return; } fWriteClan( fp, pClan ); fclose( fp ); sprintf( buf, "%s%s", CLAN_DIR, ClanFixName( pClan->name )); rename( path, buf ); } void SaveClans(){ int clan; fclose( fpReserve ); for ( clan = 0; clan < MAX_CLANS; clan++){ if (!IS_NULLSTR(clan_list[clan].name)) ClanSave( clan + 1 ); } fpReserve = fopen( NULL_FILE, "r" ); } /* commands: clan list //clan member only clan list clans //imm only clan create <clan> //imm only clan delete <clan> //imp only clan draft <victim> //clan leader only clan draft <victim> <clan> //imm/mob only clan remove <victim> //clan leader only clan remove <victim> <clan> //imm/mob only clan prom <victim> //elder only clan prom <victim> <clan> //imm/mob only clan demo <victim> //elder only clan demo <victim> <clan> //imm/mob only */ void do_clan( CHAR_DATA* ch, char* argument ){ int handle; char arg1[MIL], arg2[MIL], buf[MIL]; argument = one_argument( argument, arg1 ); if (IS_NULLSTR(arg1)){ send_to_char("Common clan commands are: draft, remove, prom, demo.\n\r", ch); return; } /* CREATE */ if (!str_prefix( arg1, "create")){ CLAN_DATA clan; memset(&clan, 0, sizeof( clan )); if (!IS_IMMORTAL(ch)){ send_to_char("You cannot create clans.\n\r", ch); return; } else if (IS_NULLSTR(argument)){ send_to_char( "Create what clan?\n\r", ch); return; } sprintf( buf, "%s", argument ); buf[0] = UPPER(buf[0]); clan.name = buf; if ( (handle = ClanNameToHandle( buf )) > 0){ send_to_char("That clan already exists.\n\r", ch); return; } else if ( (handle = ClanAdd( &clan )) < 0){ send_to_char("Error adding clan.\n\r", ch); return; } else sendf( ch, "Clan \"%s\" created.\n\r", ClanHandleToName( handle )); ClanSave( handle ); return; } /* DELETE */ if (!str_prefix( arg1, "delete")){ if (get_trust(ch) < CREATOR){ sendf( ch, "Requires level %d trust\n\r", CREATOR); return; } else if (IS_NULLSTR(argument)){ send_to_char( "Delete what clan?\n\r", ch); return; } else if ( (handle = ClanNameToHandle( argument )) < 1){ send_to_char("That clan doesn't exists.\n\r", ch); return; } else if ( !ClanRem( handle ) ){ send_to_char("Error deleting clan.\n\r", ch); return; } else{ send_to_char("Removed.\n\r", ch); } return; } /* LIST */ if (!str_prefix( arg1, "list")){ /* IMMORTAL LIST */ if (IS_IMMORTAL(ch)){ if (IS_NULLSTR(argument)){ if (GET_CLAN(ch) < 1){ send_to_char( "List which clan?\n\r", ch); return; } else handle = GET_CLAN(ch); } if (!str_cmp(argument, "clans")){ ListClans(ch); return; } else if ( (handle = ClanNameToHandle( argument )) < 1){ send_to_char("No such clan.\n\r", ch); return; } argument = one_argument( argument, arg1); ListMembers( ch, handle, TRUE, "Pts"); return; } /* MORTAL LIST */ else if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch ); return; } else if (!CLAN_ELDER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } ListMembers( ch, handle, FALSE, "Pts"); return; } /* RANKS */ else if (!str_prefix( arg1, "rank")){ /* IMMORTAL LIST */ if (IS_IMMORTAL(ch)){ if (IS_NULLSTR(argument)){ if (GET_CLAN(ch) < 1){ send_to_char( "List which clan?\n\r", ch); return; } else handle = GET_CLAN(ch); } if ( (handle = ClanNameToHandle( argument )) < 1){ send_to_char("No such clan.\n\r", ch); return; } argument = one_argument( argument, arg1); ListMembers( ch, handle, TRUE, "Rank"); return; } /* MORTAL LIST */ else if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch ); return; } else if (!CLAN_ELDER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } ListMembers( ch, handle, FALSE, "Rank"); return; } /* SENIOR */ else if (!str_prefix( arg1, "senior")){ /* IMMORTAL LIST */ if (IS_IMMORTAL(ch)){ if (IS_NULLSTR(argument)){ if (GET_CLAN(ch) < 1){ send_to_char( "List which clan?\n\r", ch); return; } else handle = GET_CLAN(ch); } if ( (handle = ClanNameToHandle( argument )) < 1){ send_to_char("No such clan.\n\r", ch); return; } argument = one_argument( argument, arg1); ListMembers( ch, handle, TRUE, "Senior"); return; } /* MORTAL LIST */ else if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch ); return; } else if (!CLAN_ELDER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } ListMembers( ch, handle, FALSE, "Senior"); return; } /* DRAFT */ else if (!str_prefix( arg1, "draft")){ CHAR_DATA* victim; argument = one_argument( argument, arg2); if ( IS_NULLSTR(arg2)){ send_to_char("Draft whom?\n\r", ch); return; } else if ((victim = get_char_room( ch, NULL, arg2)) == NULL){ send_to_char("They aren't here.\n\r", ch); return; } else if (IS_NPC(victim)){ send_to_char("Not on mobs.\n\r", ch); return; } /* IMMORTAL/NPC */ if (IS_IMMORTAL(ch) || (IS_NPC(ch) && get_trust(ch) >= IMPLEMENTOR)){ if (IS_NULLSTR(argument)){ if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("Draft them into which clan?\n\r", ch); return; } } if ( (handle = ClanNameToHandle( argument)) < 1){ send_to_char("That clan does not exist.\n\r", ch); return; } } /* MORTAL */ else if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch); return; } else if (!CLAN_ELDER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } else if (victim->master != ch && !IS_IMMORTAL(ch)){ send_to_char("They are not following you.\n\r", ch); return; } if (HAS_CLAN(victim)){ int cur = GET_CLAN(victim); ClanRemMember( cur, victim->name); ClanSave( cur ); } if ( (victim->pcdata->clan_handle = ClanAddMember( handle, victim )) < 1){ send_to_char("Error removing member.\n\r", ch); return; } ClanSave( handle ); act("$n is now a member of $t.", victim, ClanHandleToName( GET_CLAN(victim)), NULL, TO_ROOM); sendf( victim, "You are now a member of %s.\n\r", ClanHandleToName( GET_CLAN(victim)) ); return; } /* REMOVE */ else if (!str_prefix( arg1, "remove")){ CHAR_DATA* victim; argument = one_argument( argument, arg2); if ( IS_NULLSTR(arg2)){ send_to_char("Remove whom?\n\r", ch); return; } /* IMMORTAL/NPC */ if (IS_IMMORTAL(ch)){ if (IS_NULLSTR(argument)){ if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("Remove them from which clan?\n\r", ch); return; } } if ( (handle = ClanNameToHandle( argument)) < 1){ send_to_char("That clan does not exist.\n\r", ch); return; } } /* MORTAL */ else if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch); return; } else if (!CLAN_LEADER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } if (!ClanRemMember( handle, arg2)){ send_to_char("No such member in the clan.\n\r", ch); return; } if ( (victim = get_char( arg2 )) != NULL && !IS_NPC(victim)){ victim->pcdata->clan_handle = 0; send_to_char("You have been removed from your clan.\n\r", victim); } ClanSave( handle ); send_to_char("Removed.\n\r", ch); return; } /* PROMOTE */ else if (!str_prefix( arg1, "promote")){ CLAN_MEMBER* pCmd = NULL; argument = one_argument( argument, arg2); if ( IS_NULLSTR(arg2)){ send_to_char("Promote whom?\n\r", ch); return; } /* IMMORTAL/NPC */ if (IS_IMMORTAL(ch)){ if (IS_NULLSTR(argument)){ if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("Promote them in which clan?\n\r", ch); return; } } else if ( (handle = ClanNameToHandle( argument)) < 1){ send_to_char("That clan does not exist.\n\r", ch); return; } if ( (pCmd = GetClanMember(handle, arg2)) == NULL){ send_to_char("No such member in that clan.\n\r", ch); return; } } /* MORTAL */ else { if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch); return; } else if (!CLAN_ELDER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } else if ( (pCmd = GetClanMember( handle, arg2)) == NULL){ send_to_char("They are not part of your clan.\n\r", ch); return; } else if (pCmd->rank + 1 >= ch->pcdata->clan_rank){ send_to_char("You cannot promote them any further.\n\r", ch); return; } } if (pCmd){ CHAR_DATA* vch = get_char( pCmd->name ); if (pCmd->rank >= RANK_LEADER){ send_to_char("They cannot be promoted further.\n\r", ch); pCmd->rank = RANK_LEADER; } else{ pCmd->rank++; sendf(ch, "Promoted to %s.\n\r", clanr_table[pCmd->rank][1]); } if (vch && !IS_NPC(vch)){ SynchClanData( vch ); send_to_char("You have been promoted in within your clan!\n\r", vch); } } ClanSave( handle ); return; } /* DEMOTE */ else if (!str_prefix( arg1, "demote")){ CLAN_MEMBER* pCmd = NULL; argument = one_argument( argument, arg2); if ( IS_NULLSTR(arg2)){ send_to_char("Demote whom?\n\r", ch); return; } /* IMMORTAL/NPC */ if (IS_IMMORTAL(ch)){ if (IS_NULLSTR(argument)){ if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("Demote them in which clan?\n\r", ch); return; } } else if ( (handle = ClanNameToHandle( argument)) < 1){ send_to_char("That clan does not exist.\n\r", ch); return; } if ( (pCmd = GetClanMember(handle, arg2)) == NULL){ send_to_char("No such member in that clan.\n\r", ch); return; } } /* MORTAL */ else{ if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("You do not belong to a clan.\n\r", ch); return; } else if (!CLAN_LEADER(ch)){ send_to_char("You lack the privilige.\n\r", ch); return; } else if ( (pCmd = GetClanMember( handle, arg2)) == NULL){ send_to_char("They are not part of your clan.\n\r", ch); return; } else if (pCmd->rank >= ch->pcdata->clan_rank){ send_to_char("You cannot demote them.\n\r", ch); return; } } if (pCmd){ CHAR_DATA* vch = get_char( pCmd->name ); if (pCmd->rank <= RANK_NEWBIE){ send_to_char("They cannot be demoted further.\n\r", ch); pCmd->rank = RANK_NEWBIE; } else{ pCmd->rank--; sendf(ch, "Demoted to %s.\n\r", clanr_table[pCmd->rank][1]); } if (vch && !IS_NPC(vch)){ SynchClanData( vch ); send_to_char("You have been demoted in within your clan!\n\r", vch); } } ClanSave( handle ); return; } /* ALLOW */ else if (!str_prefix( arg1, "allow")){ CABAL_DATA* pCab; CLAN_MEMBER* pCmd = NULL; CHAR_DATA* victim; argument = one_argument( argument, arg2); if (!IS_IMMORTAL(ch)){ send_to_char("You are not an Immortal.\n\r", ch); return; } else if ( IS_NULLSTR(arg2)){ send_to_char("Allow whom to apply to their clan's cabal?\n\r", ch); return; } if (IS_NULLSTR(argument)){ if ( (handle = GET_CLAN(ch)) < 1){ send_to_char("Allow them in which clan?\n\r", ch); return; } } else if ( (handle = ClanNameToHandle( argument)) < 1){ send_to_char("That clan does not exist.\n\r", ch); return; } //min member check for (pCab = cabal_list; pCab; pCab = pCab->next){ if (pCab->clan == handle && pCab->cur_member >= pCab->max_member){ send_to_char("The cabal is at max. capacity.\n\r", ch); return; } } if ( (pCmd = GetClanMember(handle, arg2)) == NULL){ send_to_char("No such member in that clan.\n\r", ch); return; } pCmd->allowed = mud_data.current_time; if ( (victim = get_char( pCmd->name)) != NULL){ send_to_char("`@You have seven days to apply to your clan's cabal.``\n\r", victim); } else{ DESCRIPTOR_DATA* d; if ( (d = bring(ch->in_room, pCmd->name)) != NULL){ d->character->pcdata->roomnum *= -1; SET_BIT(d->character->pcdata->messages, MSG_CABAL_ALLOW); purge(d->character ); } } send_to_char("They have been allowed to vote for next 7 days.\n\r", ch); ClanSave( handle ); return; } else do_clan( ch, ""); } //returns clan's handle from name int GetClanHandle( char* name ){ return (ClanNameToHandle( name )); } //returns name of clan based onhandle char* GetClanName( int handle ){ return(ClanHandleToName( handle )); } //synchronizes clan and character data void SynchClanData( CHAR_DATA* ch ){ int handle; CLAN_MEMBER* pCmd; if ( (handle = GET_CLAN(ch)) < 1) return; else if ( (pCmd = GetClanMember( handle, ch->name)) == NULL) return; //synch pCmd->level = ch->level; pCmd->class = ch->class; pCmd->race = ch->race; pCmd->last_logon = ch->logoff; pCmd->pts = ch->pcdata->clan_points; if (ch->pCabal){ pCmd->rank = UMAX(ch->pcdata->rank, pCmd->rank); ch->pcdata->clan_points = 0; pCmd->pts = 0; pCmd->allowed = 0; } ch->pcdata->clan_rank = pCmd->rank; } //returns member data based on handle and name CLAN_MEMBER* GetClanMember( int handle, char* name ){ CLAN_MEMBER* pCmd; CLAN_DATA* pClan = GetClanData( handle ); if (pClan == NULL || IS_NULLSTR(name)) return NULL; for (pCmd = pClan->members.next; pCmd; pCmd = pCmd->next){ if (!str_cmp(name, pCmd->name)) return pCmd; } return NULL; } void CharToClan( CHAR_DATA* ch, int handle ){ if (IS_NPC(ch)) return; ch->pcdata->clan_handle = ClanAddMember( handle, ch); } void CharFromClan( CHAR_DATA* ch ){ int handle; if ( (handle = GET_CLAN( ch )) < 1) return; else if (ClanRemMember( handle, ch->name )) ClanSave( handle ); } void do_brownie( CHAR_DATA* ch, char* argument ){ CHAR_DATA* victim; char name[MIL]; int range; argument = one_argument( argument, name ); range = atoi( argument ); if (IS_NULLSTR(argument)){ send_to_char("Give brownie points to whom and on what scale (-2 to 2)?\n\r", ch); return; } else if ( (victim = get_char( name )) == NULL){ send_to_char("Character not found.\n\r", ch); return; } else if (IS_NPC(victim)){ send_to_char("Not on mobs.\n\r", ch); return; } else if (range == 0){ sendf( ch, "%s has %d points. Use scale of -2 to 2 to remove or add points.\n\r", PERS2(victim), victim->pcdata->clan_points); return; } else if (range < -2 || range > 2){ send_to_char("Use a scale of -2 to 52for the amount of reward.\n\r", ch); return; } switch (range){ case -2: victim->pcdata->clan_points -= 100; break; case -1: victim->pcdata->clan_points -= 50; break; case 2: victim->pcdata->clan_points += 100; break; case 1: victim->pcdata->clan_points += 50; break; default: break; } SynchClanData( victim ); sendf( ch, "%s's clan points now at %d\n\r", PERS2(victim), victim->pcdata->clan_points); save_char_obj( victim ); ClanSave( GET_CLAN(victim )); } int ClanSecondsToApply( CHAR_DATA* ch ){ int handle = GET_CLAN(ch); CLAN_MEMBER* pCmd; if (handle < 1){ return 0; } else if ( (pCmd = GetClanMember( handle, ch->name)) == NULL){ return 0; } else if (pCmd->allowed < 1){ return 0; } else if (mud_data.current_time - pCmd->allowed > CLAN_APPLY_WIN){ return 0; } else return (CLAN_APPLY_WIN - (mud_data.current_time - pCmd->allowed)); } bool ClanApplicationCheck( CHAR_DATA* ch, CABAL_DATA* pCab){ int handle = GET_CLAN(ch); CLAN_MEMBER* pCmd; if (handle < 1){ sendf(ch, "You cannot join %s beacuse you're a member of %s.\n\r", pCab->name, GetClanName(pCab->clan)); return FALSE; } else if ( (pCmd = GetClanMember( handle, ch->name)) == NULL){ sendf(ch, "You cannot join %s beacuse you're a member of %s.\n\r", pCab->name, GetClanName(pCab->clan)); return FALSE; } else if (pCmd->allowed < 1){ sendf(ch, "%s has not allowed you to apply to %s.\n\r", pCab->immortal, pCab->name ); return FALSE; } else if (mud_data.current_time - pCmd->allowed > CLAN_APPLY_WIN){ sendf(ch, "You have taken over seven days to apply. %s must allow you to do so once more.\n\r", pCab->immortal); return FALSE; } return TRUE; } void ClanEcho( int handle, char* string ){ DESCRIPTOR_DATA* d; for ( d = descriptor_list; d != NULL; d = d->next ){ if ( d->connected == CON_PLAYING && !IS_AFFECTED2(d->character, AFF_SILENCE) && !IS_NPC(d->character) && !is_affected(d->character,gsn_silence) && GET_CLAN(d->character) == handle ){ sendf(d->character,"[`8%s``]: '`0%s``'\n\r", GetClanName(handle), string); } } } bool ClanRename(int handle, char* current, char* new ){ CLAN_MEMBER* cm; if (handle < 1 || IS_NULLSTR(current) || IS_NULLSTR(new)) return FALSE; if ( (cm = GetClanMember(handle, current)) == NULL) return FALSE; free_string(cm->name); cm->name = str_dup (capitalize (new)); return TRUE; }
[ "A" ]
A
f7839ea4fd34762510b0bc2ffabc922d08b2df8e
3efe6e841b5b384976bf6cdfbc06d3c49ccb979c
/cayenne_lpp.h
da5b1a79145d1e5013eb9b8b05b22db9599e0dda
[ "MIT" ]
permissive
dron23/CayenneLPP
097d4197514c4d5bbaa0503c7e6ce3410c5717b3
74dce6fa84eb0d409f85c2ba562fdfe1f8209a06
refs/heads/master
2021-04-29T23:32:09.227265
2018-02-14T20:43:54
2018-02-14T20:43:54
121,557,152
0
0
null
null
null
null
UTF-8
C
false
false
3,284
h
struct CayenneLPP; // forward declared for encapsulation struct CayenneLPP* CayenneLPP__create(unsigned char size); void CayenneLPP__destroy(struct CayenneLPP* self); void CayenneLPP__reset(struct CayenneLPP* self); unsigned char CayenneLPP__getSize(struct CayenneLPP* self); unsigned char *CayenneLPP__getBuffer(struct CayenneLPP* self); unsigned char CayenneLPP__copy(struct CayenneLPP* self, unsigned char *dst); unsigned char CayenneLPP__addDigitalInput(struct CayenneLPP* self, unsigned char channel, unsigned char value); unsigned char CayenneLPP__addDigitalOutput(struct CayenneLPP* self, unsigned char channel, unsigned char value); unsigned char CayenneLPP__addAnalogInput(struct CayenneLPP* self, unsigned char channel, float value); unsigned char CayenneLPP__addAnalogOutput(struct CayenneLPP* self, unsigned char channel, float value); unsigned char CayenneLPP__addLuminosity(struct CayenneLPP* self, unsigned char channel, unsigned short int lux); unsigned char CayenneLPP__addPresence(struct CayenneLPP* self, unsigned char channel, unsigned char value); unsigned char CayenneLPP__addTemperature(struct CayenneLPP* self, unsigned char channel, float celsius); unsigned char CayenneLPP__addRelativeHumidity(struct CayenneLPP* self, unsigned char channel, float rh); unsigned char CayenneLPP__addAccelerometer(struct CayenneLPP* self, unsigned char channel, float x, float y, float z); unsigned char CayenneLPP__addBarometricPressure(struct CayenneLPP* self, unsigned char channel, float hpa); unsigned char CayenneLPP__addGyrometer(struct CayenneLPP* self, unsigned char channel, float x, float y, float z); unsigned char CayenneLPP__addGPS(struct CayenneLPP* self, unsigned char channel, float latitude, float longitude, float meters); #define LPP_DIGITAL_INPUT 0 // 1 byte #define LPP_DIGITAL_OUTPUT 1 // 1 byte #define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed #define LPP_ANALOG_OUTPUT 3 // 2 bytes, 0.01 signed #define LPP_LUMINOSITY 101 // 2 bytes, 1 lux unsigned #define LPP_PRESENCE 102 // 1 byte, 1 #define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed #define LPP_RELATIVE_HUMIDITY 104 // 1 byte, 0.5% unsigned #define LPP_ACCELEROMETER 113 // 2 bytes per axis, 0.001G #define LPP_BAROMETRIC_PRESSURE 115 // 2 bytes 0.1 hPa Unsigned #define LPP_GYROMETER 134 // 2 bytes per axis, 0.01 °/s #define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01 meter // Data ID + Data Type + Data Size #define LPP_DIGITAL_INPUT_SIZE 3 // 1 byte #define LPP_DIGITAL_OUTPUT_SIZE 3 // 1 byte #define LPP_ANALOG_INPUT_SIZE 4 // 2 bytes, 0.01 signed #define LPP_ANALOG_OUTPUT_SIZE 4 // 2 bytes, 0.01 signed #define LPP_LUMINOSITY_SIZE 4 // 2 bytes, 1 lux unsigned #define LPP_PRESENCE_SIZE 3 // 1 byte, 1 #define LPP_TEMPERATURE_SIZE 4 // 2 bytes, 0.1°C signed #define LPP_RELATIVE_HUMIDITY_SIZE 3 // 1 byte, 0.5% unsigned #define LPP_ACCELEROMETER_SIZE 8 // 2 bytes per axis, 0.001G #define LPP_BAROMETRIC_PRESSURE_SIZE 4 // 2 bytes 0.1 hPa Unsigned #define LPP_GYROMETER_SIZE 8 // 2 bytes per axis, 0.01 °/s #define LPP_GPS_SIZE 11 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01 meter
[ "jiri.slezka@slu.cz" ]
jiri.slezka@slu.cz
ead519138d72aacb17b14ba157ce2f4f52746d8d
8e0fac209fa8759dd956d31240fc30a61633088f
/Clase 6/sort/sort.c
3088b849f2b579256f7cc5cac7ca7d18c3215acd
[]
no_license
nmiguenz/Programacion_Laboratorio_I
c327e95177b574188446aa072e92c4aa4e17bdee
25079d7e0dfb1cd6cc5598f094c2f57c77f1557d
refs/heads/master
2020-03-07T19:57:52.335022
2018-04-18T13:34:58
2018-04-18T13:34:58
127,683,522
0
0
null
null
null
null
UTF-8
C
false
false
1,689
c
#include <stdio.h> #include <stdlib.h> int swapInt(int* primerEntero,int* segundoEntero); /** \brief Ordena un array de enteros * * \param array int* Puntero al array * \param cantidadElementos int cantidad de elementos del array * \param flagOrden int [1] Ordena de mayor a menor [0] Ordena de menor a mayor * \return int [-1] Error [0] Ok * */ int sort_ordenarArrayEnteros(int* array,int cantidadElementos, int flagOrden) { int retorno = -1; int flagSwap; int i; if(cantidadElementos > 0) { retorno = 0; do { flagSwap = 0; for(i=0;i<cantidadElementos-1;i++) { if((array[i] < array[i+1] && flagOrden)||(array[i] > array[i+1] && !flagOrden)) { swapInt(&array[i],&array[i+1]); flagSwap = 1; } } }while(flagSwap); } return retorno; } /** \brief Intercambia dos enteros * * \param primerEntero int* * \param segundoEntero int* * \return int * */ int swapInt(int* primerEntero,int* segundoEntero) { int auxiliar; auxiliar = *primerEntero; *primerEntero = *segundoEntero; *segundoEntero = auxiliar; return 0; } /** \brief * * \param array int* * \param cantidadElementos int * \return int * */ int sort_mostrarArrayEnteros(int* array, int cantidadElementos) { int retorno = -1; int i; if(cantidadElementos > 0) { retorno = 0; for(i=0;i<cantidadElementos;i++) { printf("\n%d",array[i]); } } return retorno; }
[ "noreply@github.com" ]
nmiguenz.noreply@github.com
7ef6b3a6ef018391123afc9f76a4e81e47dc7827
333f5ebf8816ba4ed89705b76c12e544d680d6c0
/Core/Src/stm32l4xx_it.c
b6b6805a8f33b70b5635a580f81d5ab14e08dec2
[]
no_license
tolae/PIDPingPongBall
4555ed4e65ab33e105f4c07483f86db3e7dc66bd
2e3cb643f7954739ba0266ec5776833757603aee
refs/heads/master
2023-01-07T17:10:56.961557
2020-11-08T20:06:10
2020-11-08T20:06:10
311,144,328
0
0
null
null
null
null
UTF-8
C
false
false
5,978
c
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file stm32l4xx_it.c * @brief Interrupt Service Routines. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32l4xx_it.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ /* USER CODE END TD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ extern TIM_HandleTypeDef htim2; extern UART_HandleTypeDef huart2; /* USER CODE BEGIN EV */ /* USER CODE END EV */ /******************************************************************************/ /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** * @brief This function handles Non maskable interrupt. */ void NMI_Handler(void) { /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ /* USER CODE END NonMaskableInt_IRQn 0 */ /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ /* USER CODE END NonMaskableInt_IRQn 1 */ } /** * @brief This function handles Hard fault interrupt. */ void HardFault_Handler(void) { /* USER CODE BEGIN HardFault_IRQn 0 */ /* USER CODE END HardFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_HardFault_IRQn 0 */ /* USER CODE END W1_HardFault_IRQn 0 */ } } /** * @brief This function handles Memory management fault. */ void MemManage_Handler(void) { /* USER CODE BEGIN MemoryManagement_IRQn 0 */ /* USER CODE END MemoryManagement_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ /* USER CODE END W1_MemoryManagement_IRQn 0 */ } } /** * @brief This function handles Prefetch fault, memory access fault. */ void BusFault_Handler(void) { /* USER CODE BEGIN BusFault_IRQn 0 */ /* USER CODE END BusFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_BusFault_IRQn 0 */ /* USER CODE END W1_BusFault_IRQn 0 */ } } /** * @brief This function handles Undefined instruction or illegal state. */ void UsageFault_Handler(void) { /* USER CODE BEGIN UsageFault_IRQn 0 */ /* USER CODE END UsageFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ /* USER CODE END W1_UsageFault_IRQn 0 */ } } /** * @brief This function handles System service call via SWI instruction. */ void SVC_Handler(void) { /* USER CODE BEGIN SVCall_IRQn 0 */ /* USER CODE END SVCall_IRQn 0 */ /* USER CODE BEGIN SVCall_IRQn 1 */ /* USER CODE END SVCall_IRQn 1 */ } /** * @brief This function handles Debug monitor. */ void DebugMon_Handler(void) { /* USER CODE BEGIN DebugMonitor_IRQn 0 */ /* USER CODE END DebugMonitor_IRQn 0 */ /* USER CODE BEGIN DebugMonitor_IRQn 1 */ /* USER CODE END DebugMonitor_IRQn 1 */ } /** * @brief This function handles Pendable request for system service. */ void PendSV_Handler(void) { /* USER CODE BEGIN PendSV_IRQn 0 */ /* USER CODE END PendSV_IRQn 0 */ /* USER CODE BEGIN PendSV_IRQn 1 */ /* USER CODE END PendSV_IRQn 1 */ } /** * @brief This function handles System tick timer. */ void SysTick_Handler(void) { /* USER CODE BEGIN SysTick_IRQn 0 */ /* USER CODE END SysTick_IRQn 0 */ HAL_IncTick(); /* USER CODE BEGIN SysTick_IRQn 1 */ /* USER CODE END SysTick_IRQn 1 */ } /******************************************************************************/ /* STM32L4xx Peripheral Interrupt Handlers */ /* Add here the Interrupt Handlers for the used peripherals. */ /* For the available peripheral interrupt handler names, */ /* please refer to the startup file (startup_stm32l4xx.s). */ /******************************************************************************/ /** * @brief This function handles TIM2 global interrupt. */ void TIM2_IRQHandler(void) { /* USER CODE BEGIN TIM2_IRQn 0 */ /* USER CODE END TIM2_IRQn 0 */ HAL_TIM_IRQHandler(&htim2); /* USER CODE BEGIN TIM2_IRQn 1 */ /* USER CODE END TIM2_IRQn 1 */ } /** * @brief This function handles USART2 global interrupt. */ void USART2_IRQHandler(void) { /* USER CODE BEGIN USART2_IRQn 0 */ /* USER CODE END USART2_IRQn 0 */ HAL_UART_IRQHandler(&huart2); /* USER CODE BEGIN USART2_IRQn 1 */ /* USER CODE END USART2_IRQn 1 */ } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
[ "ethanltola@gmail.com" ]
ethanltola@gmail.com
7128a1839763cdfacc09bb7a88f4b31e15797202
370d8ecf5c6e09e7e23dd4d3a75b620f1c026b43
/lab2.c
4aa06f26cfb661b1b343821ad09823ef0be0b196
[]
no_license
DarkProtocol/home_assigment
31258c6a1f4f6ba1123634f4f286bd30e79b694d
24f88b4bc8635df380f6d065aa76cb7ab565d382
refs/heads/master
2021-01-10T23:11:45.194883
2017-05-31T20:32:49
2017-05-31T20:32:49
70,637,927
0
3
null
null
null
null
UTF-8
C
false
false
6,236
c
#include <stdio.h> #include <string.h> #include <stdlib.h> #define INIT__STRIP_SIZE 14 #define STRIP_INC 7 /*Main turing struct*/ struct Turing { int *stripMemory; long long int stripSize; int *stripPosition; long long int memory; } turing_t; int sizePOS = 1; /* Size of variable, essential for functions begin & end */ /*main parsing function*/ void string_parse (char *s) { int i = 0, j; while (s[i] != '\0') { if ((s[i] == ' ') || (s[i] == '\t')) { for (j = i; j < strlen(s); j++) s[j] = s[j + 1]; } else { i++; } } } /* turing machine init */ void init (struct Turing *turing_t) { int i; turing_t->memory = 1; turing_t->stripSize = INIT__STRIP_SIZE; turing_t->stripMemory = (int *)malloc(turing_t->stripSize * sizeof(int)); turing_t->stripPosition = (int *)malloc(turing_t->memory * sizeof(int)); *(turing_t->stripPosition) = 0; for (i = 0; i < INIT__STRIP_SIZE; i++) { *(turing_t->stripMemory + i) = 0; } } void resize_strip_poaition (struct Turing *turing_t) { turing_t->memory++; turing_t->stripPosition = realloc(turing_t->stripPosition, turing_t->memory * sizeof(int)); *(turing_t->stripPosition + turing_t->memory) = 0; } void resize_strip (struct Turing *turing_t) { int i; turing_t->stripSize += STRIP_INC; turing_t->stripMemory = realloc(turing_t->stripMemory, turing_t->stripSize * sizeof(int)); for (i = (turing_t->stripSize - STRIP_INC); i < turing_t->stripSize; i++) { *(turing_t->stripMemory + i) = 0; } printf(" - Resize tape: new size = %d \n", turing_t->stripSize); } /* move left function */ void movl (struct Turing *turing_t) { if ( turing_t->stripSize <= ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) + 1) ) { resize_strip(turing_t); } if (32767 <= *(turing_t->stripPosition + turing_t->memory)) { resize_strip_poaition(turing_t); } (*(turing_t->stripPosition + turing_t->memory))++; printf(" - Leap to the left \n\n"); } /* move right function */ void movr (struct Turing *turing_t) { if ( ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory))) printf("Strip can't moving right \n"); else { (*(turing_t->stripPosition + turing_t->memory))--; printf("Strip was moving right \n"); } } /* increment function */ void inc (struct Turing *turing_t) { if ( *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ) == 255) { printf(" Max size is 255 \n"); *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ) = 0; } else { (*(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ))++; printf("Incrementing\n"); } } void dec (struct Turing *turing_t) { if ( *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ) == 0 ) { printf("Min size is 0 \n"); } else { (*(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ))--; printf("Decrementing \n"); } } void print (struct Turing *turing_t) { printf("Value of cell %d is", ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ); printf("%d \n\n", *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) )) ); } void get (struct Turing *turing_t) { int tmp; printf("Input value of cell: \n"); scanf("%d", &tmp); if ((tmp < 0) || (tmp > 255)) { printf("Max value is 255, min value is 0 \n"); get(turing_t); } else { *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ) = tmp; printf(" Value was changed \n"); } } void printc (struct Turing *turing_t) { printf(" - Value of cell %d is ", ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ); printf("%c \n\n", *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) )); } void begin (struct Turing *turing_t, int *fpos, FILE *fp) { char tmp[255]; if ( *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ) == 0 ) { printf("Value of cell is 0 \nthen exit from cycle \n\n"); while (strstr(tmp, "end") == 0) { fgets(tmp, 255, fp); } } else { if (ftell(fp) >= 32767) { sizePOS++; fpos = realloc(fpos, sizePOS * sizeof(int)); } *fpos = ftell(fp); } } void end (struct Turing *turing_t, int *fpos, FILE *fp) { if ( *(turing_t->stripMemory + ( ((turing_t->memory - 1) * 32767) + *(turing_t->stripPosition + turing_t->memory) ) ) == 0 ) { printf("Value of cell is 0 \nthen exit from cycle \n\n"); } else { printf("Transiting new iteration\n"); fseek(fp, *fpos, SEEK_SET); } } int main () { FILE *fp; char str[255]; int *fpos; init(&turing_t); fpos = (int *)malloc(sizePOS * sizeof(int)); fp = fopen("turing.txt", "r"); while (!feof(fp)) { fgets(str, 255, fp); string_parse(str); printf("%s", str); if (feof(fp) != 0) printf("\n"); if (strstr(str, "movl") != 0) movl(&turing_t); if (strstr(str, "movr") != 0) movr(&turing_t); if (strstr(str, "inc") != 0) inc(&turing_t); if (strstr(str, "printc") != 0) { printc(&turing_t); continue; } if (strstr(str, "dec") != 0) dec(&turing_t); if (strstr(str, "print") != 0) print(&turing_t); if (strstr(str, "get") != 0) get(&turing_t); if (strstr(str, "begin") != 0) { printf("........\n"); begin(&turing_t, fpos, fp); } if (strstr(str, "end") != 0) end(&turing_t, fpos, fp); } fclose(fp); free(turing_t.stripMemory); free(turing_t.stripPosition); free(fpos); return 0; }
[ "noreply@github.com" ]
DarkProtocol.noreply@github.com
1f182873e48a2af615b5651bff8e3e15a2fd60e9
ebb872cfebeea7f006a823d7b05022aa330eaa29
/22.c
d6835bc1285e847ab1bae383455f06130b19383f
[]
no_license
smythili1234/mythilisiva
f24489223ecad7f5f0d11f86ec0cd7fbf388f57c
e7beff79c0dd6e89b31bedc5edcba144481226c8
refs/heads/master
2021-09-09T20:01:41.444957
2018-03-19T11:24:29
2018-03-19T11:24:29
118,116,272
0
0
null
null
null
null
UTF-8
C
false
false
518
c
#include <stdio.h> int main() { int i, n; float arr[100]; printf("Enter total number of elements(1 to 100): "); scanf("%d", &n); printf("\n"); for(i = 0; i < n; ++i) { printf("Enter Number %d: ", i+1); scanf("%f", &arr[i]); } for(i = 1; i < n; ++i) { if(arr[0] < arr[i]) arr[0] = arr[i]; } printf("Largest element = %.2f", arr[0]); return 0; }
[ "noreply@github.com" ]
smythili1234.noreply@github.com
9cc41e4d48b8c6ced34ae08045986f9541a5cf19
46add311c50fe387140e1f0c3dedea5e2e12334d
/CPool_Day03/my_print_revalpha.c
4eac4bd15d31fbe7b55274891349b104ff385017
[]
no_license
jeremy9875/CPool
8c736c3f0947988327f7ba9b4647223e0303f316
f200b0dbf89d5a3c014ba6a705c4a3f27a6a8162
refs/heads/master
2020-03-25T18:13:01.828352
2018-08-08T13:38:13
2018-08-08T13:38:13
144,017,443
0
0
null
null
null
null
UTF-8
C
false
false
402
c
/* ** my_print_revalpha.c for my_print_revalpha in /home/jeremy.el-kaim/CPool_Day03 ** ** Made by jeremy elkaim ** Login <jeremy.el-kaim@epitech.net> ** ** Started on Wed Oct 5 10:50:46 2016 jeremy elkaim ** Last update Fri Oct 7 07:49:28 2016 jeremy elkaim */ int my_print_revalpha() { int c; c=122; while(c >= 97) { write(1, &c, 1); c--; } return (0); }
[ "jeremy.el-kaim@epitech.eu" ]
jeremy.el-kaim@epitech.eu
f0d4a4087b7e33f14b188ce28246afc674669fe6
1c6a7ae5dca2a38c68fde97a676478c6573bca02
/linux-3.0.1/drivers/char/efirtc.c
53c524e7b82928a78ff04e26be135ca4c1a4e428
[ "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
tonghua209/samsun6410_linux_3_0_0_1_for_aws
fab70b79dc3e506dc03ac1149e2356137869c6ca
31aa0dc27c4aab51a92309a74fd84ca65e8c6a58
refs/heads/master
2020-04-02T04:24:32.928744
2019-01-20T13:51:34
2019-01-20T13:51:34
154,015,176
0
0
Apache-2.0
2018-10-24T14:51:04
2018-10-21T14:07:31
C
UTF-8
C
false
false
9,743
c
/* * EFI Time Services Driver for Linux * * Copyright (C) 1999 Hewlett-Packard Co * Copyright (C) 1999 Stephane Eranian <eranian@hpl.hp.com> * * Based on skeleton from the drivers/char/rtc.c driver by P. Gortmaker * * This code provides an architected & portable interface to the real time * clock by using EFI instead of direct bit fiddling. The functionalities are * quite different from the rtc.c driver. The only way to talk to the device * is by using ioctl(). There is a /proc interface which provides the raw * information. * * Please note that we have kept the API as close as possible to the * legacy RTC. The standard /sbin/hwclock program should work normally * when used to get/set the time. * * NOTES: * - Locking is required for safe execution of EFI calls with regards * to interrupts and SMP. * * TODO (December 1999): * - provide the API to set/get the WakeUp Alarm (different from the * rtc.c alarm). * - SMP testing * - Add module support */ #include <linux/types.h> #include <linux/errno.h> #include <linux/miscdevice.h> #include <linux/module.h> #include <linux/init.h> #include <linux/rtc.h> #include <linux/proc_fs.h> #include <linux/efi.h> #include <linux/uaccess.h> #include <asm/system.h> #define EFI_RTC_VERSION "0.4" #define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT) /* * EFI Epoch is 1/1/1998 */ #define EFI_RTC_EPOCH 1998 static DEFINE_SPINLOCK(efi_rtc_lock); static long efi_rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg); #define is_leap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) static const unsigned short int __mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; /* * returns day of the year [0-365] */ static inline int compute_yday(efi_time_t *eft) { /* efi_time_t.month is in the [1-12] so, we need -1 */ return __mon_yday[is_leap(eft->year)][eft->month-1]+ eft->day -1; } /* * returns day of the week [0-6] 0=Sunday * * Don't try to provide a year that's before 1998, please ! */ static int compute_wday(efi_time_t *eft) { int y; int ndays = 0; if ( eft->year < 1998 ) { printk(KERN_ERR "efirtc: EFI year < 1998, invalid date\n"); return -1; } for(y=EFI_RTC_EPOCH; y < eft->year; y++ ) { ndays += 365 + (is_leap(y) ? 1 : 0); } ndays += compute_yday(eft); /* * 4=1/1/1998 was a Thursday */ return (ndays + 4) % 7; } static void convert_to_efi_time(struct rtc_time *wtime, efi_time_t *eft) { eft->year = wtime->tm_year + 1900; eft->month = wtime->tm_mon + 1; eft->day = wtime->tm_mday; eft->hour = wtime->tm_hour; eft->minute = wtime->tm_min; eft->second = wtime->tm_sec; eft->nanosecond = 0; eft->daylight = wtime->tm_isdst ? EFI_ISDST: 0; eft->timezone = EFI_UNSPECIFIED_TIMEZONE; } static void convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) { memset(wtime, 0, sizeof(*wtime)); wtime->tm_sec = eft->second; wtime->tm_min = eft->minute; wtime->tm_hour = eft->hour; wtime->tm_mday = eft->day; wtime->tm_mon = eft->month - 1; wtime->tm_year = eft->year - 1900; /* day of the week [0-6], Sunday=0 */ wtime->tm_wday = compute_wday(eft); /* day in the year [1-365]*/ wtime->tm_yday = compute_yday(eft); switch (eft->daylight & EFI_ISDST) { case EFI_ISDST: wtime->tm_isdst = 1; break; case EFI_TIME_ADJUST_DAYLIGHT: wtime->tm_isdst = 0; break; default: wtime->tm_isdst = -1; } } static long efi_rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { efi_status_t status; unsigned long flags; efi_time_t eft; efi_time_cap_t cap; struct rtc_time wtime; struct rtc_wkalrm __user *ewp; unsigned char enabled, pending; switch (cmd) { case RTC_UIE_ON: case RTC_UIE_OFF: case RTC_PIE_ON: case RTC_PIE_OFF: case RTC_AIE_ON: case RTC_AIE_OFF: case RTC_ALM_SET: case RTC_ALM_READ: case RTC_IRQP_READ: case RTC_IRQP_SET: case RTC_EPOCH_READ: case RTC_EPOCH_SET: return -EINVAL; case RTC_RD_TIME: spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.get_time(&eft, &cap); spin_unlock_irqrestore(&efi_rtc_lock,flags); if (status != EFI_SUCCESS) { /* should never happen */ printk(KERN_ERR "efitime: can't read time\n"); return -EINVAL; } convert_from_efi_time(&eft, &wtime); return copy_to_user((void __user *)arg, &wtime, sizeof (struct rtc_time)) ? - EFAULT : 0; case RTC_SET_TIME: if (!capable(CAP_SYS_TIME)) return -EACCES; if (copy_from_user(&wtime, (struct rtc_time __user *)arg, sizeof(struct rtc_time)) ) return -EFAULT; convert_to_efi_time(&wtime, &eft); spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.set_time(&eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); return status == EFI_SUCCESS ? 0 : -EINVAL; case RTC_WKALM_SET: if (!capable(CAP_SYS_TIME)) return -EACCES; ewp = (struct rtc_wkalrm __user *)arg; if ( get_user(enabled, &ewp->enabled) || copy_from_user(&wtime, &ewp->time, sizeof(struct rtc_time)) ) return -EFAULT; convert_to_efi_time(&wtime, &eft); spin_lock_irqsave(&efi_rtc_lock, flags); /* * XXX Fixme: * As of EFI 0.92 with the firmware I have on my * machine this call does not seem to work quite * right */ status = efi.set_wakeup_time((efi_bool_t)enabled, &eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); return status == EFI_SUCCESS ? 0 : -EINVAL; case RTC_WKALM_RD: spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); if (status != EFI_SUCCESS) return -EINVAL; ewp = (struct rtc_wkalrm __user *)arg; if ( put_user(enabled, &ewp->enabled) || put_user(pending, &ewp->pending)) return -EFAULT; convert_from_efi_time(&eft, &wtime); return copy_to_user(&ewp->time, &wtime, sizeof(struct rtc_time)) ? -EFAULT : 0; } return -ENOTTY; } /* * We enforce only one user at a time here with the open/close. * Also clear the previous interrupt data on an open, and clean * up things on a close. */ static int efi_rtc_open(struct inode *inode, struct file *file) { /* * nothing special to do here * We do accept multiple open files at the same time as we * synchronize on the per call operation. */ return 0; } static int efi_rtc_close(struct inode *inode, struct file *file) { return 0; } /* * The various file operations we support. */ static const struct file_operations efi_rtc_fops = { .owner = THIS_MODULE, .unlocked_ioctl = efi_rtc_ioctl, .open = efi_rtc_open, .release = efi_rtc_close, .llseek = no_llseek, }; static struct miscdevice efi_rtc_dev= { EFI_RTC_MINOR, "efirtc", &efi_rtc_fops }; /* * We export RAW EFI information to /proc/driver/efirtc */ static int efi_rtc_get_status(char *buf) { efi_time_t eft, alm; efi_time_cap_t cap; char *p = buf; efi_bool_t enabled, pending; unsigned long flags; memset(&eft, 0, sizeof(eft)); memset(&alm, 0, sizeof(alm)); memset(&cap, 0, sizeof(cap)); spin_lock_irqsave(&efi_rtc_lock, flags); efi.get_time(&eft, &cap); efi.get_wakeup_time(&enabled, &pending, &alm); spin_unlock_irqrestore(&efi_rtc_lock,flags); p += sprintf(p, "Time : %u:%u:%u.%09u\n" "Date : %u-%u-%u\n" "Daylight : %u\n", eft.hour, eft.minute, eft.second, eft.nanosecond, eft.year, eft.month, eft.day, eft.daylight); if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) p += sprintf(p, "Timezone : unspecified\n"); else /* XXX fixme: convert to string? */ p += sprintf(p, "Timezone : %u\n", eft.timezone); p += sprintf(p, "Alarm Time : %u:%u:%u.%09u\n" "Alarm Date : %u-%u-%u\n" "Alarm Daylight : %u\n" "Enabled : %s\n" "Pending : %s\n", alm.hour, alm.minute, alm.second, alm.nanosecond, alm.year, alm.month, alm.day, alm.daylight, enabled == 1 ? "yes" : "no", pending == 1 ? "yes" : "no"); if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) p += sprintf(p, "Timezone : unspecified\n"); else /* XXX fixme: convert to string? */ p += sprintf(p, "Timezone : %u\n", alm.timezone); /* * now prints the capabilities */ p += sprintf(p, "Resolution : %u\n" "Accuracy : %u\n" "SetstoZero : %u\n", cap.resolution, cap.accuracy, cap.sets_to_zero); return p - buf; } static int efi_rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { int len = efi_rtc_get_status(page); if (len <= off+count) *eof = 1; *start = page + off; len -= off; if (len>count) len = count; if (len<0) len = 0; return len; } static int __init efi_rtc_init(void) { int ret; struct proc_dir_entry *dir; printk(KERN_INFO "EFI Time Services Driver v%s\n", EFI_RTC_VERSION); ret = misc_register(&efi_rtc_dev); if (ret) { printk(KERN_ERR "efirtc: can't misc_register on minor=%d\n", EFI_RTC_MINOR); return ret; } dir = create_proc_read_entry ("driver/efirtc", 0, NULL, efi_rtc_read_proc, NULL); if (dir == NULL) { printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n"); misc_deregister(&efi_rtc_dev); return -1; } return 0; } static void __exit efi_rtc_exit(void) { /* not yet used */ } module_init(efi_rtc_init); module_exit(efi_rtc_exit); MODULE_LICENSE("GPL");
[ "kyh1022@163.com" ]
kyh1022@163.com
3d2cc3fbdda8b2ff2d371966a17869aaaefb8865
af9b7a49f5912142ff4e7cb35fd11b1e9635154d
/sdk/codec/flacdecode/main.c
47e852761e705f4255a6ed92edfdafb1bee660b3
[]
no_license
YuHsinShi/2430personal
528ff02226102af77a006fef80fe7c35139fa7bb
83e1ce53a7d872ed27bad4ba5549953975c0be3b
refs/heads/master
2023-03-06T14:44:31.607663
2020-07-25T15:55:28
2020-07-25T15:55:28
340,536,248
1
0
null
null
null
null
UTF-8
C
false
false
36,170
c
///////////////////////////////////////////////////////////////// // Include File ///////////////////////////////////////////////////////////////// #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "config.h" #include "flac.h" #if defined(ENABLE_CODECS_PLUGIN) # include "plugin.h" #endif #if defined(__OR32__) #include "i2s.h" #include "mmio.h" #endif #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) /* Code for general_printf() */ #define BITS_PER_BYTE 8 #define MINUS_SIGN 1 #define RIGHT_JUSTIFY 2 #define ZERO_PAD 4 #define CAPITAL_HEX 8 struct parameters { int number_of_output_chars; short minimum_field_width; char options; short edited_string_length; short leading_zeros; }; #endif ///////////////////////////////////////////////////////////////// // Local Variable ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // Global Variable ///////////////////////////////////////////////////////////////// FLACContext gFLACContext; /* Decode status */ static int lastRound; static int eofReached; static unsigned int pcmReadIdx; static unsigned int pcmWriteIdx; static unsigned int pcmDumpIdx; static unsigned int decTime = 0; // Decoding time in seconds on S15.16 fixed point. static unsigned int flacFrameStep; static unsigned int flacFrameAccu; static int gnWaitSize = READBUF_SIZE/2; #if defined(WIN32) || defined(__CYGWIN__) FILE *fmp3 = NULL; char *mp3save = "D:\\audio_testing\\Mp3\\MPA.mp3"; FILE *fwav = NULL; char *wavSrc = "D:\\audio_testing\\FLAC\\bird44100FLAC.wav"; char gStream[8*1024*1024]; int gStreamRead=0; #endif char streamBuf[READBUF_SIZE+2] __attribute__ ((aligned(16))); // FLAC input buffer char gOutBuf[OUTBUF_SIZE] __attribute__ ((aligned(16))); // decode pcm buffer unsigned char gTempFlac[FLAC_AVG_FRAME_SIZE]; // temp buffer for FLAC data short gFrame[FLAC_AVG_FRAME_SIZE]; #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) static unsigned int* gtAudioPluginBufferLength; static unsigned short* gtAudioPluginBuffer; static int gnTemp; static unsigned char tDumpWave[] = "C:/flac_dump.wav"; static int gCh; static int gSampleRate; int gPause = 0 ; int gPrint = 0; unsigned char *gBuf; #endif static unsigned int nFrames; ///////////////////////////////////////////////////////////////// // Global Function ///////////////////////////////////////////////////////////////// #define getUsedLen(rdptr, wrptr, len) (((wrptr) >= (rdptr)) ? ((wrptr) - (rdptr)) : ((len) - ((rdptr) - (wrptr)))) #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) static void AudioPluginAPI(int nType); __inline int ithPrintf(char* control, ...); #endif #ifdef ITE_RISC static int FillReadBuffer(int nReadBytes); static void FillWriteBuffer(int nPcmBytes); static void waitAvaliableReadBufferSize(int nWaitSize); static __inline void updateTime(void) { flacFrameAccu += (flacFrameStep & 0x7fff); decTime = decTime + (flacFrameStep >> 15) + (flacFrameAccu >> 15); flacFrameAccu = flacFrameAccu & 0x7fff; MMIO_Write(DrvDecode_Frame_Lo, (short)( ((unsigned int)decTime) & 0xffff)); MMIO_Write(DrvDecode_Frame_Hi, (short)( ((unsigned int)decTime) >> 16) ); } /************************************************************************************** * Function : AudioPluginAPI * * Description : AudioPluginAPI * * Input : plugin type * * Output : None * * Note : **************************************************************************************/ #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) static void output_and_count(struct parameters *p, int c) { if (p->number_of_output_chars >= 0) { int n = c; gBuf[gPrint++] = c; if (n >= 0) p->number_of_output_chars++; else p->number_of_output_chars = n; } } static void output_field(struct parameters *p, char *s) { short justification_length = p->minimum_field_width - p->leading_zeros - p->edited_string_length; if (p->options & MINUS_SIGN) { if (p->options & ZERO_PAD) output_and_count(p, '-'); justification_length--; } if (p->options & RIGHT_JUSTIFY) while (--justification_length >= 0) output_and_count(p, p->options & ZERO_PAD ? '0' : ' '); if (p->options & MINUS_SIGN && !(p->options & ZERO_PAD)) output_and_count(p, '-'); while (--p->leading_zeros >= 0) output_and_count(p, '0'); while (--p->edited_string_length >= 0){ output_and_count(p, *s++); } while (--justification_length >= 0) output_and_count(p, ' '); } int ithGPrintf(const char *control_string, va_list va)/*const int *argument_pointer)*/ { struct parameters p; char control_char; p.number_of_output_chars = 0; control_char = *control_string++; while (control_char != '\0') { if (control_char == '%') { short precision = -1; short long_argument = 0; short base = 0; control_char = *control_string++; p.minimum_field_width = 0; p.leading_zeros = 0; p.options = RIGHT_JUSTIFY; if (control_char == '-') { p.options = 0; control_char = *control_string++; } if (control_char == '0') { p.options |= ZERO_PAD; control_char = *control_string++; } if (control_char == '*') { //p.minimum_field_width = *argument_pointer++; control_char = *control_string++; } else { while ('0' <= control_char && control_char <= '9') { p.minimum_field_width = p.minimum_field_width * 10 + control_char - '0'; control_char = *control_string++; } } if (control_char == '.') { control_char = *control_string++; if (control_char == '*') { //precision = *argument_pointer++; control_char = *control_string++; } else { precision = 0; while ('0' <= control_char && control_char <= '9') { precision = precision * 10 + control_char - '0'; control_char = *control_string++; } } } if (control_char == 'l') { long_argument = 1; control_char = *control_string++; } if (control_char == 'd') base = 10; else if (control_char == 'x') base = 16; else if (control_char == 'X') { base = 16; p.options |= CAPITAL_HEX; } else if (control_char == 'u') base = 10; else if (control_char == 'o') base = 8; else if (control_char == 'b') base = 2; else if (control_char == 'c') { base = -1; p.options &= ~ZERO_PAD; } else if (control_char == 's') { base = -2; p.options &= ~ZERO_PAD; } if (base == 0) /* invalid conversion type */ { if (control_char != '\0') { output_and_count(&p, control_char); control_char = *control_string++; } } else { if (base == -1) /* conversion type c */ { //char c = *argument_pointer++; char c = (char)(va_arg(va, int)); p.edited_string_length = 1; output_field(&p, &c); } else if (base == -2) /* conversion type s */ { char *string; p.edited_string_length = 0; //string = *(char **) argument_pointer; //argument_pointer += sizeof(char *) / sizeof(int); string = va_arg(va, char*); while (string[p.edited_string_length] != 0) p.edited_string_length++; if (precision >= 0 && p.edited_string_length > precision) p.edited_string_length = precision; output_field(&p, string); } else /* conversion type d, b, o or x */ { unsigned long x; char buffer[BITS_PER_BYTE * sizeof(unsigned long) + 1]; p.edited_string_length = 0; if (long_argument) { //x = *(unsigned long *) argument_pointer; //argument_pointer += sizeof(unsigned long) / sizeof(int); va_arg(va, unsigned int); } else if (control_char == 'd') //x = (long) *argument_pointer++; x = va_arg(va, long); else //x = (unsigned) *argument_pointer++; x = va_arg(va, int); if (control_char == 'd' && (long) x < 0) { p.options |= MINUS_SIGN; x = -(long) x; } do { int c; c = x % base + '0'; if (c > '9') { if (p.options & CAPITAL_HEX) c += 'A' - '9' - 1; else c += 'a' - '9' - 1; } buffer[sizeof(buffer) - 1 - p.edited_string_length++] = c; } while ((x /= base) != 0); if (precision >= 0 && precision > p.edited_string_length) p.leading_zeros = precision - p.edited_string_length; output_field(&p, buffer + sizeof(buffer) - p.edited_string_length); } control_char = *control_string++; } } else { output_and_count(&p, control_char); control_char = *control_string++; } } return p.number_of_output_chars; } int ithPrintf(char* control, ...) { va_list va; va_start(va,control); gPrint = 0; gBuf = (unsigned char*)gtAudioPluginBuffer; ithGPrintf(control, va); va_end(va); return 0; } void AudioPluginAPI(int nType) { unsigned short nRegister; int i; int nTemp,nTemp1; unsigned char* pBuf; nRegister = (SMTK_AUDIO_PROCESSOR_ID<<14) | nType; switch (nType) { case SMTK_AUDIO_PLUGIN_CMD_ID_FILE_OPEN: gnTemp = sizeof(tDumpWave); //printf("[FLAC] name length %d \n",gnTemp); memcpy(&gtAudioPluginBuffer[0], &gnTemp, SMTK_AUDIO_PLUGIN_CMD_FILE_NAME_LENGTH); memcpy(&gtAudioPluginBuffer[SMTK_AUDIO_PLUGIN_CMD_FILE_NAME_LENGTH/sizeof(short)], tDumpWave, sizeof(tDumpWave)); break; case SMTK_AUDIO_PLUGIN_CMD_ID_FILE_WRITE: // printf("[FLAC] name length %d \n",gnTemp); memcpy(&gtAudioPluginBuffer[0], &gnTemp, SMTK_AUDIO_PLUGIN_CMD_FILE_NAME_LENGTH); { int i; char tmp; char *buf = (char *)&gOutBuf[pcmWriteIdx]; for(i=0; i<gnTemp; i+=2) { tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp; } } memcpy(&gtAudioPluginBuffer[SMTK_AUDIO_PLUGIN_CMD_FILE_WRITE_LENGTH/sizeof(short)], &gOutBuf[pcmWriteIdx], gnTemp); break; case SMTK_AUDIO_PLUGIN_CMD_ID_FILE_CLOSE: break; case SMTK_AUDIO_PLUGIN_CMD_ID_I2S_INIT_DAC: nTemp = gOutBuf; nTemp1 = sizeof(gOutBuf); pBuf = (unsigned char*)gtAudioPluginBuffer; memcpy(&pBuf[0], &nTemp, sizeof(int)); memcpy(&pBuf[4], &gCh, sizeof(int)); memcpy(&pBuf[8], &gSampleRate, sizeof(int)); memcpy(&pBuf[12], &nTemp1, sizeof(int)); memcpy(&pBuf[16],&gFLACContext.curr_bps,sizeof(int)); //printf("[FLAC] 0x%x %d %d %d \n",nTemp,gCh,gSampleRate,nTemp1); break; case SMTK_AUDIO_PLUGIN_CMD_ID_I2S_PAUSE_DAC: pBuf = (unsigned char*)gtAudioPluginBuffer; memcpy(&pBuf[0], &gPause, sizeof(int)); //printf("[E-AC3] pause %d \n",gPause); break; case SMTK_AUDIO_PLUGIN_CMD_ID_I2S_DEACTIVE_DAC: break; case SMTK_AUDIO_PLUGIN_CMD_ID_PRINTF: break; case SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX: pBuf = (unsigned char*)gtAudioPluginBuffer; memcpy(&pBuf[0], &pcmDumpIdx, sizeof(int)); break; default: break; } #ifdef CFG_CPU_WB ithFlushDCacheRange((void*)gtAudioPluginBuffer, gtAudioPluginBufferLength); ithFlushMemBuffer(); #endif setAudioPluginMessageStatus(nRegister); i=200000*20; do { nRegister = getAudioPluginMessageStatus(); nRegister = (nRegister & 0xc000)>>14; if (nRegister== SMTK_MAIN_PROCESSOR_ID) { //printf("[Mp3] get main procerror feedback \n"); break; } i--; }while(i && !isSTOP()); //if (i==0) //printf("[E-AC3] audio api %d %d\n",i,nType); } #endif static __inline unsigned int setStreamRdPtr(unsigned int wrPtr) { MMIO_Write(DrvDecode_RdPtr, wrPtr); return 0; } static __inline unsigned int setStreamWrPtr(unsigned int wrPtr) { MMIO_Write(DrvDecode_WrPtr, wrPtr); return 0; } static __inline unsigned int getStreamWrPtr() { unsigned int wrPtr; wrPtr = MMIO_Read(DrvDecode_WrPtr); return wrPtr; } __inline unsigned int getStreamRdPtr() { unsigned int rdPtr; rdPtr = MMIO_Read(DrvDecode_RdPtr); #if defined(__OR32__) && !defined(__OPENRTOS__) if (0xffff == rdPtr) asm volatile("l.trap 15"); #endif return rdPtr; } __inline unsigned int getOutBufRdPtr() { unsigned int rdPtr; #if defined(__OPENRTOS__) rdPtr = CODEC_I2S_GET_OUTRD_PTR(); #else rdPtr = MMIO_Read(DrvEncode_RdPtr); #endif return rdPtr; } __inline unsigned int getOutBufWrPtr() { unsigned int wrPtr; wrPtr = MMIO_Read(DrvEncode_WrPtr); return wrPtr; } static void waitAvaliableReadBufferSize(int nWaitSize) { int len = 0; int i=0; unsigned int flacReadIdx,flacWriteIdx; do { flacReadIdx = getStreamRdPtr(); // Wait Read Buffer avaliable flacWriteIdx = getStreamWrPtr(); len = getUsedLen(flacReadIdx, flacWriteIdx, READBUF_SIZE); #if defined(__OPENRTOS__) //PalSleep(2); for (i=0;i<100;i++); #else or32_delay(1); // enter sleep mode for power saving #endif } while (len < nWaitSize && !isSTOP()); } static int GetAvaliableReadBufferSize() { int len = 0; unsigned int flacReadIdx,flacWriteIdx; flacReadIdx = getStreamRdPtr(); // Wait Read Buffer avaliable flacWriteIdx = getStreamWrPtr(); len = getUsedLen(flacReadIdx, flacWriteIdx, READBUF_SIZE); return len; } /************************************************************************************** * Function : FillReadBuffer * * Description : Update the read pointer of WAVE Buffer and return the valid data length * of input buffer. * * Inputs : nReadBytes: number of bytes will read * * Global var : wavWriteIdx: write pointer of WAVE buffer * flacReadIdx : read pointer of WAVE buffer * * Return : * * TODO : * * Note : The WAVE buffer is circular buffer. * **************************************************************************************/ static int FillReadBuffer(int nReadBytes) { int len = 0; unsigned int flacReadIdx,flacWriteIdx; flacReadIdx = getStreamRdPtr(); // Update Read Buffer if (nReadBytes > 0) { flacReadIdx = flacReadIdx + nReadBytes; if (flacReadIdx >= READBUF_SIZE) { flacReadIdx -= READBUF_SIZE; } setStreamRdPtr(flacReadIdx); } #if defined(__OPENRTOS__) dc_invalidate(); // Flush Data Cache #endif // Wait Read Buffer avaliable flacWriteIdx = getStreamWrPtr(); len = getUsedLen(flacReadIdx, flacWriteIdx, READBUF_SIZE); return len; } /************************************************************************************** * Function : FillWriteBuffer * * Description : Wait the avaliable length of the output buffer bigger than on * frame of audio data. * * Inputs : * * Global Var : pcmWriteIdx: write index of output buffer. * pcmReadIdx : read index of output buffer. * * Outputs : * * Return : * * TODO : * * Note : Output buffer is a circular queue. * **************************************************************************************/ static void FillWriteBuffer(int nPcmBytes) { int len; int i; // Update Write Buffer if (nPcmBytes > 0) { //nOutWriteIdx = nOutWriteIdx + nPcmBytes; if (pcmWriteIdx+nPcmBytes >= OUTBUF_SIZE) { if(OUTBUF_SIZE-pcmWriteIdx) { memcpy(&gOutBuf[pcmWriteIdx],&gFrame[0],OUTBUF_SIZE-pcmWriteIdx); #ifdef CFG_CPU_WB ithFlushDCacheRange((void*)(gOutBuf + pcmWriteIdx), OUTBUF_SIZE-pcmWriteIdx); #endif } memcpy(&gOutBuf[0],&gFrame[OUTBUF_SIZE-pcmWriteIdx],nPcmBytes-(OUTBUF_SIZE-pcmWriteIdx)); #ifdef CFG_CPU_WB ithFlushDCacheRange((void*)(gOutBuf), nPcmBytes-(OUTBUF_SIZE-pcmWriteIdx)); ithFlushMemBuffer(); #endif pcmWriteIdx = nPcmBytes-(OUTBUF_SIZE-pcmWriteIdx); } else { memcpy(&gOutBuf[pcmWriteIdx],&gFrame[0],nPcmBytes); #ifdef CFG_CPU_WB ithFlushDCacheRange((void*)(gOutBuf + pcmWriteIdx), nPcmBytes); ithFlushMemBuffer(); #endif pcmWriteIdx+=nPcmBytes; } #if defined(__OPENRTOS__) if(isMusicCodecDump()) { if(pcmDumpIdx <= pcmWriteIdx) { i = nPcmBytes; while(i > (nPcmBytes>>1)) { pcmDumpIdx += (nPcmBytes>>1); i -= (nPcmBytes>>1); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); } if(i) { pcmDumpIdx += i; AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); } } else { uint32_t szsec0 = OUTBUF_SIZE - pcmDumpIdx; uint32_t szsec1 = nPcmBytes - szsec0; i = szsec0; while(i > (nPcmBytes>>1)) { pcmDumpIdx += (nPcmBytes>>1); if(pcmDumpIdx == OUTBUF_SIZE) pcmDumpIdx = 0; i -= (nPcmBytes>>1); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); } if(i) { pcmDumpIdx += i; if(pcmDumpIdx == OUTBUF_SIZE) pcmDumpIdx = 0; AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); } i = szsec1; while(i > (nPcmBytes>>1)) { pcmDumpIdx += (nPcmBytes>>1); i -= (nPcmBytes>>1); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); } if(i) { pcmDumpIdx += i; AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); } } // AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); // for (i=0;i<100000;i++); while (CODEC_I2S_GET_OUT_FREE_LEN() < (CODEC_I2S_GET_OUT_BUF_LEN())/2) AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PCMIDX); return; } else CODEC_I2S_SET_OUTWR_PTR(pcmWriteIdx); #else SetOutWrPtr(pcmWriteIdx); #endif } //updateTime(); // Wait output buffer avaliable do { #if defined(__OPENRTOS__) pcmReadIdx = CODEC_I2S_GET_OUTRD_PTR(); #else pcmReadIdx = GetOutRdPtr(); #endif if (pcmReadIdx <= pcmWriteIdx) { len = OUTBUF_SIZE - (pcmWriteIdx - pcmReadIdx); } else { len = pcmReadIdx - pcmWriteIdx; } if (len < FLAC_AVG_FRAME_SIZE && !isSTOP()) { #if defined(__OPENRTOS__) //PalSleep(2); for (i=0;i<100000;i++); #else or32_delay(1); // enter sleep mode for power saving #endif } else { break; } } while(1); // PRINTF("pcmWriteIdx(%d) pcmReadIdx(%d) len(%d) nPCMBytes(%d)\n", pcmWriteIdx, pcmReadIdx, len, nPCMBytes); } static __inline void checkControl(void) { static int curPause = 0; static int prePause = 0; do { eofReached = isEOF() || isSTOP(); curPause = isPAUSE(); if (!curPause) { // Un-pause if (prePause) pauseDAC(0); break; } else { // Pause if (!prePause && curPause) { pauseDAC(1); } #if defined(__OPENRTOS__) #else or32_delay(1); // delay 1ms #endif } prePause = curPause; } while(!eofReached); prePause = curPause; } /************************************************************************************** * Function : AdjustBuffer * * Description : move the reset of data to the front of buffer. * * Inputs : waitNBytes: number of bytes to read * * Global var : flacWriteIdx: write pointer of FLAC buffer * flacReadIdx : read pointer of FLAC buffer * * Return : * * TODO : * * Note : The FLAC buffer is circular buffer. * **************************************************************************************/ static int AdjustBuffer(int waitNBytes) { int len; unsigned int flacReadIdx,flacWriteIdx; int nTemp = 0; flacReadIdx = getStreamRdPtr(); flacWriteIdx = getStreamWrPtr(); // It should be invalidate the cache line which it is in the // begin of input buffer. The previous frame will // prefetch the data to the cache line, but the driver dose // not yet put it in the input buffer. It will cause the // unconsistency of cache. if (flacReadIdx + waitNBytes >= READBUF_SIZE) { // do memory move when exceed guard band // Update Read Pointer MMIO_Write(DrvDecode_RdPtr, (unsigned short)(((flacReadIdx-READBUF_BEGIN)>>1) << 1)); // Wait the flacWriteIdx get out of the area of rest data. do { checkControl(); flacReadIdx = getStreamWrPtr(); if (flacWriteIdx >= flacReadIdx && !eofReached) { #if defined(__OPENRTOS__) //taskYIELD(); #else or32_delay(1); // enter sleep mode for power saving #endif } else { break; } } while(!eofReached); if (flacWriteIdx < flacReadIdx) { #if defined(__OPENRTOS__) dc_invalidate(); // Flush Data Cache #endif // Move the rest data to the front of data buffer memcpy(&streamBuf[READBUF_BEGIN - (READBUF_SIZE - flacReadIdx)], &streamBuf[flacReadIdx], READBUF_SIZE-flacReadIdx); flacReadIdx = READBUF_BEGIN - (READBUF_SIZE - flacReadIdx); } } flacWriteIdx = getStreamWrPtr(); if (flacWriteIdx >= flacReadIdx) { len = flacWriteIdx - flacReadIdx; } else { len = READBUF_LEN - (flacReadIdx - flacWriteIdx); } return len; } void ClearRdBuffer(void) { //SetFrameNo(0); MMIO_Write(DrvDecode_WrPtr, 0); MMIO_Write(DrvDecode_RdPtr, 0); #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) //AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_I2S_DEACTIVE_DAC); #else deactiveDAC(); // Disable I2S interface #endif if (isSTOP()) { MMIO_Write(DrvAudioCtrl, MMIO_Read(DrvAudioCtrl) & ~DrvDecode_STOP); } #if !defined(WIN32) && !defined(__CYGWIN__) MMIO_Write(DrvDecode_Frame_Lo, 0); MMIO_Write(DrvDecode_Frame_Hi, 0); #endif // !defined(WIN32) && !defined(__CYGWIN__) #if defined(__FREERTOS__)|| defined(__OPENRTOS__) dc_invalidate(); // Flush DC Cache #endif gnWaitSize = READBUF_SIZE/2; } #endif // #ifdef ITE_RISC // Prepare flac data to decode buffer,and return flac frame length // Flac frame length need parsing static int getFLACFrame(){ FLACFrameInfo tFlacInfo; int len = 0; unsigned int flacReadIdx,flacWriteIdx; int nTemp = 0; int frameLength; int keep; flacFrameAccu = 0; // get flac data flacReadIdx = getStreamRdPtr(); flacWriteIdx = getStreamWrPtr(); do { #if 1 //waitAvaliableReadBufferSize(MAX_FRAME_HEADER_SIZE); waitAvaliableReadBufferSize(gnWaitSize); if (MAX_FRAME_HEADER_SIZE+flacReadIdx<READBUF_SIZE) { //memcpy(&gTempFlac[0],&streamBuf[flacReadIdx],MAX_FRAME_HEADER_SIZE); if (((streamBuf[flacReadIdx]<<8|streamBuf[flacReadIdx+1]) & 0xFFFE) == 0xFFF8) { nTemp = frame_header_is_valid(&streamBuf[flacReadIdx],&tFlacInfo); } } else { memcpy(&gTempFlac[0],&streamBuf[flacReadIdx],READBUF_SIZE-flacReadIdx); memcpy(&gTempFlac[READBUF_SIZE-flacReadIdx],&streamBuf[0],MAX_FRAME_HEADER_SIZE-(READBUF_SIZE-flacReadIdx)); if (((gTempFlac[0]<<8|gTempFlac[1]) & 0xFFFE) == 0xFFF8) { nTemp = frame_header_is_valid(&gTempFlac[0],&tFlacInfo); } } #else if (((streamBuf[flacReadIdx]<<8|streamBuf[flacReadIdx+1]) & 0xFFFE) == 0xFFF8) { nTemp = frame_header_is_valid(&streamBuf[flacReadIdx],&tFlacInfo); } #endif flacWriteIdx = getStreamWrPtr(); len = getUsedLen(flacReadIdx, flacWriteIdx, READBUF_SIZE); #if defined(__OPENRTOS__) //PalSleep(2); #else or32_delay(1); // enter sleep mode for power saving #endif flacReadIdx++; if (flacReadIdx>=READBUF_SIZE) flacReadIdx = 0; } while(nTemp==0 && !isSTOP()); if (flacReadIdx) flacReadIdx-=1; keep = flacReadIdx; setStreamRdPtr(flacReadIdx); flacReadIdx++; nTemp=0; // get flac frame length do { #if 1 waitAvaliableReadBufferSize(MAX_FRAME_HEADER_SIZE); if (MAX_FRAME_HEADER_SIZE+flacReadIdx<READBUF_SIZE) { //memcpy(&gTempFlac[0],&streamBuf[flacReadIdx],MAX_FRAME_HEADER_SIZE); if (((streamBuf[flacReadIdx]<<8|streamBuf[flacReadIdx+1]) & 0xFFFE) == 0xFFF8) { nTemp = frame_header_is_valid(&streamBuf[flacReadIdx],&tFlacInfo); } } else { memcpy(&gTempFlac[0],&streamBuf[flacReadIdx],READBUF_SIZE-flacReadIdx); memcpy(&gTempFlac[READBUF_SIZE-flacReadIdx],&streamBuf[0],MAX_FRAME_HEADER_SIZE-(READBUF_SIZE-flacReadIdx)); if (((gTempFlac[0]<<8|gTempFlac[1]) & 0xFFFE) == 0xFFF8) { nTemp = frame_header_is_valid(&gTempFlac[0],&tFlacInfo); } } #else if (((streamBuf[flacReadIdx]<<8|streamBuf[flacReadIdx+1]) & 0xFFFE) == 0xFFF8) { nTemp = frame_header_is_valid(&streamBuf[flacReadIdx],&tFlacInfo); } #endif flacWriteIdx = getStreamWrPtr(); len = getUsedLen(flacReadIdx, flacWriteIdx, READBUF_SIZE); #if defined(__OPENRTOS__) //PalSleep(2); #else or32_delay(1); // enter sleep mode for power saving #endif flacReadIdx++; if (flacReadIdx>=READBUF_SIZE) flacReadIdx = 0; } while(nTemp==0 && !isSTOP()); if (flacReadIdx) flacReadIdx--; if (flacReadIdx>=keep) frameLength = flacReadIdx - keep; else frameLength = READBUF_SIZE-keep+flacReadIdx; if (frameLength<=(READBUF_SIZE/2)){ gnWaitSize = frameLength; } else { gnWaitSize = READBUF_SIZE/2; } // store flac data to decode buffer flacReadIdx = getStreamRdPtr(); if (frameLength+flacReadIdx<READBUF_SIZE) { memcpy(&gTempFlac[0],&streamBuf[flacReadIdx],frameLength); } else { memcpy(&gTempFlac[0],&streamBuf[flacReadIdx],READBUF_SIZE-flacReadIdx); memcpy(&gTempFlac[READBUF_SIZE-flacReadIdx],&streamBuf[0],frameLength-(READBUF_SIZE-flacReadIdx)); } gFLACContext.channels = tFlacInfo.channels; gFLACContext.samplerate= tFlacInfo.samplerate; return frameLength; } # if defined(__OPENRTOS__) && !defined(ENABLE_CODECS_PLUGIN) portTASK_FUNCTION(flushdecode_task, params) # else int main(int argc, char **argv) # endif { int bytesLeft; int nTemp; int len = 0; unsigned int flacReadIdx; int init = 0; int frames = 0; int* codecStream; AUDIO_CODEC_STREAM* audioStream; #ifdef FLAC_PERFORMANCE_TEST_BY_TICK int nNewTicks,nTotalTicks; #endif #if defined(WIN32) || defined(__CYGWIN__) //param_struct param; char *fileName[]= { "FlacDecode", "-ao", //"D:\\audio_testing\\Mp3\\bird_48000.wav", //"D:\\audio_testing\\WAV\\swf_adpcm.wav", //"D:\\audio_testing\\WAV\\ima-adpcm.wav", //"D:\\Castor3_Alpha\\test_data\\dump_data.mp3", "D:\\audio_testing\\FLAC\\1.bird_44100.flac", //"D:\\audio_testing\\Mp3\\BBC7.mp3", "D:\\audio_testing\\FLAC\\bird_44100.wav" }; if ((fwav = fopen(wavSrc, "wb")) == NULL) { printf("Can not open file '%s'.\n", fwav); exit(-1); } fwrite(&gFrame[0], 1, 44, fwav); #if 0 if ((fwav = fopen(wavSrc, "rb")) == NULL) { printf("Can not open file '%s'.\n", fwav); exit(-1); } fseek(fwav, 0, SEEK_END); size = ftell(fwav); fseek(fwav, 0, SEEK_SET); if (size & 0x1) size++; if (fread(gStream, sizeof(char), size, fwav) != (unsigned)size) { printf("Data read fails.\n"); exit(-1); } fclose(fwav); if ((fmp3=fopen(mp3save, "wb")) == NULL) { printf("Can not create file '%s'\n", mp3save); exit(-1); } #endif argc+=3; argv = fileName; GetParam(argc, argv); win32_init(); #endif // defined(WIN32) || defined(__CYGWIN__) #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) codecStream=CODEC_STREAM_START_ADDRESS; //printf("[FLAC] 0x%08x \n",*codecStream); audioStream = *codecStream; audioStream->codecStreamBuf = &streamBuf[READBUF_BEGIN]; audioStream->codecStreamLength = READBUF_LEN; //printf("[FLAC] audioStream 0x%08x 0x%08x 0x%08x \n",&audioStream,&audioStream->codecStreamBuf,&audioStream->codecStreamLength); gtAudioPluginBuffer = audioStream->codecAudioPluginBuf; gtAudioPluginBufferLength = audioStream->codecAudioPluginLength; #ifdef CFG_CPU_WB ithFlushDCacheRange((void*)audioStream, sizeof(AUDIO_CODEC_STREAM)); ithFlushMemBuffer(); #endif //printf("[E-AC3] 0x%08x %d 0x%08x %d \n",audioStream->codecStreamBuf,audioStream->codecStreamLength ,audioStream->codecAudioPluginBuf,audioStream->codecAudioPluginLength); MMIO_Write(AUDIO_DECODER_START_FALG, 1); #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) ithPrintf("[FLAC] %d %d start 0x%x 0x%x \n",flacReadIdx,READBUF_LEN,streamBuf[0],streamBuf[0+1]); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PRINTF); #else #endif #endif #ifdef FLAC_PERFORMANCE_TEST_BY_TICK nTotalTicks=0; nFrames = 0; #endif //FLAC_PERFORMANCE_TEST_BY_TICK pcmWriteIdx = 0; pcmReadIdx = 0; pcmDumpIdx = 0; eofReached = 0; setStreamRdPtr(0); memset(&gFLACContext,0,sizeof(gFLACContext)); for(;;) // forever loop { int exitflag1 = 0; int frameSize; // Updates the read buffer and returns the avaliable size // of input buffer. Wait a minimun FRAME_SIZE length. bytesLeft = GetAvaliableReadBufferSize(); flacReadIdx = getStreamRdPtr(); nTemp = getFLACFrame(); #ifdef FLAC_PERFORMANCE_TEST_BY_TICK start_timer(); #endif frameSize = flac_decode_frame(&gFLACContext,&gTempFlac[0],nTemp,&gFrame[0]); #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) if (frameSize<0) { ithPrintf("[FLAC] dec error %d \n",frameSize); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PRINTF); } #else #endif #ifdef FLAC_PERFORMANCE_TEST_BY_TICK nNewTicks = get_timer(); nTotalTicks += nNewTicks; if (nFrames % 100 == 0 && nFrames>0) { ithPrintf("[FLAC] (%d~%d) total %d (ms) average %d (ms) nFrames %d system clock %d bps %d \n",(nFrames+1-100),(nFrames+1),(nTotalTicks/(PalGetSysClock()/1000)),((nTotalTicks/(PalGetSysClock()/1000))/100),nFrames+1,PalGetSysClock(),gFLACContext.bps); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PRINTF); nTotalTicks=0; } nFrames++; #endif //FLAC_PERFORMANCE_TEST_BY_TICK bytesLeft = FillReadBuffer(gFLACContext.read_byte); if (init==0 && gFLACContext.got_streaminfo == 1){ // flacFrameStep is 1.31 format. unsigned long long n = ((unsigned long long)gFLACContext.blocksize) << 31; flacFrameStep = (unsigned int)(n / gFLACContext.samplerate); #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) gCh = gFLACContext.channels; gSampleRate = gFLACContext.samplerate; AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_I2S_INIT_DAC); #else initDAC(&gOutBuf[0],gFLACContext.channels,gFLACContext.samplerate,sizeof(gOutBuf),0); #endif init = 1; } FillWriteBuffer(frameSize); updateTime(); checkControl(); if (isSTOP()) break; #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) //ithPrintf("[FLAC] decode frames %d %d %d \n",frames++,frameSize,nTemp); //AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PRINTF); #else #endif // frames++; #if defined(WIN32) || defined(__CYGWIN__) printf("decode frames %d \n",frames++); if (frames >=303) break; fwrite(&gFrame[0], 1, frameSize, fwav); #endif } //fclose(fmp3); #if defined(AUDIO_PLUGIN_MESSAGE_QUEUE) ithPrintf("[FLAC] ClearRdBuffer \n"); AudioPluginAPI(SMTK_AUDIO_PLUGIN_CMD_ID_PRINTF); #else #endif ClearRdBuffer(); }
[ "lawrence.shi@ite.com.tw" ]
lawrence.shi@ite.com.tw
480e3ef1485bb295d18ed68638b7a0a666c95de2
85377ff9cd3920aecd2dd9f6014a2e2448730522
/Vehicle State Estimator ECU1/Libraries/LIBRARIES_INCLUDES/SW_Delay.h
a887b1f11b48dddf8f5fec0e244a6bd8cb620e55
[]
no_license
mayersamir/Vehicle-State-Estimator
b87b2c49bbacbec76c462c69f426067daf12a14b
da425fbfb4b9253c1a31156fa3ceac23a0a19955
refs/heads/master
2020-09-09T21:09:48.563698
2019-11-14T15:44:17
2019-11-14T15:44:17
221,571,724
0
0
null
null
null
null
UTF-8
C
false
false
304
h
/* * SW_Delay.h * * Created on: Oct 21, 2019 * Author: AVE-LAP-070 */ #ifndef LIBRARIES_LIBRARIES_INCLUDES_SW_DELAY_H_ #define LIBRARIES_LIBRARIES_INCLUDES_SW_DELAY_H_ #define F_MC 16000000UL void SW_Delay_ms(uint32 delayValue); #endif /* LIBRARIES_LIBRARIES_INCLUDES_SW_DELAY_H_ */
[ "mayersamir1111@gmail.com" ]
mayersamir1111@gmail.com
f38a3bfbd74b55e0ea442b0eabd768d5bf4fb269
04c3d6fb1aca8cf8a77e6dea317a3521eea24200
/inversingalist.c
adb4847fe95fcea0695c670e545da77a29666dc8
[]
no_license
Ritwik33/programs
6e1f737769892aba923ddb67002e4ec557ac51e8
54760f005facb1aca64a43c5d962a90c4a4fd044
refs/heads/main
2023-06-24T17:47:10.693297
2021-07-26T07:47:47
2021-07-26T07:47:47
null
0
0
null
null
null
null
UTF-8
C
false
false
1,362
c
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<malloc.h> typedef struct node{ int val; struct node *next; }node; node *start=NULL; node *create(node *start){ int num; printf("\nEnter value: "); scanf("%d",&num); node *ptr,*new_node; while(num!=-1){ new_node=(node *)malloc(sizeof(node)); new_node->val=num; if(start==NULL){ new_node->next=NULL; start=new_node; } else{ ptr=start; while(ptr->next!=NULL) ptr=ptr->next; ptr->next=new_node; new_node->next=NULL; } printf("\nEnter value: "); scanf("%d",&num); } return start; } void display(node *start){ node *ptr; ptr=start; while(ptr->next!=NULL){ printf("%d\t",ptr->val); ptr=ptr->next; } printf("%d",ptr->val); } node *reverse(node *start){ node *prev=NULL,*curr,*next=NULL; curr=start; while(curr!=NULL){ next=curr->next; curr->next=prev; prev=curr; curr=next; } start=prev; return start; } int main(){ start=create(start); printf("\nOriginal list:\n"); display(start); start=reverse(start); printf("\nReversed list:\n"); display(start); return 0; }
[ "ritwikawesome556@gmail.com" ]
ritwikawesome556@gmail.com
fe30ed43c61ae5bd1c38350609a586ca33a8b413
740681730b9d9ab1d6751d9a7280cfafeb8b3f86
/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c
c0e15321555d36d3f6682b4c3a69030477fa75a3
[]
no_license
erikarn/athp
6486df8a7e51f956172f050921bd5161c35f3487
992669cbd68d0de54797f50feb1f00abb2cbafe3
refs/heads/master
2022-09-10T13:50:25.562578
2022-08-11T01:31:12
2022-08-11T01:31:12
63,910,625
50
20
null
2020-11-16T12:58:28
2016-07-22T00:17:50
C
UTF-8
C
false
false
31,632
c
/*- * Copyright (c) 2015-2017 Adrian Chadd <adrian@FreeBSD.org> * Copyright (c) 2005-2011 Atheros Communications Inc. * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include "opt_wlan.h" #include <sys/param.h> #include <sys/endian.h> #include <sys/sockio.h> #include <sys/mbuf.h> #include <sys/kernel.h> #include <sys/socket.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/bus.h> #include <sys/rman.h> #include <sys/firmware.h> #include <sys/module.h> #include <sys/taskqueue.h> #include <sys/condvar.h> #include <sys/proc.h> #include <machine/bus.h> #include <machine/resource.h> #include <net/bpf.h> #include <net/if.h> #include <net/if_var.h> #include <net/if_arp.h> #include <net/if_dl.h> #include <net/if_media.h> #include <net/if_types.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/in_var.h> #include <netinet/if_ether.h> #include <netinet/ip.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_ratectl.h> #include <net80211/ieee80211_input.h> #ifdef IEEE80211_SUPPORT_SUPERG #include <net80211/ieee80211_superg.h> #endif #include "hal/linux_compat.h" #include "hal/hw.h" #include "hal/chip_id.h" #include "hal/pci.h" #include "hal/targaddrs.h" #include "hal/core.h" #include "hal/htc.h" #include "hal/wmi.h" #include "if_athp_debug.h" #include "if_athp_regio.h" #include "if_athp_desc.h" #include "if_athp_stats.h" #include "if_athp_wmi.h" #include "if_athp_core.h" #include "if_athp_htc.h" #include "if_athp_var.h" #include "if_athp_hif.h" #include "if_athp_pci_ce.h" #include "if_athp_pci_hif.h" #include "if_athp_pci_pipe.h" #include "if_athp_pci.h" #include "if_athp_bmi.h" #include "if_athp_htc.h" #include "if_athp_main.h" #include "if_athp_pci_chip.h" #include "if_athp_pci_config.h" /* * Map from service/endpoint to Copy Engine. * This table is derived from the CE_PCI TABLE, above. * It is passed to the Target at startup for use by firmware. */ const struct service_to_pipe target_service_to_ce_map_wlan[] = { { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(3), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(2), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(3), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(2), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(3), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(2), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(3), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(2), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(3), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(2), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(0), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(1), }, { /* not used */ __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(0), }, { /* not used */ __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(1), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG), __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ __cpu_to_le32(4), }, { __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG), __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ __cpu_to_le32(1), }, /* (Additions here) */ { /* must be last */ __cpu_to_le32(0), __cpu_to_le32(0), __cpu_to_le32(0), }, }; static u32 ath10k_pci_targ_cpu_to_ce_addr(struct ath10k *ar, u32 addr) { u32 val = 0; switch (ar->sc_hwrev) { case ATH10K_HW_QCA988X: case ATH10K_HW_QCA6174: val = (athp_pci_read32(ar, SOC_CORE_BASE_ADDRESS(ar->sc_regofs) + CORE_CTRL_ADDRESS) & 0x7ff) << 21; break; case ATH10K_HW_QCA99X0: val = athp_pci_read32(ar, PCIE_BAR_REG_ADDRESS); break; } val |= 0x100000 | (addr & 0xfffff); return val; } /* * Diagnostic read/write access is provided for startup/config/debug usage. * Caller must guarantee proper alignment, when applicable, and single user * at any moment. */ static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data, int nbytes) { struct ath10k_pci *ar_pci = ar->sc_psc; int ret = 0; u32 buf; unsigned int completed_nbytes, orig_nbytes, remaining_bytes; unsigned int id; unsigned int flags; struct ath10k_ce_pipe *ce_diag; /* Host buffer address in CE space */ u32 ce_data; bus_addr_t ce_data_base = 0; void *data_buf = NULL; int i; /* * We're sharing the same buffer that BMI uses for exchanging * messages. */ ATHP_CONF_LOCK_ASSERT(ar); if (nbytes > 4096) { ath10k_err(ar, "%s: called with nbytes > bufsize (%d)\n", __func__, nbytes); return (-ENOMEM); } /* * Allocate a temporary bounce buffer to hold caller's data * to be DMA'ed from Target. This guarantees * 1) 4-byte alignment * 2) Buffer in DMA-able space */ /* * Note: locks are held here, so share the same buffer from BMI * whilst holding the conf lock. */ orig_nbytes = nbytes; data_buf = ar_pci->sc_bmi_txbuf.dd_desc; ce_data_base = ar_pci->sc_bmi_txbuf.dd_desc_paddr; ATHP_PCI_CE_LOCK(ar_pci); ce_diag = ar_pci->ce_diag; /* * Paranoia: ensure it's zero'ed. */ memset(data_buf, 0, orig_nbytes); remaining_bytes = orig_nbytes; ce_data = ce_data_base; /* XXX TODO: busdma operations on the descdma memory, just in case */ while (remaining_bytes) { nbytes = MIN(remaining_bytes, DIAG_TRANSFER_LIMIT); ret = __ath10k_ce_rx_post_buf(ce_diag, NULL, ce_data); if (ret != 0) goto done; /* Request CE to send from Target(!) address to Host buffer */ /* * The address supplied by the caller is in the * Target CPU virtual address space. * * In order to use this address with the diagnostic CE, * convert it from Target CPU virtual address space * to CE address space * * XXX TODO: is this in the right spot? check the write version * of this routine; address is modified before the loop. */ address = ath10k_pci_targ_cpu_to_ce_addr(ar, address); ret = ath10k_ce_send_nolock(ce_diag, NULL, (u32)address, nbytes, 0, 0); if (ret) goto done; i = 0; while (ath10k_ce_completed_send_next_nolock(ce_diag, NULL, &buf, &completed_nbytes, &id) != 0) { DELAY(1 * 1000); if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { ret = -EBUSY; goto done; } } if (nbytes != completed_nbytes) { ret = -EIO; goto done; } if (buf != (u32)address) { ret = -EIO; goto done; } i = 0; while (ath10k_ce_completed_recv_next_nolock(ce_diag, NULL, &buf, &completed_nbytes, &id, &flags) != 0) { DELAY(1 * 1000); if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { ret = -EBUSY; goto done; } } if (nbytes != completed_nbytes) { ret = -EIO; goto done; } if (buf != ce_data) { ret = -EIO; goto done; } remaining_bytes -= nbytes; address += nbytes; ce_data += nbytes; } done: if (ret == 0) memcpy(data, data_buf, orig_nbytes); else ath10k_warn(ar, "failed to read diag value at 0x%x: %d\n", address, ret); ATHP_PCI_CE_UNLOCK(ar_pci); return ret; } int ath10k_pci_diag_read32(struct ath10k *ar, u32 address, u32 *value) { __le32 val = 0; int ret; ret = ath10k_pci_diag_read_mem(ar, address, &val, sizeof(val)); *value = __le32_to_cpu(val); return ret; } static int __ath10k_pci_diag_read_hi(struct ath10k *ar, void *dest, u32 src, u32 len) { u32 host_addr, addr; int ret; host_addr = host_interest_item_address(src); ret = ath10k_pci_diag_read32(ar, host_addr, &addr); if (ret != 0) { ath10k_warn(ar, "failed to get memcpy hi address for firmware address %d: %d\n", src, ret); return ret; } ret = ath10k_pci_diag_read_mem(ar, addr, dest, len); if (ret != 0) { ath10k_warn(ar, "failed to memcpy firmware memory from %d (%d B): %d\n", addr, len, ret); return ret; } return 0; } #define ath10k_pci_diag_read_hi(ar, dest, src, len) \ __ath10k_pci_diag_read_hi(ar, dest, HI_ITEM(src), len) static void ath10k_pci_dump_registers(struct ath10k_pci *ar_pci, struct ath10k_fw_crash_data *crash_data) { struct ath10k *ar = &ar_pci->sc_sc; uint32_t reg_dump_values[REG_DUMP_COUNT_QCA988X] = {}; int i, ret; /* XXX TODO: conf lock */ ret = ath10k_pci_diag_read_hi(ar, &reg_dump_values[0], hi_failure_state, REG_DUMP_COUNT_QCA988X * sizeof(uint32_t)); if (ret) { ath10k_err(ar, "%s: failed to read dump info: %d\n", __func__, ret); return; } ath10k_err(ar, "%s: firmware crash dump\n", __func__); for (i = 0; i < REG_DUMP_COUNT_QCA988X; i += 4) { ath10k_err(ar, "[%02d]: 0x%08x 0x%08x 0x%08x 0x%08x\n", i, __le32_to_cpu(reg_dump_values[i]), __le32_to_cpu(reg_dump_values[i + 1]), __le32_to_cpu(reg_dump_values[i + 2]), __le32_to_cpu(reg_dump_values[i + 3])); } if (! crash_data) return; for (i = 0; i < REG_DUMP_COUNT_QCA988X; i++) { crash_data->registers[i] = reg_dump_values[i]; } } void ath10k_pci_fw_crashed_dump(struct ath10k_pci *ar_pci) { struct ath10k *ar = &ar_pci->sc_sc; ATHP_CONF_UNLOCK_ASSERT(ar); ath10k_err(ar, "%s: called\n", __func__); ATHP_CONF_LOCK(ar); ath10k_pci_dump_registers(ar_pci, NULL); ATHP_CONF_UNLOCK(ar); taskqueue_enqueue(ar->workqueue, &ar->restart_work); } static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, const void *data, int nbytes) { struct ath10k_pci *ar_pci = ar->sc_psc; int ret = 0; u32 buf; unsigned int completed_nbytes, orig_nbytes, remaining_bytes; unsigned int id; unsigned int flags; struct ath10k_ce_pipe *ce_diag; void *data_buf = NULL; u32 ce_data; /* Host buffer address in CE space */ bus_addr_t ce_data_base = 0; int i; ATHP_CONF_LOCK_ASSERT(ar); /* * Allocate a temporary bounce buffer to hold caller's data * to be DMA'ed to Target. This guarantees * 1) 4-byte alignment * 2) Buffer in DMA-able space */ orig_nbytes = nbytes; /* * Re-use the BMI TX buffer, under the conf lock. */ data_buf = ar_pci->sc_bmi_txbuf.dd_desc; ce_data_base = ar_pci->sc_bmi_txbuf.dd_desc_paddr; ATHP_PCI_CE_LOCK(ar_pci); ce_diag = ar_pci->ce_diag; /* Copy caller's data to allocated DMA buf */ memcpy(data_buf, data, orig_nbytes); /* * The address supplied by the caller is in the * Target CPU virtual address space. * * In order to use this address with the diagnostic CE, * convert it from * Target CPU virtual address space * to * CE address space */ address = ath10k_pci_targ_cpu_to_ce_addr(ar, address); remaining_bytes = orig_nbytes; ce_data = ce_data_base; /* XXX TODO: busdma operations on the descdma memory, just in case */ while (remaining_bytes) { /* FIXME: check cast */ nbytes = MIN(remaining_bytes, DIAG_TRANSFER_LIMIT); /* Set up to receive directly into Target(!) address */ ret = __ath10k_ce_rx_post_buf(ce_diag, NULL, address); if (ret != 0) goto done; /* * Request CE to send caller-supplied data that * was copied to bounce buffer to Target(!) address. */ ret = ath10k_ce_send_nolock(ce_diag, NULL, (u32)ce_data, nbytes, 0, 0); if (ret != 0) goto done; i = 0; while (ath10k_ce_completed_send_next_nolock(ce_diag, NULL, &buf, &completed_nbytes, &id) != 0) { DELAY(1 * 1000); if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { ret = -EBUSY; goto done; } } if (nbytes != completed_nbytes) { ret = -EIO; goto done; } if (buf != ce_data) { ret = -EIO; goto done; } i = 0; while (ath10k_ce_completed_recv_next_nolock(ce_diag, NULL, &buf, &completed_nbytes, &id, &flags) != 0) { DELAY(1 * 1000); if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { ret = -EBUSY; goto done; } } if (nbytes != completed_nbytes) { ret = -EIO; goto done; } if (buf != address) { ret = -EIO; goto done; } remaining_bytes -= nbytes; address += nbytes; ce_data += nbytes; } done: if (ret != 0) ath10k_warn(ar, "failed to write diag value at 0x%x: %d\n", address, ret); ATHP_PCI_CE_UNLOCK(ar_pci); return ret; } static int ath10k_pci_diag_write32(struct ath10k *ar, u32 address, u32 value) { __le32 val = __cpu_to_le32(value); return ath10k_pci_diag_write_mem(ar, address, &val, sizeof(val)); } static int ath10k_pci_init_config(struct ath10k *ar) { struct ath10k_pci *ar_pci = ar->sc_psc; u32 interconnect_targ_addr; u32 pcie_state_targ_addr = 0; u32 pipe_cfg_targ_addr = 0; u32 svc_to_pipe_map = 0; u32 pcie_config_flags = 0; u32 ealloc_value; u32 ealloc_targ_addr; u32 flag2_value; u32 flag2_targ_addr; int ret = 0; /* Download to Target the CE Config and the service-to-CE map */ interconnect_targ_addr = host_interest_item_address(HI_ITEM(hi_interconnect_state)); /* Supply Target-side CE configuration */ ret = ath10k_pci_diag_read32(ar, interconnect_targ_addr, &pcie_state_targ_addr); if (ret != 0) { ath10k_err(ar, "Failed to get pcie state addr: %d\n", ret); return ret; } if (pcie_state_targ_addr == 0) { ret = -EIO; ath10k_err(ar, "Invalid pcie state addr\n"); return ret; } ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + offsetof(struct pcie_state, pipe_cfg_addr)), &pipe_cfg_targ_addr); if (ret != 0) { ath10k_err(ar, "Failed to get pipe cfg addr: %d\n", ret); return ret; } if (pipe_cfg_targ_addr == 0) { ret = -EIO; ath10k_err(ar, "Invalid pipe cfg addr\n"); return ret; } ret = ath10k_pci_diag_write_mem(ar, pipe_cfg_targ_addr, target_ce_config_wlan, sizeof(struct ce_pipe_config) * NUM_TARGET_CE_CONFIG_WLAN(ar)); if (ret != 0) { ath10k_err(ar, "Failed to write pipe cfg: %d\n", ret); return ret; } ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + offsetof(struct pcie_state, svc_to_pipe_map)), &svc_to_pipe_map); if (ret != 0) { ath10k_err(ar, "Failed to get svc/pipe map: %d\n", ret); return ret; } if (svc_to_pipe_map == 0) { ret = -EIO; ath10k_err(ar, "Invalid svc_to_pipe map\n"); return ret; } ret = ath10k_pci_diag_write_mem(ar, svc_to_pipe_map, target_service_to_ce_map_wlan, sizeof(target_service_to_ce_map_wlan)); if (ret != 0) { ath10k_err(ar, "Failed to write svc/pipe map: %d\n", ret); return ret; } ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + offsetof(struct pcie_state, config_flags)), &pcie_config_flags); if (ret != 0) { ath10k_err(ar, "Failed to get pcie config_flags: %d\n", ret); return ret; } pcie_config_flags &= ~PCIE_CONFIG_FLAG_ENABLE_L1; ret = ath10k_pci_diag_write32(ar, (pcie_state_targ_addr + offsetof(struct pcie_state, config_flags)), pcie_config_flags); if (ret != 0) { ath10k_err(ar, "Failed to write pcie config_flags: %d\n", ret); return ret; } /* configure early allocation */ ealloc_targ_addr = host_interest_item_address(HI_ITEM(hi_early_alloc)); ret = ath10k_pci_diag_read32(ar, ealloc_targ_addr, &ealloc_value); if (ret != 0) { ath10k_err(ar, "Faile to get early alloc val: %d\n", ret); return ret; } /* first bank is switched to IRAM */ ealloc_value |= ((HI_EARLY_ALLOC_MAGIC << HI_EARLY_ALLOC_MAGIC_SHIFT) & HI_EARLY_ALLOC_MAGIC_MASK); ealloc_value |= ((ath10k_pci_get_num_banks(ar_pci) << HI_EARLY_ALLOC_IRAM_BANKS_SHIFT) & HI_EARLY_ALLOC_IRAM_BANKS_MASK); ret = ath10k_pci_diag_write32(ar, ealloc_targ_addr, ealloc_value); if (ret != 0) { ath10k_err(ar, "Failed to set early alloc val: %d\n", ret); return ret; } /* Tell Target to proceed with initialization */ flag2_targ_addr = host_interest_item_address(HI_ITEM(hi_option_flag2)); ret = ath10k_pci_diag_read32(ar, flag2_targ_addr, &flag2_value); if (ret != 0) { ath10k_err(ar, "Failed to get option val: %d\n", ret); return ret; } flag2_value |= HI_OPTION_EARLY_CFG_DONE; ret = ath10k_pci_diag_write32(ar, flag2_targ_addr, flag2_value); if (ret != 0) { ath10k_err(ar, "Failed to set option val: %d\n", ret); return ret; } return 0; } static int ath10k_pci_hif_tx_sg(struct ath10k *ar, u8 pipe_id, struct ath10k_hif_sg_item *items, int n_items) { struct ath10k_pci *ar_pci = ar->sc_psc; struct ath10k_pci_pipe *pci_pipe = &ar_pci->pipe_info[pipe_id]; struct ath10k_ce_pipe *ce_pipe = pci_pipe->ce_hdl; struct ath10k_ce_ring *src_ring = ce_pipe->src_ring; unsigned int nentries_mask; unsigned int sw_index; unsigned int write_index; int err, i = 0; ATHP_PCI_CE_LOCK(ar_pci); nentries_mask = src_ring->nentries_mask; sw_index = src_ring->sw_index; write_index = src_ring->write_index; if (unlikely(CE_RING_DELTA(nentries_mask, write_index, sw_index - 1) < n_items)) { err = -ENOBUFS; goto err; } for (i = 0; i < n_items - 1; i++) { ath10k_dbg(ar, ATH10K_DBG_PCI | ATH10K_DBG_CE, "pci tx item %d paddr 0x%08x len %d n_items %d\n", i, items[i].paddr, items[i].len, n_items); ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ", items[i].vaddr, items[i].len); err = ath10k_ce_send_nolock(ce_pipe, items[i].transfer_context, items[i].paddr, items[i].len, items[i].transfer_id, CE_SEND_FLAG_GATHER); if (err) goto err; } /* `i` is equal to `n_items -1` after for() */ ath10k_dbg(ar, ATH10K_DBG_PCI | ATH10K_DBG_CE, "pci tx item %d paddr 0x%08x len %d n_items %d\n", i, items[i].paddr, items[i].len, n_items); ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ", items[i].vaddr, items[i].len); err = ath10k_ce_send_nolock(ce_pipe, items[i].transfer_context, items[i].paddr, items[i].len, items[i].transfer_id, 0); if (err) goto err; ATHP_PCI_CE_UNLOCK(ar_pci); return 0; err: for (; i > 0; i--) __ath10k_ce_send_revert(ce_pipe); ATHP_PCI_CE_UNLOCK(ar_pci); return err; } static int ath10k_pci_hif_diag_read(struct ath10k *ar, u32 address, void *buf, size_t buf_len) { return ath10k_pci_diag_read_mem(ar, address, buf, buf_len); } static u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe) { struct ath10k_pci *ar_pci = ar->sc_psc; ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif get free queue number\n"); return ath10k_ce_num_free_src_entries(ar_pci->pipe_info[pipe].ce_hdl); } static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, int force) { ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif send complete check\n"); if (!force) { int resources; /* * Decide whether to actually poll for completions, or just * wait for a later chance. * If there seem to be plenty of resources left, then just wait * since checking involves reading a CE register, which is a * relatively expensive operation. */ resources = ath10k_pci_hif_get_free_queue_number(ar, pipe); /* * If at least 50% of the total resources are still available, * don't bother checking again yet. */ if (resources > (host_ce_config_wlan[pipe].src_nentries >> 1)) return; } ath10k_ce_per_engine_service(ar, pipe); } static void ath10k_pci_hif_set_callbacks(struct ath10k *ar, struct ath10k_hif_cb *callbacks) { struct ath10k_pci *ar_pci = ar->sc_psc; ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif set callbacks\n"); memcpy(&ar_pci->msg_callbacks_current, callbacks, sizeof(ar_pci->msg_callbacks_current)); } static int ath10k_pci_hif_map_service_to_pipe(struct ath10k *ar, u16 service_id, u8 *ul_pipe, u8 *dl_pipe, int *ul_is_polled, int *dl_is_polled) { const struct service_to_pipe *entry; bool ul_set = false, dl_set = false; int i; ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif map service\n"); /* polling for received messages not supported */ *dl_is_polled = 0; for (i = 0; i < nitems(target_service_to_ce_map_wlan); i++) { entry = &target_service_to_ce_map_wlan[i]; if (__le32_to_cpu(entry->service_id) != service_id) continue; switch (__le32_to_cpu(entry->pipedir)) { case PIPEDIR_NONE: break; case PIPEDIR_IN: WARN_ON(dl_set); *dl_pipe = __le32_to_cpu(entry->pipenum); dl_set = true; break; case PIPEDIR_OUT: WARN_ON(ul_set); *ul_pipe = __le32_to_cpu(entry->pipenum); ul_set = true; break; case PIPEDIR_INOUT: WARN_ON(dl_set); WARN_ON(ul_set); *dl_pipe = __le32_to_cpu(entry->pipenum); *ul_pipe = __le32_to_cpu(entry->pipenum); dl_set = true; ul_set = true; break; } } if (WARN_ON(!ul_set || !dl_set)) return -ENOENT; *ul_is_polled = (host_ce_config_wlan[*ul_pipe].flags & CE_ATTR_DIS_INTR) != 0; return 0; } static void ath10k_pci_hif_get_default_pipe(struct ath10k *ar, u8 *ul_pipe, u8 *dl_pipe) { int ul_is_polled, dl_is_polled; ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif get default pipe\n"); (void)ath10k_pci_hif_map_service_to_pipe(ar, ATH10K_HTC_SVC_ID_RSVD_CTRL, ul_pipe, dl_pipe, &ul_is_polled, &dl_is_polled); } static int ath10k_pci_hif_start(struct ath10k *ar) { struct ath10k_pci *ar_pci = ar->sc_psc; ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n"); ath10k_pci_irq_enable(ar_pci); ath10k_pci_rx_post(ar); pci_write_config(ar->sc_dev, ar_pci->sc_cap_off + PCIER_LINK_CTL, ar_pci->link_ctl, 4); return 0; } static void ath10k_pci_hif_stop(struct ath10k *ar) { struct ath10k_pci *ar_pci = ar->sc_psc; ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif stop\n"); /* Most likely the device has HTT Rx ring configured. The only way to * prevent the device from accessing (and possible corrupting) host * memory is to reset the chip now. * * There's also no known way of masking MSI interrupts on the device. * For ranged MSI the CE-related interrupts can be masked. However * regardless how many MSI interrupts are assigned the first one * is always used for firmware indications (crashes) and cannot be * masked. To prevent the device from asserting the interrupt reset it * before proceeding with cleanup. */ ath10k_pci_safe_chip_reset(ar_pci); ath10k_pci_irq_disable(ar_pci); ath10k_pci_irq_sync(ar_pci); ath10k_pci_flush(ar); ATHP_PCI_PS_LOCK(ar_pci); if (ar_pci->ps_wake_refcount > 0) { ath10k_warn(ar, "%s: TODO: ensure we go to sleep; wake_refcount=%d\n", __func__, (int) ar_pci->ps_wake_refcount); } ATHP_PCI_PS_UNLOCK(ar_pci); } static void ath10k_pci_bmi_send_done(struct ath10k_ce_pipe *ce_state) { struct bmi_xfer *xfer; u32 ce_data; unsigned int nbytes; unsigned int transfer_id; if (ath10k_ce_completed_send_next(ce_state, (void **)&xfer, &ce_data, &nbytes, &transfer_id)) return; xfer->tx_done = true; } static void ath10k_pci_bmi_recv_data(struct ath10k_ce_pipe *ce_state) { struct ath10k *ar = ce_state->ar; struct bmi_xfer *xfer; u32 ce_data; unsigned int nbytes; unsigned int transfer_id; unsigned int flags; if (ath10k_ce_completed_recv_next(ce_state, (void **)&xfer, &ce_data, &nbytes, &transfer_id, &flags)) return; if (WARN_ON_ONCE(!xfer)) return; if (!xfer->wait_for_resp) { ath10k_warn(ar, "unexpected: BMI data received; ignoring\n"); return; } xfer->resp_len = nbytes; xfer->rx_done = true; } static int ath10k_pci_bmi_wait(struct ath10k_ce_pipe *tx_pipe, struct ath10k_ce_pipe *rx_pipe, struct bmi_xfer *xfer) { int interval; interval = ticks + ((2000 * hz) / 1000); /* Wait up to 2 seconds for each transfer */ while (! ieee80211_time_after(ticks, interval)) { ath10k_pci_bmi_send_done(tx_pipe); ath10k_pci_bmi_recv_data(rx_pipe); if (xfer->tx_done && (xfer->rx_done == xfer->wait_for_resp)) return 0; kern_yield(PRI_USER); } printf("%s: timed out\n", __func__); return -ETIMEDOUT; } static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar, void *req, u32 req_len, void *resp, u32 *resp_len) { struct ath10k_pci *ar_pci = ar->sc_psc; struct ath10k_pci_pipe *pci_tx = &ar_pci->pipe_info[BMI_CE_NUM_TO_TARG]; struct ath10k_pci_pipe *pci_rx = &ar_pci->pipe_info[BMI_CE_NUM_TO_HOST]; struct ath10k_ce_pipe *ce_tx = pci_tx->ce_hdl; struct ath10k_ce_pipe *ce_rx = pci_rx->ce_hdl; struct bmi_xfer xfer = {}; bus_addr_t req_paddr = 0; bus_addr_t resp_paddr = 0; // void *treq, *tresp = NULL; int ret = 0; might_sleep(); ATHP_CONF_LOCK_ASSERT(ar); if (resp && !resp_len) return -EINVAL; if (resp && resp_len && *resp_len == 0) return -EINVAL; /* * Don't allocate temporary descriptor memory here. * This should be done for us outside of holding locks. */ #if 0 /* * Allocate temporary descriptor memory for the request. * Yes, it's a descriptor and a bit heavyweight. Grr. * * These are zero'ed so freeing them if we don't allocate them * doesn't panic things. */ bzero(&dd_req, sizeof(dd_req)); bzero(&dd_resp, sizeof(dd_resp)); #endif #if 0 ret = athp_descdma_alloc(ar, &dd_req, "bmi_msg_req", 4, req_len); if (ret != 0) return -ENOMEM; #endif /* Copy request into the allocate descriptor */ memcpy(ar_pci->sc_bmi_txbuf.dd_desc, req, req_len); /* Get physical mapping for the allocated descriptor */ req_paddr = ar_pci->sc_bmi_txbuf.dd_desc_paddr; /* Get a descriptor w/ physical mapping for the response */ if (resp && resp_len) { #if 0 ret = athp_descdma_alloc(ar, &dd_resp, "bmi_msg_resp", 4, *resp_len); if (ret != 0) { ret = -ENOMEM; goto err_req; } #endif resp_paddr = ar_pci->sc_bmi_rxbuf.dd_desc_paddr; xfer.wait_for_resp = true; xfer.resp_len = 0; ath10k_ce_rx_post_buf(ce_rx, &xfer, resp_paddr); } ret = ath10k_ce_send(ce_tx, &xfer, req_paddr, req_len, -1, 0); if (ret) goto err_resp; ret = ath10k_pci_bmi_wait(ce_tx, ce_rx, &xfer); if (ret) { u32 unused_buffer; unsigned int unused_nbytes; unsigned int unused_id; ath10k_ce_cancel_send_next(ce_tx, NULL, &unused_buffer, &unused_nbytes, &unused_id); } else { /* non-zero means we did not time out */ ret = 0; } err_resp: if (resp) { u32 unused_buffer; ath10k_ce_revoke_recv_next(ce_rx, NULL, &unused_buffer); } if (ret == 0 && resp_len) { *resp_len = min(*resp_len, xfer.resp_len); /* Copy result from response descriptor to caller */ memcpy(resp, ar_pci->sc_bmi_rxbuf.dd_desc, xfer.resp_len); } return ret; } static int ath10k_pci_hif_power_up(struct ath10k *ar) { struct ath10k_pci *ar_pci = ar->sc_psc; int ret; ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n"); ar_pci->link_ctl = pci_read_config(ar->sc_dev, ar_pci->sc_cap_off + PCIER_LINK_CTL, 4); pci_write_config(ar->sc_dev, ar_pci->sc_cap_off + PCIER_LINK_CTL, ar_pci->link_ctl & ~PCIEM_LINK_CTL_ASPMC, 4); /* * Bring the target up cleanly. * * The target may be in an undefined state with an AUX-powered Target * and a Host in WoW mode. If the Host crashes, loses power, or is * restarted (without unloading the driver) then the Target is left * (aux) powered and running. On a subsequent driver load, the Target * is in an unexpected state. We try to catch that here in order to * reset the Target and retry the probe. */ ret = ath10k_pci_chip_reset(ar_pci); if (ret) { if (ath10k_pci_has_fw_crashed(ar_pci)) { ath10k_warn(ar, "firmware crashed during chip reset\n"); ath10k_pci_fw_crashed_clear(ar_pci); ath10k_pci_fw_crashed_dump(ar_pci); } ath10k_err(ar, "failed to reset chip: %d\n", ret); goto err_sleep; } ret = ath10k_pci_init_pipes(ar); if (ret) { ath10k_err(ar, "failed to initialize CE: %d\n", ret); goto err_sleep; } ret = ath10k_pci_init_config(ar); if (ret) { ath10k_err(ar, "failed to setup init config: %d\n", ret); goto err_ce; } ret = ath10k_pci_wake_target_cpu(ar_pci); if (ret) { ath10k_err(ar, "could not wake up target CPU: %d\n", ret); goto err_ce; } return 0; err_ce: ath10k_pci_ce_deinit(ar); err_sleep: return ret; } static void ath10k_pci_hif_power_down(struct ath10k *ar) { ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n"); /* Currently hif_power_up performs effectively a reset and hif_stop * resets the chip as well so there's no point in resetting here. */ } static int ath10k_pci_hif_suspend(struct ath10k *ar) { struct ath10k_pci *ar_pci = ar->sc_psc; ath10k_warn(ar, "%s: called\n", __func__); /* The grace timer can still be counting down and ar->ps_awake be true. * It is known that the device may be asleep after resuming regardless * of the SoC powersave state before suspending. Hence make sure the * device is asleep before proceeding. */ ath10k_pci_sleep_sync(ar_pci); return 0; } static int ath10k_pci_hif_resume(struct ath10k *ar) { ath10k_warn(ar, "%s: called\n", __func__); /* Suspend/Resume resets the PCI configuration space, so we have to * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries * from interfering with C3 CPU state. pci_restore_state won't help * here since it only restores the first 64 bytes pci config header. */ pci_write_config(ar->sc_dev, 0x41, 0, 1); return 0; } const struct ath10k_hif_ops ath10k_pci_hif_ops = { .tx_sg = ath10k_pci_hif_tx_sg, .diag_read = ath10k_pci_hif_diag_read, .diag_write = ath10k_pci_diag_write_mem, .exchange_bmi_msg = ath10k_pci_hif_exchange_bmi_msg, .start = ath10k_pci_hif_start, .stop = ath10k_pci_hif_stop, .map_service_to_pipe = ath10k_pci_hif_map_service_to_pipe, .get_default_pipe = ath10k_pci_hif_get_default_pipe, .send_complete_check = ath10k_pci_hif_send_complete_check, .set_callbacks = ath10k_pci_hif_set_callbacks, .get_free_queue_number = ath10k_pci_hif_get_free_queue_number, .power_up = ath10k_pci_hif_power_up, .power_down = ath10k_pci_hif_power_down, .read32 = athp_pci_read32, .write32 = athp_pci_write32, .suspend = ath10k_pci_hif_suspend, .resume = ath10k_pci_hif_resume, };
[ "adrian@freebsd.org" ]
adrian@freebsd.org
acf8438913177f546fa766daee66fb4bcf348f84
2f4f6f407cee422aaf0d3056c18a4056c3e96772
/libs/motan_tools.c
70f177c9f0e43eb3f4eceb2729bdee63f4d15975
[ "Apache-2.0" ]
permissive
superliyang/motan-openresty
1a07925fd2fe7243efb1c4488374877d34990c4c
fe07ba1519ed675ddd178a9a0f93674c5c1840ce
refs/heads/master
2020-03-09T05:13:07.705523
2017-12-05T11:25:01
2017-12-05T11:25:01
null
0
0
null
null
null
null
UTF-8
C
false
false
2,640
c
#include <sys/socket.h> #include <arpa/inet.h> #include <net/if.h> #include <sys/ioctl.h> #include <string.h> #include <stdlib.h> #include <stdio.h> // gcc -g -o libmotan_tools.so -fpic -shared motan_tools.c // gcc -c -g motan_tools.c -o motan_tools.o // gcc motan_tools.o -dynamiclib -o libmotan_tools.dylib // sudo cp libmotan_tools.dylib /usr/local/lib/ void perror(const char *); int close(int); int get_local_ip(char * ifname, char * ip) { char *temp = NULL; int inet_sock; struct ifreq ifr; inet_sock = socket(AF_INET, SOCK_DGRAM, 0); memset(ifr.ifr_name, 0, sizeof(ifr.ifr_name)); memcpy(ifr.ifr_name, ifname, strlen(ifname)); if(0 != ioctl(inet_sock, SIOCGIFADDR, &ifr)) { perror("ioctl error"); return -1; } temp = inet_ntoa(((struct sockaddr_in*)&(ifr.ifr_addr))->sin_addr); memcpy(ip, temp, strlen(temp)); close(inet_sock); return 0; } char *itoa(u_int64_t value, char *result, int base); char *itoa(u_int64_t value, char *result, int base) { // check that the base if valid if (base < 2 || base > 36) { *result = '\0'; return result; } char *ptr = result, *ptr1 = result, tmp_char; u_int64_t tmp_value; do { tmp_value = value; value /= base; *ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + (tmp_value - value * base)]; } while (value); // Apply negative sign // if (tmp_value < 0) // *ptr++ = '-'; *ptr-- = '\0'; while (ptr1 < ptr) { tmp_char = *ptr; *ptr-- = *ptr1; *ptr1++ = tmp_char; } return result; } int get_request_id_bytes(const char *request_id_str, char *rs_bytes); int get_request_id_bytes(const char *request_id_str, char *rs_bytes) { char bytes[8]; int width = 8, i = 0; u_int64_t j = 0xff; u_int64_t rid_num = strtoull(request_id_str, NULL, 10); for (; i < 8;i++) { width --; bytes[width] = (j & rid_num) >> (i * 8); j = j << 8; } memcpy(rs_bytes, bytes, 8 * sizeof(char)); return 0; } int get_request_id(uint8_t bytes[8], char *request_id_str); int get_request_id(uint8_t bytes[8], char *request_id_str) { int bytes_len = sizeof(bytes); u_int64_t r_id = (u_int64_t)bytes[0] << (bytes_len - 1) * 8; int i = 0; for (i = 1; i < bytes_len; i++) { if (i <= bytes_len - 2) r_id = r_id | (u_int64_t)bytes[i] << (bytes_len - (i + 1)) * 8; else r_id = r_id | (u_int64_t)bytes[i]; } itoa(r_id, request_id_str, 10); return 0; }
[ "zhoujing_k49@163.com" ]
zhoujing_k49@163.com
95534b74802c3dfd8fae265af763b1ea57dea67c
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/timescaledb/src/bgw/extr_job_stat.c_ts_bgw_job_stat_mark_end.c
063bcceafe9ab8d1e6378ad8d110ee8e615774f1
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
1,430
c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_8__ TYPE_3__ ; typedef struct TYPE_7__ TYPE_2__ ; typedef struct TYPE_6__ TYPE_1__ ; /* Type definitions */ struct TYPE_6__ {int /*<<< orphan*/ id; } ; struct TYPE_8__ {TYPE_1__ fd; } ; struct TYPE_7__ {int /*<<< orphan*/ result; TYPE_3__* job; } ; typedef TYPE_2__ JobResultCtx ; typedef int /*<<< orphan*/ JobResult ; typedef TYPE_3__ BgwJob ; /* Variables and functions */ int /*<<< orphan*/ ERROR ; int /*<<< orphan*/ RowExclusiveLock ; int /*<<< orphan*/ bgw_job_stat_scan_job_id (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ *,TYPE_2__*,int /*<<< orphan*/ ) ; int /*<<< orphan*/ bgw_job_stat_tuple_mark_end ; int /*<<< orphan*/ elog (int /*<<< orphan*/ ,char*,int /*<<< orphan*/ ) ; void ts_bgw_job_stat_mark_end(BgwJob *job, JobResult result) { JobResultCtx res = { .job = job, .result = result, }; if (!bgw_job_stat_scan_job_id(job->fd.id, bgw_job_stat_tuple_mark_end, NULL, &res, RowExclusiveLock)) elog(ERROR, "unable to find job statistics for job %d", job->fd.id); }
[ "brenocfg@gmail.com" ]
brenocfg@gmail.com
076bb66ab1d0a8792ceaf8684a9ef7bf10ac6435
1e1bf5518390dc1e56a9f3b38473861965721e66
/Code/畅柯/第一周/hui_wen.c
e0bf86af7cc36aa54b8d98acbac9cb53b74b1d50
[]
no_license
XiyouLinuxGroup-2018-Summer/TeamD
2f879f4220b0af686103bbe16ef0f2b4f12c2673
7e850a38478db73b6040450f70dac554e80cfb18
refs/heads/master
2020-03-23T06:31:17.428428
2018-08-22T14:31:12
2018-08-22T14:31:12
141,213,769
0
2
null
2018-07-23T02:13:36
2018-07-17T01:23:38
C
UTF-8
C
false
false
496
c
#include<stdio.h> #include<stdlib.h> #define N 20 int VerifyStr(char*str); int main(){ int n,i; char str[N]; scanf("%d",&n); while('\n'!=getchar()); while((scanf("%s",str))!=EOF){ while('\n'!=getchar()); i=VerifyStr(str); if(i==0)printf("no\n"); else printf("yes\n"); n--; if(n==0)break; } } int VerifyStr(char*str){ int i=0,k,m=0; while(*(str+i)!='\0')i++; k=i/2; while(1){ if(*(str+m)==*(str+i-m-1)){ m++; if(m==k+1)return 1; }else{ return 0; } } }
[ "sunny666@xiyoulinux.org" ]
sunny666@xiyoulinux.org
c76e6e313fd1d345e2ee6c9944a9ab2edefab564
f40e00bb2482e0c681553fd1154cbf7e5f08266f
/CapApp/Config/L3G4200D_Lcfg.c
9235687708668486da6fbbee96ae53aebcbf4836
[]
no_license
amr-abdelghafar/BACT
edf9529e38087e0d2fc03b8534b51dac294980c3
09ebea15a44b2e13fc4dfa94a5f7bc144891a334
refs/heads/master
2021-07-22T21:34:38.982195
2017-11-03T10:58:24
2017-11-03T10:58:24
null
0
0
null
null
null
null
UTF-8
C
false
false
1,165
c
/* * L3G4200D_Lcfg.c * * Created: 27/09/2015 02:11:03 م * Author: hossam & Amr Tarek */ #include "L3G4200D_Lcfg.h" #include "BasicTypes.h" #include "L3G4200D_Lcfg.h" #include "../HAL/L3G4200D.h" const L3G4200D_CfgType L3G4200D_ConfigParam = {.u8FullScaleValue = u8FS_250, .strAxisActivation.u8XAxisActivation = u8X_AXIS_ACTIVE, .strAxisActivation.u8YAxisActivation = u8Y_AXIS_ACTIVE, .strAxisActivation.u8ZAxisActivation = u8Z_AXIS_ACTIVE, .strFilterCfg.u8FilterOnData = u8NO_FILTERS, .strFilterCfg.u8FilterOnInterrupt = u8NO_FILTERS, .strIntCfg.u16ThresholdX = 0X2CA4, .strIntCfg.u16ThresholdY = 0x2CA4, .strIntCfg.u16ThresholdZ = 0x2CA4, .strIntCfg.u8IntDuration = 0x00, .strIntCfg.u8XAxisInterrupt = u8INT1_X, .strIntCfg.u8YAxisInterrupt = u8INT1_Y, .strIntCfg.u8ZAxisInterrupt = u8INT1_Z};
[ "mail.amrtarek@gmail.com" ]
mail.amrtarek@gmail.com
53be962e2f0e1f81cdea3853f0adf626653830bb
66cb8e707d43a908044e7dc6f946e48097c4d1c1
/libft/ft_memcmp.c
ecbeabc0c17ffd186162a921e652c2b8b5333786
[]
no_license
SergeiGusachenko/Printf
320dd3d32313b7c40fd4318b7354b65a73d57826
3a5739ec7fb456448a70636dd90178d0c1240a79
refs/heads/master
2020-06-06T17:47:21.100510
2019-06-28T03:52:50
2019-06-28T03:52:50
192,811,179
2
0
null
null
null
null
UTF-8
C
false
false
1,201
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: sgusache <sgusache@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/12/01 16:43:26 by sgusache #+# #+# */ /* Updated: 2018/12/03 10:47:42 by sgusache ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int ft_memcmp(const void *s1, const void *s2, size_t n) { unsigned char *str1; unsigned char *str2; size_t i; i = 0; str1 = (unsigned char*)s1; str2 = (unsigned char*)s2; while (i < n) { if (str1[i] == str2[i]) i++; else return (str1[i] - str2[i]); } return (0); }
[ "sgusache@e1z3r6p4.42.us.org" ]
sgusache@e1z3r6p4.42.us.org
cf571d95be410d13cf36276a5d6f0d6390d24e63
7f4a3265b4c3d7b070f3b5e69bd64c53cbae0c82
/TCPEchoClient4/TCPEchoClient4/TCPEchoClient4.c
10985cb95e46a645cddf7f75d4ec8ab840868740
[]
no_license
JonneyDai/iOSDev
25690c009d2d96c3137eefe54355527a059a3ac4
3d058eba66245c71f976e28b27ca3101b9104094
refs/heads/master
2020-12-29T01:54:16.197140
2016-08-01T13:40:24
2016-08-01T13:40:24
41,417,363
0
0
null
null
null
null
UTF-8
C
false
false
2,935
c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include "Practical.h" int main(int argc, char * argv[]) { if (argc < 3 || argc > 4) { //Test for correct number of arguments DieWithUserMessage("Parameter(s)","<Server Address> <Echo Word> [<Server Port>]"); } char *servIP = argv[1]; //First arg :server ip address char *echoString = argv[2]; //Second arg : String to Echo //Third arg (optional): server port(numeric)7 is well-known echo port in_port_t servPort = (argc == 4) ? atoi(argv[3]) : 7; //Creat a reliable, stream socket using Tcp int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { DieWithSystemMessage("socket () failed"); } //Construct the server address structure struct sockaddr_in servAddr; //Server address; memset(&servAddr, 0, sizeof(servAddr)); // Zero out structure servAddr.sin_family = AF_INET; //IPV4 address family //Convert address int rtnVal = inet_pton(AF_INET, servIP, &servAddr.sin_addr.s_addr); if (rtnVal == 0) { DieWithUserMessage("inet_pton() failed", "invalid address string"); }else if( rtnVal < 0) { DieWithSystemMessage("inet_pton () failed"); } servAddr.sin_port = htons(servPort); //server Port //Establish the connection to the echo server if (connect(sock, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) { DieWithSystemMessage("connect() failed"); } size_t echoStringLen = strlen(echoString); //Determine input length //send the string to the server ssize_t numBytes = send(sock, echoString, echoStringLen, 0); if (numBytes < 0) { DieWithSystemMessage("send() failed"); }else if (numBytes != echoStringLen){ DieWithUserMessage("send()", "send the unexpected number of bytes"); } //receive the same string back from the server unsigned int totalBytesRcvd = 0; //count if total bytes received fputs("Received:", stdout); //setup to print the echoed string while (totalBytesRcvd < echoStringLen) { char buffer[BUFSIZ];// I/O buffer /* receive up to the buffer size (minus 1 to leave space for a null termanator) bytes from the sender*/ numBytes = recv(sock, buffer, BUFSIZ - 1, 0); if (numBytes < 0) { DieWithSystemMessage("recv() failed"); }else if (numBytes == 0){ DieWithUserMessage("revc()", "recv connetion colsed prematurely"); } totalBytesRcvd += numBytes; // keep tally of total bytes buffer[numBytes] = '\0'; //terminate the string fputs(buffer, stdout); //print the echo buffer } fputc('\n', stdout); //print a finall linefeed close(sock); exit(0); }
[ "jonneydai@126.com" ]
jonneydai@126.com
650d1d2bef197e18133a177b08e6f813ca3f3658
a1446c3f95df2dfe097a9bd6b463767b00f18140
/lib/libc/net/getifaddrs.c
6f7ea15721549a29719ba1864745f93674980124
[]
no_license
chrissicool/l4openbsd
e2fb756debc1c3bdc1c2da509fa228c25a3185e8
077177814444e08500e47bc2488502f11469bc60
refs/heads/master
2021-04-09T17:12:53.122136
2011-08-22T16:52:58
2011-08-22T16:52:58
1,706,491
18
4
null
2017-04-06T19:17:29
2011-05-05T14:08:03
C
UTF-8
C
false
false
7,050
c
/* $OpenBSD: getifaddrs.c,v 1.10 2008/11/24 20:08:49 claudio Exp $ */ /* * Copyright (c) 1995, 1999 * Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. * * BSDI getifaddrs.c,v 2.12 2000/02/23 14:51:59 dab Exp */ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <net/if.h> #include <sys/param.h> #include <net/route.h> #include <sys/sysctl.h> #include <net/if_dl.h> #include <errno.h> #include <ifaddrs.h> #include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define SALIGN (sizeof(long) - 1) #define SA_RLEN(sa) ((sa)->sa_len ? (((sa)->sa_len + SALIGN) & ~SALIGN) : (SALIGN + 1)) int getifaddrs(struct ifaddrs **pif) { int icnt = 1; int dcnt = 0; int ncnt = 0; int mib[6]; size_t needed; char *buf; char *next; struct ifaddrs *cif = 0; char *p, *p0; struct rt_msghdr *rtm; struct if_msghdr *ifm; struct ifa_msghdr *ifam; struct sockaddr_dl *dl; struct sockaddr *sa; u_short index = 0; size_t len, alen, dlen; struct ifaddrs *ifa, *ift; int i; char *data; char *names; mib[0] = CTL_NET; mib[1] = PF_ROUTE; mib[2] = 0; /* protocol */ mib[3] = 0; /* wildcard address family */ mib[4] = NET_RT_IFLIST; mib[5] = 0; /* no flags */ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) return (-1); if ((buf = malloc(needed)) == NULL) return (-1); if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { free(buf); return (-1); } for (next = buf; next < buf + needed; next += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)next; if (rtm->rtm_version != RTM_VERSION) continue; switch (rtm->rtm_type) { case RTM_IFINFO: ifm = (struct if_msghdr *)rtm; if (ifm->ifm_addrs & RTA_IFP) { index = ifm->ifm_index; ++icnt; dl = (struct sockaddr_dl *)(next + rtm->rtm_hdrlen); dcnt += SA_RLEN((struct sockaddr *)dl) + ALIGNBYTES; dcnt += sizeof(ifm->ifm_data); ncnt += dl->sdl_nlen + 1; } else index = 0; break; case RTM_NEWADDR: ifam = (struct ifa_msghdr *)rtm; if (index && ifam->ifam_index != index) abort(); /* XXX abort illegal in library */ #define RTA_MASKS (RTA_NETMASK | RTA_IFA | RTA_BRD) if (index == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0) break; p = next + rtm->rtm_hdrlen; ++icnt; /* Scan to look for length of address */ alen = 0; for (p0 = p, i = 0; i < RTAX_MAX; i++) { if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) == 0) continue; sa = (struct sockaddr *)p; len = SA_RLEN(sa); if (i == RTAX_IFA) { alen = len; break; } p += len; } for (p = p0, i = 0; i < RTAX_MAX; i++) { if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) == 0) continue; sa = (struct sockaddr *)p; len = SA_RLEN(sa); if (i == RTAX_NETMASK && sa->sa_len == 0) dcnt += alen; else dcnt += len; p += len; } break; } } if (icnt + dcnt + ncnt == 1) { *pif = NULL; free(buf); return (0); } data = malloc(sizeof(struct ifaddrs) * icnt + dcnt + ncnt); if (data == NULL) { free(buf); return(-1); } ifa = (struct ifaddrs *)data; data += sizeof(struct ifaddrs) * icnt; names = data + dcnt; memset(ifa, 0, sizeof(struct ifaddrs) * icnt); ift = ifa; index = 0; for (next = buf; next < buf + needed; next += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)next; if (rtm->rtm_version != RTM_VERSION) continue; switch (rtm->rtm_type) { case RTM_IFINFO: ifm = (struct if_msghdr *)rtm; if (ifm->ifm_addrs & RTA_IFP) { index = ifm->ifm_index; dl = (struct sockaddr_dl *)(next + rtm->rtm_hdrlen); cif = ift; ift->ifa_name = names; ift->ifa_flags = (int)ifm->ifm_flags; memcpy(names, dl->sdl_data, dl->sdl_nlen); names[dl->sdl_nlen] = 0; names += dl->sdl_nlen + 1; ift->ifa_addr = (struct sockaddr *)data; memcpy(data, dl, ((struct sockaddr *)dl)->sa_len); data += SA_RLEN((struct sockaddr *)dl); /* ifm_data needs to be aligned */ ift->ifa_data = data = (void *)ALIGN(data); dlen = rtm->rtm_hdrlen - offsetof(struct if_msghdr, ifm_data); if (dlen > sizeof(ifm->ifm_data)) dlen = sizeof(ifm->ifm_data); memcpy(data, &ifm->ifm_data, dlen); data += sizeof(ifm->ifm_data); ift = (ift->ifa_next = ift + 1); } else index = 0; break; case RTM_NEWADDR: ifam = (struct ifa_msghdr *)rtm; if (index && ifam->ifam_index != index) abort(); /* XXX abort illegal in library */ if (index == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0) break; ift->ifa_name = cif->ifa_name; ift->ifa_flags = cif->ifa_flags; ift->ifa_data = NULL; p = next + rtm->rtm_hdrlen; /* Scan to look for length of address */ alen = 0; for (p0 = p, i = 0; i < RTAX_MAX; i++) { if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) == 0) continue; sa = (struct sockaddr *)p; len = SA_RLEN(sa); if (i == RTAX_IFA) { alen = len; break; } p += len; } for (p = p0, i = 0; i < RTAX_MAX; i++) { if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) == 0) continue; sa = (struct sockaddr *)p; len = SA_RLEN(sa); switch (i) { case RTAX_IFA: ift->ifa_addr = (struct sockaddr *)data; memcpy(data, p, len); data += len; break; case RTAX_NETMASK: ift->ifa_netmask = (struct sockaddr *)data; if (sa->sa_len == 0) { memset(data, 0, alen); data += alen; break; } memcpy(data, p, len); data += len; break; case RTAX_BRD: ift->ifa_broadaddr = (struct sockaddr *)data; memcpy(data, p, len); data += len; break; } p += len; } ift = (ift->ifa_next = ift + 1); break; } } free(buf); if (--ift >= ifa) { ift->ifa_next = NULL; *pif = ifa; } else { *pif = NULL; free(ifa); } return (0); } void freeifaddrs(struct ifaddrs *ifp) { free(ifp); }
[ "cludwig@net.t-labs.tu-berlin.de" ]
cludwig@net.t-labs.tu-berlin.de
0e6ab48538ae5dc78079e654a0140f9ce99df738
77d42049f38b30db7808c4ff924313aee1e4f17f
/User/SysTick.c
07db17d371e3b15ca266f5b25c6302ad1ff3752b
[]
no_license
ChenMiaohong/second
ef8dc039c032c8b0e57ae8ac6673d74aa2729086
1d10c4c9dc09c074f35a99d67f86219a4f55ac2f
refs/heads/master
2021-01-10T18:17:30.063630
2016-02-25T10:17:20
2016-02-25T10:17:20
52,515,727
0
0
null
null
null
null
UTF-8
C
false
false
412
c
#include"stm32f10x.h" #include"SysTick.h" static __IO u32 TimingDelay; void SysTick_Init() {if(SysTick_Config(SystemCoreClock/10000)) { while(1); } SysTick->CTRL &=~SysTick_CTRL_ENABLE_Msk; } void Delay_us(__IO u32 nTime) {TimingDelay=nTime; SysTick->CTRL|= SysTick_CTRL_ENABLE_Msk; while(TimingDelay!=0); } void TimingDelay_Decrement(void) { if(TimingDelay!=0x00); { TimingDelay--; } }
[ "you@example.com" ]
you@example.com
bfee26a34b054d705830aa66323362ce8d47943c
f026cb616ef14bae15a1d251ca6dbe0f55016d9c
/linux/26712.c
024cc7509595df91427bd9fb9d710f2a39423293
[]
no_license
jajajasalu2/cocci-lkmp-c-files
3eb7d451929dca5cb6beb56aabd69fe3f7fc176c
5da943aabe1589e393a131121dbf8e7a84b3cf2a
refs/heads/master
2020-12-02T17:30:14.411816
2020-01-29T08:36:30
2020-01-29T08:36:30
231,053,574
1
0
null
null
null
null
UTF-8
C
false
false
917
c
cocci_test_suite() { unsigned int cocci_id/* samples/timers/hpet_example.c 53 */; struct hpet_command { char *command; void (*func)(int argc, const char **argv); } cocci_id/* samples/timers/hpet_example.c 28 */[]; struct hpet_info cocci_id/* samples/timers/hpet_example.c 228 */; sig_t cocci_id/* samples/timers/hpet_example.c 227 */; unsigned long cocci_id/* samples/timers/hpet_example.c 225 */; const char **cocci_id/* samples/timers/hpet_example.c 223 */; int cocci_id/* samples/timers/hpet_example.c 223 */; void cocci_id/* samples/timers/hpet_example.c 222 */; void cocci_id/* samples/timers/hpet_example.c 22 */(int, const char **); long cocci_id/* samples/timers/hpet_example.c 139 */; struct timezone cocci_id/* samples/timers/hpet_example.c 138 */; struct timeval cocci_id/* samples/timers/hpet_example.c 137 */; struct pollfd cocci_id/* samples/timers/hpet_example.c 135 */; }
[ "jaskaransingh7654321@gmail.com" ]
jaskaransingh7654321@gmail.com
cb97a7ad95500b8f4485ba82c5c19bc4936888cf
c5b02d3b0888c5b7bfd849afdc87f6f57181c8f0
/mudlib/d/camps/catacombs/rooms/catac113.c
389d7eb524894cc3cb166a57da0ba6d1f4c08811
[]
no_license
jpeckham/DarkeLIB
8a311164f460cf2acd9e0fc7e1e1e69710f31b80
87c020b4974981879aa68f5d19b0dc2e96d2fe7d
refs/heads/master
2021-09-11T08:55:34.673296
2021-09-05T04:58:33
2021-09-05T04:58:33
141,068,816
2
5
null
2021-09-05T03:06:16
2018-07-16T00:39:43
C
UTF-8
C
false
false
1,053
c
/* Room coded by Duridian for DarkeMud. */ #include <std.h> inherit ROOM; void create() { ::create(); set_property("light", 1); set_property("indoors", 1); set("short", "Dark Dungeon"); set("long", "The passageway widens slightly as it runs from the west and northeast " "from this point. A few torches affixed to the wall provide very " "little light in this corridor." ); set_smell("default", "The air smells of dust."); set_listen("default", "There is not a sound."); set_items( ([ ({"walls", "wall", "floor", "dust"}): "The walls and floor are covered in a thin layer of dust.", ({"torches", "small torches"}): "The small torches that are affixed to the wall provide very little light.", ]) ); set_exits( ([ "west": PATH+"catac114", "northeast": PATH+"catac112", ]) ); } void reset() { ::reset(); if(!present("mithril skeleton")) new(MON_PATH+"mithskel")->move(this_object()); }
[ "jdpeckham@gmail.com" ]
jdpeckham@gmail.com
23e6fab52f86c08a646ba3ddc799afb558724b70
0aacfdcef43037ec2fd35c35977822f82afadbc7
/Practice C and CPP/bitwise.c
d0a5962ca25019c2cec6ccaabce5ee3147bccf27
[ "MIT" ]
permissive
Vitamin-111/py-web-hack
65ccd0868c984d64229d99ff2f9fc0e474bd92e9
5d879dbaa736ca43903a6ad9c44e7de995a45195
refs/heads/master
2023-04-30T23:42:23.231459
2020-05-13T09:05:53
2020-05-13T09:05:53
null
0
0
null
null
null
null
UTF-8
C
false
false
785
c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> //Complete the following function. void calculate_the_maximum(int n, int k) { int maxAnd = 0; int maxOr = 0; int maxXor = 0; for (int i=1; i<=n; i++) { for (int j=i+1; j<=n; j++) { if (((i&j) > maxAnd) && ((i&j) < k)) { maxAnd = i&j; } if (((i|j) > maxOr) && ((i|j) < k)) { maxOr = i|j; } if (((i^j) > maxXor) && ((i^j) < k)) { maxXor = i^j; } } } printf("%d\n%d\n%d\n", maxAnd, maxOr, maxXor); } int main() { int n, k; scanf("%d %d", &n, &k); calculate_the_maximum(n, k); return 0; }
[ "marshtomp.1999@hotmail.com" ]
marshtomp.1999@hotmail.com
71117f23a68561fe474be824aa904756ec1b961d
a8b888a8eb1ffcc9fa39a1e914338a3086705397
/src/vnsq.h
7bc02b5f6aa011420d06bffa7545807312b7b248
[ "HPND-sell-variant" ]
permissive
rajesh-g92/crashme
5ae1f974ecd66522120b5cea1d3262785aa43c2d
a7b35a4be905e3bdc0e6759f171842fb78b2d653
refs/heads/master
2020-06-23T11:24:48.818560
2013-07-09T11:52:12
2013-07-09T11:52:33
null
0
0
null
null
null
null
UTF-8
C
false
false
68
h
void init_vnsq(unsigned long seed); unsigned long vnsq_int32(void);
[ "SND\\publius_cp@2327b42d-5241-43d6-9e2a-de5ac946f064" ]
SND\publius_cp@2327b42d-5241-43d6-9e2a-de5ac946f064
3d85a67a01bcaf346ca518fb25113817dd93ef6d
515756675f130c5f7cf356fcb187104576bd4abf
/andEngineMODPlayerExtension/src/main/jni/loaders/stx_load.c
630a9448197599fcedff180d1638b700336c48fd
[]
no_license
stephtelolahy/AndEngineDemo
0a87e56b19d3113640ebef2abd1677001f56e7f4
d8a492323479b77c6da80a393e39948bd77376c4
refs/heads/master
2020-12-26T03:01:21.121824
2014-10-29T18:52:08
2014-10-29T19:07:01
25,823,289
2
1
null
null
null
null
UTF-8
C
false
false
7,954
c
/* Extended Module Player * Copyright (C) 1996-2010 Claudio Matsuoka and Hipolito Carraro Jr * * This file is part of the Extended Module Player and is distributed * under the terms of the GNU General Public License. See doc/COPYING * for more information. */ /* From the STMIK 0.2 documentation: * * "The STMIK uses a special [Scream Tracker] beta-V3.0 module format. * Due to the module formats beta nature, the current STMIK uses a .STX * extension instead of the normal .STM. I'm not intending to do a * STX->STM converter, so treat STX as the format to be used in finished * programs, NOT as a format to be used in distributing modules. A program * called STM2STX is included, and it'll convert STM modules to the STX * format for usage in your own programs." * * Tested using "Future Brain" from Mental Surgery by Future Crew and * STMs converted with STM2STX. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "load.h" #include "stx.h" #include "s3m.h" #include "period.h" static int stx_test (FILE *, char *, const int); static int stx_load (struct xmp_context *, FILE *, const int); struct xmp_loader_info stx_loader = { "STX", "STMIK 0.2", stx_test, stx_load }; static int stx_test(FILE *f, char *t, const int start) { char buf[8]; fseek(f, start + 20, SEEK_SET); if (fread(buf, 1, 8, f) < 8) return -1; if (memcmp(buf, "!Scream!", 8) && memcmp(buf, "BMOD2STM", 8)) return -1; fseek(f, start + 60, SEEK_SET); if (fread(buf, 1, 4, f) < 4) return -1; if (memcmp(buf, "SCRM", 4)) return -1; fseek(f, start + 0, SEEK_SET); read_title(f, t, 20); return 0; } #define FX_NONE 0xff static uint16 *pp_ins; /* Parapointers to instruments */ static uint16 *pp_pat; /* Parapointers to patterns */ static uint8 fx[] = { FX_NONE, FX_TEMPO, FX_JUMP, FX_BREAK, FX_VOLSLIDE, FX_PORTA_DN, FX_PORTA_UP, FX_TONEPORTA, FX_VIBRATO, FX_TREMOR, FX_ARPEGGIO }; static int stx_load(struct xmp_context *ctx, FILE *f, const int start) { struct xmp_player_context *p = &ctx->p; struct xmp_mod_context *m = &p->m; int c, r, i, broken = 0; struct xxm_event *event = 0, dummy; struct stx_file_header sfh; struct stx_instrument_header sih; uint8 n, b; uint16 x16; int bmod2stm = 0; LOAD_INIT(); fread(&sfh.name, 20, 1, f); fread(&sfh.magic, 8, 1, f); sfh.psize = read16l(f); sfh.unknown1 = read16l(f); sfh.pp_pat = read16l(f); sfh.pp_ins = read16l(f); sfh.pp_chn = read16l(f); sfh.unknown2 = read16l(f); sfh.unknown3 = read16l(f); sfh.gvol = read8(f); sfh.tempo = read8(f); sfh.unknown4 = read16l(f); sfh.unknown5 = read16l(f); sfh.patnum = read16l(f); sfh.insnum = read16l(f); sfh.ordnum = read16l(f); sfh.unknown6 = read16l(f); sfh.unknown7 = read16l(f); sfh.unknown8 = read16l(f); fread(&sfh.magic2, 4, 1, f); /* BMOD2STM does not convert pitch */ if (!strncmp ((char *) sfh.magic, "BMOD2STM", 8)) bmod2stm = 1; #if 0 if ((strncmp ((char *) sfh.magic, "!Scream!", 8) && !bmod2stm) || strncmp ((char *) sfh.magic2, "SCRM", 4)) return -1; #endif m->xxh->ins = sfh.insnum; m->xxh->pat = sfh.patnum; m->xxh->trk = m->xxh->pat * m->xxh->chn; m->xxh->len = sfh.ordnum; m->xxh->tpo = MSN (sfh.tempo); m->xxh->smp = m->xxh->ins; m->c4rate = C4_NTSC_RATE; /* STM2STX 1.0 released with STMIK 0.2 converts STMs with the pattern * length encoded in the first two bytes of the pattern (like S3M). */ fseek(f, start + (sfh.pp_pat << 4), SEEK_SET); x16 = read16l(f); fseek(f, start + (x16 << 4), SEEK_SET); x16 = read16l(f); if (x16 == sfh.psize) broken = 1; strncpy(m->name, (char *)sfh.name, 20); if (bmod2stm) sprintf(m->type, "STMIK 0.2 (BMOD2STM)"); else snprintf(m->type, XMP_NAMESIZE, "STMIK 0.2 (STM2STX 1.%d)", broken ? 0 : 1); MODULE_INFO(); pp_pat = calloc (2, m->xxh->pat); pp_ins = calloc (2, m->xxh->ins); /* Read pattern pointers */ fseek(f, start + (sfh.pp_pat << 4), SEEK_SET); for (i = 0; i < m->xxh->pat; i++) pp_pat[i] = read16l(f); /* Read instrument pointers */ fseek(f, start + (sfh.pp_ins << 4), SEEK_SET); for (i = 0; i < m->xxh->ins; i++) pp_ins[i] = read16l(f); /* Skip channel table (?) */ fseek(f, start + (sfh.pp_chn << 4) + 32, SEEK_SET); /* Read orders */ for (i = 0; i < m->xxh->len; i++) { m->xxo[i] = read8(f); fseek(f, 4, SEEK_CUR); } INSTRUMENT_INIT(); /* Read and convert instruments and samples */ reportv(ctx, 1, " Sample name Len LBeg LEnd L Vol C2Spd\n"); for (i = 0; i < m->xxh->ins; i++) { m->xxi[i] = calloc (sizeof (struct xxm_instrument), 1); fseek(f, start + (pp_ins[i] << 4), SEEK_SET); sih.type = read8(f); fread(&sih.dosname, 13, 1, f); sih.memseg = read16l(f); sih.length = read32l(f); sih.loopbeg = read32l(f); sih.loopend = read32l(f); sih.vol = read8(f); sih.rsvd1 = read8(f); sih.pack = read8(f); sih.flags = read8(f); sih.c2spd = read16l(f); sih.rsvd2 = read16l(f); fread(&sih.rsvd3, 4, 1, f); sih.int_gp = read16l(f); sih.int_512 = read16l(f); sih.int_last = read32l(f); fread(&sih.name, 28, 1, f); fread(&sih.magic, 4, 1, f); m->xxih[i].nsm = !!(m->xxs[i].len = sih.length); m->xxs[i].lps = sih.loopbeg; m->xxs[i].lpe = sih.loopend; if (m->xxs[i].lpe == 0xffff) m->xxs[i].lpe = 0; m->xxs[i].flg = m->xxs[i].lpe > 0 ? WAVE_LOOPING : 0; m->xxi[i][0].vol = sih.vol; m->xxi[i][0].pan = 0x80; m->xxi[i][0].sid = i; copy_adjust(m->xxih[i].name, sih.name, 12); if (V(1) && (strlen((char *) m->xxih[i].name) || (m->xxs[i].len > 1))) { report ("[%2X] %-14.14s %04x %04x %04x %c V%02x %5d\n", i, m->xxih[i].name, m->xxs[i].len, m->xxs[i].lps, m->xxs[i].lpe, m->xxs[i].flg & WAVE_LOOPING ? 'L' : ' ', m->xxi[i][0].vol, sih.c2spd); } sih.c2spd = 8363 * sih.c2spd / 8448; c2spd_to_note (sih.c2spd, &m->xxi[i][0].xpo, &m->xxi[i][0].fin); } PATTERN_INIT(); /* Read and convert patterns */ reportv(ctx, 0, "Stored patterns: %d ", m->xxh->pat); for (i = 0; i < m->xxh->pat; i++) { PATTERN_ALLOC (i); m->xxp[i]->rows = 64; TRACK_ALLOC (i); if (!pp_pat[i]) continue; fseek(f, start + (pp_pat[i] << 4), SEEK_SET); if (broken) fseek(f, 2, SEEK_CUR); for (r = 0; r < 64; ) { b = read8(f); if (b == S3M_EOR) { r++; continue; } c = b & S3M_CH_MASK; event = c >= m->xxh->chn ? &dummy : &EVENT (i, c, r); if (b & S3M_NI_FOLLOW) { n = read8(f); switch (n) { case 255: n = 0; break; /* Empty note */ case 254: n = XMP_KEY_OFF; break; /* Key off */ default: n = 25 + 12 * MSN (n) + LSN (n); } event->note = n; event->ins = read8(f);; } if (b & S3M_VOL_FOLLOWS) { event->vol = read8(f) + 1; } if (b & S3M_FX_FOLLOWS) { event->fxt = fx[read8(f)]; event->fxp = read8(f); switch (event->fxt) { case FX_TEMPO: event->fxp = MSN (event->fxp); break; case FX_NONE: event->fxp = event->fxt = 0; break; } } } reportv(ctx, 0, "."); } reportv(ctx, 0, "\n"); free (pp_pat); free (pp_ins); /* Read samples */ reportv(ctx, 0, "Stored samples : %d ", m->xxh->smp); for (i = 0; i < m->xxh->ins; i++) { xmp_drv_loadpatch(ctx, f, m->xxi[i][0].sid, m->c4rate, 0, &m->xxs[m->xxi[i][0].sid], NULL); reportv(ctx, 0, "."); } reportv(ctx, 0, "\n"); m->quirk |= XMP_QRK_VSALL | XMP_QUIRK_ST3; return 0; }
[ "stephano.telolahy@gmail.com" ]
stephano.telolahy@gmail.com
bea98fd8ffbdae247b93cd313a2e57393bfa4edb
90f519ad024334fbf328e57dcf195493473bc78b
/lan/cindepth/cs/if_else/p2.c
c7137e9c6d7c4eeb76af4c75fed1ccc1fc18f631
[]
no_license
yoginsavani/c
74101a50ae2af6319a447011ad26f407283e60d9
25d38dffb66574e96a14768bd7f4d9d560b22de3
refs/heads/master
2021-05-17T22:26:58.593728
2020-03-29T07:49:04
2020-03-29T07:49:04
250,980,148
4
0
null
null
null
null
UTF-8
C
false
false
171
c
#include<stdio.h> int main(void) { int a=0; if(a=0) printf("a is zero\t"); else printf("a is not zero\t"); printf("Value of a is %d\n",a); return 0; }
[ "62587987+yogin-1510@users.noreply.github.com" ]
62587987+yogin-1510@users.noreply.github.com
789c07d237e687bf7d32b6301156f3115bfb340c
aeff2a5a844ac4b11f5425a58ca15740beacb1d8
/src/ElVis/Extensions/JacobiExtension/Isosurface.h
43c983c4f908ccdb7d8d11857aff3f98628d8783
[]
no_license
z-jack/ElVisX
2ab0cb1dfb2b362b17e9708c17ca8dd1064e50c1
ce314d5a939b8cf4233d40ba42479faaa893f569
refs/heads/master
2020-04-11T21:08:05.080308
2018-12-17T08:26:20
2018-12-17T08:26:20
162,096,000
0
0
null
null
null
null
UTF-8
C
false
false
2,986
h
//////////////////////////////////////////////////////////////////////////////// // // File: hoIsosurface.h // // The MIT License // // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA), // Department of Aeronautics, Imperial College London (UK), and Scientific // Computing and Imaging Institute, University of Utah (USA). // // License for the specific language governing rights and limitations under // 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. // // Description: Precompiled header. // //////////////////////////////////////////////////////////////////////////////// #ifndef ELVIS_JACOBI_EXTENSION_ELVIS_HIGH_ORDER_ISOSURFACE_HO_ISOSURFACE_H #define ELVIS_JACOBI_EXTENSION_ELVIS_HIGH_ORDER_ISOSURFACE_HO_ISOSURFACE_H #include <ElVis/Extensions/JacobiExtension/Declspec.h> #include <ElVis/Extensions/JacobiExtension/Edge.h> #include <ElVis/Extensions/JacobiExtension/EndianConvert.h> #include <ElVis/Extensions/JacobiExtension/FiniteElementMath.h> #include <ElVis/Extensions/JacobiExtension/FiniteElementVolume.h> #include <ElVis/Extensions/JacobiExtension/Hexahedron.h> #include <ElVis/Extensions/JacobiExtension/Jacobi.hpp> #include <ElVis/Extensions/JacobiExtension/NumericalIntegration.hpp> #include <ElVis/Extensions/JacobiExtension/PointTransformations.hpp> #include <ElVis/Extensions/JacobiExtension/Polyhedra.h> #include <ElVis/Extensions/JacobiExtension/PolyhedraBoundingBox.h> #include <ElVis/Extensions/JacobiExtension/Polylib.h> #include <ElVis/Extensions/JacobiExtension/Polynomial.hpp> #include <ElVis/Extensions/JacobiExtension/PolynomialInterpolation.hpp> #include <ElVis/Extensions/JacobiExtension/Prism.h> #include <ElVis/Extensions/JacobiExtension/Pyramid.h> #include <ElVis/Extensions/JacobiExtension/SimpleMatrix.hpp> #include <ElVis/Extensions/JacobiExtension/Tetrahedron.h> #include <ElVis/Extensions/JacobiExtension/Writers.h> #endif //ELVIS_HIGH_ORDER_ISOSURFACE_HO_ISOSURFACE_H
[ "emailjiong@126.com" ]
emailjiong@126.com
a35b51e4f1dceee23d1ba30888c66c53b26a8ab5
2d1487aaf93acb606541fc42eef86d27e01a2de7
/driver/touch/ns2009/mean.c
70fafef88538ec2a129323c49510aabfa18ee2ec
[]
no_license
hilaolu/k210
072e5c463e764735abbb1ddfc5cb47e976b616f9
93030e1f4f11fae9a9fbfa9ef99edce6f2bc6f98
refs/heads/master
2022-04-13T17:18:13.956801
2020-04-01T10:33:08
2020-04-01T10:33:08
null
0
0
null
null
null
null
UTF-8
C
false
false
1,433
c
/* * libc/filter/mean.c */ #include <math.h> #include <mean.h> #include <stddef.h> #include "touchscreen.h" struct mean_filter_t *mean_alloc(int length) { struct mean_filter_t *filter; int i; if (length <= 0) return NULL; filter = touchscreen_malloc(sizeof(struct mean_filter_t)); if (!filter) return NULL; filter->buffer = touchscreen_malloc(sizeof(int) * length); if (!filter->buffer) { touchscreen_free(filter); return NULL; } for (i = 0; i < length; i++) filter->buffer[i] = 0; filter->length = length; filter->index = 0; filter->count = 0; filter->sum = 0; return filter; } void mean_free(struct mean_filter_t *filter) { if (filter) { if (filter->buffer) touchscreen_free(filter->buffer); touchscreen_free(filter); } } int mean_update(struct mean_filter_t *filter, int value) { filter->sum -= filter->buffer[filter->index]; filter->sum += value; filter->buffer[filter->index] = value; filter->index = (filter->index + 1) % filter->length; if (filter->count < filter->length) filter->count++; return filter->sum / filter->count; } void mean_clear(struct mean_filter_t *filter) { int i; if (filter) { for (i = 0; i < filter->length; i++) filter->buffer[i] = 0; filter->index = 0; filter->count = 0; filter->sum = 0; } }
[ "hhslzzyyes@outlook.com" ]
hhslzzyyes@outlook.com
a66b6c0fc7b05e3402f69723008fcb8489f4c309
c66c276b8a7401449f5ce7894440db4a4b7d4a6b
/TivaC/Print_Num.c
9977db98643a0b18c8e9f879d3de40b62aa4155a
[]
no_license
Shanky-Robot/AGV_firmware
6fbef6f57a83acf4fd272d6f542e8df181f2f910
6743890b1dd776fca760c3b1896420c1a75c181b
refs/heads/master
2023-02-11T21:37:36.960580
2021-01-10T18:35:58
2021-01-10T18:35:58
null
0
0
null
null
null
null
UTF-8
C
false
false
2,090
c
/*---------------------------------------------------------------------------- * Name: Print_Num.c * Purpose: Converting numerical data into charachters to print *----------------------------------------------------------------------------*/ #include "TM4C1292NCPDT.h" // Device header #include "Print_Num.h" #include "PORTs/PORT_A.h" void PrintHEX(char CHAR) { if((CHAR>>4)>9) SER0_PutChar((CHAR>>4)+55); else SER0_PutChar((CHAR>>4)+'0'); if((CHAR&0x0F)>9) SER0_PutChar((CHAR&0x0F)+55); else SER0_PutChar((CHAR&0x0F)+'0'); } void PrintDEC_Monitor(int16_t data_Pos) { if((data_Pos) < 0) { data_Pos = data_Pos * -1; SER0_PutChar('-'); } uint16_t data_Pos_4,data_Pos_3,data_Pos_2,data_Pos_1,data_Pos_0; data_Pos_4 = data_Pos - (data_Pos%10000); data_Pos = data_Pos - data_Pos_4; data_Pos_3 = data_Pos - (data_Pos%1000); data_Pos = data_Pos - data_Pos_3; data_Pos_2 = data_Pos - (data_Pos%100); data_Pos = data_Pos - data_Pos_2; data_Pos_1 = data_Pos - (data_Pos%10); data_Pos_0 = data_Pos - data_Pos_1; data_Pos_3 = data_Pos_3 / 1000; data_Pos_2 = data_Pos_2 / 100; data_Pos_1 = data_Pos_1 / 10; SER0_PutChar(data_Pos_4+'0'); SER0_PutChar(data_Pos_3+'0'); SER0_PutChar(data_Pos_2+'0'); SER0_PutChar(data_Pos_1+'0'); SER0_PutChar(data_Pos_0+'0'); SER0_PutChar('\n'); SER0_PutChar('\r'); } void PrintDEC_Plotter(uint16_t data_Pos) { uint16_t data_Pos_3,data_Pos_2,data_Pos_1,data_Pos_0; data_Pos_3 = data_Pos - (data_Pos%1000); data_Pos = data_Pos - data_Pos_3; data_Pos_2 = data_Pos - (data_Pos%100); data_Pos = data_Pos - data_Pos_2; data_Pos_1 = data_Pos - (data_Pos%10); data_Pos_0 = data_Pos - data_Pos_1; data_Pos_3 = data_Pos_3 / 1000; data_Pos_2 = data_Pos_2 / 100; data_Pos_1 = data_Pos_1 / 10; SER0_PutChar('$'); SER0_PutChar(data_Pos_3+'0'); SER0_PutChar(','); SER0_PutChar(data_Pos_2+'0'); SER0_PutChar(','); SER0_PutChar(data_Pos_1+'0'); SER0_PutChar(','); SER0_PutChar(data_Pos_0+'0'); SER0_PutChar(';'); }
[ "magdaoud@uwaterloo.ca" ]
magdaoud@uwaterloo.ca
174f466fdfb397d58d65538b0cb769b85c3bd5e0
2a43d289528ef3e2ced854fa570da99194aefd3e
/src/ftdilcd.c
300798f4b091a879324e5091685b18006af9820d
[]
no_license
xjjx/fhctrl
9eb8ce2dbdafc6f3898db6b0df4e746679c37247
02e969ca582596d7509a09fb6cc2ad7032ed7e93
refs/heads/master
2021-01-23T17:42:53.568592
2017-09-08T00:23:15
2017-09-08T00:23:15
102,774,995
0
0
null
null
null
null
UTF-8
C
false
false
3,328
c
#include <stdio.h> #include <string.h> #include <ftdi.h> #include "ftdilcd.h" #include "log.h" /* * bitbang I/O pin mappings * * #define PIN_TXD 0x01 * #define PIN_RXD 0x02 * #define PIN_RTS 0x04 * #define PIN_CTS 0x08 * #define PIN_DTR 0x10 * #define PIN_DSR 0x20 * #define PIN_DCD 0x40 * #define PIN_RI 0x80 */ /* From Jacek K. TXD(D0) (pin11) D4 D0 (0x01) RXD(D1) (pin12) D5 D1 (0x02) RTS(D2) (pin13) D6 D2 (0x04) CTS(D3) (pin14) D7 D3 (0x08) DTR(D4) (pin6) EN D4 (0x10) DSR(D5) (pin5) RW D5 (0x20) DCD(D6) (pin4) RS D6 (0x40) */ #define FTDI_BAUDRATE 921600 #define FTDI_VENDOR 0x0403 #define FTDI_PRODUCT 0x6001 #define LCD_EN 0x10 #define LCD_RW 0x20 #define LCD_RS 0x40 #define LCD_WIDTH 16 #define LCD_HEIGHT 4 #define LCD_CMD_CLEAR 0x01 #define LCD_CMD_RETURN_HOME 0x02 #define LCD_CMD_CURSOR_RIGHT 0x06 #define LCD_CMD_DISPON_NOCUR 0x0C #define LCD_CMD_DISPON_SOLID 0x0E #define LCD_CMD_DISPON_BLINK 0x0F #define LCD_CMD_4BIT_1LINE 0x20 #define LCD_CMD_4BIT_2LINE 0x28 #define LCD_LINE1 0x80 #define LCD_LINE2 LCD_LINE1+64 #define LCD_LINE3 LCD_LINE1+LCD_WIDTH #define LCD_LINE4 LCD_LINE2+LCD_WIDTH struct ftdi_context* ftdic; enum LCD_MODE { LCD_CMD, LCD_DATA }; static void lcd_write (enum LCD_MODE lcd_mode, char data) { unsigned char buf[4]; unsigned char portControl = 0; int f; if (lcd_mode == LCD_DATA) portControl |= LCD_RS; buf[0] = ((data >> 4) & 0x0F) | portControl | LCD_EN; buf[1] = ((data >> 4) & 0x0F) | portControl; buf[2] = (data & 0x0F) | portControl | LCD_EN; buf[3] = (data & 0x0F) | portControl; f = ftdi_write_data(ftdic, buf, 4); if (f < 0) { LOG("unable to open ftdi device: %d (%s)", f, ftdi_get_error_string(ftdic)); return; } } static void lcd_cmd(char cmd) { lcd_write(LCD_CMD, cmd); } static bool lcd_pos(short x, short y) { int ca; // Cursor Address if (x >= LCD_WIDTH || y >= LCD_HEIGHT) return false; switch(y) { case 0: ca = LCD_LINE1; break; case 1: ca = LCD_LINE2; break; case 2: ca = LCD_LINE3; break; case 3: ca = LCD_LINE4; break; default: return false; } ca += x; lcd_cmd(ca); return true; } void lcd_text(short x, short y, char* txt) { int i; char* blank = " "; // Set Cursor at line if (! lcd_pos(0, y)) return; for(i=0; i<LCD_WIDTH; i++) { if (i >= x && i < strlen(txt)) { lcd_write(LCD_DATA, txt[i]); } else { lcd_write(LCD_DATA, *blank); } } } bool lcd_init() { int f; ftdic = ftdi_new(); /* Initialize context for subsequent function calls */ ftdi_init(ftdic); ftdi_set_interface(ftdic, INTERFACE_A); f = ftdi_usb_open(ftdic, FTDI_VENDOR, FTDI_PRODUCT); if (f < 0) { LOG("FTDI: Can't open device %d", f); free(ftdic); return false; } f = ftdi_set_baudrate(ftdic, FTDI_BAUDRATE); if (f < 0) { LOG("FTDI: Can't set baudrate to %d", FTDI_BAUDRATE); free(ftdic); return false; } ftdi_set_bitmode(ftdic, 0xFF, BITMODE_BITBANG); lcd_cmd(LCD_CMD_CLEAR); lcd_cmd(LCD_CMD_4BIT_2LINE); lcd_cmd(LCD_CMD_CURSOR_RIGHT); lcd_cmd(LCD_CMD_DISPON_NOCUR); return true; } void lcd_close() { if (ftdic) { ftdi_deinit(ftdic); ftdi_free(ftdic); } }
[ "xj@wp.pl" ]
xj@wp.pl
f69e2e8471f493837e0db138ded2210e5d48e42c
b44448fc66cbf7ff92c2d098f76dd623d09195d4
/src/wiimoteTask.c
39ce1045aabff6064187272a03f0c092d5ed0bf8
[]
no_license
jesionaj/RTOSBot
8a82b826b501c2671b05d13c3f3610d6140ffee7
5d1d6519c932bc3c4eea9a7b5b68601c605bdca3
refs/heads/master
2020-04-16T01:44:27.064575
2016-07-04T20:36:35
2016-07-04T20:36:35
31,404,072
1
0
null
null
null
null
UTF-8
C
false
false
2,709
c
// 2015 Adam Jesionowski #include <xc.h> #include <plib.h> #include "wiimoteTask.h" #include "motorTask.h" #include "sdCard.h" #include "serialLCD.h" #include "config.h" #include "rtos.h" // Timer runs at 20 MHz, so we want 2,000,000 for 100 ms #define TIMER_LENGTH (2000000UL) static uintd_t wiimoteTask_stack[DFLT_STACK_SIZE] = {0}; Task_t wiimoteTask_task = { PRIORITY_4, {NULL, NULL, &wiimoteTask_task}, 0, wiimoteTask_stack }; static Event_t wiimoteSampleEvent; /* * This is the callback that will occur when 100 ms have passed. This is on the OS stack, * and we want to kick off the wiimote task */ static void TriggerWiimoteSample() { // This will ready the wiimote task and immediately switch to it TriggerEvent(&wiimoteSampleEvent); SwitchToHighestPriorityTaskFromISR(); } void wiimoteTask_init() { wiimoteTask_task.stackPtr = &wiimoteTask_stack[DFLT_STACK_SIZE-1]; wiimoteTask_task.stackPtr = (uintd_t*)InitStack(wiimoteTask_task.stackPtr, wiimoteTask_main); wiimoteSampleEvent.blockedTasks = NULL; } void wiimoteTask_main() { uint8_t buffer[6]; // Data from wiimote is 6 bytes long RobotState_t state = {0}; int8_t leftDir; int8_t rightDir; // Wait for Wiimote to start up DelayCurrentTask(100); // Handshake with Wiimote StartWiimote(); // Kick off the event timer. This auto-reloads and triggers the event every 100 ms // This is necessary for accurate timing so that our replay works properly TimerEnable(WIIMOTE_TIMER, TIMER_LENGTH, TriggerWiimoteSample, true); while(1) { GetAndResetCounts(&state.leftEncoderCount, &state.rightEncoderCount); // Figure out which direction the motors are moving in (sets as 1 or -1), // Then multiply accordingly. Wiimote Task is a higher task than Motor Task, // so it won't be able to prempt this. // TODO: This is a bad way of passing data between tasks, but a queue is too heavy // duty. Figure out a better method. GetMotorDirection(&leftDir, &rightDir); state.leftEncoderCount *= leftDir; state.rightEncoderCount *= rightDir; // Get the joystick data WiimoteGetData(buffer); state.joystick.x = buffer[0]; state.joystick.y = buffer[1]; // Send the data off Enqueue(&motorInputQueue, (uint8_t*)&state.joystick); Enqueue(&lcdQueue, (uint8_t*)&state); Enqueue(&sdCardQueue, (uint8_t*)&state); // We'll complete the code above way before the event re-triggers // We do it this way because getting data from I2C takes a long time (~4 ms). WaitForEvent(&wiimoteSampleEvent); } }
[ "cmdprompt+gh@gmail.com" ]
cmdprompt+gh@gmail.com
149a62ad4a38378f24b7c992aae07bff958e1127
1888a34bcbb0a572176123bade6f632593a36314
/src/test/test_ccnx_NameReader.c
542cfc7c39e959b566e1dad6d7ddc043b3f9c6f5
[]
no_license
chris-wood/ccnx-name-reader
af4bf0add6a84210eac073fd7c810c8f17b600ba
5b98361423fb3e17d04af72f3bc164673b0360e6
refs/heads/master
2021-01-17T20:53:17.912937
2016-10-19T21:49:34
2016-10-22T21:49:34
65,566,972
0
0
null
null
null
null
UTF-8
C
false
false
2,541
c
#include <stdio.h> #include <LongBow/unit-test.h> #include <LongBow/debugging.h> #include <parc/algol/parc_SafeMemory.h> #include <parc/algol/parc_Memory.h> #include "../ccnx_NameReader.c" LONGBOW_TEST_RUNNER(test_ccnx_NameReader) { // The following Test Fixtures will run their corresponding Test Cases. // Test Fixtures are run in the order specified, but all tests should be idempotent. // Never rely on the execution order of tests or share state between them. LONGBOW_RUN_TEST_FIXTURE(Global); } // The Test Runner calls this function once before any Test Fixtures are run. LONGBOW_TEST_RUNNER_SETUP(test_ccnx_NameReader) { return LONGBOW_STATUS_SUCCEEDED; } // The Test Runner calls this function once after all the Test Fixtures are run. LONGBOW_TEST_RUNNER_TEARDOWN(test_ccnx_NameReader) { return LONGBOW_STATUS_SUCCEEDED; } LONGBOW_TEST_FIXTURE(Global) { LONGBOW_RUN_TEST_CASE(Global, ccnxNameReader_Create); LONGBOW_RUN_TEST_CASE(Global, ccnxNameReader_Read); } LONGBOW_TEST_FIXTURE_SETUP(Global) { return LONGBOW_STATUS_SUCCEEDED; } LONGBOW_TEST_FIXTURE_TEARDOWN(Global) { uint32_t outstandingAllocations = parcSafeMemory_ReportAllocation(STDOUT_FILENO); if (outstandingAllocations != 0) { printf("%s leaks memory by %d allocations\n", longBowTestCase_GetName(testCase), outstandingAllocations); return LONGBOW_STATUS_MEMORYLEAK; } return LONGBOW_STATUS_SUCCEEDED; } LONGBOW_TEST_CASE(Global, ccnxNameReader_Create) { CCNxNameReader *reader = ccnxNameReader_Create("test_uris.txt"); assertNotNull(reader, "Expected a non-NULL reader"); ccnxNameReader_Release(&reader); } LONGBOW_TEST_CASE(Global, ccnxNameReader_Read) { CCNxNameReader *reader = ccnxNameReader_Create("test_uris.txt"); assertNotNull(reader, "Expected a non-NULL reader"); PARCIterator *iterator = ccnxNameReader_Iterator(reader); while (parcIterator_HasNext(iterator)) { CCNxName *name = (CCNxName *) parcIterator_Next(iterator); char *nameString = ccnxName_ToString(name); printf("Read: %s\n", nameString); parcMemory_Deallocate((void **) &nameString); ccnxName_Release(&name); } parcIterator_Release(&iterator); ccnxNameReader_Release(&reader); } int main(int argc, char *argv[argc]) { LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(test_ccnx_NameReader); int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); longBowTestRunner_Destroy(&testRunner); exit(exitStatus); }
[ "christopherwood07@gmail.com" ]
christopherwood07@gmail.com
15d40213a9ba812c1f1f379a351a0e904add5e8f
0ed044ce0c079dc28f62b4ae6102aca175ce33b1
/inc/mat_mult_from_doc.h
d9e24199d9b0549be12c2b0e13e8ed40fc39374d
[]
no_license
shaneaaron380/final
8639ec0c96e24cfa016d466fa7516aa7227bb4dc
0b5b77d1f7b2b7237abeef6a1ca1d02a4ec22720
refs/heads/master
2020-05-26T21:15:42.907728
2011-05-14T19:20:53
2011-05-14T19:20:53
1,662,463
0
0
null
null
null
null
UTF-8
C
false
false
173
h
#ifndef __MAT_MULT_FROM_DOC_H__ #define __MAT_MULT_FROM_DOC_H__ #include "matrix.h" #define BLOCK_SIZE 16 void MatMult(const Matrix A, const Matrix B, Matrix C); #endif
[ "aaron.r.stacy@gmail.com" ]
aaron.r.stacy@gmail.com
fd012fd1ba64099dddd69cc5c5697727936973a0
88e5d83332234c10f984f92de8954c9d05557e46
/roboFinist2018/smartLine/slalom_03.c
a9fc541da382957ceb30cdda591cdd2b6b8127ca
[]
no_license
drAlexAK/Lego
09646a27a210414aefbe7397f8186f6d50d626ac
cf5ba42805416f2c7f517218031c957fc1864d85
refs/heads/master
2021-01-12T10:14:17.397139
2018-09-08T22:07:18
2018-09-08T22:07:18
76,393,350
1
2
null
null
null
null
UTF-8
C
false
false
6,457
c
#pragma config(Sensor, S4, sLightLeft2, sensorI2CCustom9V) #pragma config(Sensor, S1, sLightRight2, sensorI2CCustom9V) #pragma config(Sensor, S2, sLightCenter, sensorI2CCustom9V) #pragma config(Motor, motorB, mLeft, tmotorNXT, openLoop) #pragma config(Motor, motorC, mRight, tmotorNXT, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// #include "mindsensors-lineleader.h" #include "mindsensors-lightsensorarray.h" // time: 08:20 - 08:40 (left) 8:60 - 8:80 (right) fast // direction: left // motors: 2 // ger: direct // tire: \__/ #61481 + #56145c04 #define Max(x, y) (((x) > (y)) ? (x) : (y)) #define Min(x, y) (((x) < (y)) ? (x) : (y)) #define RELEASE //#define DEBUG //-------------------- task sensorLeft(); task sensorRight(); task sensorCenter(); task speedUp(); //-------------------- void calibrate (); void waitTouchRelease(); //-------------------- int vBase = 60; int const vMax = 80; int const vMin = 10; int const k = 35; int iAlert = 0; bool leftAlert = false; bool rightAlert = false; //-------------------- tByteArray rawLightLeft2; tByteArray rawLightRight2; tByteArray rawLightCenter; //-------------------- task speedUp() { int vFinish = vBase; int const vStart = 30; int const tSpeedUp = 600; int tSleep = tSpeedUp / ( vFinish - vStart ); for ( int i = vStart ; i <= vFinish ; i++ ) { vBase = i ; sleep(tSleep); } } //-------------------- task sensorLeft() { tByteArray a; while (true) { MSLSAreadSensors(sLightLeft2, &a[0]); memcpy(rawLightLeft2, a, 8); sleep(1); } } task sensorRight() { tByteArray a; while (true) { MSLSAreadSensors(sLightRight2, &a[0]); memcpy(rawLightRight2, a, 8); sleep(1); } } task sensorCenter() { tByteArray a; while (true) { LLreadSensorRaw(sLightCenter, a); memcpy(rawLightCenter, a, 8); sleep(1); } } task main() { MSLSAinit(sLightLeft2); // Set up Line Leader sensor type MSLSAinit(sLightRight2); // Set up Line Leader sensor type MSLSAsetEU(sLightLeft2); // European frequency compensation MSLSAsetEU(sLightRight2); // European frequency compensation LLinit(sLightCenter); // Set up Line Leader sensor type _lineLeader_cmd(sLightCenter, 'E'); // European frequency compensation calibrate(); waitTouchRelease(); int eOld = 0; int e = 0; int u = 0; int v = 0; int vLeft = 0; int vRight = 0; int centerLeft = 0; int centerRight = 0; leftAlert = false; rightAlert = false; int leftLevel = 0; int rightLevel = 0; startTask(sensorLeft ); startTask(sensorRight); startTask(sensorCenter); startTask(speedUp); while(true) { leftLevel = 8; for (int j = 0 ; j < 8; j++) { if (rawLightLeft2[j] < 20) break; leftLevel--; } rightLevel = 8; for (int j = 7 ; j >= 0; j--) { if (rawLightRight2[j] < 20) break; rightLevel--; } centerLeft = (rawLightCenter[4] + rawLightCenter[5] + rawLightCenter[6] + rawLightCenter[7]); centerRight = (rawLightCenter[0] + rawLightCenter[1] + rawLightCenter[2] + rawLightCenter[3]); /* displayBigTextLine(1,"l: %d", leftLevel); displayBigTextLine(3,"r: %d", rightLevel); displayBigTextLine(5,"la: %d", leftAlert); displayBigTextLine(7,"ra: %d", rightAlert); */ if (leftAlert == false) leftAlert = (leftLevel > 0); if (leftAlert && (iAlert > 0) && ((centerRight < 300) || (rightLevel > 0))) { leftAlert = false; iAlert = 0; } if (rightAlert == false) rightAlert = (rightLevel > 0); if (rightAlert && (iAlert > 0) && ((centerLeft < 300) || (leftLevel > 0))) { rightAlert = false; iAlert = 0; } if (leftAlert) { if(leftLevel == 0) leftLevel = 8; vLeft = vMax - (iAlert+1)*2;//(vMax - vMin) * leftLevel / 8 ; vRight = vMax ; iAlert ++; } else if (rightAlert) { if(rightLevel == 0)rightLevel = 8; vLeft = vMax; vRight = vMax - (iAlert+1) * 2;//(vMax - vMin) * rightLevel / 8 ; iAlert ++; } else { e = centerLeft - centerRight; u = (e * 1 + (e - eOld ) * 7) / k; //+ i; v = (vBase - abs(u) * 0.65);//0.65 ) ; vLeft = v + u; vRight = v - u; iAlert = 0; } if (vLeft < vMin) vLeft = vMin; if (vRight < vMin) vRight = vMin; if (vLeft > vMax) vLeft = vMax; if (vRight > vMax) vRight = vMax; eOld = e; #ifdef RELEASE motor[mLeft] = vLeft; motor[mRight] = vRight; #endif #ifdef DEBUG // displayTextLine(0,"rwL %d",rwLeft); // displayTextLine(1,"rwR %d", rwRight); displayTextLine(2,"lAlert %d", leftAlert); displayTextLine(3,"rAlert %d",rightAlert); displayTextLine(4,"e %d",e); displayTextLine(5,"u %d",u); displayTextLine(6,"vLeft %d",vLeft); displayTextLine(7, "vRight %d",vRight); #endif sleep (1); //if (SensorValue(sTouch) == 1) break; } MSLSASleep(sLightLeft2); // Sleep to conserve power when not in use MSLSASleep(sLightRight2); // Sleep to conserve power when not in use } //--------------------------------- void calibrate () { displayBigTextLine(4, " WHITE"); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } break; } sleep (10); } MSLSAcalWhite(sLightLeft2); MSLSAcalWhite(sLightRight2); LLcalWhite(sLightCenter); playSound(soundBlip); displayBigTextLine(4, " Done"); sleep(1000); displayBigTextLine(4, "CENTER BLACK"); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } break; } sleep (10); } LLcalBlack(sLightCenter); sleep(1000); displayBigTextLine(4, "LEFT BLACK"); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } break; } sleep (10); } MSLSAcalBlack(sLightLeft2); playSound(soundBlip); displayBigTextLine(4, " Done"); sleep(1000); displayBigTextLine(4, "RIGHT BLACK"); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } break; } sleep (10); } MSLSAcalBlack(sLightRight2); playSound(soundBlip); displayBigTextLine(4, " Done"); sleep(1000); } //------------------------------- void waitTouchRelease() { displayBigTextLine(4, " START"); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } break; } sleep (10); } eraseDisplay(); }
[ "alex.a.kudryashov@gmail.com" ]
alex.a.kudryashov@gmail.com
0ac58334fd25908623fc139c738ffbbe7a20fb3b
6ef9f8416e555dcc347352a61d40c5800d0725c6
/output/root.c
d5d765acae59b1047c3d4a5c945ebfe05e76679c
[ "MIT" ]
permissive
bytbox/EVAN
10eed1729d9fafefececeb3df2d4fca55a51f910
9cec8cfcd41168dec85677214c9df6a9cc215baa
refs/heads/master
2016-09-02T00:05:25.043669
2012-09-12T15:06:48
2012-09-12T15:06:48
2,978,697
0
0
null
null
null
null
UTF-8
C
false
false
339
c
#include "output.h" void root_number(FILE *f, const char **opts, double d) { // TODO } void root_bars(FILE *f, const char **opts, int sz, double d[]) { // TODO } void root_histogram(FILE *f, const char **opts, int sz, double d[]) { // TODO } void root_contour(FILE *f, const char **opts, int xsz, int ysz, double d[]) { // TODO }
[ "bytbox@gmail.com" ]
bytbox@gmail.com
3718a94342336860b8159b262b8bd0e8b80b17b5
b54ded614dcc6474b72e4e0740837dec776c683b
/Practica_3/ejercicio4.c
1a5cd5a32a48bdea697aa038dfb0b11ea255441a
[]
no_license
miguelarman/Soper_2018
54f539f6cdcbaaef902751e989168954cf6c2f57
1b7839667599ef9a5cc8fde753c5e2d062e9b05a
refs/heads/master
2022-03-29T02:41:32.748610
2019-12-23T14:09:08
2019-12-23T14:09:08
119,996,165
0
0
null
null
null
null
UTF-8
C
false
false
3,420
c
/** * @brief Ejercicio 4 de la Práctica * * En este ejercicio se nos pide trabajar * con la funcion de C mmap que es útil para * mapear memoria y acceder desde otros * procesos a la misma. Un hilo se comunica * en este ejercicio con otro hilo mediante * el uso de dicha función. * * @file ejercicio4.c * @author José Manuel Chacón Aguilera y Miguel Arconada Manteca * @date 17-4-2018 */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <sys/types.h> #include <sys/shm.h> #include <sys/mman.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/ipc.h> #include <fcntl.h> #include <signal.h> #include <string.h> #include <unistd.h> #include "aleat_num.h" #define FILENAME "files/ej4/fichero_ej4" /*!< Nombre del Fichero donde se genera*/ /* Funciones privadas */ /** * @brief Ejecución del primer hilo, escribe números aleatorios en un fichero de texto * * @return void */ void *primer_hilo(); /** * @brief Ejecución del Segundo hilo, mapea la memoria del fichero escrito por el primer hilo y modifica el * * @return void */ void *segundo_hilo(); /** * @brief Función Main del ejercicio, invoca a dos hilos y posteriormente los ejecuta con las funciones descritas en este mismo archivo * * @return 0 si todo se ejecuta correctamente, y -1 en cualquier * otro caso */ int main () { pthread_t h1; pthread_t h2; /*Primer Hilo*/ pthread_create(&h1, NULL, primer_hilo, NULL); pthread_join(h1, NULL); pthread_cancel(h1); /*Segundo Hilo*/ pthread_create(&h2, NULL, segundo_hilo, NULL); pthread_join(h2, NULL); pthread_cancel(h2); exit(EXIT_SUCCESS); } /******************************************************************************/ /********************** FUNCIONES PRIVADAS ****************************/ /******************************************************************************/ void *primer_hilo() { int cantidad; int i; int numero; FILE *pf; /* Abre el fichero para escribir los numeros */ pf = fopen(FILENAME, "w"); if (pf == NULL) { perror("Error al abrir el fichero"); exit(EXIT_FAILURE); } cantidad = aleat_num(1000, 2000); for (i = 0; i < cantidad; i++) { numero = aleat_num(100, 1000); fprintf(pf, "%d", numero); fprintf(pf, ","); } /* Cierra el fichero */ fclose(pf); pthread_exit(NULL); } void *segundo_hilo() { char *ruta; int i, id, debbug; struct stat buf; /*Conseguimos el fichero en memoria compartida*/ id = open(FILENAME, O_RDWR); fstat(id, &buf); ruta = (char*) mmap(NULL, buf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, id, 0); if (ruta == MAP_FAILED){ close(id); perror("Error al hacer el mapeo de memoria"); exit(EXIT_FAILURE); } /*Ahora cambiamos las comas por espacios recoriendo el fichero caractera a caracter*/ for (i = 0; i < strlen(ruta); i++){ if (ruta[i] == ','){ ruta[i] = ' '; } } printf("Estos son los datos leidos y modificados: %s\n", ruta); /*Eliminamos el Mapeo*/ debbug = munmap(ruta, buf.st_size); if (debbug == -1){ close(id); perror("Error al hacer munmap"); exit(EXIT_FAILURE); } close(id); pthread_exit(NULL); }
[ "miguelarman@gmail.com" ]
miguelarman@gmail.com
56617203572c3be8b16626e56b1303d01de35dc7
b725ba18b99398ce8459b8877691135e0cdf4d51
/utils/hwstub/stub/jz4760b/target-config.h
5737e0bc873c538c82df2ce8f013228a937ae33f
[ "BSD-3-Clause" ]
permissive
Rockbox-Chinese-Community/Rockbox-RCC
8d3069271d14144281a40694c60128cac852cd3a
a701aefe45f03ca391a8e2f1a6e3da1b8774b2f2
refs/heads/lab-general
2020-12-01T22:59:14.427025
2017-04-29T06:17:24
2017-04-29T06:17:24
1,565,842
29
16
NOASSERTION
2019-03-21T03:45:53
2011-04-04T06:19:32
C
UTF-8
C
false
false
524
h
#define CONFIG_JZ4760B #define TCSM0_ORIG 0xf4000000 #define TCSM0_SIZE 0x4000 #define TCSM0_UNCACHED_ADDRESS 0xb32b0000 #define CPU_MIPS #define STACK_SIZE 0x300 #define DCACHE_SIZE 0x4000 /* 16 kB */ #define DCACHE_LINE_SIZE 0x20 /* 32 B */ #define ICACHE_SIZE 0x4000 /* 16 kB */ #define ICACHE_LINE_SIZE 0x20 /* 32 B */ /* we need to flush caches before executing */ #define CONFIG_FLUSH_CACHES /* something provides define * #define mips 1 * which breaks paths badly */ #undef mips
[ "amaury.pouly@gmail.com" ]
amaury.pouly@gmail.com
30c48d273d10afbd3e8589127b9a823f086d9607
ee0a9b7cad8582e8ce061687a28d68048abd097d
/src/fs/block.c
670daf2c9316362e7585c8598c4906fb55a48dcb
[]
no_license
brainix/brainix.old
af67a3b4ba6fa19943d35fb3c78757ed77c6b26c
226b2314e763ea765780b4e6a8a21070a50ec2e3
refs/heads/master
2021-05-28T18:50:28.776136
2009-09-04T23:53:53
2009-09-04T23:53:53
null
0
0
null
null
null
null
WINDOWS-1252
C
false
false
7,441
c
/*----------------------------------------------------------------------------*\ | block.c | | | | Copyright © 2002-2007, Team Brainix, original authors. | | All rights reserved. | \*----------------------------------------------------------------------------*/ /* | This program is free software: you can redistribute it and/or modify it under | the terms of the GNU General Public License as published by the Free Software | Foundation, either version 3 of the License, or (at your option) any later | version. | | This program is distributed in the hope that it will be useful, but WITHOUT | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | details. | | You should have received a copy of the GNU General Public License along with | this program. If not, see <http://www.gnu.org/licenses/>. */ #include <fs/fs.h> /*----------------------------------------------------------------------------*\ | block_init() | \*----------------------------------------------------------------------------*/ void block_init(void) { /* Initialize the block cache. */ block_t *block_ptr; /* Initialize each block in the cache. */ for (block_ptr = &block[0]; block_ptr < &block[NUM_BLOCKS]; block_ptr++) { block_ptr->dev = NO_DEV; block_ptr->blk = 0; block_ptr->count = 0; block_ptr->dirty = false; block_ptr->prev = block_ptr - 1; block_ptr->next = block_ptr + 1; } /* Make the cache linked list circular. */ block[0].prev = &block[NUM_BLOCKS - 1]; block[NUM_BLOCKS - 1].next = &block[0]; /* Initialize the least recently used position in the cache. */ lru = &block[0]; } /*----------------------------------------------------------------------------*\ | recently_used() | \*----------------------------------------------------------------------------*/ void recently_used(block_t *block_ptr, bool most) { /* | If most is true, move a block to the most recently used position in the | cache. Otherwise, move a block to the least recently used position in the | cache. */ /* Remove the block from the cache linked list. */ if (block_ptr == lru) lru = lru->next; block_ptr->prev->next = block_ptr->next; block_ptr->next->prev = block_ptr->prev; /* | Reinsert the block into the desired position in the cache linked | list. */ block_ptr->prev = lru->prev; block_ptr->next = lru; block_ptr->next->prev = block_ptr->prev->next = block_ptr; if (!most) lru = lru->prev; } /*----------------------------------------------------------------------------*\ | block_rw() | \*----------------------------------------------------------------------------*/ void block_rw(block_t *block_ptr, bool read) { /* | If read is true, read a block from its device into the cache. Otherwise, | write a block from the cache to its device. */ dev_t dev = block_ptr->dev; off_t off = block_ptr->blk * BLOCK_SIZE; void *buf = block_ptr->data; super_t *super_ptr; if (!block_ptr->dirty) /* | The cached block is already synchronized with the block on | its device. No reason to read or write anything. */ return; /* | Read the block from its device into the cache, or write the block | from the cache to its device. */ dev_rw(dev, BLOCK, read, off, BLOCK_SIZE, buf); /* The cached block is now synchronized with the block on its device. */ block_ptr->dirty = false; if (!read) { super_ptr = super_get(block_ptr->dev); super_ptr->s_wtime = do_time(NULL); super_ptr->dirty = true; } } /*----------------------------------------------------------------------------*\ | dev_sync() | \*----------------------------------------------------------------------------*/ void dev_sync(dev_t dev) { /* Write all of a device's cached blocks to the device. */ blkcnt_t j; /* Iterate over each block in the cache. */ for (j = 0; j < NUM_BLOCKS; j++) /* Does the current block reside on the device being synched? */ if (block[j].dev == dev) /* Yes - write it. */ block_rw(&block[j], WRITE); } /*----------------------------------------------------------------------------*\ | dev_purge() | \*----------------------------------------------------------------------------*/ void dev_purge(dev_t dev) { /* | Reinitialize all of a device's cached blocks. This is done on unmount so | that (for example) if an old floppy is unmounted and removed, and a new | floppy is inserted and mounted, the cached blocks for the old floppy are not | used when accessing the new floppy. */ blkcnt_t j; /* Iterate over each block in the cache. */ for (j = 0; j < NUM_BLOCKS; j++) /* Does the current block reside on the device being purged? */ if (block[j].dev == dev) { /* | Yes - reinitialize it and force it to the least | recently used position, as its lifetime has ended. */ block[j].dev = NO_DEV; block[j].blk = 0; block[j].count = 0; block[j].dirty = false; recently_used(&block[j], LEAST); } } /*----------------------------------------------------------------------------*\ | block_get() | \*----------------------------------------------------------------------------*/ block_t *block_get(dev_t dev, blkcnt_t blk) { /* | Search the cache for a block. If it is found, return a pointer to it. | Otherwise, evict a free block, cache the block, and return a pointer to | it. */ block_t *block_ptr; /* Search the cache for the block. */ for (block_ptr = lru->prev; ; ) if (block_ptr->dev == dev && block_ptr->blk == blk) { /* | Found the block. Increment the number of times it is | used, mark it recently used, and return a pointer to | it. */ block_ptr->count++; recently_used(block_ptr, MOST); return block_ptr; } else if ((block_ptr = block_ptr->prev) == lru->prev) /* Oops - we've searched the entire cache already. */ break; /* | The requested block is not cached. Search the cache for the least | recently used free block. */ for (block_ptr = lru; ; ) if (block_ptr->count == 0) { /* | Found the least recently used free block. Evict it. | Cache the requested block, mark it recently used, and | return a pointer to it. */ block_rw(block_ptr, WRITE); block_ptr->dev = dev; block_ptr->blk = blk; block_ptr->count = 1; block_ptr->dirty = true; block_rw(block_ptr, READ); recently_used(block_ptr, MOST); return block_ptr; } else if ((block_ptr = block_ptr->next) == lru) /* Oops - we've searched the entire cache already. */ break; /* There are no free blocks in the cache. Vomit. */ panic("block_get", "no free blocks"); return NULL; } /*----------------------------------------------------------------------------*\ | block_put() | \*----------------------------------------------------------------------------*/ void block_put(block_t *block_ptr, bool important) { /* | Decrement the number of times a block is used. If no one is using it, write | it to its device (if necessary). */ if (block_ptr == NULL || --block_ptr->count > 0) return; switch (ROBUST) { case PARANOID: block_rw(block_ptr, WRITE); return; case SANE: if (important) block_rw(block_ptr, WRITE); return; case SLOPPY: return; } }
[ "brainix@b9563320-9421-0410-b604-179ae615efef" ]
brainix@b9563320-9421-0410-b604-179ae615efef
28eaabd3df90413872632a53d7f3a0d07b200e66
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/fastsocket/kernel/sound/pci/ali5451/extr_ali5451.c_snd_ali_hw_params.c
871a48c55da5e58be92ba4f93c1a79f7caa6d1d0
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
844
c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ /* Type definitions */ struct snd_pcm_substream {int dummy; } ; struct snd_pcm_hw_params {int dummy; } ; /* Variables and functions */ int /*<<< orphan*/ params_buffer_bytes (struct snd_pcm_hw_params*) ; int snd_pcm_lib_malloc_pages (struct snd_pcm_substream*,int /*<<< orphan*/ ) ; __attribute__((used)) static int snd_ali_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); }
[ "brenocfg@gmail.com" ]
brenocfg@gmail.com
4165e610efa90a70f994568c6e2b6d84da784131
a27fd5c560ff702871cb10d2154d8b4781819e8b
/relevant materials/recitation_assignment_1/print_info.c
6794332e0f948190c5046252039747ae6879a22d
[]
no_license
cwru-eecs338/cwru-eecs338.github.com
207c5ac0f599ad3120139b1ec1093a95a0b5f4af
56fff1577b010143d439436e4856159344f8c9f1
refs/heads/master
2021-01-19T01:43:58.911259
2017-01-11T01:42:22
2017-01-11T01:42:22
1,269,383
6
6
null
null
null
null
UTF-8
C
false
false
393
c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { char * cuser_id_str; uid_t euid, uid; gid_t gid, egid; cuser_id_str = (char *) cuserid(NULL); printf("cuserid: %s\n", cuser_id_str); uid = getuid(); euid = geteuid(); gid = getgid(); egid = getegid(); // print them... printf("%d\n", uid); return EXIT_SUCCESS; }
[ "dms230@eecslinab3.(none)" ]
dms230@eecslinab3.(none)
6734db8bd8bd2d23afd9fada3a3b9c72fa20449e
a5a7c65811a941f38048e9195fa2ac24d6013be4
/Final Lab/Final Lab/UARTIntsTestMain.c
8e9227669caa437d7d02796a967596a2b0041604
[]
no_license
hydershad/Embedded-Systems-Design-Lab
8b0afac2f0347b8b80014ba3fc57116047250514
caf297a5b7174251ee67f6450f7ddcf33ee5e496
refs/heads/master
2020-07-14T22:15:39.170355
2019-08-30T22:10:34
2019-08-30T22:10:34
205,414,322
0
0
null
null
null
null
UTF-8
C
false
false
5,033
c
//HYDER SHAD //UT EID: hs25796 //EE 445L Lab 11 //TTH 12:30 - 2pm //12/5/2018 /* This example accompanies the book "Embedded Systems: Real Time Interfacing to Arm Cortex M Microcontrollers", ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2015 Program 5.11 Section 5.6, Program 3.10 Copyright 2015 by Jonathan W. Valvano, valvano@mail.utexas.edu You may use, edit, run or distribute this file as long as the above copyright notice remains THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. VALVANO SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. For more information about my classes, my research, and my books, see http://users.ece.utexas.edu/~valvano/ */ #include <stdint.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include "PLL.h" #include "SysTickInts.h" #include "motor.h" #include "ST7735.h" #include "ADCT0ATrigger.h" #include "UART5.h" #include "step.h" #include "PWM.h" #include "ports.h" void DisableInterrupts(void); // Disable interrupts void EnableInterrupts(void); // Enable interrupts long StartCritical (void); // previous I bit, disable interrupts void EndCritical(long sr); // restore I bit to previous value void WaitForInterrupt(void); // low power mode char buffer [64] = {0}; //UART buffer char flag = 0; //motor control flag char input = 0; int alt_drive = 0; //alternate between driving and steering wheels uint32_t adc = 0; uint32_t ADC0_InSeq3(void); int fifostatus = 0; char ax[8] = "0"; //string arrays to convert data values char ay[8] = "0"; char az[8] = "0"; int x_val, y_val, z_val = 0; //integer gyro/accel values int main(void){ PLL_Init(Bus80MHz); // set system clock to 50 MHz DisableInterrupts(); Step_Init(); //12v, oscillating rotation motor_init(); //set up Port D and F Output_Init(); //st7735 redtab initialization UART5_start(); SysTick_Init(400000); //Systick Handler SETS FLAG TO CHECK for New Data PWM0B_Init(40000,20000); ADC0_InitSoftwareTriggerSeq3PD3(); EnableInterrupts(); GPIO_PORTD_DATA_R &= ~0xC3; while(1){ if(flag){ //check for UART data in FIFO if(ESP8266_GetMessage(buffer)){ //input recieved as a string, values separated by ; strcpy(ax, strtok(buffer, ";")); strcpy(ay, strtok(NULL, ";")); strcpy(az, strtok(NULL, ";")); //strcpy(&pin_int, buffer); // Integer value that is determined by the Blynk App x_val = atoi(ax); // Need to convert ASCII to integer y_val = atoi(ay); z_val = atoi(az); //not used for motion, just for debug if(alt_drive){ if(-5350 <x_val < -1200){ PWM0B_Duty(20000); //half power reverse GPIO_PORTD_DATA_R &= ~0xC3; GPIO_PORTD_DATA_R |= 0x41; } else if(x_val < -5350){ PWM0B_Duty(40000); //full power reverse GPIO_PORTD_DATA_R &= ~0xC3; GPIO_PORTD_DATA_R |= 0x41; } else if(3800 <x_val < 6600){ PWM0B_Duty(20000); //half power drive GPIO_PORTD_DATA_R &= ~0xC3; GPIO_PORTD_DATA_R |= 0x82; } else if(6600 <x_val){ PWM0B_Duty(40000); //full power drive GPIO_PORTD_DATA_R &= ~0xC3; GPIO_PORTD_DATA_R |= 0x82; } else{ GPIO_PORTD_DATA_R = 0x00; //coast } } else{ if(y_val>6200){ //left turn alt_drive = !alt_drive; GPIO_PORTD_DATA_R &= ~0xC3; GPIO_PORTD_DATA_R |= 0x40; } else if(y_val<-4700){ //right turn GPIO_PORTD_DATA_R &= ~0xC3; GPIO_PORTD_DATA_R |= 0x01; } else{ GPIO_PORTD_DATA_R = 0x00; //coast; } } Output_Clear(); //output UART info on screen for debug and user viewing ST7735_SetCursor(0,0); ST7735_OutString("ax = "); //accelerometer info ST7735_OutString(ax); ST7735_SetCursor(0,1); ST7735_OutString("ay = "); ST7735_OutString(ay); ST7735_SetCursor(0,2); ST7735_OutString("az = "); ST7735_OutString(az); ST7735_SetCursor(0,4); ST7735_OutUDec(x_val); ST7735_SetCursor(0,5); ST7735_OutString("lidar position = "); //stepper motor position ST7735_OutUDec(stepper_pos); } alt_drive = !alt_drive; //toggle between turning commands and driving commands so robot moves in nice arc flag= 0; //reset flag so code will run after SysTick Interrupt } } } void SysTick_Handler(void){ GPIO_PORTF_DATA_R ^= 0x0C; //heartbeat for debug flag = 1; //set flag for motor control uint32_t x = ADC0_InSeq3(); //scan for IR beam if(x<50){ Step(); } } uint32_t ADC0_InSeq3(void){ uint32_t result; ADC0_PSSI_R = 0x0008; // 1) initiate SS3 while((ADC0_RIS_R&0x08)==0){}; // 2) wait for conversion done // if you have an A0-A3 revision number, you need to add an 8 usec wait here result = ADC0_SSFIFO3_R&0xFFF; // 3) read result ADC0_ISC_R = 0x0008; // 4) acknowledge completion return result; }
[ "hydershad@utexas.edu" ]
hydershad@utexas.edu
26a4aae66d7d8da6d4cf5ea42b6f414720c2154e
24ae6d51b0a12d0671771a21fff35109f5f45148
/app/BCM53101 sdk-all-6.5.7/libs/phymod/chip/falcon16/tier1/include/falcon16_tsc_internal_error.h
a5b006711d5545bbd261cfcbb764674689f969d7
[]
no_license
jiaotilizi/cross
e3b7d37856353a20c55f0ddf4c49aaf3c36c79fc
aa3c064fc0fe0494129ddd57114a6f538175b205
refs/heads/master
2020-04-08T14:47:57.798814
2018-11-03T09:16:17
2018-11-03T09:16:17
null
0
0
null
null
null
null
UTF-8
C
false
false
2,512
h
/********************************************************************************** ********************************************************************************** * * * Revision : * * * * Description : Internal API error functions * * * * $Copyright: (c) 2016 Broadcom. * Broadcom Proprietary and Confidential. All rights reserved.$ * * No portions of this material may be reproduced in any form without * * the written permission of: * * Broadcom Corporation * * 5300 California Avenue * * Irvine, CA 92617 * * * * All information contained in this document is Broadcom Corporation * * company private proprietary, and trade secret. * * * ********************************************************************************** **********************************************************************************/ /** @file falcon16_tsc_internal_error.h * Internal API error functions */ #ifndef FALCON16_TSC_API_INTERNAL_ERROR_H #define FALCON16_TSC_API_INTERNAL_ERROR_H #include "common/srds_api_err_code.h" /** * Error-trapping macro. * * In other then SerDes-team post-silicon evaluation builds, simply yields * the error code supplied as an argument, without further action. */ #define _error(err_code) falcon16_tsc_INTERNAL_print_err_msg(err_code) /**@}*/ /** Print Error messages to screen before returning. * @param err_code Error Code input which is returned as well * @return Error Code */ err_code_t falcon16_tsc_INTERNAL_print_err_msg(uint16_t err_code); /** Print Convert Error code to String. * @param err_code Error Code input which is converted to string * @return String containing Error code information. */ char* falcon16_tsc_INTERNAL_e2s_err_code(err_code_t err_code); #endif
[ "andy.4.liu@nokia-sbell.com" ]
andy.4.liu@nokia-sbell.com
e63f67bfe578770cf6aef5f3653ced5a22d279eb
5f29fb884b34243b159f7ba6d89afed0ae247f62
/TaxyClient/TaxiXpress/Utils/Constants/ESUtilConstants.h
a14e1058293001469413fefb80806b03799fc7bd
[]
no_license
urieloko/demo
a53853c86aae1498a93f6c4d2b57f0194ca51ece
a641100838ec85b08e4b2cf2814f2fd600053705
refs/heads/master
2020-04-18T03:36:13.815734
2014-08-21T21:57:14
2014-08-21T21:57:14
null
0
0
null
null
null
null
UTF-8
C
false
false
1,331
h
// // ESUtilConstants.h // TaxiXpress // // Created by Roy on 30/06/14. // Copyright (c) 2014 Extend Solutions. All rights reserved. // #pragma mark - Notification Center Constants extern NSString * const NOTIFICACTION_RESPUESTA_TAXISTA; #pragma Font Constants extern NSString * const FONT_KOMIKAX; extern NSString * const FONT_FABULOUSS0S_NORMAL; extern NSString * const FONT_TREBUCHETMS; extern NSString * const FONT_TREBUCHETMS_BOLD; #pragma Color Constants extern const int COLOR_PLACEHOLDER; extern const int COLOR_TAB_ON; extern const int COLOR_TAB_OFF; // Map Taxi View Controller extern const int COLOR_BUTTON_MAP_ENABLED; extern const int COLOR_BUTTON_MAP_DISABLED; extern const int COLOR_TITLE_BUTTON_MAP; //Place Taxi View Controller extern const int COLOR_AQUA_PLACE; extern const int COLOR_YELLOW_PLACE; extern const int COLOR_ORANGE_PLACE; extern const int COLOR_TITLE_CELL_PLACE; extern const int COLOR_SUBTITLE_CELL_PLACE; #pragma Size Constants extern const CGFloat SIZE_DEFAULT; extern const CGFloat SIZE_TEXT_TAB; extern const CGFloat SIZE_SMAL; extern const CGFloat SIZE_SNIPPET_BIG; extern const CGFloat SIZE_SNIPPET_SMALL; //Place Taxi View Controller extern const CGFloat SIZE_TITLE_CELL_PLACE; extern const CGFloat SIZE_SUBTITLE_CELL_PLACE; #pragma Others extern const CGFloat CORNER_RADIOUS;
[ "tfsextend" ]
tfsextend
b3ab23be1cacdb5a71e2c8d99f1465092b0015db
5c8a0d7752e7c37e207f28a7e03d96a5011f8d68
/MapTweet/iOS/Classes/Native/System_System_Uri19570940MethodDeclarations.h
067aea670d045259db96e098ed3f634067772192
[]
no_license
anothercookiecrumbles/ar_storytelling
8119ed664c707790b58fbb0dcf75ccd8cf9a831b
002f9b8d36a6f6918f2d2c27c46b893591997c39
refs/heads/master
2021-01-18T20:00:46.547573
2017-03-10T05:39:49
2017-03-10T05:39:49
84,522,882
1
0
null
null
null
null
UTF-8
C
false
false
14,977
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // System.Uri struct Uri_t19570940; // System.String struct String_t; // System.Runtime.Serialization.SerializationInfo struct SerializationInfo_t228987430; // System.Object struct Il2CppObject; // System.UriParser struct UriParser_t1012511323; // System.Char[] struct CharU5BU5D_t1328083999; // System.IO.MemoryStream struct MemoryStream_t743994179; // System.Text.Encoding struct Encoding_t663144255; #include "codegen/il2cpp-codegen.h" #include "mscorlib_System_String2029220233.h" #include "mscorlib_System_Runtime_Serialization_Serialization228987430.h" #include "mscorlib_System_Runtime_Serialization_StreamingCon1417235061.h" #include "System_System_UriKind1128731744.h" #include "System_System_Uri19570940.h" #include "System_System_UriHostNameType2148127109.h" #include "mscorlib_System_Object2689449295.h" #include "System_System_UriPartial112107391.h" #include "mscorlib_System_IO_MemoryStream743994179.h" #include "mscorlib_System_Text_Encoding663144255.h" // System.Void System.Uri::.ctor(System.String) extern "C" void Uri__ctor_m3927533881 (Uri_t19570940 * __this, String_t* ___uriString0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) extern "C" void Uri__ctor_m1764202390 (Uri_t19570940 * __this, SerializationInfo_t228987430 * ___serializationInfo0, StreamingContext_t1417235061 ___streamingContext1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.String,System.UriKind) extern "C" void Uri__ctor_m1027317340 (Uri_t19570940 * __this, String_t* ___uriString0, int32_t ___uriKind1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.Uri,System.Uri) extern "C" void Uri__ctor_m371762263 (Uri_t19570940 * __this, Uri_t19570940 * ___baseUri0, Uri_t19570940 * ___relativeUri1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.String,System.Boolean) extern "C" void Uri__ctor_m3854873816 (Uri_t19570940 * __this, String_t* ___uriString0, bool ___dontEscape1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.Uri,System.String) extern "C" void Uri__ctor_m3550796566 (Uri_t19570940 * __this, Uri_t19570940 * ___baseUri0, String_t* ___relativeUri1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.cctor() extern "C" void Uri__cctor_m1067120252 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) extern "C" void Uri_System_Runtime_Serialization_ISerializable_GetObjectData_m214698768 (Uri_t19570940 * __this, SerializationInfo_t228987430 * ___info0, StreamingContext_t1417235061 ___context1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::Merge(System.Uri,System.String) extern "C" void Uri_Merge_m2181117222 (Uri_t19570940 * __this, Uri_t19570940 * ___baseUri0, String_t* ___relativeUri1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_AbsolutePath() extern "C" String_t* Uri_get_AbsolutePath_m802771013 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_AbsoluteUri() extern "C" String_t* Uri_get_AbsoluteUri_m2120317928 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_Authority() extern "C" String_t* Uri_get_Authority_m936382664 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_Host() extern "C" String_t* Uri_get_Host_m395387191 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.UriHostNameType System.Uri::get_HostNameType() extern "C" int32_t Uri_get_HostNameType_m3115129436 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::get_IsDefaultPort() extern "C" bool Uri_get_IsDefaultPort_m3069892608 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::get_IsFile() extern "C" bool Uri_get_IsFile_m3814355526 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::get_IsLoopback() extern "C" bool Uri_get_IsLoopback_m2113378011 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::get_IsUnc() extern "C" bool Uri_get_IsUnc_m2111738174 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_LocalPath() extern "C" String_t* Uri_get_LocalPath_m1625111831 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_PathAndQuery() extern "C" String_t* Uri_get_PathAndQuery_m2303438487 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Uri::get_Port() extern "C" int32_t Uri_get_Port_m834512465 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_Query() extern "C" String_t* Uri_get_Query_m2101975817 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_Scheme() extern "C" String_t* Uri_get_Scheme_m55908894 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::get_IsAbsoluteUri() extern "C" bool Uri_get_IsAbsoluteUri_m4123650233 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_OriginalString() extern "C" String_t* Uri_get_OriginalString_m2475338851 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.UriHostNameType System.Uri::CheckHostName(System.String) extern "C" int32_t Uri_CheckHostName_m1287220449 (Il2CppObject * __this /* static, unused */, String_t* ___name0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::IsIPv4Address(System.String) extern "C" bool Uri_IsIPv4Address_m2432278818 (Il2CppObject * __this /* static, unused */, String_t* ___name0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::IsDomainAddress(System.String) extern "C" bool Uri_IsDomainAddress_m2274973493 (Il2CppObject * __this /* static, unused */, String_t* ___name0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::CheckSchemeName(System.String) extern "C" bool Uri_CheckSchemeName_m3372242109 (Il2CppObject * __this /* static, unused */, String_t* ___schemeName0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::IsAlpha(System.Char) extern "C" bool Uri_IsAlpha_m558908574 (Il2CppObject * __this /* static, unused */, Il2CppChar ___c0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::Equals(System.Object) extern "C" bool Uri_Equals_m3973746240 (Uri_t19570940 * __this, Il2CppObject * ___comparant0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::InternalEquals(System.Uri) extern "C" bool Uri_InternalEquals_m3793998582 (Uri_t19570940 * __this, Uri_t19570940 * ___uri0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Uri::GetHashCode() extern "C" int32_t Uri_GetHashCode_m1277616868 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::GetLeftPart(System.UriPartial) extern "C" String_t* Uri_GetLeftPart_m2731673534 (Uri_t19570940 * __this, int32_t ___part0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Uri::FromHex(System.Char) extern "C" int32_t Uri_FromHex_m2384283021 (Il2CppObject * __this /* static, unused */, Il2CppChar ___digit0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::HexEscape(System.Char) extern "C" String_t* Uri_HexEscape_m4163162129 (Il2CppObject * __this /* static, unused */, Il2CppChar ___character0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::IsHexDigit(System.Char) extern "C" bool Uri_IsHexDigit_m4245599548 (Il2CppObject * __this /* static, unused */, Il2CppChar ___digit0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::IsHexEncoding(System.String,System.Int32) extern "C" bool Uri_IsHexEncoding_m2681830252 (Il2CppObject * __this /* static, unused */, String_t* ___pattern0, int32_t ___index1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::AppendQueryAndFragment(System.String&) extern "C" void Uri_AppendQueryAndFragment_m2358658590 (Uri_t19570940 * __this, String_t** ___result0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::ToString() extern "C" String_t* Uri_ToString_m544968420 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::EscapeString(System.String) extern "C" String_t* Uri_EscapeString_m1753508368 (Il2CppObject * __this /* static, unused */, String_t* ___str0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::EscapeString(System.String,System.Boolean,System.Boolean,System.Boolean) extern "C" String_t* Uri_EscapeString_m3852329619 (Il2CppObject * __this /* static, unused */, String_t* ___str0, bool ___escapeReserved1, bool ___escapeHex2, bool ___escapeBrackets3, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::ParseUri(System.UriKind) extern "C" void Uri_ParseUri_m5711497 (Uri_t19570940 * __this, int32_t ___kind0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::Unescape(System.String) extern "C" String_t* Uri_Unescape_m3356737110 (Uri_t19570940 * __this, String_t* ___str0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::Unescape(System.String,System.Boolean) extern "C" String_t* Uri_Unescape_m3541958225 (Il2CppObject * __this /* static, unused */, String_t* ___str0, bool ___excludeSpecial1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::ParseAsWindowsUNC(System.String) extern "C" void Uri_ParseAsWindowsUNC_m1252728245 (Uri_t19570940 * __this, String_t* ___uriString0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::ParseAsWindowsAbsoluteFilePath(System.String) extern "C" String_t* Uri_ParseAsWindowsAbsoluteFilePath_m1108586962 (Uri_t19570940 * __this, String_t* ___uriString0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::ParseAsUnixAbsoluteFilePath(System.String) extern "C" void Uri_ParseAsUnixAbsoluteFilePath_m999044698 (Uri_t19570940 * __this, String_t* ___uriString0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::Parse(System.UriKind,System.String) extern "C" void Uri_Parse_m138615641 (Uri_t19570940 * __this, int32_t ___kind0, String_t* ___uriString1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::ParseNoExceptions(System.UriKind,System.String) extern "C" String_t* Uri_ParseNoExceptions_m1151989845 (Uri_t19570940 * __this, int32_t ___kind0, String_t* ___uriString1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::CompactEscaped(System.String) extern "C" bool Uri_CompactEscaped_m1050204715 (Il2CppObject * __this /* static, unused */, String_t* ___scheme0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::Reduce(System.String,System.Boolean) extern "C" String_t* Uri_Reduce_m2577728307 (Il2CppObject * __this /* static, unused */, String_t* ___path0, bool ___compact_escaped1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Char System.Uri::HexUnescapeMultiByte(System.String,System.Int32&,System.Char&) extern "C" Il2CppChar Uri_HexUnescapeMultiByte_m25670899 (Il2CppObject * __this /* static, unused */, String_t* ___pattern0, int32_t* ___index1, Il2CppChar* ___surrogate2, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::GetSchemeDelimiter(System.String) extern "C" String_t* Uri_GetSchemeDelimiter_m3479551962 (Il2CppObject * __this /* static, unused */, String_t* ___scheme0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Uri::GetDefaultPort(System.String) extern "C" int32_t Uri_GetDefaultPort_m2114319579 (Il2CppObject * __this /* static, unused */, String_t* ___scheme0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::GetOpaqueWiseSchemeDelimiter() extern "C" String_t* Uri_GetOpaqueWiseSchemeDelimiter_m3686606461 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::IsPredefinedScheme(System.String) extern "C" bool Uri_IsPredefinedScheme_m3823323378 (Il2CppObject * __this /* static, unused */, String_t* ___scheme0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.UriParser System.Uri::get_Parser() extern "C" UriParser_t1012511323 * Uri_get_Parser_m2250631932 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::UnescapeDataString(System.String) extern "C" String_t* Uri_UnescapeDataString_m2626506023 (Il2CppObject * __this /* static, unused */, String_t* ___stringToUnescape0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Uri::GetInt(System.Byte) extern "C" int32_t Uri_GetInt_m1220038581 (Il2CppObject * __this /* static, unused */, uint8_t ___b0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Uri::GetChar(System.String,System.Int32,System.Int32) extern "C" int32_t Uri_GetChar_m3554035265 (Il2CppObject * __this /* static, unused */, String_t* ___str0, int32_t ___offset1, int32_t ___length2, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Char[] System.Uri::GetChars(System.IO.MemoryStream,System.Text.Encoding) extern "C" CharU5BU5D_t1328083999* Uri_GetChars_m1006552869 (Il2CppObject * __this /* static, unused */, MemoryStream_t743994179 * ___b0, Encoding_t663144255 * ___e1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::EnsureAbsoluteUri() extern "C" void Uri_EnsureAbsoluteUri_m1892758054 (Uri_t19570940 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::op_Equality(System.Uri,System.Uri) extern "C" bool Uri_op_Equality_m110355127 (Il2CppObject * __this /* static, unused */, Uri_t19570940 * ___u10, Uri_t19570940 * ___u21, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::op_Inequality(System.Uri,System.Uri) extern "C" bool Uri_op_Inequality_m853767938 (Il2CppObject * __this /* static, unused */, Uri_t19570940 * ___u10, Uri_t19570940 * ___u21, const MethodInfo* method) IL2CPP_METHOD_ATTR;
[ "priyanjana@mac.com" ]
priyanjana@mac.com
e72b602e6805d9964fb70496e9833846e4b41923
4cf1536dd9adf6014034c970a116d2d048a61274
/libraries/drivers/keypad/gpio_button/button.h
ed95f8b1680aa4aba3e675d7730282209074a940
[ "MIT" ]
permissive
LiberalArtist/mxos
a21bccfd7e9a48a0d47408a339118054d8358acd
2d93e6e2a90d9af090d6b1698d8674119da96608
refs/heads/master
2022-01-26T07:04:21.883383
2019-06-05T03:05:17
2019-06-05T03:05:17
null
0
0
null
null
null
null
UTF-8
C
false
false
2,247
h
/** ****************************************************************************** * @file button.h * @author Eshen Wang * @version V1.0.0 * @date 1-May-2015 * @brief user key operation. ****************************************************************************** * UNPUBLISHED PROPRIETARY SOURCE CODE * Copyright (c) 2016 MXCHIP Inc. * * The contents of this file may not be disclosed to third parties, copied or * duplicated in any form, in whole or in part, without the prior written * permission of MXCHIP Corporation. ****************************************************************************** */ #ifndef __BUTTON_H_ #define __BUTTON_H_ #ifdef __cplusplus extern "C" { #endif #include "mxos.h" /** @addtogroup MXOS_Drivers_interface * @{ */ /** @defgroup MXOS_keypad_Driver MXOS keypad Driver * @brief Provide driver interface for keypad devices * @{ */ /** @addtogroup MXOS_keypad_Driver * @{ */ /** @defgroup MXOS_Button_Driver MXOS Button Driver * @brief Provide driver interface for button * @{ */ //-------------------------------- pin defines -------------------------------- enum _button_idle_state_e{ IOBUTTON_IDLE_STATE_LOW = 0, IOBUTTON_IDLE_STATE_HIGH, }; typedef uint8_t btn_idle_state; typedef void (*button_pressed_cb)(void) ; typedef void (*button_long_pressed_cb)(void) ; typedef struct _button_context_t { mxos_gpio_t gpio; btn_idle_state idle; uint32_t long_pressed_timeout; button_pressed_cb pressed_func; button_long_pressed_cb long_pressed_func; /* Use by driver, do not initialze */ mos_timer_id_t _user_button_timer; uint32_t start_time; #ifdef CONFIG_MX108 uint32_t ignore; #endif } button_context_t; //------------------------------ user interfaces ------------------------------- /** * @brief Initialize button device. * * @param btn_context: button driver context data, should be persist at button's life time * * @return none */ void button_init( button_context_t *btn_context ); /** * @} */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif // __BUTTON_H_
[ "yangsw@mxchip.com" ]
yangsw@mxchip.com
544814ce594158272626ad7d7c2195daeef823e2
95c849db894dbcfd19ce50e8bf5dcc6195b3ab72
/libft/ft_memchr.c
6e9e61b2d1855ff8ba606dd75ed493d800a37384
[]
no_license
Qwesaqwes/RT
f88270af45e693fefd663ad5757ca01a0d21c1bf
61524683568eef48d1515591f0e452745818cbc3
refs/heads/master
2021-01-20T01:32:27.621722
2017-05-02T20:44:55
2017-05-02T20:44:55
71,300,214
0
0
null
null
null
null
UTF-8
C
false
false
1,132
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memchr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dsusheno <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/28 19:14:11 by dsusheno #+# #+# */ /* Updated: 2015/12/04 15:54:51 by dsusheno ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void *ft_memchr(const void *s, int c, size_t n) { unsigned char *src; size_t i; i = 0; src = (unsigned char*)s; while (i < n) { if (src[i] == (unsigned char)c) return (&src[i]); i++; } return (NULL); }
[ "daniil.sushi@gmail.com" ]
daniil.sushi@gmail.com
41dbf4c10cda5e9e3c9c1dfbf66edaa6fc36736f
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/linux/drivers/net/netdevsim/extr_bpf.c_nsim_bpf_map_free.c
0ba5fd6fa83db65db5b06c7e79f8a8670c757701
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
1,244
c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_2__ TYPE_1__ ; /* Type definitions */ struct nsim_bpf_bound_map {int /*<<< orphan*/ mutex; int /*<<< orphan*/ l; TYPE_1__* entry; } ; struct bpf_offloaded_map {struct nsim_bpf_bound_map* dev_priv; } ; struct TYPE_2__ {struct nsim_bpf_bound_map* value; struct nsim_bpf_bound_map* key; } ; /* Variables and functions */ unsigned int ARRAY_SIZE (TYPE_1__*) ; int /*<<< orphan*/ kfree (struct nsim_bpf_bound_map*) ; int /*<<< orphan*/ list_del_init (int /*<<< orphan*/ *) ; int /*<<< orphan*/ mutex_destroy (int /*<<< orphan*/ *) ; __attribute__((used)) static void nsim_bpf_map_free(struct bpf_offloaded_map *offmap) { struct nsim_bpf_bound_map *nmap = offmap->dev_priv; unsigned int i; for (i = 0; i < ARRAY_SIZE(nmap->entry); i++) { kfree(nmap->entry[i].key); kfree(nmap->entry[i].value); } list_del_init(&nmap->l); mutex_destroy(&nmap->mutex); kfree(nmap); }
[ "brenocfg@gmail.com" ]
brenocfg@gmail.com
6bdaf8067791c20fc6e729b219723c47e1988cb7
b38a1c0b7aa9cde7b6c983d15f4c5b7fe05d0944
/tests/simple-test.c
0f556bafb102dd5124c18537eda94de4e523af11
[]
no_license
chicken-mobile/concurrent-native-callbacks
d7ac6df5d00016177a2dcafc04035338cedf6d8a
6b483c406198e814ff09789ba1d2035873c5f7f7
refs/heads/master
2021-06-04T09:04:49.918244
2019-06-24T17:49:48
2019-06-24T17:49:48
9,669,281
0
0
null
2018-10-02T21:48:39
2013-04-25T10:27:28
Scheme
UTF-8
C
false
false
1,074
c
/* simple test for CNCB */ #include <stdio.h> #include <pthread.h> #include <chicken.h> pthread_t chicken_thread; extern void foo(int x); /* callback */ extern int bar(int t, int x); /* callback */ extern void voidresult(int t); /* callback */ static void * start_chicken(void *arg) { CHICKEN_run(C_toplevel); printf("chicken returned.\n"); return NULL; } static void * start1(void *arg) { foo(42); printf("foo done.\n"); return NULL; } static void * start2(void *arg) { int r = bar(0, 43); printf("bar done: %d\n", r); voidresult(0); return NULL; } int main(int argc, char *argv[]) { pthread_t t1, t2; pthread_addr_t a; pthread_attr_init(&a); pthread_attr_setstacksize(&a, 4000000); pthread_create(&chicken_thread, &a, start_chicken, NULL); sleep(2); /* give it some time to get running */ printf("creating threads ...\n"); pthread_create(&t1, NULL, start1, NULL); sleep(1); pthread_create(&t2, NULL, start2, NULL); pthread_join(t1, NULL); pthread_join(t2, NULL); sleep(3); printf("done.\n"); return 0; }
[ "felix@call-with-current-continuation.org" ]
felix@call-with-current-continuation.org
08488f5ea3d866f2a7aa78cbfe6dab83a793689e
a9d543f77a79e7a83ea857855a48c7a7176a2525
/ext/mcpp/include/main.c
d774601d5b1979706870b4fa169ddbf8b641fdfa
[ "MIT", "BSD-2-Clause" ]
permissive
lotsopa/Savvy
099b85480fdce3c729366c49cacb0e885f36f4ba
45adede88c3a326710cac14c0a73fa3842bf7686
refs/heads/master
2021-01-10T19:11:47.722257
2019-03-06T09:34:23
2019-03-06T09:34:23
35,677,117
36
6
null
null
null
null
UTF-8
C
false
false
31,413
c
/*- * Copyright (c) 1998, 2002-2008 Kiyoshi Matsui <kmatsui@t3.rim.or.jp> * All rights reserved. * * Some parts of this code are derived from the public domain software * DECUS cpp (1984,1985) written by Martin Minow. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. */ /* * M A I N . C * M C P P M a i n P r o g r a m * * The main routine and it's supplementary routines are placed here. * The post-preprocessing routines are also placed here. */ #include "system.H" #include "internal.H" extern char * sharp_filename; /* Function pointer to expand_macro() functions. */ char * (*expand_macro)( DEFBUF * defp, char * out, char * out_end , LINE_COL line_col, int * pragma_op); /* The boolean flags specified by the execution options. */ struct option_flags_ option_flags = { FALSE, /* c: -C (keep comments) */ }; int mcpp_mode = STD; /* Mode of preprocessing */ long stdc_ver = 0L; /* Value of __STDC_VERSION__ */ int stdc_val = 0; /* Value of __STDC__ */ int std_line_prefix = STD_LINE_PREFIX; /* Output line and file information in C source style */ /* * Commonly used global variables: * src_line is the current input line number. * wrong_line is set in many places when the actual output line is out of * sync with the numbering, e.g, when expanding a macro with an * embedded newline. * identifier holds the last identifier scanned (which might be a candidate * for macro expansion). * errors is the running mcpp error counter. * infile is the head of a linked list of input files (extended by * #include and macros being expanded). 'infile' always points * to the current file/macro. 'infile->parent' to the includer, * etc. 'infile->fp' is NULL if this input stream is not a file. * inc_dirp Directory of #includer with trailing PATH_DELIM. This points * to one of incdir[] or to the current directory (represented as * "". This should not be NULL. */ long src_line; /* Current line number */ int wrong_line; /* Force #line to compiler */ int newlines; /* Count of blank lines */ int errors = 0; /* Cpp error counter */ int warn_level = -1; /* Level of warning (have to initialize)*/ FILEINFO * infile = NULL; /* Current input file */ int include_nest = 0; /* Nesting level of #include */ const char * null = ""; /* "" string for convenience */ const char ** inc_dirp; /* Directory of #includer */ const char * cur_fname; /* Current source file name */ /* cur_fname is not rewritten by #line directive */ const char * cur_fullname; /* Full path of current source file (i.e. infile->full_fname) */ char identifier[ IDMAX + IDMAX/8]; /* Current identifier */ int mcpp_debug = 0; /* != 0 if debugging now */ /* * in_directive is set TRUE while a directive line is scanned by directive(). * It modifies the behavior of squeeze_ws() in expand.c so that newline is * not skipped even if getting macro arguments. */ int in_directive = FALSE; /* TRUE scanning directive line */ int in_define = FALSE; /* TRUE scanning #define line */ int in_getarg = FALSE; /* TRUE collecting macro arguments */ int in_include = FALSE; /* TRUE scanning #include line */ int in_if = FALSE; /* TRUE scanning #if and in non-skipped expr. */ /* * macro_line is set to the line number of start of a macro call while * expanding the macro, else set to 0. Line number is remembered for * diagnostics of unterminated macro call. On unterminated macro call * macro_line is set to MACRO_ERROR. */ long macro_line = 0L; /* * macro_name is the currently expanding macro. */ char * macro_name; /* * openum is the return value of scan_op() in support.c. */ int openum; /* * mkdep means to output source file dependency line, specified by -M* * option. The OR of the following values is used. * MD_MKDEP (1) : Output dependency line. * MD_SYSHEADER(2) : Print also system headers or headers with * absolute path not only user headers. * MD_FILE (4) : Output to the file named *.d instead of fp_out. * Normal output is done to fp_out as usual. */ int mkdep = 0; /* * If option_flags.z is TRUE, no_output is incremented when a file is * #included, and decremented when the file is finished. * If no_output is larger than 0, processed files are not output, meanwhile * the macros in the files are defined. * If mkdep != 0 && (mkdep & MD_FILE) == 0, no_output is set to 1 initially. */ int no_output = 0; /* * keep_comments is set TRUE by the -C option. If TRUE, comments are written * directly to the output stream. option_flags.c contains the permanent state * of the -C option. keep_comments is always falsified when compilation is * supressed by a false #if or when no_output is TRUE. */ int keep_comments = 0; /* Write out comments flag */ /* * keep_spaces is set to TRUE by the -k option. If TRUE, spaces and tabs in * an input line are written out to the output line without squeezing to one * space. option_flags.k contains the permanent state of the -k option. * keep_spaces is falsified when compilation is suppressed by a false #if. */ int keep_spaces = 0; /* Keep white spaces of line*/ /* * ifstack[] holds information about nested #if's. It is always accessed via * ifptr->stat. The information is as follows: * WAS_COMPILING state of compiling flag at outer level. * ELSE_SEEN set TRUE when #else seen to prevent 2nd #else. * TRUE_SEEN set TRUE when #if or #elif succeeds * ifstack[0].stat holds the compiling flag. It is WAS_COMPILING if compila- * tion is currently enabled. Note that this must be initialized to * WAS_COMPILING. */ IFINFO ifstack[ BLK_NEST + 1] = { {WAS_COMPILING, 0L, 0L}, }; /* Note: '+1' is necessary for the initial state. */ IFINFO * ifptr = ifstack; /* -> current ifstack[] */ /* * In POST_STD mode, insert_sep is set to INSERT_SEP when : * 1. the next get_ch() shall insert a token separator. * 2. unget_ch() has been called when insert_sep == INSERTED_SEP. * set to INSERTED_SEP when : * get_ch() has been called when insert_sep == INSERT_SEP. * set to NO_SEP when : * get_ch() has been called when insert_sep == INSERTED_SEP. */ int insert_sep = NO_SEP; /* File pointers for input and output. */ FILE * fp_in; /* Input stream to preprocess */ FILE * fp_out; /* Output stream preprocessed */ FILE * fp_err; /* Diagnostics stream */ FILE * fp_debug; /* Debugging information stream */ /* Variables on multi-byte character encodings. */ int mbchk; /* Character type of possible multi-byte char */ /* Function pointer to mb_read_*() functions. */ size_t (*mb_read)( int c1, char ** in_pp, char ** out_pp); jmp_buf error_exit; /* Exit on fatal error */ /* * Translation limits specified by C90, C99 or C++. */ struct std_limits_ std_limits = { /* The following three are temporarily set for do_options() */ NBUFF, /* Least maximum of string length */ IDMAX, /* Least maximum of identifier length */ NMACPARS, /* Least maximum of number of macro params */ }; /* * work_buf[] and workp are used to store one piece of text as a temporary * buffer. * To initialize storage, set workp = work_buf. Note that the work buffer is * used by several subroutines -- be sure that your data won't be overwritten. * work_buf[] is used for: * 1. macro expansion (def_special(), prescan(), catenate(), * stringize()). * 2. processing directive line (directive.c, eval.c, get_unexpandable(), * do_pragma() and its subroutines). * 3. processing _Pragma() operator (do_pragma_op()). * 4. miscellaneous (init_gcc_macro(), curfile()). */ char work_buf[ NWORK + IDMAX]; /* Work buffer */ char * workp; /* Pointer into work_buf[] */ char * const work_end = & work_buf[ NWORK]; /* End of buffer of work_buf[] */ /* * src_col is the current input column number, but is rarely used. * It is used to put spaces after #line line in keep_spaces mode * on some special cases. */ static int src_col = 0; /* Column number of source line */ static void init_main( void); /* Initialize static variables */ static void init_defines( void); /* Predefine macros */ static void mcpp_main( void); /* Main loop to process input lines */ static void do_pragma_op( void); /* Execute the _Pragma() operator */ static void put_seq( char * begin, char * seq); /* Put out the failed sequence */ static char * de_stringize( char * in, char * out); /* "De-stringize" for _Pragma() op. */ static void putout( char * out); /* May concatenate adjacent string */ static void devide_line( char * out); /* Devide long line for compiler */ static void put_a_line( char * out); /* Put out the processed line */ static void init_main( void) /* Initialize global variables on re-entering. */ { mcpp_mode = STD; stdc_ver = 0L; stdc_val = 0; std_line_prefix = STD_LINE_PREFIX; errors = src_col = 0; warn_level = -1; infile = NULL; in_directive = in_define = in_getarg = in_include = in_if = FALSE; src_line = macro_line = 0L; mcpp_debug = mkdep = no_output = keep_comments = keep_spaces = 0; include_nest = 0; insert_sep = NO_SEP; ifptr = ifstack; ifstack[0].stat = WAS_COMPILING; ifstack[0].ifline = ifstack[0].elseline = 0L; std_limits.str_len = NBUFF; std_limits.id_len = IDMAX; std_limits.n_mac_pars = NMACPARS; option_flags.c = FALSE; sh_file = NULL; sh_line = 0; } int mcpp_lib_main(int argc, char ** argv, char* a_InFile, char* a_OutFile) { char * in_file = a_InFile; char * out_file = a_OutFile; char * stdin_name = "<stdin>"; if (setjmp( error_exit) == -1) { errors++; goto fatal_error_exit; } /* Initialize global and static variables. */ init_main(); init_directive(); init_eval(); init_support(); init_system(); fp_in = stdin; fp_out = stdout; fp_err = stderr; fp_debug = stdout; /* * Debugging information is output to stdout in order to * synchronize with preprocessed output. */ inc_dirp = &null; /* Initialize to current (null) directory */ cur_fname = cur_fullname = "(predefined)"; /* For predefined macros */ init_defines(); /* Predefine macros */ mb_init(TRUE); /* Should be initialized prior to get options */ do_options( argc, argv, &in_file, &out_file); /* Command line options */ /* Open input file, "-" means stdin. */ if (in_file != NULL && ! str_eq( in_file, "-")) { if ((fp_in = fopen( in_file, "r")) == NULL) { mcpp_fprintf( ERR, "Can't open input file \"%s\".\n", in_file); errors++; goto fatal_error_exit; } } else { in_file = stdin_name; } /* Open output file, "-" means stdout. */ if (out_file != NULL && ! str_eq( out_file, "-")) { if ((fp_out = fopen( out_file, "w")) == NULL) { mcpp_fprintf( ERR, "Can't open output file \"%s\".\n", out_file); errors++; goto fatal_error_exit; } fp_debug = fp_out; } init_sys_macro(); /* Initialize system-specific macros */ add_file( fp_in, NULL, in_file, in_file, FALSE); /* "open" main input file */ infile->dirp = inc_dirp; infile->sys_header = FALSE; cur_fullname = in_file; if (mkdep && str_eq( infile->real_fname, stdin_name) == FALSE) put_depend( in_file); /* Putout target file name */ at_start(); /* Do the pre-main commands */ mcpp_main(); /* Process main file */ if (mkdep) put_depend( NULL); /* Append '\n' to dependency line */ at_end(); /* Do the final commands */ fatal_error_exit: /* Free malloced memory */ if (mcpp_debug & MACRO_CALL) { if (in_file != stdin_name) { free( in_file); in_file = 0; } } if(in_file) { free( in_file); in_file = 0; } if (sharp_filename) { free(sharp_filename); sharp_filename = NULL; } clear_filelist(); clear_symtable(); if (fp_in != stdin) fclose( fp_in); if (fp_out != stdout) fclose( fp_out); if (fp_err != stderr) fclose( fp_err); if (mcpp_debug & MEMORY) print_heap(); if (errors > 0) { mcpp_fprintf( ERR, "%d error%s in preprocessor.\n", errors, (errors == 1) ? "" : "s"); return IO_ERROR; } return IO_SUCCESS; /* No errors */ } /* * This is the table used to predefine target machine, operating system and * compiler designators. It may need hacking for specific circumstances. * The -N option supresses these definitions. */ typedef struct pre_set { const char * name; const char * val; } PRESET; static PRESET preset[] = { { NULL, NULL}, /* End of macros beginning with alphabet */ { NULL, NULL}, /* End of macros with value of any integer */ }; static void init_defines( void) /* * Initialize the built-in #define's. * Called only on cpp startup prior to do_options(). * * Note: the built-in static definitions are removed by the -N option. */ { int n = sizeof preset / sizeof (PRESET); int nargs; PRESET * pp; /* Predefine the built-in symbols. */ nargs = DEF_NOARGS_PREDEF_OLD; for (pp = preset; pp < preset + n; pp++) { if (pp->name && *(pp->name)) look_and_install( pp->name, nargs, null, pp->val); else if (! pp->name) nargs = DEF_NOARGS_PREDEF; } look_and_install( "__MCPP", DEF_NOARGS_PREDEF, null, "2"); /* MCPP V.2.x */ /* This macro is predefined and is not undefined by -N option, */ /* yet can be undefined by -U or #undef. */ } void un_predefine( int clearall /* TRUE for -N option */ ) /* * Remove predefined symbols from the symbol table. */ { PRESET * pp; DEFBUF * defp; int n = sizeof preset / sizeof (PRESET); for (pp = preset; pp < preset + n; pp++) { if (pp->name) { if (*(pp->name) && (defp = look_id( pp->name)) != NULL && defp->nargs >= DEF_NOARGS_PREDEF) undefine( pp->name); } else if (clearall == FALSE) { /* -S<n> option */ break; } } } /* * output[] and out_ptr are used for: * buffer to store preprocessed line (this line is put out or handed to * post_preproc() via putout() in some cases) */ static char output[ NMACWORK]; /* Buffer for preprocessed line */ static char * const out_end = & output[ NWORK - 2]; /* Limit of output line for other than GCC and VC */ static char * const out_wend = & output[ NMACWORK - 2]; /* Buffer end of output line */ static char * out_ptr; /* Current pointer into output[]*/ static void mcpp_main( void) /* * Main process for mcpp -- copies tokens from the current input stream * (main file or included file) to the output file. */ { int c; /* Current character */ char * wp; /* Temporary pointer */ DEFBUF * defp; /* Macro definition */ int line_top; /* Is in the line top, possibly spaces */ LINE_COL line_col; /* Location of macro call in source */ keep_comments = option_flags.c && !no_output; line_col.col = line_col.line = 0L; /* * This loop is started "from the top" at the beginning of each line. * 'wrong_line' is set TRUE in many places if it is necessary to write * a #line record. (But we don't write them when expanding macros.) * * 'newlines' variable counts the number of blank lines that have been * skipped over. These are then either output via #line records or * by outputting explicit blank lines. * 'newlines' will be cleared on end of an included file by get_ch(). */ while (1) { /* For the whole input */ newlines = 0; /* Count empty lines */ while (1) { /* For each line, ... */ out_ptr = output; /* Top of the line buf */ c = get_ch(); if (src_col) break; /* There is a residual tokens on the line */ while (char_type[ c] & HSP) { /* ' ' or '\t' */ if (c != COM_SEP) *out_ptr++ = c; /* Retain line top white spaces */ /* Else skip 0-length comment */ c = get_ch(); } if (c == '#') { /* Is 1st non-space '#' */ directive(); /* Do a #directive */ } else if (c == CHAR_EOF) { /* End of input */ break; } else if (! compiling) { /* #ifdef false? */ skip_nl(); /* Skip to newline */ newlines++; /* Count it, too. */ } else if (c == '\n') { /* Blank line */ if (keep_comments) mcpp_fputc( '\n', FP_OUT); /* May flush comments */ else newlines++; /* Wait for a token */ } else { break; /* Actual token */ } } if (c == CHAR_EOF) /* Exit process at */ break; /* end of input */ /* * If the loop didn't terminate because of end of file, we * know there is a token to compile. First, clean up after * absorbing newlines. newlines has the number we skipped. */ if (no_output) { wrong_line = FALSE; } else { if (wrong_line || newlines > 10) { sharp( NULL, 0); /* Output # line number */ if (keep_spaces && src_col) { while (src_col--) /* Adjust columns */ mcpp_fputc( ' ', FP_OUT); src_col = 0; } } else { /* If just a few, stuff */ while (newlines-- > 0) /* them out ourselves */ mcpp_fputc('\n', FP_OUT); } } /* * Process each token on this line. */ line_top = TRUE; while (c != '\n' && c != CHAR_EOF) { /* For the whole line */ /* * has_pragma is set to TRUE so as to execute _Pragma() operator * when the psuedo macro _Pragma() is found. */ int has_pragma; if ((mcpp_debug & MACRO_CALL) && ! in_directive) { line_col.line = src_line; /* Location in source */ line_col.col = infile->bptr - infile->buffer - 1; } if (scan_token( c, (wp = out_ptr, &wp), out_wend) == NAM && (defp = is_macro( &wp)) != NULL) { /* A macro */ wp = expand_macro( defp, out_ptr, out_wend, line_col , & has_pragma); /* Expand it completely */ if (line_top) { /* The first token is a macro */ char * tp = out_ptr; while (char_type[ *tp & UCHARMAX] & HSP) tp++; /* Remove excessive spaces */ memmove( out_ptr, tp, strlen( tp) + 1); wp -= (tp - out_ptr); } if (has_pragma) { /* Found _Pramga() */ do_pragma_op(); /* Do _Pragma() operator*/ out_ptr = output; /* Do the rest of line */ wrong_line = TRUE; /* Line-num out of sync */ } else { out_ptr = wp; } if (keep_spaces && wrong_line && infile && *(infile->bptr) != '\n' && *(infile->bptr) != EOS) { src_col = infile->bptr - infile->buffer; /* Remember the current colums */ break; /* Do sharp() now */ } } else { /* Not a macro call */ out_ptr = wp; /* Advance the place */ if (wrong_line) /* is_macro() swallowed */ break; /* the newline */ } while (char_type[ c = get_ch()] & HSP) { /* Horizontal space */ if (c != COM_SEP) /* Skip 0-length comment*/ *out_ptr++ = c; } line_top = FALSE; /* Read over some token */ } /* Loop for line */ putout( output); /* Output the line */ } /* Continue until EOF */ } static void do_pragma_op( void) /* * Execute the _Pragma() operator contained in an expanded macro. * Note: _Pragma() operator is also implemented as a special macro. Therefore * it is always searched as a macro. * There might be more than one _Pragma() in a expanded macro and those may be * surrounded by other token sequences. * Since all the macros have been expanded completely, any name identical to * macro should not be re-expanded. * However, a macro in the string argument of _Pragma() may be expanded by * do_pragma() after de_stringize(), if EXPAND_PRAGMA == TRUE. */ { FILEINFO * file; DEFBUF * defp; int prev = output < out_ptr; /* There is a previous sequence */ int token_type; char * cp1, * cp2; int c; file = unget_string( out_ptr, NULL); while (c = get_ch(), file == infile) { if (char_type[ c] & HSP) { *out_ptr++ = c; continue; } if (scan_token( c, (cp1 = out_ptr, &cp1), out_wend) == NAM && (defp = is_macro( &cp1)) != NULL && defp->nargs == DEF_PRAGMA) { /* _Pragma() operator */ if (prev) { putout( output); /* Putout the previous sequence */ cp1 = stpcpy( output, "pragma "); /* From top of buffer */ } /* is_macro() already read over possible spaces after _Pragma */ *cp1++ = get_ch(); /* '(' */ while (char_type[ c = get_ch()] & HSP) *cp1++ = c; if (((token_type = scan_token( c, (cp2 = cp1, &cp1), out_wend)) != STR && token_type != WSTR)) { /* Not a string literal */ put_seq( output, cp1); return; } workp = de_stringize( cp2, work_buf); while (char_type[ c = get_ch()] & HSP) *cp1++ = c; if (c != ')') { /* More than a string literal */ unget_ch(); put_seq( output, cp1); return; } strcpy( workp, "\n"); /* Terminate with <newline> */ unget_string( work_buf, NULL); do_pragma(); /* Do the #pragma "line" */ infile->bptr += strlen( infile->bptr); /* Clear sequence */ cp1 = out_ptr = output; /* From the top of buffer */ prev = FALSE; } else { /* Not pragma sequence */ out_ptr = cp1; prev = TRUE; } } unget_ch(); if (prev) putout( output); } static void put_seq( char * begin, /* Sequence already in buffer */ char * seq /* Sequence to be read */ ) /* * Put out the failed sequence as it is. */ { FILEINFO * file = infile; int c; cerror( "Operand of _Pragma() is not a string literal" /* _E_ */ , NULL, 0L, NULL); while (c = get_ch(), file == infile) *seq++ = c; unget_ch(); out_ptr = seq; putout( begin); } static char * de_stringize( char * in, /* Null terminated string literal */ char * out /* Output buffer */ ) /* * Make token sequence from a string literal for _Pragma() operator. */ { char * in_p; int c1, c; in_p = in; if (*in_p == 'L') in_p++; /* Skip 'L' prefix */ while ((c = *++in_p) != EOS) { if (c == '\\' && ((c1 = *(in_p + 1), c1 == '\\') || c1 == '"')) c = *++in_p; /* "De-escape" escape sequence */ *out++ = c; } *--out = EOS; /* Remove the closing '"' */ return out; } static void putout( char * out /* Output line (line-end is always 'out_ptr') */ ) /* * Put out a line with or without "post-preprocessing". */ { size_t len; *out_ptr++ = '\n'; /* Put out a newline */ *out_ptr = EOS; /* Else no post-preprocess */ /* GCC and Visual C can accept very long line */ len = strlen( out); if (len > NWORK - 1) devide_line( out); /* Devide a too long line */ else put_a_line( out); } static void devide_line( char * out /* 'out' is 'output' in actual */ ) /* * Devide a too long line into output lines shorter than NWORK. * This routine is called from putout(). */ { FILEINFO * file; char * save; char * wp; int c; file = unget_string( out, NULL); /* To re-read the line */ wp = out_ptr = out; while ((c = get_ch()), file == infile) { if (char_type[ c] & HSP) { if (keep_spaces || out == out_ptr || (char_type[ *(out_ptr - 1) & UCHARMAX] & HSP)) { *out_ptr++ = c; wp++; } continue; } scan_token( c, &wp, out_wend); /* Read a token */ if (NWORK-2 < wp - out_ptr) { /* Too long a token */ cfatal( "Too long token %s", out_ptr, 0L, NULL); /* _F_ */ } else if (out_end <= wp) { /* Too long line */ if (mcpp_debug & MACRO_CALL) { /* -K option */ /* Other than GCC or Visual C */ /* scan_token() scans a comment as sequence of some */ /* tokens such as '/', '*', ..., '*', '/', since it */ /* does not expect comment. */ save = out_ptr; while ((save = strrchr( save, '/')) != NULL) { if (*(save - 1) == '*') { /* '*' '/' sequence */ out_ptr = save + 1; /* Devide at the end*/ break; /* of a comment*/ } } } save = save_string( out_ptr); /* Save the token */ *out_ptr++ = '\n'; /* Append newline */ *out_ptr = EOS; put_a_line( out); /* Putout the former tokens */ wp = out_ptr = stpcpy( out, save); /* Restore the token */ free( save); } else { /* Still in size */ out_ptr = wp; /* Advance the pointer */ } } unget_ch(); /* Push back the source character */ put_a_line( out); /* Putout the last tokens */ sharp( NULL, 0); /* Correct line number */ } static void put_a_line( char * out ) /* * Finally put out the preprocessed line. */ { size_t len; char * out_p; char * tp; if (no_output) return; len = strlen( out); tp = out_p = out + len - 2; /* Just before '\n' */ while (char_type[ *out_p & UCHARMAX] & SPA) out_p--; /* Remove trailing white spaces */ if (out_p < tp) { *++out_p = '\n'; *++out_p = EOS; } if (mcpp_fputs( out, FP_OUT) == EOF) cfatal( "File write error", NULL, 0L, NULL); /* _F_ */ }
[ "apostol_dadachev@yahoo.com" ]
apostol_dadachev@yahoo.com
ce39e45797128edf8b2c9777497e7ed3fd797902
099d37a70848d2e4054ec456c0c14a72c14b8841
/src/os/shared/common/src/com/ngos/shared/common/pci/database/generated/vendor10de/pcisubdevice10de07d6.h
f44fdee5ee30e645e8ae34ded63427e96b038b5d
[]
no_license
Gris87/ngos
c96e702b26fb5bcae894400657573ba71b72c996
e5e20c632ea53ee6fcc82475c0b9ed6852932397
refs/heads/master
2022-11-08T01:16:55.262819
2022-10-23T08:55:10
2022-10-23T08:55:10
115,521,164
1
0
null
null
null
null
UTF-8
C
false
false
2,032
h
// This file generated with the code_generator // Please do not modify it manually #ifndef COM_NGOS_SHARED_COMMON_PCI_DATABASE_GENERATED_VENDOR10DE_PCISUBDEVICE10DE07D6_H #define COM_NGOS_SHARED_COMMON_PCI_DATABASE_GENERATED_VENDOR10DE_PCISUBDEVICE10DE07D6_H #include <com/ngos/shared/common/ngos/types.h> #include <com/ngos/shared/common/printf/printf.h> enum class PciSubDevice10DE07D6: u32 // Ignore CppEnumVerifier { NONE = 0, SUBDEVICE_1019297A = 0x1019297A, SUBDEVICE_147B1C3E = 0x147B1C3E, SUBDEVICE_1AFA7150 = 0x1AFA7150 }; inline const char8* enumToString(PciSubDevice10DE07D6 subDevice) // TEST: NO { // COMMON_LT((" | subDevice = %u", subDevice)); // Commented to avoid bad looking logs switch (subDevice) { case PciSubDevice10DE07D6::NONE: return "NONE"; case PciSubDevice10DE07D6::SUBDEVICE_1019297A: return "SUBDEVICE_1019297A"; case PciSubDevice10DE07D6::SUBDEVICE_147B1C3E: return "SUBDEVICE_147B1C3E"; case PciSubDevice10DE07D6::SUBDEVICE_1AFA7150: return "SUBDEVICE_1AFA7150"; default: return "UNKNOWN"; } } inline const char8* enumToFullString(PciSubDevice10DE07D6 subDevice) // TEST: NO { // COMMON_LT((" | subDevice = %u", subDevice)); // Commented to avoid bad looking logs static char8 res[32]; sprintf(res, "0x%08X (%s)", (u32)subDevice, enumToString(subDevice)); return res; } inline const char8* enumToHumanString(PciSubDevice10DE07D6 subDevice) // TEST: NO { // COMMON_LT((" | subDevice = %u", subDevice)); // Commented to avoid bad looking logs switch (subDevice) { case PciSubDevice10DE07D6::SUBDEVICE_1019297A: return "MCP73PVT-SM"; case PciSubDevice10DE07D6::SUBDEVICE_147B1C3E: return "I-N73V motherboard"; case PciSubDevice10DE07D6::SUBDEVICE_1AFA7150: return "JW-IN7150-HD"; default: return "Unknown device"; } } #endif // COM_NGOS_SHARED_COMMON_PCI_DATABASE_GENERATED_VENDOR10DE_PCISUBDEVICE10DE07D6_H
[ "Gris87@yandex.ru" ]
Gris87@yandex.ru
27b06fc5d5150f8823052fcf289362f5c1e37cc3
3e894018ee2ededbacf2317ae6c014f99dcdf794
/my-lan/win_sjis/diksam_book_0_2/compiler/error_message_not_gcc.c
7a2d246d56a14329f67a8bc31512b584645e0ed1
[]
no_license
haiy/test_project
d588c379a58df3b1b054ddcfebeaed6f2134e3ff
496581b87ec88d0d53f238d951fcd222dd16b927
refs/heads/master
2022-06-04T18:21:04.132123
2020-07-07T12:54:18
2020-07-07T12:54:18
26,891,797
2
1
null
2020-10-13T00:43:25
2014-11-20T02:20:14
C
GB18030
C
false
false
1,519
c
#include <string.h> #include "diksamc.h" ErrorDefinition dkc_error_message_format[] = { {"dummy"}, {"在($(token))附近发生语法错误"}, {"不正确的字符($(bad_char))"}, {"函数名重复($(name))"}, {"不正确的多字节字符。"}, {"预期外的宽字符串。"}, {"数组元素不能标识为final。"}, {"复合赋值运算符不能用于final值"}, {"函数的参数名重复($(name))。"}, {"变量名$(name)重复。"}, {"找不到变量或函数$(name)。"}, {"$(name)是函数名,但没有函数调用的()。"}, {"不能强制转型为派生类型。"}, {"不能将$(src)转型为$(dest)。"}, {"算数运算符的操作数类型不正确。"}, {"比较运算符的操作数类型不正确。"}, {"逻辑and/or运算符的操作数类型不正确。"}, {"减法运算符的操作数类型不正确。"}, {"逻辑非运算符的操作数类型不正确。"}, {"自增/自减运算符的操作数类型不正确。"}, {"函数调用运算符的操作数不是函数名。"}, {"找不到函数$(name)。"}, {"函数的参数数量错误。"}, {"赋值运算符的左边不是一个左边值。"}, {"标签$(label)不存在。"}, {"数组字面量必须至少有一个元素"}, {"下标运算符[]的左边不是数组类型"}, {"数组的下标不是int。"}, {"数组的大小不是int。"}, {"整数值不能被0除。"}, {"dummy"} };
[ "haiyangfu512@gmail.com" ]
haiyangfu512@gmail.com
88c3ed37bc6c62df614bc868caf81e8608328953
9f32dca665db865ff5007305c530ccfa922551c6
/Classes/Native/Mono_Security_Mono_Security_ASN1924533535MethodDeclarations.h
49653ae62f0a88905f3d61f187036e70558da420
[]
no_license
Sid-ah/BS_V5
81586670b6d774e7ebea8b248011f937772fe923
f1443bf85e2dab42c0db842c1865e4df1c57d055
refs/heads/master
2021-01-21T10:46:45.341844
2017-02-28T23:04:27
2017-02-28T23:04:27
83,488,305
1
2
null
null
null
null
UTF-8
C
false
false
4,067
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // Mono.Security.ASN1 struct ASN1_t924533536; // System.Byte[] struct ByteU5BU5D_t3397334013; // System.String struct String_t; #include "codegen/il2cpp-codegen.h" #include "Mono_Security_Mono_Security_ASN1924533535.h" // System.Void Mono.Security.ASN1::.ctor(System.Byte) extern "C" void ASN1__ctor_m32691595 (ASN1_t924533536 * __this, uint8_t ___tag0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.ASN1::.ctor(System.Byte,System.Byte[]) extern "C" void ASN1__ctor_m3688855288 (ASN1_t924533536 * __this, uint8_t ___tag0, ByteU5BU5D_t3397334013* ___data1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.ASN1::.ctor(System.Byte[]) extern "C" void ASN1__ctor_m2812922997 (ASN1_t924533536 * __this, ByteU5BU5D_t3397334013* ___data0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 Mono.Security.ASN1::get_Count() extern "C" int32_t ASN1_get_Count_m579313466 (ASN1_t924533536 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Byte Mono.Security.ASN1::get_Tag() extern "C" uint8_t ASN1_get_Tag_m2798873007 (ASN1_t924533536 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 Mono.Security.ASN1::get_Length() extern "C" int32_t ASN1_get_Length_m778823697 (ASN1_t924533536 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Byte[] Mono.Security.ASN1::get_Value() extern "C" ByteU5BU5D_t3397334013* ASN1_get_Value_m2229768312 (ASN1_t924533536 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.ASN1::set_Value(System.Byte[]) extern "C" void ASN1_set_Value_m1063274345 (ASN1_t924533536 * __this, ByteU5BU5D_t3397334013* ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean Mono.Security.ASN1::CompareArray(System.Byte[],System.Byte[]) extern "C" bool ASN1_CompareArray_m2071014626 (ASN1_t924533536 * __this, ByteU5BU5D_t3397334013* ___array10, ByteU5BU5D_t3397334013* ___array21, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean Mono.Security.ASN1::CompareValue(System.Byte[]) extern "C" bool ASN1_CompareValue_m3117818461 (ASN1_t924533536 * __this, ByteU5BU5D_t3397334013* ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // Mono.Security.ASN1 Mono.Security.ASN1::Add(Mono.Security.ASN1) extern "C" ASN1_t924533536 * ASN1_Add_m1528660622 (ASN1_t924533536 * __this, ASN1_t924533536 * ___asn10, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Byte[] Mono.Security.ASN1::GetBytes() extern "C" ByteU5BU5D_t3397334013* ASN1_GetBytes_m3982410951 (ASN1_t924533536 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.ASN1::Decode(System.Byte[],System.Int32&,System.Int32) extern "C" void ASN1_Decode_m947929221 (ASN1_t924533536 * __this, ByteU5BU5D_t3397334013* ___asn10, int32_t* ___anPos1, int32_t ___anLength2, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void Mono.Security.ASN1::DecodeTLV(System.Byte[],System.Int32&,System.Byte&,System.Int32&,System.Byte[]&) extern "C" void ASN1_DecodeTLV_m2898581687 (ASN1_t924533536 * __this, ByteU5BU5D_t3397334013* ___asn10, int32_t* ___pos1, uint8_t* ___tag2, int32_t* ___length3, ByteU5BU5D_t3397334013** ___content4, const MethodInfo* method) IL2CPP_METHOD_ATTR; // Mono.Security.ASN1 Mono.Security.ASN1::get_Item(System.Int32) extern "C" ASN1_t924533536 * ASN1_get_Item_m3505242534 (ASN1_t924533536 * __this, int32_t ___index0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // Mono.Security.ASN1 Mono.Security.ASN1::Element(System.Int32,System.Byte) extern "C" ASN1_t924533536 * ASN1_Element_m1568353429 (ASN1_t924533536 * __this, int32_t ___index0, uint8_t ___anTag1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String Mono.Security.ASN1::ToString() extern "C" String_t* ASN1_ToString_m2669105451 (ASN1_t924533536 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
[ "kenobi82403@gmail.com" ]
kenobi82403@gmail.com
613b5eecded658cc84d86db2f72f916dea5a83de
712268bc25d366eec3aefac128de55e7b9609e22
/实验二报告/whoami.c
167cb9a0695f250677896fb52bee9f263e83253b
[]
no_license
reecefan/Oslab
84e1f00b6c2ffe3a2d572f7d9859584bb90310c5
2a8b49e1904b57704a7ae43aa397189a56e14ff7
refs/heads/master
2021-01-12T02:45:47.307750
2017-01-05T08:33:48
2017-01-05T08:33:48
78,092,159
1
0
null
null
null
null
UTF-8
C
false
false
338
c
#define __LIBRARY__ #include "unistd.h" #include <stdlib.h> #include <errno.h> #include <stdio.h> _syscall2(int,whoami,char*,name,unsigned int,size) int main(int argc,char *argv[]) { char *username; username=(char *)malloc(sizeof(char)*128); whoami(username,128); printf("%s\n",username); free(username); return 0; }
[ "2284789237@qq.com" ]
2284789237@qq.com
4c4f9b0aa54bf62a312c6b24c1bed4acf3d07115
92515f0e9d8f6c0ce76b2c75022896651985fc5c
/libgfx/gfx_sleep.c
9b7ba361d42a227efefd1e2523676ab5f983c5e1
[ "BSD-2-Clause", "LicenseRef-scancode-public-domain" ]
permissive
RelativisticMechanic/stdgfx
9127e09d086c618e3de30ceed4e900a093f5f328
461944286e458541b2236987c4ffffc294bab25b
refs/heads/master
2021-04-03T09:59:01.760606
2018-04-11T12:21:37
2018-04-11T12:21:37
124,190,695
1
0
null
null
null
null
UTF-8
C
false
false
72
c
#include "stdgfx.h" void gfx_sleep(int s) { __gfx_backend_sleep(s); }
[ "cyclicintegral@gmail.com" ]
cyclicintegral@gmail.com
1a8f3001b0698a0478372bd4105c88b37bdd8c1f
c47c254ca476c1f9969f8f3e89acb4d0618c14b6
/datasets/linux-4.11-rc3/drivers/clk/ti/clk-43xx.c
e816a7500e43d908f00361aed2b5d6bd68f14378
[ "Linux-syscall-note", "GPL-2.0-only", "BSD-2-Clause" ]
permissive
yijunyu/demo
5cf4e83f585254a28b31c4a050630b8f661a90c8
11c0c84081a3181494b9c469bda42a313c457ad2
refs/heads/master
2023-02-22T09:00:12.023083
2021-01-25T16:51:40
2021-01-25T16:51:40
175,939,000
3
6
BSD-2-Clause
2021-01-09T23:00:12
2019-03-16T07:13:00
C
UTF-8
C
false
false
6,400
c
/* * AM43XX Clock init * * Copyright (C) 2013 Texas Instruments, Inc * Tero Kristo (t-kristo@ti.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation version 2. * * This program is distributed "as is" WITHOUT ANY WARRANTY of any * kind, whether express or implied; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/kernel.h> #include <linux/list.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/clk/ti.h> #include "clock.h" static struct ti_dt_clk am43xx_clks[] = { DT_CLK(NULL, "clk_32768_ck", "clk_32768_ck"), DT_CLK(NULL, "clk_rc32k_ck", "clk_rc32k_ck"), DT_CLK(NULL, "virt_19200000_ck", "virt_19200000_ck"), DT_CLK(NULL, "virt_24000000_ck", "virt_24000000_ck"), DT_CLK(NULL, "virt_25000000_ck", "virt_25000000_ck"), DT_CLK(NULL, "virt_26000000_ck", "virt_26000000_ck"), DT_CLK(NULL, "sys_clkin_ck", "sys_clkin_ck"), DT_CLK(NULL, "tclkin_ck", "tclkin_ck"), DT_CLK(NULL, "dpll_core_ck", "dpll_core_ck"), DT_CLK(NULL, "dpll_core_x2_ck", "dpll_core_x2_ck"), DT_CLK(NULL, "dpll_core_m4_ck", "dpll_core_m4_ck"), DT_CLK(NULL, "dpll_core_m5_ck", "dpll_core_m5_ck"), DT_CLK(NULL, "dpll_core_m6_ck", "dpll_core_m6_ck"), DT_CLK(NULL, "dpll_mpu_ck", "dpll_mpu_ck"), DT_CLK(NULL, "dpll_mpu_m2_ck", "dpll_mpu_m2_ck"), DT_CLK(NULL, "dpll_ddr_ck", "dpll_ddr_ck"), DT_CLK(NULL, "dpll_ddr_m2_ck", "dpll_ddr_m2_ck"), DT_CLK(NULL, "dpll_disp_ck", "dpll_disp_ck"), DT_CLK(NULL, "dpll_disp_m2_ck", "dpll_disp_m2_ck"), DT_CLK(NULL, "dpll_per_ck", "dpll_per_ck"), DT_CLK(NULL, "dpll_per_m2_ck", "dpll_per_m2_ck"), DT_CLK(NULL, "dpll_per_m2_div4_wkupdm_ck", "dpll_per_m2_div4_wkupdm_ck"), DT_CLK(NULL, "dpll_per_m2_div4_ck", "dpll_per_m2_div4_ck"), DT_CLK(NULL, "adc_tsc_fck", "adc_tsc_fck"), DT_CLK(NULL, "clkdiv32k_ck", "clkdiv32k_ck"), DT_CLK(NULL, "clkdiv32k_ick", "clkdiv32k_ick"), DT_CLK(NULL, "dcan0_fck", "dcan0_fck"), DT_CLK(NULL, "dcan1_fck", "dcan1_fck"), DT_CLK(NULL, "pruss_ocp_gclk", "pruss_ocp_gclk"), DT_CLK(NULL, "mcasp0_fck", "mcasp0_fck"), DT_CLK(NULL, "mcasp1_fck", "mcasp1_fck"), DT_CLK(NULL, "smartreflex0_fck", "smartreflex0_fck"), DT_CLK(NULL, "smartreflex1_fck", "smartreflex1_fck"), DT_CLK(NULL, "sha0_fck", "sha0_fck"), DT_CLK(NULL, "aes0_fck", "aes0_fck"), DT_CLK(NULL, "rng_fck", "rng_fck"), DT_CLK(NULL, "timer1_fck", "timer1_fck"), DT_CLK(NULL, "timer2_fck", "timer2_fck"), DT_CLK(NULL, "timer3_fck", "timer3_fck"), DT_CLK(NULL, "timer4_fck", "timer4_fck"), DT_CLK(NULL, "timer5_fck", "timer5_fck"), DT_CLK(NULL, "timer6_fck", "timer6_fck"), DT_CLK(NULL, "timer7_fck", "timer7_fck"), DT_CLK(NULL, "wdt1_fck", "wdt1_fck"), DT_CLK(NULL, "l3_gclk", "l3_gclk"), DT_CLK(NULL, "dpll_core_m4_div2_ck", "dpll_core_m4_div2_ck"), DT_CLK(NULL, "l4hs_gclk", "l4hs_gclk"), DT_CLK(NULL, "l3s_gclk", "l3s_gclk"), DT_CLK(NULL, "l4ls_gclk", "l4ls_gclk"), DT_CLK(NULL, "clk_24mhz", "clk_24mhz"), DT_CLK(NULL, "cpsw_125mhz_gclk", "cpsw_125mhz_gclk"), DT_CLK(NULL, "cpsw_cpts_rft_clk", "cpsw_cpts_rft_clk"), DT_CLK(NULL, "dpll_clksel_mac_clk", "dpll_clksel_mac_clk"), DT_CLK(NULL, "gpio0_dbclk_mux_ck", "gpio0_dbclk_mux_ck"), DT_CLK(NULL, "gpio0_dbclk", "gpio0_dbclk"), DT_CLK(NULL, "gpio1_dbclk", "gpio1_dbclk"), DT_CLK(NULL, "gpio2_dbclk", "gpio2_dbclk"), DT_CLK(NULL, "gpio3_dbclk", "gpio3_dbclk"), DT_CLK(NULL, "gpio4_dbclk", "gpio4_dbclk"), DT_CLK(NULL, "gpio5_dbclk", "gpio5_dbclk"), DT_CLK(NULL, "mmc_clk", "mmc_clk"), DT_CLK(NULL, "gfx_fclk_clksel_ck", "gfx_fclk_clksel_ck"), DT_CLK(NULL, "gfx_fck_div_ck", "gfx_fck_div_ck"), DT_CLK(NULL, "timer_32k_ck", "clkdiv32k_ick"), DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"), DT_CLK(NULL, "sysclk_div", "sysclk_div"), DT_CLK(NULL, "disp_clk", "disp_clk"), DT_CLK(NULL, "clk_32k_mosc_ck", "clk_32k_mosc_ck"), DT_CLK(NULL, "clk_32k_tpm_ck", "clk_32k_tpm_ck"), DT_CLK(NULL, "dpll_extdev_ck", "dpll_extdev_ck"), DT_CLK(NULL, "dpll_extdev_m2_ck", "dpll_extdev_m2_ck"), DT_CLK(NULL, "mux_synctimer32k_ck", "mux_synctimer32k_ck"), DT_CLK(NULL, "synctimer_32kclk", "synctimer_32kclk"), DT_CLK(NULL, "timer8_fck", "timer8_fck"), DT_CLK(NULL, "timer9_fck", "timer9_fck"), DT_CLK(NULL, "timer10_fck", "timer10_fck"), DT_CLK(NULL, "timer11_fck", "timer11_fck"), DT_CLK(NULL, "cpsw_50m_clkdiv", "cpsw_50m_clkdiv"), DT_CLK(NULL, "cpsw_5m_clkdiv", "cpsw_5m_clkdiv"), DT_CLK(NULL, "dpll_ddr_x2_ck", "dpll_ddr_x2_ck"), DT_CLK(NULL, "dpll_ddr_m4_ck", "dpll_ddr_m4_ck"), DT_CLK(NULL, "dpll_per_clkdcoldo", "dpll_per_clkdcoldo"), DT_CLK(NULL, "dll_aging_clk_div", "dll_aging_clk_div"), DT_CLK(NULL, "div_core_25m_ck", "div_core_25m_ck"), DT_CLK(NULL, "func_12m_clk", "func_12m_clk"), DT_CLK(NULL, "vtp_clk_div", "vtp_clk_div"), DT_CLK(NULL, "usbphy_32khz_clkmux", "usbphy_32khz_clkmux"), DT_CLK("48300200.ehrpwm", "tbclk", "ehrpwm0_tbclk"), DT_CLK("48302200.ehrpwm", "tbclk", "ehrpwm1_tbclk"), DT_CLK("48304200.ehrpwm", "tbclk", "ehrpwm2_tbclk"), DT_CLK("48306200.ehrpwm", "tbclk", "ehrpwm3_tbclk"), DT_CLK("48308200.ehrpwm", "tbclk", "ehrpwm4_tbclk"), DT_CLK("4830a200.ehrpwm", "tbclk", "ehrpwm5_tbclk"), DT_CLK("48300200.pwm", "tbclk", "ehrpwm0_tbclk"), DT_CLK("48302200.pwm", "tbclk", "ehrpwm1_tbclk"), DT_CLK("48304200.pwm", "tbclk", "ehrpwm2_tbclk"), DT_CLK("48306200.pwm", "tbclk", "ehrpwm3_tbclk"), DT_CLK("48308200.pwm", "tbclk", "ehrpwm4_tbclk"), DT_CLK("4830a200.pwm", "tbclk", "ehrpwm5_tbclk"), { .node_name = NULL }, }; int __init am43xx_dt_clk_init(void) { struct clk *clk1, *clk2; ti_dt_clocks_register(am43xx_clks); omap2_clk_disable_autoidle_all(); /* * cpsw_cpts_rft_clk has got the choice of 3 clocksources * dpll_core_m4_ck, dpll_core_m5_ck and dpll_disp_m2_ck. * By default dpll_core_m4_ck is selected, witn this as clock * source the CPTS doesnot work properly. It gives clockcheck errors * while running PTP. * clockcheck: clock jumped backward or running slower than expected! * By selecting dpll_core_m5_ck as the clocksource fixes this issue. * In AM335x dpll_core_m5_ck is the default clocksource. */ clk1 = clk_get_sys(NULL, "cpsw_cpts_rft_clk"); clk2 = clk_get_sys(NULL, "dpll_core_m5_ck"); clk_set_parent(clk1, clk2); return 0; }
[ "y.yu@open.ac.uk" ]
y.yu@open.ac.uk
f8f39f4e868349ad891cc5a445400b65bcaa604b
c780def34ce678339ed325d3302ddfe9aaaeb299
/APP/http/http.h
bd769ef85581001bce3b29563b80cc04eb08f3fd
[]
no_license
yonglunyao/geophone-stm32-ucos3
c7a82ec5106620af7e823d3ba3537b5f1a5435e8
63fe6c41246b9574b5c3bef75cbf8fee4f4b6acb
refs/heads/main
2023-09-04T10:45:31.508156
2021-10-19T06:14:47
2021-10-19T06:14:47
383,852,680
2
1
null
null
null
null
UTF-8
C
false
false
211
h
#ifndef _HTTP_H_ #define _HTTP_H_ #include "socket.h" void Serialize_HttpReport(u8* buf,Packet_connectData data,u8* buflen); u8 transport_HttpSendPacketBuffer(u8* server_addr,u8* port,u8* buf,u8 buflen); #endif
[ "yonglunyao@mail.dlut.edu.cn" ]
yonglunyao@mail.dlut.edu.cn
2fc2b5c0b396a6382d9ea6d54d9c257483236547
107d50aca951595955d100c6b7141147e359f564
/P00249.c
0a9426ab9bb49ec25751f2b59917c60e42a6f52c
[]
no_license
mylo2202/codefun.vn
6de8d4ea70ca5a7f31742626ca8c8e4bdecfd20c
e85c769755665023f0217e6e17da44b4a392d511
refs/heads/master
2020-07-28T16:51:37.641465
2019-09-19T05:36:10
2019-09-19T05:36:10
209,470,513
0
0
null
null
null
null
UTF-8
C
false
false
359
c
#include <stdio.h> int main() { int n, i, a[10000], s=0, j=0; scanf("%d", &n); for(i=1; i<=n; i++) scanf("%d", &a[i]); for(i=1; i<=n; i++) { s=s+a[i]; j++; if(s<0) break; } if(j==n) printf("VICTORY"); else printf("DEFEATED AT CITY %d", j); }
[ "48115847+mylo2202@users.noreply.github.com" ]
48115847+mylo2202@users.noreply.github.com
32b427758c625281b11e45d8a9aa5fd0783ee8d8
91c8015f0e8f4864b87ce70df3b9e194f4bd414b
/AD7124/Code/H7AD7124_FSM/H7AD7124_FSM/emWin/emWinDemo/GUIDEMO.h
79b538fbbf526c48d99dd1321e8e2641fcc6bd54
[]
no_license
EasonZhangYT/Nuedc_Preparation
315866c6e37b9f9f0577e040c4aed0c80e608f8b
c48922afef25925ca2b15f6f94cbe756a2369cf4
refs/heads/master
2023-06-30T10:19:58.960727
2021-08-07T15:04:04
2021-08-07T15:04:04
393,558,350
0
0
null
null
null
null
UTF-8
C
false
false
12,360
h
/********************************************************************* * SEGGER Microcontroller GmbH & Co. KG * * Solutions for real time microcontroller applications * ********************************************************************** * * * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG * * * * Internet: www.segger.com Support: support@segger.com * * * ********************************************************************** ** emWin V5.30 - Graphical user interface for embedded applications ** All Intellectual Property rights in the Software belongs to SEGGER. emWin is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with the following terms: The software has been licensed to ARM LIMITED whose registered office is situated at 110 Fulbourn Road, Cambridge CB1 9NJ, England solely for the purposes of creating libraries for ARM7, ARM9, Cortex-M series, and Cortex-R4 processor-based devices, sublicensed and distributed as part of the MDK-ARM Professional under the terms and conditions of the End User License supplied with the MDK-ARM Professional. Full source code is available at: www.segger.com We appreciate your understanding and fairness. ---------------------------------------------------------------------- Licensing information Licensor: SEGGER Software GmbH Licensed to: ARM Ltd Licensed SEGGER software: emWin License number: GUI-00181 License model: LES-SLA-20007, Agreement, effective since October 1st 2011 Licensed product: MDK-ARM Professional Licensed platform: ARM7/9, Cortex-M/R4 Licensed number of seats: - ---------------------------------------------------------------------- File : GUIDEMO.h Purpose : Configuration file of GUIDemo ---------------------------------------------------------------------- */ #ifndef GUIDEMO_H #define GUIDEMO_H #if defined(__cplusplus) extern "C" { /* Make sure we have C-declarations in C++ programs */ #endif #ifdef _RTE_ #include "RTE_Components.h" #endif #include "GUI.h" #if GUI_WINSUPPORT #include "WM.h" #include "CHECKBOX.h" #include "FRAMEWIN.h" #include "PROGBAR.h" #include "TEXT.h" #include "BUTTON.h" #include "SLIDER.h" #include "HEADER.h" #include "GRAPH.h" #include "ICONVIEW.h" #include "LISTVIEW.h" #include "TREEVIEW.h" #else #include <stdlib.h> // Definition of NULL #endif /********************************************************************* * * Defines * ********************************************************************** */ #define CONTROL_SIZE_X 80 #define CONTROL_SIZE_Y 61 #define INFO_SIZE_Y 65 #define BUTTON_SIZE_X 36 #define BUTTON_SIZE_Y 22 #define PROGBAR_SIZE_X 74 #define PROGBAR_SIZE_Y 12 #define TEXT_SIZE_X 69 #define TEXT_SIZE_Y 7 #define SHOW_PROGBAR_AT 100 #define GUI_ID_HALT (GUI_ID_USER + 0) #define GUI_ID_NEXT (GUI_ID_USER + 1) #define BK_COLOR_0 GUI_MAKE_COLOR(0xFF5555) #define BK_COLOR_1 GUI_MAKE_COLOR(0x880000) #define NUMBYTES_NEEDED 0x200000UL #define CIRCLE_RADIUS 100 #define LOGO_DIST_BORDER 5 #define CHAR_READING_TIME 80 #define XSIZE_MIN 320 #define YSIZE_MIN 240 // // Use an or-combination of the following flags to configure the // GUIDemo container for the current application. // #define GUIDEMO_SHOW_CURSOR (1 << 0) #define GUIDEMO_SHOW_INFO (1 << 1) #define GUIDEMO_SHOW_CONTROL (1 << 2) #define SHIFT_RIGHT_16(x) ((x) / 65536) /********************************************************************* * * Configuration of modules to be used * ********************************************************************** */ #ifdef RTE_Graphics_Demo_AA_Text #define SHOW_GUIDEMO_AATEXT (1) #else #define SHOW_GUIDEMO_AATEXT (1) #endif #ifdef RTE_Graphics_Demo_Automotive #define SHOW_GUIDEMO_AUTOMOTIVE (1) #else #define SHOW_GUIDEMO_AUTOMOTIVE (0) #endif #ifdef RTE_Graphics_Demo_BarGraph #define SHOW_GUIDEMO_BARGRAPH (1) #else #define SHOW_GUIDEMO_BARGRAPH (0) #endif #ifdef RTE_Graphics_Demo_Bitmap #define SHOW_GUIDEMO_BITMAP (1) #else #define SHOW_GUIDEMO_BITMAP (1) #endif #ifdef RTE_Graphics_Demo_ColorBar #define SHOW_GUIDEMO_COLORBAR (1) #else #define SHOW_GUIDEMO_COLORBAR (0) #endif #ifdef RTE_Graphics_Demo_Cursor #define SHOW_GUIDEMO_CURSOR (1) #else #define SHOW_GUIDEMO_CURSOR (0) #endif #ifdef RTE_Graphics_Demo_Fading #define SHOW_GUIDEMO_FADING (1) #else #define SHOW_GUIDEMO_FADING (0) #endif #ifdef RTE_Graphics_Demo_Graph #define SHOW_GUIDEMO_GRAPH (1) #else #define SHOW_GUIDEMO_GRAPH (0) #endif #ifdef RTE_Graphics_Demo_IconView #define SHOW_GUIDEMO_ICONVIEW (1) #else #define SHOW_GUIDEMO_ICONVIEW (0) #endif #ifdef RTE_Graphics_Demo_ImageFlow #define SHOW_GUIDEMO_IMAGEFLOW (1) #else #define SHOW_GUIDEMO_IMAGEFLOW (0) #endif #ifdef RTE_Graphics_Demo_ListView #define SHOW_GUIDEMO_LISTVIEW (1) #else #define SHOW_GUIDEMO_LISTVIEW (0) #endif #ifdef RTE_Graphics_Demo_RadialMenu #define SHOW_GUIDEMO_RADIALMENU (1) #else #define SHOW_GUIDEMO_RADIALMENU (0) #endif #ifdef RTE_Graphics_Demo_Skinning #define SHOW_GUIDEMO_SKINNING (1) #else #define SHOW_GUIDEMO_SKINNING (1) #endif #ifdef RTE_Graphics_Demo_Speed #define SHOW_GUIDEMO_SPEED (1) #else #define SHOW_GUIDEMO_SPEED (1) #endif #ifdef RTE_Graphics_Demo_Speedometer #define SHOW_GUIDEMO_SPEEDOMETER (1) #else #define SHOW_GUIDEMO_SPEEDOMETER (0) #endif #ifdef RTE_Graphics_Demo_TransparentDialog #define SHOW_GUIDEMO_TRANSPARENTDIALOG (1) #else #define SHOW_GUIDEMO_TRANSPARENTDIALOG (1) #endif #ifdef RTE_Graphics_Demo_Treeview #define SHOW_GUIDEMO_TREEVIEW (1) #else #define SHOW_GUIDEMO_TREEVIEW (0) #endif #ifdef RTE_Graphics_Demo_VScreen #define SHOW_GUIDEMO_VSCREEN (1) #else #define SHOW_GUIDEMO_VSCREEN (0) #endif #ifdef RTE_Graphics_Demo_WashingMachine #define SHOW_GUIDEMO_WASHINGMACHINE (1) #else #define SHOW_GUIDEMO_WASHINGMACHINE (0) #endif #ifdef RTE_Graphics_Demo_ZoomAndRotate #define SHOW_GUIDEMO_ZOOMANDROTATE (1) #else #define SHOW_GUIDEMO_ZOOMANDROTATE (1) #endif /********************************************************************* * * Configuration macros * ********************************************************************** */ #ifndef GUIDEMO_SHOW_SPRITES #define GUIDEMO_SHOW_SPRITES (1) #endif #ifndef GUIDEMO_USE_VNC #define GUIDEMO_USE_VNC (0) #endif #ifndef GUIDEMO_USE_AUTO_BK #define GUIDEMO_USE_AUTO_BK (1) #endif #ifndef GUIDEMO_SUPPORT_TOUCH #define GUIDEMO_SUPPORT_TOUCH (1) #endif #ifndef GUIDEMO_SUPPORT_CURSOR #define GUIDEMO_SUPPORT_CURSOR (GUI_SUPPORT_CURSOR && GUI_SUPPORT_TOUCH) #endif #ifndef GUIDEMO_CF_SHOW_SPRITES #define GUIDEMO_CF_SHOW_SPRITES (GUIDEMO_SHOW_SPRITES << 0) #endif #ifndef GUIDEMO_CF_USE_VNC #define GUIDEMO_CF_USE_VNC (GUIDEMO_USE_VNC << 1) #endif #ifndef GUIDEMO_CF_USE_AUTO_BK #define GUIDEMO_CF_USE_AUTO_BK (GUIDEMO_USE_AUTO_BK << 2) #endif #ifndef GUIDEMO_CF_SUPPORT_TOUCH #define GUIDEMO_CF_SUPPORT_TOUCH (GUI_WINSUPPORT ? GUIDEMO_SUPPORT_TOUCH << 3 : 0) #endif /********************************************************************* * * GUIDEMO_CONFIG */ typedef struct GUIDEMO_CONFIG { void (* * apFunc)(void); int NumDemos; U16 Flags; #if GUIDEMO_USE_VNC int (* pGUI_VNC_X_StartServer)(int LayerIndex, int ServerIndex); #endif } GUIDEMO_CONFIG; #if (GUI_WINSUPPORT == 0) #define GUIDEMO_NotifyStartNext GUIDEMO_ClearHalt #define GUIDEMO_Delay GUI_Delay #else void GUIDEMO_NotifyStartNext (void); void GUIDEMO_Delay (int Time); #endif /********************************************************************* * * Internal functions * ********************************************************************** */ void GUIDEMO_AddIntToString (char * pText, U32 Number); void GUIDEMO_AddStringToString(char * pText, const char * pAdd); int GUIDEMO_CheckCancel (void); int GUIDEMO_CheckCancelDelay (int Delay); void GUIDEMO_ClearHalt (void); void GUIDEMO_ClearText (char * pText); void GUIDEMO_Config (GUIDEMO_CONFIG * pConfig); void GUIDEMO_ConfigureDemo (char * pTitle, char * pDescription, unsigned Flags); void GUIDEMO_DispHint (char * pHint); void GUIDEMO_DispTitle (char * pTitle); void GUIDEMO_DrawBk (void); U16 GUIDEMO_GetConfFlag (U16 Flag); int GUIDEMO_GetTime (void); int GUIDEMO_GetTitleSizeY (void); void GUIDEMO_HideCursor (void); void GUIDEMO_Intro (void); void GUIDEMO_Main (void); GUI_COLOR GUIDEMO_MixColors (GUI_COLOR Color0, GUI_COLOR Color1, U8 Intens); void GUIDEMO_SetInfoText (const char * pInfo); int GUIDEMO_ShiftRight (int Value, U8 NumBits); void GUIDEMO_ShowCursor (void); void GUIDEMO_Wait (int TimeWait); /********************************************************************* * * Demo modules * ********************************************************************** */ void GUIDEMO_AntialiasedText (void); void GUIDEMO_Automotive (void); void GUIDEMO_BarGraph (void); void GUIDEMO_Bitmap (void); void GUIDEMO_ColorBar (void); void GUIDEMO_Cursor (void); void GUIDEMO_Fading (void); void GUIDEMO_Graph (void); void GUIDEMO_IconView (void); void GUIDEMO_ImageFlow (void); void GUIDEMO_Listview (void); void GUIDEMO_RadialMenu (void); void GUIDEMO_Skinning (void); void GUIDEMO_Speed (void); void GUIDEMO_Speedometer (void); void GUIDEMO_TransparentDialog(void); void GUIDEMO_Treeview (void); void GUIDEMO_VScreen (void); void GUIDEMO_WashingMachine (void); void GUIDEMO_ZoomAndRotate (void); /********************************************************************* * * Externs * ********************************************************************** */ extern GUI_CONST_STORAGE GUI_BITMAP bmSeggerLogo; extern GUI_CONST_STORAGE GUI_BITMAP bmSeggerLogo70x35; extern GUI_CONST_STORAGE GUI_BITMAP bmplay; extern GUI_CONST_STORAGE GUI_BITMAP bmforward; extern GUI_CONST_STORAGE GUI_BITMAP bmstop; extern GUI_CONST_STORAGE GUI_BITMAP bmbutton_1; extern GUI_CONST_STORAGE GUI_BITMAP bmbutton_0; extern GUI_CONST_STORAGE GUI_BITMAP bmgrad_32x16; extern GUI_CONST_STORAGE GUI_FONT GUI_FontRounded16; extern GUI_CONST_STORAGE GUI_FONT GUI_FontRounded22; extern GUI_CONST_STORAGE GUI_FONT GUI_FontSouvenir18; extern GUI_CONST_STORAGE GUI_FONT GUI_FontD6x8; extern GUI_CONST_STORAGE GUI_FONT GUI_FontAA2_32; extern GUI_CONST_STORAGE GUI_FONT GUI_FontAA4_32; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_00; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_01; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_02; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_03; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_04; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_10; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_11; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_12; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_13; extern GUI_CONST_STORAGE GUI_BITMAP bmDolphin_14; #if defined(__cplusplus) } #endif #endif // Avoid multiple inclusion /*************************** End of file ****************************/
[ "313158485@qq.com" ]
313158485@qq.com