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
60db1c2dc5abbafb16a5d6d61a3f6f1a6bc5dbb2
b9435874ac443d72bf9d9fd7fb41477fe6008772
/include/udap/threadpool.h
60962f462474c6238f7e2311619bf5906e9a8293
[ "Zlib" ]
permissive
Degget1986/uplexa-network
9b4a88e9553c871625d410e07410b7bda0b23590
55493d8653d6271732f77c3999b473928ec2261c
refs/heads/master
2022-02-25T15:35:14.136628
2019-09-05T22:08:31
2019-09-05T22:08:31
208,914,609
1
0
NOASSERTION
2019-09-16T23:12:20
2019-09-16T23:12:20
null
UTF-8
C
false
false
1,161
h
#ifndef UDAP_THREADPOOL_H #define UDAP_THREADPOOL_H #ifdef __cplusplus extern "C" { #endif struct udap_threadpool; struct udap_threadpool * udap_init_threadpool(int workers, const char *name); /// for single process mode struct udap_threadpool * udap_init_same_process_threadpool(); void udap_free_threadpool(struct udap_threadpool **tp); typedef void (*udap_thread_work_func)(void *); /** job to be done in worker thread */ struct udap_thread_job { /** user data to pass to work function */ void *user; /** called in threadpool worker thread */ udap_thread_work_func work; #ifdef __cplusplus udap_thread_job(void *u, udap_thread_work_func w) : user(u), work(w) { } udap_thread_job() : user(nullptr), work(nullptr) { } #endif }; /// for single process mode void udap_threadpool_tick(struct udap_threadpool *tp); void udap_threadpool_queue_job(struct udap_threadpool *tp, struct udap_thread_job j); void udap_threadpool_stop(struct udap_threadpool *tp); void udap_threadpool_join(struct udap_threadpool *tp); void udap_threadpool_wait(struct udap_threadpool *tp); #ifdef __cplusplus } #endif #endif
[ "piercecoding@gmail.com" ]
piercecoding@gmail.com
65fc54a3c8e20f2960958b2086ff5b3dc4c0b599
c55f03e0a5b854546899bfac8d67674442765058
/ConsoleApplication1/ConsoleApplication1/B.h
ad56600c8f439256b3114ffa3d71ae8ec1db46b9
[]
no_license
VERAJUAN/EjerciciosFunciones
363b0920c290af47f9288c5393e17f890104f448
30ee17a6afaf09eba9bd90372d8bac940965aaa2
refs/heads/master
2020-03-12T10:27:42.922259
2018-05-01T20:47:15
2018-05-01T20:47:15
130,573,395
1
0
null
null
null
null
UTF-8
C
false
false
50
h
#pragma once #include "stdafx.h" void f(double);
[ "noreply@github.com" ]
VERAJUAN.noreply@github.com
a5f082878256b9ba2a1b1a82f7dfc92fc190e110
2f0242d56aacf89248885c1ca789a72925b1d01a
/src/php-7.4.2-src/main/config.w32.h
508d5d3041ebfb5feb71272f34b797f8f4a3b7e9
[]
no_license
morpher-ru/php-src
6c5ac61c48864c609c3ce903f9d844d3b18c380f
fde2c370b3e96fd488de78e2d11b7e860ba17ec0
refs/heads/master
2021-06-04T16:33:01.900015
2020-02-11T22:26:37
2020-02-11T22:26:37
112,384,388
2
0
null
2020-02-11T22:26:39
2017-11-28T20:17:05
C
UTF-8
C
false
false
4,293
h
/* Build Configuration Template for Win32. $Id$ */ /* Define the minimum supported version */ #undef _WIN32_WINNT #undef NTDDI_VERSION #define _WIN32_WINNT 0x0601 #define NTDDI_VERSION 0x06010000 /* Default PHP / PEAR directories */ #define PHP_CONFIG_FILE_PATH (getenv("SystemRoot"))?getenv("SystemRoot"):"" #define CONFIGURATION_FILE_PATH "php.ini" #define PEAR_INSTALLDIR "@PREFIX@\\pear" #define PHP_BINDIR "@PREFIX@" #define PHP_DATADIR "@PREFIX@" #define PHP_EXTENSION_DIR "@PREFIX@\\ext" #define PHP_INCLUDE_PATH ".;@PREFIX@\\pear" #define PHP_LIBDIR "@PREFIX@" #define PHP_LOCALSTATEDIR "@PREFIX@" #define PHP_PREFIX "@PREFIX@" #define PHP_SYSCONFDIR "@PREFIX@" /* Enable / Disable crypt() function (default: enabled) */ #define HAVE_CRYPT 1 #define PHP_STD_DES_CRYPT 1 #define PHP_EXT_DES_CRYPT 1 #define PHP_MD5_CRYPT 1 #define PHP_BLOWFISH_CRYPT 1 #define PHP_SHA512_CRYPT 1 #define PHP_SHA256_CRYPT 1 /* PHP Runtime Configuration */ #define PHP_URL_FOPEN 1 #define USE_CONFIG_FILE 1 #define DEFAULT_SHORT_OPEN_TAG "1" /* Platform-Specific Configuration. Should not be changed. */ #define PHP_SIGCHILD 0 #define HAVE_LIBBIND 1 #define HAVE_GETSERVBYNAME 1 #define HAVE_GETSERVBYPORT 1 #define HAVE_GETPROTOBYNAME 1 #define HAVE_GETPROTOBYNUMBER 1 #define HAVE_GETHOSTNAME 1 #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 #define HAVE_ERRMSG_H 0 #undef HAVE_ADABAS #undef HAVE_SOLID #undef HAVE_LINK #undef HAVE_SYMLINK /* its in win32/time.c */ #define HAVE_USLEEP 1 #define HAVE_NANOSLEEP 1 #define PHP_SLEEP_NON_VOID 1 #define HAVE_GETHOSTNAME 1 #define HAVE_GETCWD 1 #define HAVE_POSIX_READDIR_R 1 #define NEED_ISBLANK 1 #define DISCARD_PATH 0 #undef HAVE_SETITIMER #undef HAVE_SIGSETJMP #undef HAVE_IODBC #define HAVE_LIBDL 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_PUTENV 1 #define HAVE_LIMITS_H 1 #define HAVE_TZSET 1 #define HAVE_TZNAME 1 #undef HAVE_FLOCK #define HAVE_ALLOCA 1 #undef HAVE_SYS_TIME_H #define HAVE_SIGNAL_H 1 #undef HAVE_ST_BLKSIZE #undef HAVE_ST_BLOCKS #define HAVE_ST_RDEV 1 #define HAVE_UTIME_NULL 1 #define HAVE_VPRINTF 1 #define STDC_HEADERS 1 #define REGEX 1 #define HSREGEX 1 #define HAVE_GCVT 1 #define HAVE_GETLOGIN 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_PUTENV 1 #define HAVE_REGCOMP 1 #define HAVE_SETLOCALE 1 #define HAVE_LOCALECONV 1 #define HAVE_LOCALE_H 1 #ifndef HAVE_LIBBIND # define HAVE_SETVBUF 1 #endif #define HAVE_SHUTDOWN 1 #define HAVE_SNPRINTF 1 #define HAVE_VSNPRINTF 1 #define HAVE_STRCASECMP 1 #define HAVE_STRDUP 1 #define HAVE_STRERROR 1 #define HAVE_STRSTR 1 #define HAVE_TEMPNAM 1 #define HAVE_UTIME 1 #undef HAVE_DIRENT_H #define HAVE_ASSERT_H 1 #define HAVE_FCNTL_H 1 #define HAVE_GRP_H 0 #undef HAVE_PWD_H #define HAVE_STRING_H 1 #undef HAVE_SYS_FILE_H #undef HAVE_SYS_SOCKET_H #undef HAVE_SYS_WAIT_H #define HAVE_SYSLOG_H 1 #undef HAVE_UNISTD_H #define HAVE_SYS_TYPES_H 1 #define HAVE_STDARG_H 1 #undef HAVE_ALLOCA_H #undef HAVE_KILL #define HAVE_GETPID 1 #define HAVE_LIBM 1 #define HAVE_CUSERID 0 #undef HAVE_RINT #define HAVE_STRFTIME 1 #define SIZEOF_SHORT 2 /* int and long are stll 32bit in 64bit compiles */ #define SIZEOF_INT 4 #define SIZEOF_LONG 4 /* MSVC.6/NET don't allow 'long long' or know 'intmax_t' */ #define SIZEOF_LONG_LONG_INT 0 #define SIZEOF_LONG_LONG 8 /* defined as __int64 */ #define SIZEOF_INTMAX_T 0 #define ssize_t SSIZE_T #ifdef _WIN64 # define SIZEOF_SIZE_T 8 # define SIZEOF_PTRDIFF_T 8 #else # define SIZEOF_SIZE_T 4 # define SIZEOF_PTRDIFF_T 4 #endif #define HAVE_FNMATCH #define HAVE_GLOB #define PHP_SHLIB_SUFFIX "dll" #define HAVE_SQLDATASOURCES /* Win32 supports strcoll */ #define HAVE_STRCOLL 1 /* Win32 supports socketpair by the emulation in win32/sockets.c */ #define HAVE_SOCKETPAIR 1 #define HAVE_SOCKLEN_T 1 /* Win32 support proc_open */ #define PHP_CAN_SUPPORT_PROC_OPEN 1 /* inet_ntop() / inet_pton() */ #define HAVE_INET_PTON 1 #define HAVE_INET_NTOP 1 #define HAVE_MBLEN #undef HAVE_ATOF_ACCEPTS_NAN #undef HAVE_ATOF_ACCEPTS_INF #define HAVE_HUGE_VAL_NAN 0 /* vs.net 2005 has a 64-bit time_t. This will likely break * 3rdParty libs that were built with older compilers; switch * back to 32-bit */ //#ifndef _WIN64 //# define _USE_32BIT_TIME_T 1 //#endif //#define HAVE_STDLIB_H 1
[ "noreply@github.com" ]
morpher-ru.noreply@github.com
2878bda288888805864cb36db64e70866f0a7919
05bd89f61623c130cfa36d3c5b0d1e8617005cc4
/0x13-more_singly_linked_lists/4-free_listint.c
088c22e608b1fa503a6faad2dc543d367959f63e
[]
no_license
stevenbrand99/holbertonschool-low_level_programming
bf832e2188f8fa832d08532a0dff161fd29554c3
c72c1e8716190251271f19ca9e42dcbf34f1dd89
refs/heads/master
2022-12-14T19:45:48.322233
2020-08-27T05:11:33
2020-08-27T05:11:33
null
0
0
null
null
null
null
UTF-8
C
false
false
212
c
#include "lists.h" /** * free_listint - free_listint * @head: head */ void free_listint(listint_t *head) { listint_t *store; while (head != NULL) { store = head->next; free(head); head = store; } }
[ "steven.brand1999@gmail.com" ]
steven.brand1999@gmail.com
7a41ee094cfb1f370d67e6deadc8c8de6c2e2ae6
102b6cf872cf4d5653b2ae9c0dc7baa3c2418644
/25Hz prototype/source/Safety_EEprom.c
d25dfb99ae9b2aec2f2da55486be19584b02596a
[]
no_license
capeter123/LY25HZ_50HZ
ba90d5b5a0b51b16f99a77d24f044da00e571f3c
55d923fc6ff276fa1135fce7a0c2716d966ec234
refs/heads/master
2021-10-19T05:04:38.777137
2019-02-18T11:10:49
2019-02-18T11:10:49
null
0
0
null
null
null
null
TIS-620
C
false
false
12,103
c
/*=============================================================================* * Copyright(c) 2009-2011, ALL RIGHTS RESERVED * * FILENAME : 50KW_Safety_EEprom.c * * PURPOSE : * * HISTORY : * DATE VERSION AUTHOR NOTE * * *---------------------------------------------------------------------------- * GLOBAL VARIABLES * NAME DESCRIPTION * *---------------------------------------------------------------------------- * GLOBAL FUNCTIONS * NAME DESCRIPTION * *============================================================================*/ #include "DSP2833x_Device.h" // DSP2833x Headerfile Include File #include "3KW_MAINHEADER.h" // Main include file extern void Times_ReadFromEEPROM(); extern void Times_WriteToEEPROM(); extern void Ref_ReadFromEEPROM(); extern void Ref_WriteToEEPROM(); extern void Sample_ReadFromEEPROM(); extern void Sample_WriteToEEPROM(); /*=============================================================================* * FUNCTION: ReadSafetyFromEEPROM() * * PURPOSE : * * INPUT: Uint16 u16StartAddr----EEPROM address start to be read out. * SAFETY_PARAMETER_REG* p_safety----Will be filled with the value read out. * * RETURN: Uint16 type value: * I2C_W_R_OK * I2C_W_R_EXCEED_LIMIT * I2C_W_R_DATA_AMOUNT_IS_ZERO * I2C_R_FAILED * * CALLS: I2C_Read_InWord() * * CALLED BY: Main.c * * MORE INFO: *============================================================================*/ void TSK_Time_Record(void) { static Uint16 temp = 0; while(1) { if(SEM_pend(&SEM_Time_Record, SYS_FOREVER) == 1) { temp ++; if (temp == 10) { RunningTime.Second ++; temp = 0; } if (RunningTime.Second == 60) { RunningTime.Minute++; RunningTime.Second = 0; } if (RunningTime.Minute == 60) { RunningTime.Hour_L++; RunningTime.Minute = 0; } if (RunningTime.Hour_L == 0xFFFF) { RunningTime.Hour_L = 0; RunningTime.Hour_H ++; } if (RunningTime.Hour_H == 0xFFFF) { RunningTime.Hour_H = 0; RunningTime.Hour_L = 0; RunningTime.Minute = 0; RunningTime.Second = 0; RunningTime.OverFlow = 1; } if (RunningTime.OverFlow == 1) { g_StateCheck.bit.Time_Overflow = 1; } else { g_StateCheck.bit.Time_Overflow = 0; } } } } void Times_ReadFromEEPROM() { HWI_disable(); Uint16 Check = 0; RunningTime.Second = AT24c512_ReadByte(0x0000); RunningTime.Minute = AT24c512_ReadByte(0x0001); AT24c512_ReadSeriseWord(0x0002, &RunningTime.Hour_L , 2); RunningTime.OverFlow = AT24c512_ReadByte(0x0006); RunningTime.TimeCheck = AT24c512_ReadWord(0x0007); Check ^= RunningTime.Second; Check ^= RunningTime.Minute; Check ^= RunningTime.Hour_L; Check ^= RunningTime.Hour_H; Check ^= RunningTime.OverFlow; if (Check != RunningTime.TimeCheck || RunningTime.Second == 65535) { RunningTime.Second = 0; RunningTime.Minute = 0; RunningTime.Hour_L = 0; RunningTime.Hour_H = 0; RunningTime.OverFlow = 0; Times_WriteToEEPROM(); } HWI_enable(); } /*=============================================================================* * FUNCTION: SaveSafetyInEEPROM() * * PURPOSE : * * INPUT: Uint16 u16StartAddr----EEPROM address to be written in, * SAFETY_PARAMETER_REG safety-------Safety instance to be written in * * RETURN: Uint16 type value: * I2C_W_R_OK * I2C_W_R_EXCEED_LIMIT * I2C_W_R_DATA_AMOUNT_IS_ZERO * I2C_R_FAILED * * CALLS: I2C_Write_InWord() * * CALLED BY: * * MORE INFO: *============================================================================*/ void Times_WriteToEEPROM() { HWI_disable(); RunningTime.TimeCheck = 0; RunningTime.TimeCheck ^= RunningTime.Second; RunningTime.TimeCheck ^= RunningTime.Minute; RunningTime.TimeCheck ^= RunningTime.Hour_L; RunningTime.TimeCheck ^= RunningTime.Hour_H; RunningTime.TimeCheck ^= RunningTime.OverFlow; AT24c512_WriteByte(0x0000, RunningTime.Second); AT24c512_WriteByte(0x0001, RunningTime.Minute); AT24c512_WriteSeriseWord(0x0002, &RunningTime.Hour_L, 2); AT24c512_WriteByte(0x0006, RunningTime.OverFlow); AT24c512_WriteWord(0x0007, RunningTime.TimeCheck); HWI_enable(); } void Ref_ReadFromEEPROM() { HWI_disable(); Uint16 read_ref_check1 = 0; Uint16 ref_check1 = 0; Uint16 invh_ref1= 0; Uint16 invl_ref1= 0; invh_ref1 = AT24c512_ReadWord(0x0009); invl_ref1 = AT24c512_ReadWord(0x000B); read_ref_check1 = AT24c512_ReadWord(0x000D); ref_check1 ^= invh_ref1; ref_check1 ^= invl_ref1; if (ref_check1 == read_ref_check1&& invh_ref1 != 65535) { SafetyReg.f32InvH_VoltRms_Ref_LCD = invh_ref1 * 0.1; SafetyReg.f32InvL_VoltRms_Ref_LCD = invl_ref1 * 0.1; } else { SafetyReg.f32InvH_VoltRms_Ref_LCD = 220; SafetyReg.f32InvL_VoltRms_Ref_LCD = 110; Ref_WriteToEEPROM(); } HWI_enable(); } void Ref_WriteToEEPROM() { HWI_disable(); Uint16 ref_check2= 0; Uint16 invh_ref2= 0; Uint16 invl_ref2= 0; invh_ref2 = (Uint16)(SafetyReg.f32InvH_VoltRms_Ref_LCD * 10); invl_ref2 = (Uint16)(SafetyReg.f32InvL_VoltRms_Ref_LCD * 10); ref_check2 ^= invh_ref2; ref_check2 ^= invl_ref2; AT24c512_WriteWord(0x0009, invh_ref2); AT24c512_WriteWord(0x000B, invl_ref2); AT24c512_WriteWord(0x000D, ref_check2); HWI_enable(); } void Sample_ReadFromEEPROM() { HWI_disable(); Uint16 Read_Sample_Check1 = 0; Uint16 Sample_Correct_VInvH1= 0; Uint16 Sample_Correct_VInvL1= 0; Uint16 Sample_Correct_IOutH1= 0; Uint16 Sample_Correct_IOutL1= 0; Uint16 Sample_Correct_VGrid1= 0; Uint16 Sample_Correct_IGrid1= 0; Uint16 Sample_Correct_VBusP1= 0; Uint16 Sample_Correct_VBusN1= 0; Uint16 Sample_Correct_VOutH1= 0; Uint16 Sample_Correct_VOutL1= 0; Uint16 Sample_Correct_TempPFC1= 0; Uint16 Sample_Correct_TempInvH1= 0; Uint16 Sample_Correct_TempInvL1= 0; Uint16 Sample_Para_InvH1= 0; Uint16 Sample_Para_InvL1= 0; Uint16 Sample_Check1 = 0; Sample_Correct_VInvH1 = AT24c512_ReadWord(0x0010); Sample_Correct_VInvL1 = AT24c512_ReadWord(0x0012); Sample_Correct_IOutH1 = AT24c512_ReadWord(0x0014); Sample_Correct_IOutL1 = AT24c512_ReadWord(0x0016); Sample_Correct_VGrid1 = AT24c512_ReadWord(0x0018); Sample_Correct_IGrid1 = AT24c512_ReadWord(0x001A); Sample_Correct_VBusP1 = AT24c512_ReadWord(0x001C); Sample_Correct_VBusN1 = AT24c512_ReadWord(0x001E); Sample_Correct_VOutH1= AT24c512_ReadWord(0x0020) ; Sample_Correct_VOutL1= AT24c512_ReadWord(0x0022); Sample_Correct_TempPFC1= AT24c512_ReadWord(0x0024); Sample_Correct_TempInvH1= AT24c512_ReadWord(0x0026); Sample_Correct_TempInvL1= AT24c512_ReadWord(0x0028); //Sample_Para_InvH1= AT24c512_ReadWord(0x002A); //Sample_Para_InvL1= AT24c512_ReadWord(0x002C); Read_Sample_Check1 = AT24c512_ReadWord(0x002A); //**********ืขาโตุึท************** Sample_Check1 ^= Sample_Correct_VInvH1; Sample_Check1 ^= Sample_Correct_VInvL1; Sample_Check1 ^= Sample_Correct_IOutH1; Sample_Check1 ^= Sample_Correct_IOutL1; Sample_Check1 ^= Sample_Correct_VGrid1; Sample_Check1 ^= Sample_Correct_IGrid1; Sample_Check1 ^= Sample_Correct_VBusP1; Sample_Check1 ^= Sample_Correct_VBusN1; Sample_Check1 ^= Sample_Correct_VOutH1; Sample_Check1 ^= Sample_Correct_VOutL1; Sample_Check1 ^= Sample_Correct_TempPFC1; Sample_Check1 ^= Sample_Correct_TempInvH1; Sample_Check1 ^= Sample_Correct_TempInvL1; //Sample_Check1 ^= Sample_Para_InvH1; //Sample_Check1 ^= Sample_Para_InvL1; if (Sample_Check1 == Read_Sample_Check1 && Sample_Correct_VInvH1 != 65535) { ADCorrection.f32VInvH = Sample_Correct_VInvH1 * 0.001f; ADCorrection.f32VInvL = Sample_Correct_VInvL1 * 0.001f; ADCorrection.f32IOutH = Sample_Correct_IOutH1 * 0.001f; ADCorrection.f32IOutL = Sample_Correct_IOutL1 * 0.001f; ADCorrection.f32VGrid = Sample_Correct_VGrid1 * 0.001f; ADCorrection.f32IGrid = Sample_Correct_IGrid1 * 0.001f; ADCorrection.f32VBusP = Sample_Correct_VBusP1 * 0.001f; ADCorrection.f32VBusN = Sample_Correct_VBusN1 * 0.001f; ADCorrection.f32VOutH = Sample_Correct_VOutH1 * 0.001f; ADCorrection.f32VOutL = Sample_Correct_VOutL1 * 0.001f; ADCorrection.f32TempPFC = Sample_Correct_TempPFC1 * 0.001f; ADCorrection.f32TempInvH = Sample_Correct_TempInvH1 * 0.001f; ADCorrection.f32TempInvL = Sample_Correct_TempInvL1 * 0.001f; //InvHVoltConReg.f32Drop_Coeff = Sample_Para_InvH1 * 0.001f; //InvLVoltConReg.f32Drop_Coeff = Sample_Para_InvL1 * 0.001f; } else { ADCorrection.f32VInvH = 1.0f; ADCorrection.f32VInvL= 1.0f; ADCorrection.f32IOutH = 1.0f; ADCorrection.f32IOutL = 1.0f; ADCorrection.f32VGrid = 1.0f; ADCorrection.f32IGrid = 1.0f; ADCorrection.f32VBusP = 1.0f; ADCorrection.f32VBusN = 1.0f; ADCorrection.f32VOutH = 1.0f; ADCorrection.f32VOutL = 1.0f; ADCorrection.f32TempPFC = 1.0f; ADCorrection.f32TempInvH = 1.0f; ADCorrection.f32TempInvL = 1.0f; //InvHVoltConReg.f32Drop_Coeff = 0.0f; //InvLVoltConReg.f32Drop_Coeff = 0.0f; Sample_WriteToEEPROM(); } HWI_enable(); } void Sample_WriteToEEPROM() { HWI_disable(); Uint16 Sample_Correct_VInvH2= 0; Uint16 Sample_Correct_VInvL2= 0; Uint16 Sample_Correct_IOutH2= 0; Uint16 Sample_Correct_IOutL2= 0; Uint16 Sample_Correct_VGrid2= 0; Uint16 Sample_Correct_IGrid2= 0; Uint16 Sample_Correct_VBusP2= 0; Uint16 Sample_Correct_VBusN2= 0; Uint16 Sample_Correct_VOutH2= 0; Uint16 Sample_Correct_VOutL2= 0; Uint16 Sample_Correct_TempPFC2= 0; Uint16 Sample_Correct_TempInvH2= 0; Uint16 Sample_Correct_TempInvL2= 0; Uint16 Sample_Para_InvH2= 0; Uint16 Sample_Para_InvL2= 0; Uint16 Sample_Check2 = 0; Sample_Correct_VInvH2 = (Uint16)(ADCorrection.f32VInvH * 1000); Sample_Correct_VInvL2 = (Uint16)(ADCorrection.f32VInvL * 1000); Sample_Correct_IOutH2 = (Uint16)(ADCorrection.f32IOutH * 1000); Sample_Correct_IOutL2 = (Uint16)(ADCorrection.f32IOutL * 1000); Sample_Correct_VGrid2 = (Uint16)(ADCorrection.f32VGrid* 1000); Sample_Correct_IGrid2 = (Uint16)(ADCorrection.f32IGrid * 1000); Sample_Correct_VBusP2 = (Uint16)(ADCorrection.f32VBusP * 1000); Sample_Correct_VBusN2= (Uint16)(ADCorrection.f32VBusN * 1000 ); Sample_Correct_VOutH2= (Uint16)(ADCorrection.f32VOutH * 1000); Sample_Correct_VOutL2= (Uint16)(ADCorrection.f32VOutL * 1000); Sample_Correct_TempPFC2= (Uint16)(ADCorrection.f32TempPFC * 1000); Sample_Correct_TempInvH2= (Uint16)(ADCorrection.f32TempInvH * 1000); Sample_Correct_TempInvL2= (Uint16)(ADCorrection.f32TempInvL * 1000); //Sample_Para_InvH2= (Uint16)(InvHVoltConReg.f32Drop_Coeff * 1000); //Sample_Para_InvL2= (Uint16)(InvLVoltConReg.f32Drop_Coeff * 1000); Sample_Check2 ^= Sample_Correct_VInvH2; Sample_Check2 ^= Sample_Correct_VInvL2; Sample_Check2 ^= Sample_Correct_IOutH2; Sample_Check2 ^= Sample_Correct_IOutL2; Sample_Check2 ^= Sample_Correct_VGrid2; Sample_Check2 ^= Sample_Correct_IGrid2; Sample_Check2 ^= Sample_Correct_VBusP2; Sample_Check2 ^= Sample_Correct_VBusN2; Sample_Check2 ^= Sample_Correct_VOutH2; Sample_Check2 ^= Sample_Correct_VOutL2; Sample_Check2 ^= Sample_Correct_TempPFC2; Sample_Check2 ^= Sample_Correct_TempInvH2; Sample_Check2 ^= Sample_Correct_TempInvL2; //Sample_Check2 ^= Sample_Para_InvH2; //Sample_Check2 ^= Sample_Para_InvL2; AT24c512_WriteWord(0x0010, Sample_Correct_VInvH2); AT24c512_WriteWord(0x0012, Sample_Correct_VInvL2); AT24c512_WriteWord(0x0014, Sample_Correct_IOutH2); AT24c512_WriteWord(0x0016, Sample_Correct_IOutL2); AT24c512_WriteWord(0x0018, Sample_Correct_VGrid2); AT24c512_WriteWord(0x001A, Sample_Correct_IGrid2); AT24c512_WriteWord(0x001C, Sample_Correct_VBusP2); AT24c512_WriteWord(0x001E, Sample_Correct_VBusN2); AT24c512_WriteWord(0x0020, Sample_Correct_VOutH2); AT24c512_WriteWord(0x0022, Sample_Correct_VOutL2); AT24c512_WriteWord(0x0024, Sample_Correct_TempPFC2); AT24c512_WriteWord(0x0026, Sample_Correct_TempInvH2); AT24c512_WriteWord(0x0028, Sample_Correct_TempInvL2); //AT24c512_WriteWord(0x002A, Sample_Para_InvH2); //AT24c512_WriteWord(0x002C, Sample_Para_InvL2); AT24c512_WriteWord(0x002A, Sample_Check2); HWI_enable(); }
[ "xindangmoziyuan@163.com" ]
xindangmoziyuan@163.com
cf8fbbdc34eb8b3a53263738736824fff0bdd2e9
230764d82733fac64c3e0eae1ce0a4030965dc4a
/third_party/gst-plugins-base/gst-libs/gst/audio/audio-resampler-neon.h
5a77d45d3be38c83920c8b080503154267b56ba0
[ "BSD-3-Clause", "LGPL-2.1-only", "LGPL-2.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
isabella232/aistreams
478f6ae94189aecdfd9a9cc19742bcb4b4e20bcc
209f4385425405676a581a749bb915e257dbc1c1
refs/heads/master
2023-03-06T14:49:27.864415
2020-09-25T19:48:04
2020-09-25T19:48:04
298,772,653
0
0
Apache-2.0
2021-02-23T10:11:29
2020-09-26T08:40:34
null
UTF-8
C
false
false
30,554
h
/* GStreamer * Copyright (C) <2016> Wim Taymans <wim.taymans@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ static inline void inner_product_gint16_full_1_neon (gint16 * o, const gint16 * a, const gint16 * b, gint len, const gint16 * icoeff, gint bstride) { uint32_t remainder = len % 16; len = len - remainder; asm volatile (" vmov.s32 q0, #0\n" " cmp %[len], #0\n" " beq 2f\n" " vmov.s32 q1, #0\n" "1:" " vld1.16 {d16, d17, d18, d19}, [%[b]]!\n" " vld1.16 {d20, d21, d22, d23}, [%[a]]!\n" " subs %[len], %[len], #16\n" " vmlal.s16 q0, d16, d20\n" " vmlal.s16 q1, d17, d21\n" " vmlal.s16 q0, d18, d22\n" " vmlal.s16 q1, d19, d23\n" " bne 1b\n" " vadd.s32 q0, q0, q1\n" "2:" " cmp %[remainder], #0\n" " beq 4f\n" "3:" " vld1.16 {d16}, [%[b]]!\n" " vld1.16 {d20}, [%[a]]!\n" " subs %[remainder], %[remainder], #4\n" " vmlal.s16 q0, d16, d20\n" " bgt 3b\n" "4:" " vadd.s32 d0, d0, d1\n" " vpadd.s32 d0, d0, d0\n" " vqrshrn.s32 d0, q0, #15\n" " vst1.16 d0[0], [%[o]]\n" : [a] "+r" (a), [b] "+r" (b), [len] "+r" (len), [remainder] "+r" (remainder) : [o] "r" (o) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23"); } static inline void inner_product_gint16_linear_1_neon (gint16 * o, const gint16 * a, const gint16 * b, gint len, const gint16 * icoeff, gint bstride) { uint32_t remainder = len % 16; const gint16 *c[2] = {(gint16*)((gint8*)b + 0*bstride), (gint16*)((gint8*)b + 1*bstride)}; len = len - remainder; asm volatile (" vmov.s16 q0, #0\n" " vmov.s16 q1, #0\n" " cmp %[len], #0\n" " beq 2f\n" "1:" " vld1.16 {d16, d17, d18, d19}, [%[c0]]!\n" " vld1.16 {d20, d21, d22, d23}, [%[c1]]!\n" " vld1.16 {d24, d25, d26, d27}, [%[a]]!\n" " subs %[len], %[len], #16\n" " vmlal.s16 q0, d16, d24\n" " vmlal.s16 q1, d20, d24\n" " vmlal.s16 q0, d17, d25\n" " vmlal.s16 q1, d21, d25\n" " vmlal.s16 q0, d18, d26\n" " vmlal.s16 q1, d22, d26\n" " vmlal.s16 q0, d19, d27\n" " vmlal.s16 q1, d23, d27\n" " bne 1b\n" "2:" " cmp %[remainder], #0\n" " beq 4f\n" "3:" " vld1.16 {d16}, [%[c0]]!\n" " vld1.16 {d20}, [%[c1]]!\n" " vld1.16 {d24}, [%[a]]!\n" " subs %[remainder], %[remainder], #4\n" " vmlal.s16 q0, d16, d24\n" " vmlal.s16 q1, d20, d24\n" " bgt 3b\n" "4:" " vld2.16 {d20[], d21[]}, [%[ic]]\n" " vshrn.s32 d0, q0, #15\n" " vshrn.s32 d2, q1, #15\n" " vmull.s16 q0, d0, d20\n" " vmlal.s16 q0, d2, d21\n" " vadd.s32 d0, d0, d1\n" " vpadd.s32 d0, d0, d0\n" " vqrshrn.s32 d0, q0, #15\n" " vst1.16 d0[0], [%[o]]\n" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [len] "+r" (len), [remainder] "+r" (remainder) : [o] "r" (o), [ic] "r" (icoeff) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27", "memory"); } static inline void inner_product_gint16_cubic_1_neon (gint16 * o, const gint16 * a, const gint16 * b, gint len, const gint16 * icoeff, gint bstride) { const gint16 *c[4] = {(gint16*)((gint8*)b + 0*bstride), (gint16*)((gint8*)b + 1*bstride), (gint16*)((gint8*)b + 2*bstride), (gint16*)((gint8*)b + 3*bstride)}; asm volatile (" vmov.s32 q0, #0\n" " vmov.s32 q1, #0\n" " vmov.s32 q2, #0\n" " vmov.s32 q3, #0\n" " cmp %[len], #0\n" " beq 2f\n" "1:" " vld1.16 {d16, d17}, [%[c0]]!\n" " vld1.16 {d18, d19}, [%[c1]]!\n" " vld1.16 {d20, d21}, [%[c2]]!\n" " vld1.16 {d22, d23}, [%[c3]]!\n" " vld1.16 {d24, d25}, [%[a]]!\n" " subs %[len], %[len], #8\n" " vmlal.s16 q0, d16, d24\n" " vmlal.s16 q1, d18, d24\n" " vmlal.s16 q2, d20, d24\n" " vmlal.s16 q3, d22, d24\n" " vmlal.s16 q0, d17, d25\n" " vmlal.s16 q1, d19, d25\n" " vmlal.s16 q2, d21, d25\n" " vmlal.s16 q3, d23, d25\n" " bne 1b\n" "2:" " vld4.16 {d20[], d21[], d22[], d23[]}, [%[ic]]\n" " vshrn.s32 d0, q0, #15\n" " vshrn.s32 d2, q1, #15\n" " vshrn.s32 d4, q2, #15\n" " vshrn.s32 d6, q3, #15\n" " vmull.s16 q0, d0, d20\n" " vmlal.s16 q0, d2, d21\n" " vmlal.s16 q0, d4, d22\n" " vmlal.s16 q0, d6, d23\n" " vadd.s32 d0, d0, d1\n" " vpadd.s32 d0, d0, d0\n" " vqrshrn.s32 d0, q0, #15\n" " vst1.16 d0[0], [%[o]]\n" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [c2] "+r" (c[2]), [c3] "+r" (c[3]), [len] "+r" (len) : [o] "r" (o), [ic] "r" (icoeff) : "cc", "q0", "q1", "q2", "q3", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "memory"); } static inline void interpolate_gint16_linear_neon (gpointer op, const gpointer ap, gint len, const gpointer icp, gint astride) { gint16 *o = op, *a = ap, *ic = icp; const gint16 *c[2] = {(gint16*)((gint8*)a + 0*astride), (gint16*)((gint8*)a + 1*astride)}; asm volatile (" cmp %[len], #0\n" " beq 2f\n" " vld2.16 {d20[], d21[]}, [%[ic]]\n" "1:" " vld1.16 {d16, d17}, [%[c0]]!\n" " vld1.16 {d18, d19}, [%[c1]]!\n" " subs %[len], %[len], #8\n" " vmull.s16 q0, d16, d20\n" " vmull.s16 q1, d17, d20\n" " vmlal.s16 q0, d18, d21\n" " vmlal.s16 q1, d19, d21\n" " vqrshrn.s32 d0, q0, #15\n" " vqrshrn.s32 d1, q1, #15\n" " vst1.16 {d0, d1}, [%[o]]!\n" " bne 1b\n" "2:" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (ic) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "memory"); } static inline void interpolate_gint16_cubic_neon (gpointer op, const gpointer ap, gint len, const gpointer icp, gint astride) { gint16 *o = op, *a = ap, *ic = icp; const gint16 *c[4] = {(gint16*)((gint8*)a + 0*astride), (gint16*)((gint8*)a + 1*astride), (gint16*)((gint8*)a + 2*astride), (gint16*)((gint8*)a + 3*astride)}; asm volatile (" cmp %[len], #0\n" " beq 2f\n" " vld4.16 {d24[], d25[], d26[], d27[]}, [%[ic]]\n" "1:" " vld1.16 {d16, d17}, [%[c0]]!\n" " vld1.16 {d18, d19}, [%[c1]]!\n" " vld1.16 {d20, d21}, [%[c2]]!\n" " vld1.16 {d22, d23}, [%[c3]]!\n" " subs %[len], %[len], #8\n" " vmull.s16 q0, d16, d24\n" " vmull.s16 q1, d17, d24\n" " vmlal.s16 q0, d18, d25\n" " vmlal.s16 q1, d19, d25\n" " vmlal.s16 q0, d20, d26\n" " vmlal.s16 q1, d21, d26\n" " vmlal.s16 q0, d22, d27\n" " vmlal.s16 q1, d23, d27\n" " vqrshrn.s32 d0, q0, #15\n" " vqrshrn.s32 d1, q1, #15\n" " vst1.16 {d0, d1}, [%[o]]!\n" " bne 1b\n" "2:" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [c2] "+r" (c[2]), [c3] "+r" (c[3]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (ic) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27", "memory"); } static inline void inner_product_gint32_full_1_neon (gint32 * o, const gint32 * a, const gint32 * b, gint len, const gint32 * icoeff, gint bstride) { uint32_t remainder = len % 8; len = len - remainder; asm volatile (" vmov.s64 q0, #0\n" " cmp %[len], #0\n" " beq 2f\n" " vmov.s64 q1, #0\n" "1:" " vld1.32 {d16, d17, d18, d19}, [%[b]]!\n" " vld1.32 {d20, d21, d22, d23}, [%[a]]!\n" " subs %[len], %[len], #8\n" " vmlal.s32 q0, d16, d20\n" " vmlal.s32 q1, d17, d21\n" " vmlal.s32 q0, d18, d22\n" " vmlal.s32 q1, d19, d23\n" " bne 1b\n" " vadd.s64 q0, q0, q1\n" "2:" " cmp %[remainder], #0\n" " beq 4f\n" "3:" " vld1.32 {d16, d17}, [%[b]]!\n" " vld1.32 {d20, d21}, [%[a]]!\n" " subs %[remainder], %[remainder], #4\n" " vmlal.s32 q0, d16, d20\n" " vmlal.s32 q0, d17, d21\n" " bgt 3b\n" "4:" " vadd.s64 d0, d0, d1\n" " vqrshrn.s64 d0, q0, #31\n" " vst1.32 d0[0], [%[o]]\n" : [a] "+r" (a), [b] "+r" (b), [len] "+r" (len), [remainder] "+r" (remainder) : [o] "r" (o) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23"); } static inline void inner_product_gint32_linear_1_neon (gint32 * o, const gint32 * a, const gint32 * b, gint len, const gint32 * icoeff, gint bstride) { const gint32 *c[2] = {(gint32*)((gint8*)b + 0*bstride), (gint32*)((gint8*)b + 1*bstride)}; asm volatile (" vmov.s64 q0, #0\n" " vmov.s64 q1, #0\n" " cmp %[len], #0\n" " beq 2f\n" "1:" " vld1.32 {d16, d17, d18, d19}, [%[c0]]!\n" " vld1.32 {d20, d21, d22, d23}, [%[c1]]!\n" " vld1.32 {d24, d25, d26, d27}, [%[a]]!\n" " subs %[len], %[len], #8\n" " vmlal.s32 q0, d16, d24\n" " vmlal.s32 q1, d20, d24\n" " vmlal.s32 q0, d17, d25\n" " vmlal.s32 q1, d21, d25\n" " vmlal.s32 q0, d18, d26\n" " vmlal.s32 q1, d22, d26\n" " vmlal.s32 q0, d19, d27\n" " vmlal.s32 q1, d23, d27\n" " bne 1b\n" "2:" " vld2.32 {d20[], d21[]}, [%[ic]]\n" " vshrn.s64 d0, q0, #31\n" " vshrn.s64 d2, q1, #31\n" " vmull.s32 q0, d0, d20\n" " vmlal.s32 q0, d2, d21\n" " vadd.s64 d0, d0, d1\n" " vqrshrn.s64 d0, q0, #31\n" " vst1.32 d0[0], [%[o]]\n" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [len] "+r" (len) : [o] "r" (o), [ic] "r" (icoeff) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27", "memory"); } static inline void inner_product_gint32_cubic_1_neon (gint32 * o, const gint32 * a, const gint32 * b, gint len, const gint32 * icoeff, gint bstride) { const gint32 *c[4] = {(gint32*)((gint8*)b + 0*bstride), (gint32*)((gint8*)b + 1*bstride), (gint32*)((gint8*)b + 2*bstride), (gint32*)((gint8*)b + 3*bstride)}; asm volatile (" vmov.s64 q0, #0\n" " vmov.s64 q1, #0\n" " vmov.s64 q2, #0\n" " vmov.s64 q3, #0\n" " cmp %[len], #0\n" " beq 2f\n" "1:" " vld1.32 {d16, d17}, [%[c0]]!\n" " vld1.32 {d18, d19}, [%[c1]]!\n" " vld1.32 {d20, d21}, [%[c2]]!\n" " vld1.32 {d22, d23}, [%[c3]]!\n" " vld1.32 {d24, d25}, [%[a]]!\n" " subs %[len], %[len], #4\n" " vmlal.s32 q0, d16, d24\n" " vmlal.s32 q1, d18, d24\n" " vmlal.s32 q2, d20, d24\n" " vmlal.s32 q3, d22, d24\n" " vmlal.s32 q0, d17, d25\n" " vmlal.s32 q1, d19, d25\n" " vmlal.s32 q2, d21, d25\n" " vmlal.s32 q3, d23, d25\n" " bne 1b\n" "2:" " vld4.32 {d20[], d21[], d22[], d23[]}, [%[ic]]\n" " vshrn.s64 d0, q0, #31\n" " vshrn.s64 d2, q1, #31\n" " vshrn.s64 d4, q2, #31\n" " vshrn.s64 d6, q3, #31\n" " vmull.s32 q0, d0, d20\n" " vmlal.s32 q0, d2, d21\n" " vmlal.s32 q0, d4, d22\n" " vmlal.s32 q0, d6, d23\n" " vadd.s64 d0, d0, d1\n" " vqrshrn.s64 d0, q0, #31\n" " vst1.32 d0[0], [%[o]]\n" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [c2] "+r" (c[2]), [c3] "+r" (c[3]), [len] "+r" (len) : [o] "r" (o), [ic] "r" (icoeff) : "cc", "q0", "q1", "q2", "q3", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "memory"); } static inline void interpolate_gint32_linear_neon (gpointer op, const gpointer ap, gint len, const gpointer icp, gint astride) { gint32 *o = op, *a = ap, *ic = icp; const gint32 *c[2] = {(gint32*)((gint8*)a + 0*astride), (gint32*)((gint8*)a + 1*astride)}; asm volatile (" cmp %[len], #0\n" " beq 2f\n" " vld2.32 {d24[], d25[]}, [%[ic]]!\n" "1:" " vld1.32 {d16, d17, d18, d19}, [%[c0]]!\n" " vld1.32 {d20, d21, d22, d23}, [%[c1]]!\n" " subs %[len], %[len], #8\n" " vmull.s32 q0, d16, d24\n" " vmull.s32 q1, d17, d24\n" " vmull.s32 q2, d18, d24\n" " vmull.s32 q3, d19, d24\n" " vmlal.s32 q0, d20, d25\n" " vmlal.s32 q1, d21, d25\n" " vmlal.s32 q2, d22, d25\n" " vmlal.s32 q3, d23, d25\n" " vqrshrn.s64 d0, q0, #31\n" " vqrshrn.s64 d1, q1, #31\n" " vqrshrn.s64 d2, q2, #31\n" " vqrshrn.s64 d3, q3, #31\n" " vst1.32 {d0, d1, d2, d3}, [%[o]]!\n" " bne 1b\n" "2:" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (ic) : "cc", "q0", "q1", "q2", "q3", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "memory"); } static inline void interpolate_gint32_cubic_neon (gpointer op, const gpointer ap, gint len, const gpointer icp, gint astride) { gint32 *o = op, *a = ap, *ic = icp; const gint32 *c[4] = {(gint32*)((gint8*)a + 0*astride), (gint32*)((gint8*)a + 1*astride), (gint32*)((gint8*)a + 2*astride), (gint32*)((gint8*)a + 3*astride)}; asm volatile (" cmp %[len], #0\n" " beq 2f\n" " vld4.32 {d24[], d25[], d26[], d27[]}, [%[ic]]!\n" "1:" " vld1.32 {d16, d17}, [%[c0]]!\n" " vld1.32 {d18, d19}, [%[c1]]!\n" " vld1.32 {d20, d21}, [%[c2]]!\n" " vld1.32 {d22, d23}, [%[c3]]!\n" " subs %[len], %[len], #4\n" " vmull.s32 q0, d16, d24\n" " vmull.s32 q1, d17, d24\n" " vmlal.s32 q0, d18, d25\n" " vmlal.s32 q1, d19, d25\n" " vmlal.s32 q0, d20, d26\n" " vmlal.s32 q1, d21, d26\n" " vmlal.s32 q0, d22, d27\n" " vmlal.s32 q1, d23, d27\n" " vqrshrn.s64 d0, q0, #31\n" " vqrshrn.s64 d1, q1, #31\n" " vst1.32 {d0, d1}, [%[o]]!\n" " bne 1b\n" "2:" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [c2] "+r" (c[2]), [c3] "+r" (c[3]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (ic) : "cc", "q0", "q1", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27", "memory"); } static inline void inner_product_gfloat_full_1_neon (gfloat * o, const gfloat * a, const gfloat * b, gint len, const gfloat * icoeff, gint bstride) { uint32_t remainder = len % 16; len = len - remainder; asm volatile (" vmov.f32 q0, #0.0\n" " cmp %[len], #0\n" " beq 2f\n" " vmov.f32 q1, #0.0\n" "1:" " vld1.32 {q4, q5}, [%[b]]!\n" " vld1.32 {q8, q9}, [%[a]]!\n" " vld1.32 {q6, q7}, [%[b]]!\n" " vld1.32 {q10, q11}, [%[a]]!\n" " subs %[len], %[len], #16\n" " vmla.f32 q0, q4, q8\n" " vmla.f32 q1, q5, q9\n" " vmla.f32 q0, q6, q10\n" " vmla.f32 q1, q7, q11\n" " bne 1b\n" " vadd.f32 q0, q0, q1\n" "2:" " cmp %[remainder], #0\n" " beq 4f\n" "3:" " vld1.32 {q6}, [%[b]]!\n" " vld1.32 {q10}, [%[a]]!\n" " subs %[remainder], %[remainder], #4\n" " vmla.f32 q0, q6, q10\n" " bgt 3b\n" "4:" " vadd.f32 d0, d0, d1\n" " vpadd.f32 d0, d0, d0\n" " vst1.32 d0[0], [%[o]]\n" : [a] "+r" (a), [b] "+r" (b), [len] "+r" (len), [remainder] "+r" (remainder) : [o] "r" (o) : "cc", "q0", "q1", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11"); } static inline void inner_product_gfloat_linear_1_neon (gfloat * o, const gfloat * a, const gfloat * b, gint len, const gfloat * icoeff, gint bstride) { const gfloat *c[2] = {(gfloat*)((gint8*)b + 0*bstride), (gfloat*)((gint8*)b + 1*bstride)}; asm volatile (" vmov.f32 q0, #0.0\n" " vmov.f32 q1, #0.0\n" " cmp %[len], #0\n" " beq 2f\n" "1:" " vld1.32 {q8, q9}, [%[c0]]!\n" " vld1.32 {q10, q11}, [%[c1]]!\n" " vld1.32 {q12, q13}, [%[a]]!\n" " subs %[len], %[len], #8\n" " vmla.f32 q0, q8, q12\n" " vmla.f32 q1, q10, q12\n" " vmla.f32 q0, q9, q13\n" " vmla.f32 q1, q11, q13\n" " bne 1b\n" "2:" " vld2.32 {d20[], d21[]}, [%[ic]]\n" " vmul.f32 d0, d0, d20\n" " vmla.f32 d0, d1, d20\n" " vmla.f32 d0, d2, d21\n" " vmla.f32 d0, d3, d21\n" " vpadd.f32 d0, d0, d0\n" " vst1.32 d0[0], [%[o]]\n" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [len] "+r" (len) : [o] "r" (o), [ic] "r" (icoeff) : "cc", "q0", "q1", "q8", "q9", "q10", "q11", "q12", "q13", "memory"); } static inline void inner_product_gfloat_cubic_1_neon (gfloat * o, const gfloat * a, const gfloat * b, gint len, const gfloat * icoeff, gint bstride) { const gfloat *c[4] = {(gfloat*)((gint8*)b + 0*bstride), (gfloat*)((gint8*)b + 1*bstride), (gfloat*)((gint8*)b + 2*bstride), (gfloat*)((gint8*)b + 3*bstride)}; asm volatile (" vmov.f32 q0, #0.0\n" " vmov.f32 q1, #0.0\n" " vmov.f32 q2, #0.0\n" " vmov.f32 q3, #0.0\n" " cmp %[len], #0\n" " beq 2f\n" "1:" " vld1.32 {q8}, [%[c0]]!\n" " vld1.32 {q9}, [%[c1]]!\n" " vld1.32 {q10}, [%[c2]]!\n" " vld1.32 {q11}, [%[c3]]!\n" " vld1.32 {q12}, [%[a]]!\n" " subs %[len], %[len], #4\n" " vmla.f32 q0, q8, q12\n" " vmla.f32 q1, q9, q12\n" " vmla.f32 q2, q10, q12\n" " vmla.f32 q3, q11, q12\n" " bne 1b\n" "2:" " vld4.32 {d20[], d21[], d22[], d23[]}, [%[ic]]\n" " vmul.f32 d0, d0, d20\n" " vmla.f32 d0, d1, d20\n" " vmla.f32 d0, d2, d21\n" " vmla.f32 d0, d3, d21\n" " vmla.f32 d0, d4, d22\n" " vmla.f32 d0, d5, d22\n" " vmla.f32 d0, d6, d23\n" " vmla.f32 d0, d7, d23\n" " vpadd.f32 d0, d0, d0\n" " vst1.32 d0[0], [%[o]]\n" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [c2] "+r" (c[2]), [c3] "+r" (c[3]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (icoeff) : "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "memory"); } static inline void interpolate_gfloat_linear_neon (gpointer op, const gpointer ap, gint len, const gpointer icp, gint astride) { gfloat *o = op, *a = ap, *ic = icp; const gfloat *c[2] = {(gfloat*)((gint8*)a + 0*astride), (gfloat*)((gint8*)a + 1*astride)}; asm volatile (" cmp %[len], #0\n" " beq 2f\n" " vld2.32 {d24[], d26[]}, [%[ic]]!\n" " vmov.32 d25, d24\n" " vmov.32 d27, d26\n" "1:" " vld1.32 {q8, q9}, [%[c0]]!\n" " vld1.32 {q10, q11}, [%[c1]]!\n" " subs %[len], %[len], #8\n" " vmul.f32 q0, q8, q12\n" " vmul.f32 q1, q9, q12\n" " vmla.f32 q0, q10, q13\n" " vmla.f32 q1, q11, q13\n" " vst1.32 {q0, q1}, [%[o]]!\n" " bne 1b\n" "2:" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (ic) : "cc", "q0", "q1", "q8", "q9", "q10", "q11", "q12", "q13", "memory"); } static inline void interpolate_gfloat_cubic_neon (gpointer op, const gpointer ap, gint len, const gpointer icp, gint astride) { gfloat *o = op, *a = ap, *ic = icp; const gfloat *c[4] = {(gfloat*)((gint8*)a + 0*astride), (gfloat*)((gint8*)a + 1*astride), (gfloat*)((gint8*)a + 2*astride), (gfloat*)((gint8*)a + 3*astride)}; asm volatile (" cmp %[len], #0\n" " beq 2f\n" " vld4.32 {d24[], d26[], d28[], d30[]}, [%[ic]]!\n" " vmov.32 d25, d24\n" " vmov.32 d27, d26\n" " vmov.32 d29, d28\n" " vmov.32 d31, d30\n" "1:" " vld1.32 {q8}, [%[c0]]!\n" " vld1.32 {q9}, [%[c1]]!\n" " vld1.32 {q10}, [%[c2]]!\n" " vld1.32 {q11}, [%[c3]]!\n" " subs %[len], %[len], #4\n" " vmul.f32 q0, q8, q12\n" " vmla.f32 q0, q9, q13\n" " vmla.f32 q0, q10, q14\n" " vmla.f32 q0, q11, q15\n" " vst1.32 {q0}, [%[o]]!\n" " bne 1b\n" "2:" : [a] "+r" (a), [c0] "+r" (c[0]), [c1] "+r" (c[1]), [c2] "+r" (c[2]), [c3] "+r" (c[3]), [len] "+r" (len), [o] "+r" (o) : [ic] "r" (ic) : "cc", "q0", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory"); } MAKE_RESAMPLE_FUNC_STATIC (gint16, full, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gint16, linear, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gint16, cubic, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gint32, full, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gint32, linear, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gint32, cubic, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gfloat, full, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gfloat, linear, 1, neon); MAKE_RESAMPLE_FUNC_STATIC (gfloat, cubic, 1, neon); static void audio_resampler_check_neon (const gchar *option) { if (!strcmp (option, "neon")) { GST_DEBUG ("enable NEON optimisations"); resample_gint16_full_1 = resample_gint16_full_1_neon; resample_gint16_linear_1 = resample_gint16_linear_1_neon; resample_gint16_cubic_1 = resample_gint16_cubic_1_neon; interpolate_gint16_linear = interpolate_gint16_linear_neon; interpolate_gint16_cubic = interpolate_gint16_cubic_neon; resample_gint32_full_1 = resample_gint32_full_1_neon; resample_gint32_linear_1 = resample_gint32_linear_1_neon; resample_gint32_cubic_1 = resample_gint32_cubic_1_neon; interpolate_gint32_linear = interpolate_gint32_linear_neon; interpolate_gint32_cubic = interpolate_gint32_cubic_neon; resample_gfloat_full_1 = resample_gfloat_full_1_neon; resample_gfloat_linear_1 = resample_gfloat_linear_1_neon; resample_gfloat_cubic_1 = resample_gfloat_cubic_1_neon; interpolate_gfloat_linear = interpolate_gfloat_linear_neon; interpolate_gfloat_cubic = interpolate_gfloat_cubic_neon; } }
[ "dschao@google.com" ]
dschao@google.com
e52ddabf597623c9e98ce120b844a50689b1fe89
2875e427d9931ab8cfe2e066e1568c3130fcc3f2
/Solaris_2.6/os_net/src_ws/usr/src/lib/libcurses/screen/compiler.h
4338dee919e150e1fb30fa90fd384608f5a12856
[]
no_license
legacy-codedigger/Solaris-2.6-Source-Code
3afaff70487fb96c864d55bd5845dd11c6c5c871
60a0b3093caa7d84e63dd891a23df0e8e720bf3d
refs/heads/master
2022-05-23T16:05:32.631954
2020-04-25T01:07:08
2020-04-25T01:07:08
258,658,903
1
1
null
null
null
null
UTF-8
C
false
false
5,179
h
/* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ /* The copyright notice above does not evidence any */ /* actual or intended publication of such source code. */ #ident "@(#)compiler.h 1.5 92/07/14 SMI" /* SVr4.0 1.5 */ /********************************************************************* * COPYRIGHT NOTICE * ********************************************************************** * This software is copyright (C) 1982 by Pavel Curtis * * * * Permission is granted to reproduce and distribute * * this file by any means so long as no fee is charged * * above a nominal handling fee and so long as this * * notice is always included in the copies. * * * * Other rights are reserved except as explicitly granted * * by written permission of the author. * * Pavel Curtis * * Computer Science Dept. * * 405 Upson Hall * * Cornell University * * Ithaca, NY 14853 * * * * Ph- (607) 256-4934 * * * * Pavel.Cornell@Udel-Relay (ARPAnet) * * decvax!cornell!pavel (UUCPnet) * *********************************************************************/ /* * compiler.h - Global variables and structures for the terminfo * compiler. * * $Header: RCS/compiler.v Revision 2.1 82/10/25 14:46:04 pavel Exp$ * * $Log: RCS/compiler.v $ Revision 2.1 82/10/25 14:46:04 pavel Added Copyright Notice Revision 2.0 82/10/24 15:17:20 pavel Beta-one Test Release Revision 1.3 82/08/23 22:30:09 pavel The REAL Alpha-one Release Version Revision 1.2 82/08/19 19:10:10 pavel Alpha Test Release One Revision 1.1 82/08/12 18:38:11 pavel Initial revision * */ #include <stdio.h> #include <signal.h> /* use this file to determine if this is SVR4.0 system */ #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef EXTERN /* for machines w/o multiple externs */ # define EXTERN extern #endif /* EXTERN */ #define SINGLE /* only one terminal (actually none) */ extern char *destination; /* destination directory for object files */ EXTERN long start_time; /* time at start of compilation */ extern long time(); EXTERN int curr_line; /* current line # in input */ EXTERN long curr_file_pos; /* file offset of current line */ EXTERN int debug_level; /* level of debugging output */ #define DEBUG(level, fmt, a1) \ if (debug_level >= level)\ fprintf(stderr, fmt, a1); /* * These are the types of tokens returned by the scanner. * The first three are also used in the hash table of capability * names. The scanner returns one of these values after loading * the specifics into the global structure curr_token. * */ #define BOOLEAN 0 /* Boolean capability */ #define NUMBER 1 /* Numeric capability */ #define STRING 2 /* String-valued capability */ #define CANCEL 3 /* Capability to be cancelled in following tc's */ #define NAMES 4 /* The names for a terminal type */ #define MAXBOOLS 64 /* Maximum # of boolean caps we can handle */ #define MAXNUMS 64 /* Maximum # of numeric caps we can handle */ #define MAXSTRINGS 512 /* Maximum # of string caps we can handle */ /* * The global structure in which the specific parts of a * scanned token are returned. * */ struct token { char *tk_name; /* name of capability */ int tk_valnumber; /* value of capability (if a number) */ char *tk_valstring; /* value of capability (if a string) */ }; EXTERN struct token curr_token; /* * The file comp_captab.c contains an array of these structures, * one per possible capability. These are then made into a hash * table array of the same structures for use by the parser. * */ struct name_table_entry { struct name_table_entry *nte_link; char *nte_name; /* name to hash on */ int nte_type; /* BOOLEAN, NUMBER or STRING */ short nte_index; /* index of associated variable in its array */ }; extern struct name_table_entry cap_table[]; extern struct name_table_entry *cap_hash_table[]; extern int Captabsize; extern int Hashtabsize; extern int BoolCount; extern int NumCount; extern int StrCount; #define NOTFOUND ((struct name_table_entry *) 0) /* * Function types * */ struct name_table_entry *find_entry(); /* look up entry in hash table */ int next_char(); int trans_string(); #ifdef SIGSTOP /* SVR4.0 and beyond */ #define SRCDIR "/usr/share/lib/terminfo" #else #define SRCDIR "/usr/lib/terminfo" #endif
[ "zahir.meddour@protonmail.com" ]
zahir.meddour@protonmail.com
a04001b2b15aae24f19eb13721a0624dd761f563
5838cf8f133a62df151ed12a5f928a43c11772ed
/NT/com/netfx/src/clr/toolbox/tlbimp/tlbimpcode/__file__.h
0b2942c6ac8250263661b975b63378a8cd971847
[]
no_license
proaholic/Win2K3
e5e17b2262f8a2e9590d3fd7a201da19771eb132
572f0250d5825e7b80920b6610c22c5b9baaa3aa
refs/heads/master
2023-07-09T06:15:54.474432
2021-08-11T09:09:14
2021-08-11T09:09:14
null
0
0
null
null
null
null
UTF-8
C
false
false
444
h
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== #ifdef _DEBUG #define VER_FILEFLAGS VS_FF_DEBUG #else #define VER_FILEFLAGS VS_FF_SPECIALBUILD #endif #define VER_FILETYPE VFT_DLL #define VER_INTERNALNAME_STR "TLBIMPCODE.DLL" #define VER_FILEDESCRIPTION_STR "Microsoft Type Library to .NET Assembly Converter Implementation\0" #define VER_ORIGFILENAME_STR "TlbImpCode.dll\0"
[ "blindtiger@foxmail.com" ]
blindtiger@foxmail.com
b51b6941e732d4ac14e96952356b51db5c84da76
11ee3810ad0e2334e7f5af76867a7e8de98715d8
/C_06/ex03/ft_sort_params.c
057e442bab37cf955eb20db882479f9e75ae3fed
[]
no_license
ncliff-git/school21_pool_by_ncliff
38f1ee9c5fb2c1206224aaeabed2d647007c6513
a24601f66c0b74ca0d18fd2723c3767c3941ba29
refs/heads/master
2023-08-01T00:13:30.659337
2021-09-12T11:07:16
2021-09-12T11:07:16
286,780,068
0
0
null
null
null
null
UTF-8
C
false
false
1,630
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_sort_params.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ncliff <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/07/30 15:50:20 by ncliff #+# #+# */ /* Updated: 2020/07/30 17:00:24 by ncliff ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> int my_strcmp(char *s1, char *s2) { int i; int n; i = 0; n = 0; while (s1[i] != '\0' || s2[i] != '\0') { if (s1[i] - s2[i] != 0) { n = s1[i] - s2[i]; break ; } i++; } return (n); } void write_argv(int argc, char **argv) { int i; int n; n = 1; while (n < argc) { i = 0; while (argv[n][i]) { write(1, &argv[n][i], 1); i++; } n++; write(1, "\n", 1); } } int main(int argc, char *argv[]) { int i; int n; char *swap; i = 1; n = 1; while (i < argc) { while (n < argc - 1) { if (my_strcmp(argv[n], argv[n + 1]) > 0) { swap = argv[n]; argv[n] = argv[n + 1]; argv[n + 1] = swap; } n++; } n = 1; i++; } write_argv(argc, argv); }
[ "ncliff@un-h6.kzn.21-school.ru" ]
ncliff@un-h6.kzn.21-school.ru
22eb5565d4e4bd60d5774f3ede7dddda4fc0e0de
21b34921c86f311eb99e6d6af5d72744b2d9ba73
/buffer.h
969c5d8678c5bcf8aaa73f2b0511f86330ebec04
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain" ]
permissive
io7m/coreland-corelib
39d1aef2a16b858101df1b743e9a67681fa42f8b
f0c27f147c9757980de95189ff4435dae7d13dd3
refs/heads/master
2020-04-09T08:10:15.939615
2009-10-23T04:24:55
2009-10-23T04:24:55
null
0
0
null
null
null
null
UTF-8
C
false
false
1,390
h
#ifndef CORELIB_BUFFER_H #define CORELIB_BUFFER_H #define BUFFER_OUTSIZE 8192 #define BUFFER_INSIZE 8192 #define BUFFER_ZERO {0,0,0,0,0} struct buffer { char *buf; unsigned long pos; unsigned long size; int fd; long (*op)(int, char *, unsigned long); }; typedef long (*buffer_op)(int, char *, unsigned long); #define buffer_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (buffer_op)(op) } void buffer_init(struct buffer *, long (*)(int, char *, unsigned long), int, char *, unsigned long); long buffer_get(struct buffer *, char *, unsigned long); long buffer_feed(struct buffer *); char *buffer_peek(struct buffer *); void buffer_seek(struct buffer *, unsigned long); long buffer_flush(struct buffer *); int buffer_put(struct buffer *, const char *, unsigned long); int buffer_puts(struct buffer *, const char *); int buffer_putflush(struct buffer *, const char *, unsigned long); int buffer_putsflush(struct buffer *, const char *); int buffer_copy(struct buffer *, struct buffer *); #define buffer_PEEK(s) ( (s)->buf + (s)->size ) #define buffer_SEEK(s,len) ( ( (s)->pos -= (len) ) , ( (s)->size += (len) ) ) #define buffer_GETC(s,c) \ ( ((s)->pos > 0) \ ? ( *(c) = (s)->buf[(s)->size], buffer_SEEK((s),1), 1 ) \ : buffer_get((s),(c),1) \ ) extern struct buffer *buffer0; extern struct buffer *buffer1; extern struct buffer *buffer2; #endif
[ "markzero@6e7d7e42-f3d6-da11-80d8-00d0b73f4485" ]
markzero@6e7d7e42-f3d6-da11-80d8-00d0b73f4485
d680aa70237e2fccb1e1474cbd7f43262b91e8b5
04788e316e71ce9af7a1299a7b73a5f5843f2167
/srcs/do_the_s.c
560e877d64df794f6a86d488b7c7f89e948c5828
[]
no_license
adolivei/ft_printf
51890366d0bce5889a8f564dba7cbebc91495615
603d8dd3ada8769c72841a43d110bfc2d6f217eb
refs/heads/main
2023-05-15T11:49:49.638236
2021-06-03T12:29:04
2021-06-03T12:29:04
373,213,107
0
0
null
null
null
null
UTF-8
C
false
false
1,728
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* do_the_s.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adolivei <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/05/07 18:20:52 by adolivei #+# #+# */ /* Updated: 2021/05/07 18:20:54 by adolivei ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/ft_printf.h" int update_str_len(t_printf *vars, int len, char *s) { if (vars->precision == 0 && vars->precision_ex) { vars->zerop_zerov = 1; len = 0; } if (vars->precision_ex && vars->precision < (int)ft_strlen(s)) len = vars->precision; else len = ft_strlen(s); vars->precision = 0; vars->print_len = len; return (len); } char *cut_str(char *s, int len) { char *temp; temp = (char *)malloc(sizeof(char) * (len + 1)); if (!temp) return (NULL); temp[len] = '\0'; len--; while (len > -1) { temp[len] = s[len]; len--; } return (temp); } void do_the_s(t_printf *vars) { char *s; int len; int neg; neg = 0; len = 0; s = va_arg(vars->argptr, char *); if (!s) s = "(null)"; len = update_str_len(vars, len, s); s = cut_str(s, len); printer(vars, s, len, neg); free(s); }
[ "adolivei@c1r13s1.42lisboa.com" ]
adolivei@c1r13s1.42lisboa.com
0e7a90538e1df8571644c766e15cdf81543ce621
202731ff01216915a791b31bb99b332e77ea765d
/Lexical-Analysis/testcases/test7.c
47c2f5e1a54bc9053585e3aaf1fd2d5d5172aafe
[ "Apache-2.0" ]
permissive
rahulkumdas/Mini-Compiler-project
e2bb583ad3c38d8260da1707ec598a853c181740
c30d64ef9f18a74637ff687b21a16358ba1ac804
refs/heads/master
2022-04-06T15:05:22.325637
2020-01-29T08:34:17
2020-01-29T08:34:17
235,524,099
2
0
null
null
null
null
UTF-8
C
false
false
204
c
#include<stdio.h> int square(int a) { return(a*a); } /*struct abc { int a; char b; };*/ int main() { int num = 2; int num2 = square(num); printf("Square of %d is %d", num, num2); return 0; }
[ "rahul.kr0324@gmail.com" ]
rahul.kr0324@gmail.com
741726dbabd9668a3c8a0f337250c96ff85d46fc
2800e6ff27e23b536c190907793ad3aeb0a9f7f0
/external/curl/tests/libtest/chkhostname.c
e49da133c9749163786c559f9e2de07e79208288
[ "curl", "MIT" ]
permissive
SpaceManiac/HamSandwich
c091735dc64bdc1e5128c77d18d916c645c80c5d
b3910715eeea3691ee64af03bffb6991c7be8eda
refs/heads/master
2023-08-16T18:24:27.788739
2023-08-05T20:35:40
2023-08-05T20:35:40
186,207,665
33
13
MIT
2022-06-10T04:11:05
2019-05-12T03:40:47
C++
UTF-8
C
false
false
1,608
c
/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * * SPDX-License-Identifier: curl * ***************************************************************************/ #include "curl_setup.h" #include "curl_gethostname.h" #define HOSTNAME_MAX 1024 int main(int argc, char *argv[]) { char buff[HOSTNAME_MAX]; if(argc != 2) { printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]); return 1; } if(Curl_gethostname(buff, HOSTNAME_MAX)) { printf("Curl_gethostname() failed\n"); return 1; } /* compare the name returned by Curl_gethostname() with the expected one */ if(strncmp(buff, argv[1], HOSTNAME_MAX)) { printf("got unexpected host name back, LD_PRELOAD failed\n"); return 1; } return 0; }
[ "tad@platymuus.com" ]
tad@platymuus.com
ee7c28d552e74a466873e4e53c9d7331f337dd1b
ad0f70df9a874f388515ca5263a3e35c250c82c6
/lab2-2_1/lab2-2_1.c
97819943fe27e785c5c1c628bb1293be8e076ec3
[]
no_license
JJuOn/2019-01-iotsw
fdf131392fe84db0355db1c96e9bd1425de241aa
885c5fca43f4fc40efedf03fd9936cc855f3807d
refs/heads/master
2020-05-17T22:43:26.121868
2019-06-21T04:30:55
2019-06-21T04:30:55
184,009,223
1
0
null
null
null
null
UTF-8
C
false
false
410
c
#include <stdio.h> #include <wiringPi.h> #define LED_ON 1 #define LED_OFF 0 const int Led[16]={4,17,18,27,22,23,24,25,6,12,13,16,19,20,26,21}; int main() { int i; if(wiringPiSetupGpio()==-1) return 1; for(i=0;i<16;i++) { pinMode(Led[i],OUTPUT); digitalWrite(Led[i],LED_OFF); } while(1) { digitalWrite(Led[0],LED_ON); delay(500); digitalWrite(Led[0],LED_OFF); delay(500); } return 0; }
[ "jwseo001@khu.ac.kr" ]
jwseo001@khu.ac.kr
b2625c08e5d4c9ec306611b16c9f398e5aab39c2
b945b2fac11f237a49de33af1b8fa02ba3ed1814
/vds/vdaim/test2/main.c
c921ffdcd1071a280d8453dbbee5267b94659dc6
[]
no_license
ahundiak/isdp
b94f56f7a7b02b806209ff06da8e22497f6e1386
07572eb18f07cbf762505ef34e471fa47c102df4
refs/heads/master
2021-03-12T20:02:34.067237
2011-12-16T20:03:20
2011-12-16T20:03:20
37,136,442
0
0
null
null
null
null
UTF-8
C
false
false
4,345
c
#include <stdio.h> #include <string.h> #include <glib.h> #include <gio/gio.h> extern test_ftp(); #define POSTMAN_MAGICNO 1234567876 /* good buffer identifier prefix */ #define FULL_BUFFER 1 /* needs packing buffer on CLIX */ #define LEAN_BUFFER 2 /* no mfail etc; saves packing space */ #define INIT_REQUEST 100 /* first dummy initialize request from clix */ #define SYNC_REQUEST 101 /* syncing packet while reading/writing */ #define CHUNKSIZE_INFO 102 /* chunksize information, back from server */ /* ------ Header Packet Structure -------- */ typedef struct header { int magicno; /* POSTMAN MAGIC NUM - check for valid packets */ int packettype; /* packet type - see #define constants */ int bytecount; /* bytecount of data buffer to follow separately */ } THeader; /* header packet is sent by itself, then data */ /* ------ Data Packet Structures -------- */ typedef union pmdatabuf { union fullbufTag /* postman buffer format */ { struct pmebufTag /* dm2 communication */ { int dstat; /* method function return code */ int mfail; /* method return code via argument */ char buf[1]; /* errmsg string (null-term), rest .. */ /* nonascii or null-terminated ascii data */ } pmebuf; struct postmanTag /* only postman<->clix communication */ { int request; /* see #defines */ int info; /* depends on request */ char buf[1]; /* not used */ } postman; } fullbuf; union leanbufTag /* lean buffer - no packing buffer needed */ { struct pmebufTag2 /* DM2 request from CLIX */ { char data[1]; /* nonascii or null-terminated ascii data */ } pmebuf; } leanbuf; } TPayload; int main(int argc, char *argv) { GSocketClient *client; GIOStream *conn; // GSocketConnection GOutputStream *connOut; GInputStream *connInn; const gchar *clientHostName; TPayload *payload; THeader header; gchar *buf; gssize bufLen; gssize count; // For gobject g_type_init(); test_ftp(); if (1) return 0; // Connect client = g_socket_client_new(); conn = (GIOStream *)g_socket_client_connect_to_host(client,"avd_aim_test",9083,NULL,NULL); g_assert(conn); g_tcp_connection_set_graceful_disconnect((GTcpConnection*)conn,TRUE); // Ask server for chunk info clientHostName = g_get_host_name(); bufLen = sizeof(TPayload) + strlen(clientHostName); header.magicno = POSTMAN_MAGICNO; header.packettype = FULL_BUFFER; header.bytecount = bufLen; buf = g_malloc0(bufLen + 1000); payload = (TPayload *)buf; payload->fullbuf.postman.request = INIT_REQUEST; memcpy(buf+sizeof(TPayload),clientHostName,strlen(clientHostName)); connOut = g_io_stream_get_output_stream(conn); connInn = g_io_stream_get_input_stream (conn); count = g_output_stream_write(connOut,&header,sizeof(THeader),NULL,NULL); g_assert_cmpint(sizeof(THeader),==,count); count = g_output_stream_write(connOut,buf,bufLen,NULL,NULL); g_assert_cmpint(bufLen,==,count); count = g_input_stream_read(connInn,&header,sizeof(THeader),NULL,NULL); g_assert_cmpint(sizeof(THeader),==,count); g_assert_cmpint(header.magicno, ==, POSTMAN_MAGICNO); g_assert_cmpint(header.packettype,==, FULL_BUFFER); g_assert_cmpint(header.bytecount, ==, 9); bufLen = header.bytecount; count = g_input_stream_read(connInn,buf,bufLen,NULL,NULL); g_assert_cmpint(bufLen,==,count); g_assert_cmpint(payload->fullbuf.postman.request,==,CHUNKSIZE_INFO); g_assert_cmpint(payload->fullbuf.postman.info, ==,99995); // Not just sure if this is just a hack or not but the serve sends a second message with status code count = g_input_stream_read(connInn,&header,sizeof(THeader),NULL,NULL); g_assert_cmpint(sizeof(THeader),==,count); count = g_input_stream_read(connInn,buf,bufLen,NULL,NULL); g_assert_cmpint(bufLen,==,count); g_assert_cmpint(payload->fullbuf.pmebuf.dstat,==,0); g_assert_cmpint(payload->fullbuf.pmebuf.mfail,==,0); // Try to read again, it will block, need to figure out how to break out // count = g_input_stream_read(connInn,&header,sizeof(THeader),NULL,NULL); // Close down g_io_stream_close(conn,NULL,NULL); // Free it g_object_unref(conn); g_object_unref(client); }
[ "ahundiak@e9faf64c-7e38-11de-a453-d5a50d962d30" ]
ahundiak@e9faf64c-7e38-11de-a453-d5a50d962d30
3e541acf3fcb22613f9a07de10e7d837ae8fa561
c2cedcf36667730f558ab354bea4505b616c90d2
/players/astaroth/nk1.c
b82d466121b5983c9ef1dd3f22cee39b5e60f3e1
[]
no_license
wugouzi/Nirvlp312mudlib
965ed876c7080ab00e28c5d8cd5ea9fc9e46258f
616cad7472279cc97c9693f893940f5336916ff8
refs/heads/master
2023-03-16T03:45:05.510851
2017-09-21T17:05:00
2017-09-21T17:05:00
null
0
0
null
null
null
null
UTF-8
C
false
false
361
c
inherit "obj/monster"; reset(arg) { if(!arg) ::reset(arg); set_name("johnathan"); set_level(1); set_alias("newkid"); set_race("man"); set_hp(15); set_aggressive(1); set_al(-1000); set_short("Johnathan"); set_long("This is an evil new kid.\n" + "He belongs on the chopping block.\n" + ""); set_wc(5); set_ac(3); }
[ "rump.nirv@gmail.com" ]
rump.nirv@gmail.com
6044329e2720d29a4234d6f088cee598a805e17d
c0bfd93cd7f26a271268e504959256f1e02c6806
/components/esp8266/include/driver/i2s.h
3b4e6056d781b31b57160923a0794a0694a1151a
[ "Apache-2.0" ]
permissive
espressif/ESP8266_RTOS_SDK
606f396e92d2675d9854f0fabd88587fbbbaf267
af0cdc36fa2600033d0a09301c754008cf1503c1
refs/heads/master
2023-08-24T22:40:15.373553
2023-05-06T02:04:24
2023-05-06T02:04:24
27,584,181
3,163
1,749
Apache-2.0
2023-08-09T10:48:13
2014-12-05T09:27:12
C
UTF-8
C
false
false
10,411
h
// Copyright 2018-2025 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include <stdint.h> #include "esp_err.h" #ifdef __cplusplus extern "C" { #endif /** * @brief I2S bit width per sample. */ typedef enum { I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< I2S bits per sample: 8-bits*/ I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< I2S bits per sample: 16-bits*/ I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< I2S bits per sample: 24-bits*/ } i2s_bits_per_sample_t; /** * @brief I2S channel. */ typedef enum { I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/ I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/ } i2s_channel_t; /** * @brief I2S communication standard format */ typedef enum { I2S_COMM_FORMAT_I2S = 0x01, /*!< I2S communication format I2S*/ I2S_COMM_FORMAT_I2S_MSB = 0x02, /*!< I2S format MSB*/ I2S_COMM_FORMAT_I2S_LSB = 0x04, /*!< I2S format LSB*/ } i2s_comm_format_t; /** * @brief I2S channel format type */ typedef enum { I2S_CHANNEL_FMT_RIGHT_LEFT = 0x00, I2S_CHANNEL_FMT_ALL_RIGHT, I2S_CHANNEL_FMT_ALL_LEFT, I2S_CHANNEL_FMT_ONLY_RIGHT, I2S_CHANNEL_FMT_ONLY_LEFT, } i2s_channel_fmt_t; /** * @brief I2S Peripheral, 0 */ typedef enum { I2S_NUM_0 = 0x0, /*!< I2S 0*/ I2S_NUM_MAX, } i2s_port_t; /** * @brief I2S Mode, defaut is I2S_MODE_MASTER | I2S_MODE_TX */ typedef enum { I2S_MODE_MASTER = 1, I2S_MODE_SLAVE = 2, I2S_MODE_TX = 4, I2S_MODE_RX = 8, } i2s_mode_t; /** * @brief I2S configuration parameters for i2s_param_config function */ typedef struct { i2s_mode_t mode; /*!< I2S work mode*/ int sample_rate; /*!< I2S sample rate*/ i2s_bits_per_sample_t bits_per_sample; /*!< I2S bits per sample*/ i2s_channel_fmt_t channel_format; /*!< I2S channel format */ i2s_comm_format_t communication_format; /*!< I2S communication format */ int dma_buf_count; /*!< I2S DMA Buffer Count */ int dma_buf_len; /*!< I2S DMA Buffer Length */ bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */ } i2s_config_t; /** * @brief I2S event types */ typedef enum { I2S_EVENT_DMA_ERROR, I2S_EVENT_TX_DONE, /*!< I2S DMA finish sent 1 buffer*/ I2S_EVENT_RX_DONE, /*!< I2S DMA finish received 1 buffer*/ I2S_EVENT_MAX, /*!< I2S event max index*/ } i2s_event_type_t; /** * @brief Event structure used in I2S event queue */ typedef struct { i2s_event_type_t type; /*!< I2S event type */ size_t size; /*!< I2S data size for I2S_DATA event*/ } i2s_event_t; /** * @brief I2S pin enable for i2s_set_pin */ typedef struct { int bck_o_en; /*!< BCK out pin*/ int ws_o_en; /*!< WS out pin*/ int bck_i_en; /*!< BCK in pin*/ int ws_i_en; /*!< WS in pin*/ int data_out_en; /*!< DATA out pin*/ int data_in_en; /*!< DATA in pin*/ } i2s_pin_config_t; /** * @brief Set I2S pin number * * @param i2s_num I2S_NUM_0 * @param pin I2S Pin structure * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_FAIL IO error */ esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin); /** * @brief Install and start I2S driver. * * @note This function must be called before any I2S driver read/write operations. * * @param i2s_num I2S_NUM_0 * @param i2s_config I2S configurations - see i2s_config_t struct * @param queue_size I2S event queue size/depth. * @param i2s_queue I2S event queue handle, if set NULL, driver will not use an event queue. * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NO_MEM Out of memory */ esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void *i2s_queue); /** * @brief Uninstall I2S driver. * * @param i2s_num I2S_NUM_0 * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num); /** * @brief Write data to I2S DMA transmit buffer. * * @note many ticks pass without space becoming available in the DMA * transmit buffer, then the function will return (note that if the * data is written to the DMA buffer in pieces, the overall operation * may still take longer than this timeout.) Pass portMAX_DELAY for no * timeout. * * @param i2s_num I2S_NUM_0 * @param src Source address to write from * @param size Size of data in bytes * @param[out] bytes_written Number of bytes written, if timeout, the result will be less than the size passed in. * @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_write(i2s_port_t i2s_num, const void *src, size_t size, size_t *bytes_written, TickType_t ticks_to_wait); /** * @brief Write data to I2S DMA transmit buffer while expanding the number of bits per sample. For example, expanding 16-bit PCM to 32-bit PCM. * * @note many ticks pass without space becoming available in the DMA * transmit buffer, then the function will return (note that if the * data is written to the DMA buffer in pieces, the overall operation * may still take longer than this timeout.) Pass portMAX_DELAY for no * timeout. * Format of the data in source buffer is determined by the I2S * configuration (see i2s_config_t). * * @param i2s_num I2S_NUM_0 * @param src Source address to write from * @param size Size of data in bytes * @param src_bits Source audio bit * @param aim_bits Bit wanted, no more than 32, and must be greater than src_bits * @param[out] bytes_written Number of bytes written, if timeout, the result will be less than the size passed in. * @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_write_expand(i2s_port_t i2s_num, const void *src, size_t size, size_t src_bits, size_t aim_bits, size_t *bytes_written, TickType_t ticks_to_wait); /** * @brief Read data from I2S DMA receive buffer * * @note If the built-in ADC mode is enabled, we should call i2s_adc_start and i2s_adc_stop around the whole reading process, * to prevent the data getting corrupted. * * @param i2s_num I2S_NUM_0 * @param dest Destination address to read into * @param size Size of data in bytes * @param[out] bytes_read Number of bytes read, if timeout, bytes read will be less than the size passed in. * @param ticks_to_wait RX buffer wait timeout in RTOS ticks. If this many ticks pass without bytes becoming available in the DMA receive buffer, then the function will return (note that if data is read from the DMA buffer in pieces, the overall operation may still take longer than this timeout.) Pass portMAX_DELAY for no timeout. * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait); /** * @brief Set sample rate used for I2S RX and TX. * * @note The bit clock rate is determined by the sample rate and i2s_config_t configuration parameters (number of channels, bits_per_sample). * `bit_clock = rate * (number of channels) * bits_per_sample` * * @param i2s_num I2S_NUM_0 * @param rate I2S sample rate (ex: 8000, 44100...) * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NO_MEM Out of memory */ esp_err_t i2s_set_sample_rates(i2s_port_t i2s_num, uint32_t rate); /** * @brief Stop I2S driver * * @note Disables I2S TX/RX, until i2s_start() is called. * * @param i2s_num I2S_NUM_0 * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_stop(i2s_port_t i2s_num); /** * @brief Start I2S driver * * @note It is not necessary to call this function after i2s_driver_install() (it is started automatically), however it is necessary to call it after i2s_stop(). * * @param i2s_num I2S_NUM_0 * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_start(i2s_port_t i2s_num); /** * @brief Zero the contents of the TX DMA buffer. * * @note Pushes zero-byte samples into the TX DMA buffer, until it is full. * * @param i2s_num I2S_NUM_0 * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num); /** * @brief Set clock & bit width used for I2S RX and TX. * * @note Similar to i2s_set_sample_rates(), but also sets bit width. * * @param i2s_num I2S_NUM_0 * @param rate I2S sample rate (ex: 8000, 44100...) * @param bits I2S bit width (I2S_BITS_PER_SAMPLE_16BIT, I2S_BITS_PER_SAMPLE_24BIT) * @param ch I2S channel, (I2S_CHANNEL_MONO, I2S_CHANNEL_STEREO) * * @return * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NO_MEM Out of memory */ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t bits, i2s_channel_t ch); #ifdef __cplusplus } #endif
[ "xiongyu@espressif.com" ]
xiongyu@espressif.com
d2992ef2f29855880b5236609463f866dca97f58
d41b90545b1d5a417cef4510e530a4b392e9f247
/source/src/sdk/src/qcommon/qcommon.h
ab1810b7245f30bd94f407fe3a7e88555260557e
[]
no_license
annihil-com/eth32nix_resurrection
d36d47c85ea2cbcff04f03b8826864852e2f8eb6
b45c8e29cc60bcf778ef0420f9951d157706f9d0
refs/heads/master
2022-10-10T00:00:26.118732
2020-06-07T14:51:52
2020-06-07T14:51:52
268,081,021
1
0
null
null
null
null
UTF-8
C
false
false
32,521
h
/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. This file is part of Quake III Arena source code. Quake III Arena source code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Quake III Arena source code 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 Foobar; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ // qcommon.h -- definitions common between client and server, but not game.or ref modules #ifndef _QCOMMON_H_ #define _QCOMMON_H_ #include "cm_public.h" //#define PRE_RELEASE_DEMO //============================================================================ // // msg.c // typedef struct { qboolean allowoverflow; // if false, do a Com_Error qboolean overflowed; // set to true if the buffer size failed (with allowoverflow set) qboolean oob; // set to true if the buffer size failed (with allowoverflow set) byte *data; int maxsize; int cursize; int readcount; int bit; // for bitwise reads and writes } msg_t; void MSG_Init (msg_t *buf, byte *data, int length); void MSG_InitOOB( msg_t *buf, byte *data, int length ); void MSG_Clear (msg_t *buf); void MSG_WriteData (msg_t *buf, const void *data, int length); void MSG_Bitstream( msg_t *buf ); // TTimo // copy a msg_t in case we need to store it as is for a bit // (as I needed this to keep an msg_t from a static var for later use) // sets data buffer as MSG_Init does prior to do the copy void MSG_Copy(msg_t *buf, byte *data, int length, msg_t *src); struct usercmd_s; struct entityState_s; struct playerState_s; void MSG_WriteBits( msg_t *msg, int value, int bits ); void MSG_WriteChar (msg_t *sb, int c); void MSG_WriteByte (msg_t *sb, int c); void MSG_WriteShort (msg_t *sb, int c); void MSG_WriteLong (msg_t *sb, int c); void MSG_WriteFloat (msg_t *sb, float f); void MSG_WriteString (msg_t *sb, const char *s); void MSG_WriteBigString (msg_t *sb, const char *s); void MSG_WriteAngle16 (msg_t *sb, float f); void MSG_BeginReading (msg_t *sb); void MSG_BeginReadingOOB(msg_t *sb); int MSG_ReadBits( msg_t *msg, int bits ); int MSG_ReadChar (msg_t *sb); int MSG_ReadByte (msg_t *sb); int MSG_ReadShort (msg_t *sb); int MSG_ReadLong (msg_t *sb); float MSG_ReadFloat (msg_t *sb); char *MSG_ReadString (msg_t *sb); char *MSG_ReadBigString (msg_t *sb); char *MSG_ReadStringLine (msg_t *sb); float MSG_ReadAngle16 (msg_t *sb); void MSG_ReadData (msg_t *sb, void *buffer, int size); void MSG_WriteDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to ); void MSG_ReadDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to ); void MSG_WriteDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to ); void MSG_ReadDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to ); void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to , qboolean force ); void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, int number ); void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to ); void MSG_ReadDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to ); void MSG_ReportChangeVectors_f( void ); //============================================================================ /* ============================================================== NET ============================================================== */ #define PACKET_BACKUP 32 // number of old messages that must be kept on client and // server for delta comrpession and ping estimation #define PACKET_MASK (PACKET_BACKUP-1) #define MAX_PACKET_USERCMDS 32 // max number of usercmd_t in a packet #define PORT_ANY -1 #define MAX_RELIABLE_COMMANDS 64 // max string commands buffered for restransmit typedef enum { NA_BOT, NA_BAD, // an address lookup failed NA_LOOPBACK, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX } netadrtype_t; typedef enum { NS_CLIENT, NS_SERVER } netsrc_t; typedef struct { netadrtype_t type; byte ip[4]; byte ipx[10]; unsigned short port; } netadr_t; void NET_Init( void ); void NET_Shutdown( void ); void NET_Restart( void ); void NET_Config( qboolean enableNetworking ); void NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to); void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...); void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len ); qboolean NET_CompareAdr (netadr_t a, netadr_t b); qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b); qboolean NET_IsLocalAddress (netadr_t adr); const char *NET_AdrToString (netadr_t a); qboolean NET_StringToAdr ( const char *s, netadr_t *a); qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message); void NET_Sleep(int msec); #define MAX_MSGLEN 16384 // max length of a message, which may // be fragmented into multiple packets #define MAX_DOWNLOAD_WINDOW 8 // max of eight download frames #define MAX_DOWNLOAD_BLKSIZE 2048 // 2048 byte block chunks /* Netchan handles packet fragmentation and out of order / duplicate suppression */ typedef struct { netsrc_t sock; int dropped; // between last packet and previous netadr_t remoteAddress; int qport; // qport value to write when transmitting // sequencing variables int incomingSequence; int outgoingSequence; // incoming fragment assembly buffer int fragmentSequence; int fragmentLength; byte fragmentBuffer[MAX_MSGLEN]; // outgoing fragment buffer // we need to space out the sending of large fragmented messages qboolean unsentFragments; int unsentFragmentStart; int unsentLength; byte unsentBuffer[MAX_MSGLEN]; } netchan_t; void Netchan_Init( int qport ); void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport ); void Netchan_Transmit( netchan_t *chan, int length, const byte *data ); void Netchan_TransmitNextFragment( netchan_t *chan ); qboolean Netchan_Process( netchan_t *chan, msg_t *msg ); /* ============================================================== PROTOCOL ============================================================== */ #define PROTOCOL_VERSION 68 // 1.31 - 67 // maintain a list of compatible protocols for demo playing // NOTE: that stuff only works with two digits protocols extern int demo_protocols[]; #define UPDATE_SERVER_NAME "update.quake3arena.com" // override on command line, config files etc. #ifndef MASTER_SERVER_NAME #define MASTER_SERVER_NAME "master.quake3arena.com" #endif #ifndef AUTHORIZE_SERVER_NAME #define AUTHORIZE_SERVER_NAME "authorize.quake3arena.com" #endif #define PORT_MASTER 27950 #define PORT_UPDATE 27951 #ifndef PORT_AUTHORIZE #define PORT_AUTHORIZE 27952 #endif #define PORT_SERVER 27960 #define NUM_SERVER_PORTS 4 // broadcast scan this many ports after // PORT_SERVER so a single machine can // run multiple servers // the svc_strings[] array in cl_parse.c should mirror this // // server to client // enum svc_ops_e { svc_bad, svc_nop, svc_gamestate, svc_configstring, // [short] [string] only in gamestate messages svc_baseline, // only in gamestate messages svc_serverCommand, // [string] to be executed by client game module svc_download, // [short] size [size bytes] svc_snapshot, svc_EOF }; // // client to server // enum clc_ops_e { clc_bad, clc_nop, clc_move, // [[usercmd_t] clc_moveNoDelta, // [[usercmd_t] clc_clientCommand, // [string] message clc_EOF }; /* ============================================================== VIRTUAL MACHINE ============================================================== */ typedef struct vm_s vm_t; typedef enum { VMI_NATIVE, VMI_BYTECODE, VMI_COMPILED } vmInterpret_t; typedef enum { TRAP_MEMSET = 100, TRAP_MEMCPY, TRAP_STRNCPY, TRAP_SIN, TRAP_COS, TRAP_ATAN2, TRAP_SQRT, TRAP_MATRIXMULTIPLY, TRAP_ANGLEVECTORS, TRAP_PERPENDICULARVECTOR, TRAP_FLOOR, TRAP_CEIL, TRAP_TESTPRINTINT, TRAP_TESTPRINTFLOAT } sharedTraps_t; void VM_Init( void ); vm_t *VM_Create( const char *module, int (*systemCalls)(int *), vmInterpret_t interpret ); // module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm" void VM_Free( vm_t *vm ); void VM_Clear(void); vm_t *VM_Restart( vm_t *vm ); int QDECL VM_Call( vm_t *vm, int callNum, ... ); void VM_Debug( int level ); void *VM_ArgPtr( int intValue ); void *VM_ExplicitArgPtr( vm_t *vm, int intValue ); /* ============================================================== CMD Command text buffering and command execution ============================================================== */ /* Any number of commands can be added in a frame, from several different sources. Most commands come from either keybindings or console line input, but entire text files can be execed. */ void Cbuf_Init (void); // allocates an initial text buffer that will grow as needed void Cbuf_AddText( const char *text ); // Adds command text at the end of the buffer, does NOT add a final \n void Cbuf_ExecuteText( int exec_when, const char *text ); // this can be used in place of either Cbuf_AddText or Cbuf_InsertText void Cbuf_Execute (void); // Pulls off \n terminated lines of text from the command buffer and sends // them through Cmd_ExecuteString. Stops when the buffer is empty. // Normally called once per frame, but may be explicitly invoked. // Do not call inside a command function, or current args will be destroyed. //=========================================================================== /* Command execution takes a null terminated string, breaks it into tokens, then searches for a command or variable that matches the first token. */ typedef void (*xcommand_t) (void); void Cmd_Init (void); void Cmd_AddCommand( const char *cmd_name, xcommand_t function ); // called by the init functions of other parts of the program to // register commands and functions to call for them. // The cmd_name is referenced later, so it should not be in temp memory // if function is NULL, the command will be forwarded to the server // as a clc_clientCommand instead of executed locally void Cmd_RemoveCommand( const char *cmd_name ); void Cmd_CommandCompletion( void(*callback)(const char *s) ); // callback with each valid string int Cmd_Argc (void); char *Cmd_Argv (int arg); void Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength ); char *Cmd_Args (void); char *Cmd_ArgsFrom( int arg ); void Cmd_ArgsBuffer( char *buffer, int bufferLength ); char *Cmd_Cmd (void); // The functions that execute commands get their parameters with these // functions. Cmd_Argv () will return an empty string, not a NULL // if arg > argc, so string operations are allways safe. void Cmd_TokenizeString( const char *text ); // Takes a null terminated string. Does not need to be /n terminated. // breaks the string up into arg tokens. void Cmd_ExecuteString( const char *text ); // Parses a single line of text into arguments and tries to execute it // as if it was typed at the console /* ============================================================== CVAR ============================================================== */ /* cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly in C code. The user can access cvars from the console in three ways: r_draworder prints the current value r_draworder 0 sets the current value to 0 set r_draworder 0 as above, but creates the cvar if not present Cvars are restricted from having the same names as commands to keep this interface from being ambiguous. The are also occasionally used to communicated information between different modules of the program. */ cvar_t *Cvar_Get( const char *var_name, const char *value, int flags ); // creates the variable if it doesn't exist, or returns the existing one // if it exists, the value will not be changed, but flags will be ORed in // that allows variables to be unarchived without needing bitflags // if value is "", the value will not override a previously set value. void Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); // basically a slightly modified Cvar_Get for the interpreted modules void Cvar_Update( vmCvar_t *vmCvar ); // updates an interpreted modules' version of a cvar void Cvar_Set( const char *var_name, const char *value ); // will create the variable with no flags if it doesn't exist void Cvar_SetLatched( const char *var_name, const char *value); // don't set the cvar immediately void Cvar_SetValue( const char *var_name, float value ); // expands value to a string and calls Cvar_Set float Cvar_VariableValue( const char *var_name ); int Cvar_VariableIntegerValue( const char *var_name ); // returns 0 if not defined or non numeric char *Cvar_VariableString( const char *var_name ); void Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ); // returns an empty string if not defined void Cvar_CommandCompletion( void(*callback)(const char *s) ); // callback with each valid string void Cvar_Reset( const char *var_name ); void Cvar_SetCheatState( void ); // reset all testing vars to a safe value qboolean Cvar_Command( void ); // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known // command. Returns true if the command was a variable reference that // was handled. (print or change) void Cvar_WriteVariables( fileHandle_t f ); // writes lines containing "set variable value" for all variables // with the archive flag set to true. void Cvar_Init( void ); char *Cvar_InfoString( int bit ); char *Cvar_InfoString_Big( int bit ); // returns an info string containing all the cvars that have the given bit set // in their flags ( CVAR_USERINFO, CVAR_SERVERINFO, CVAR_SYSTEMINFO, etc ) void Cvar_InfoStringBuffer( int bit, char *buff, int buffsize ); void Cvar_Restart_f( void ); extern int cvar_modifiedFlags; // whenever a cvar is modifed, its flags will be OR'd into this, so // a single check can determine if any CVAR_USERINFO, CVAR_SERVERINFO, // etc, variables have been modified since the last check. The bit // can then be cleared to allow another change detection. /* ============================================================== FILESYSTEM No stdio calls should be used by any part of the game, because we need to deal with all sorts of directory and seperator char issues. ============================================================== */ // referenced flags // these are in loop specific order so don't change the order #define FS_GENERAL_REF 0x01 #define FS_UI_REF 0x02 #define FS_CGAME_REF 0x04 #define FS_QAGAME_REF 0x08 // number of id paks that will never be autodownloaded from baseq3 #define NUM_ID_PAKS 9 #define MAX_FILE_HANDLES 64 #define BASEGAME "baseq3" qboolean FS_Initialized(); void FS_InitFilesystem (void); void FS_Shutdown( qboolean closemfp ); qboolean FS_ConditionalRestart( int checksumFeed ); void FS_Restart( int checksumFeed ); // shutdown and restart the filesystem so changes to fs_gamedir can take effect char **FS_ListFiles( const char *directory, const char *extension, int *numfiles ); // directory should not have either a leading or trailing / // if extension is "/", only subdirectories will be returned // the returned files will not include any directories or / void FS_FreeFileList( char **list ); qboolean FS_FileExists( const char *file ); int FS_LoadStack(); int FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ); int FS_GetModList( char *listbuf, int bufsize ); fileHandle_t FS_FOpenFileWrite( const char *qpath ); // will properly create any needed paths and deal with seperater character issues int FS_filelength( fileHandle_t f ); fileHandle_t FS_SV_FOpenFileWrite( const char *filename ); int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ); void FS_SV_Rename( const char *from, const char *to ); int FS_FOpenFileRead( const char *qpath, fileHandle_t *file, qboolean uniqueFILE ); // if uniqueFILE is true, then a new FILE will be fopened even if the file // is found in an already open pak file. If uniqueFILE is false, you must call // FS_FCloseFile instead of fclose, otherwise the pak FILE would be improperly closed // It is generally safe to always set uniqueFILE to true, because the majority of // file IO goes through FS_ReadFile, which Does The Right Thing already. int FS_FileIsInPAK(const char *filename, int *pChecksum ); // returns 1 if a file is in the PAK file, otherwise -1 int FS_Write( const void *buffer, int len, fileHandle_t f ); int FS_Read2( void *buffer, int len, fileHandle_t f ); int FS_Read( void *buffer, int len, fileHandle_t f ); // properly handles partial reads and reads from other dlls void FS_FCloseFile( fileHandle_t f ); // note: you can't just fclose from another DLL, due to MS libc issues int FS_ReadFile( const char *qpath, void **buffer ); // returns the length of the file // a null buffer will just return the file length without loading // as a quick check for existance. -1 length == not present // A 0 byte will always be appended at the end, so string ops are safe. // the buffer should be considered read-only, because it may be cached // for other uses. void FS_ForceFlush( fileHandle_t f ); // forces flush on files we're writing to. void FS_FreeFile( void *buffer ); // frees the memory returned by FS_ReadFile void FS_WriteFile( const char *qpath, const void *buffer, int size ); // writes a complete file, creating any subdirectories needed int FS_filelength( fileHandle_t f ); // doesn't work for files that are opened from a pack file int FS_FTell( fileHandle_t f ); // where are we? void FS_Flush( fileHandle_t f ); void QDECL FS_Printf( fileHandle_t f, const char *fmt, ... ); // like fprintf int FS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode ); // opens a file for reading, writing, or appending depending on the value of mode int FS_Seek( fileHandle_t f, long offset, int origin ); // seek on a file (doesn't work for zip files!!!!!!!!) qboolean FS_FilenameCompare( const char *s1, const char *s2 ); const char *FS_GamePureChecksum( void ); // Returns the checksum of the pk3 from which the server loaded the qagame.qvm const char *FS_LoadedPakNames( void ); const char *FS_LoadedPakChecksums( void ); const char *FS_LoadedPakPureChecksums( void ); // Returns a space separated string containing the checksums of all loaded pk3 files. // Servers with sv_pure set will get this string and pass it to clients. const char *FS_ReferencedPakNames( void ); const char *FS_ReferencedPakChecksums( void ); const char *FS_ReferencedPakPureChecksums( void ); // Returns a space separated string containing the checksums of all loaded // AND referenced pk3 files. Servers with sv_pure set will get this string // back from clients for pure validation void FS_ClearPakReferences( int flags ); // clears referenced booleans on loaded pk3s void FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames ); void FS_PureServerSetLoadedPaks( const char *pakSums, const char *pakNames ); // If the string is empty, all data sources will be allowed. // If not empty, only pk3 files that match one of the space // separated checksums will be checked for files, with the // sole exception of .cfg files. qboolean FS_idPak( char *pak, char *base ); qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ); void FS_Rename( const char *from, const char *to ); /* ============================================================== Edit fields and command line history/completion ============================================================== */ #define MAX_EDIT_LINE 256 typedef struct { int cursor; int scroll; int widthInChars; char buffer[MAX_EDIT_LINE]; } field_t; void Field_Clear( field_t *edit ); void Field_CompleteCommand( field_t *edit ); /* ============================================================== MISC ============================================================== */ // TTimo // vsnprintf is ISO/IEC 9899:1999 // abstracting this to make it portable #ifdef WIN32 #define Q_vsnprintf _vsnprintf #else // TODO: do we need Mac define? #define Q_vsnprintf vsnprintf #endif // centralizing the declarations for cl_cdkey // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=470 extern char cl_cdkey[34]; // returnbed by Sys_GetProcessorId #define CPUID_GENERIC 0 // any unrecognized processor #define CPUID_AXP 0x10 #define CPUID_INTEL_UNSUPPORTED 0x20 // Intel 386/486 #define CPUID_INTEL_PENTIUM 0x21 // Intel Pentium or PPro #define CPUID_INTEL_MMX 0x22 // Intel Pentium/MMX or P2/MMX #define CPUID_INTEL_KATMAI 0x23 // Intel Katmai #define CPUID_AMD_3DNOW 0x30 // AMD K6 3DNOW! // TTimo // centralized and cleaned, that's the max string you can send to a Com_Printf / Com_DPrintf (above gets truncated) #define MAXPRINTMSG 4096 char *CopyString( const char *in ); void Info_Print( const char *s ); void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *)); void Com_EndRedirect( void ); void QDECL Com_Printf( const char *fmt, ... ); void QDECL Com_DPrintf( const char *fmt, ... ); void QDECL Com_Error( int code, const char *fmt, ... ); void Com_Quit_f( void ); int Com_EventLoop( void ); int Com_Milliseconds( void ); // will be journaled properly unsigned Com_BlockChecksum( const void *buffer, int length ); unsigned Com_BlockChecksumKey (void *buffer, int length, int key); int Com_HashKey(char *string, int maxlen); int Com_Filter(char *filter, char *name, int casesensitive); int Com_FilterPath(char *filter, char *name, int casesensitive); int Com_RealTime(qtime_t *qtime); qboolean Com_SafeMode( void ); void Com_StartupVariable( const char *match ); // checks for and removes command line "+set var arg" constructs // if match is NULL, all set commands will be executed, otherwise // only a set with the exact name. Only used during startup. extern cvar_t *com_developer; extern cvar_t *com_dedicated; extern cvar_t *com_speeds; extern cvar_t *com_timescale; extern cvar_t *com_sv_running; extern cvar_t *com_cl_running; extern cvar_t *com_viewlog; // 0 = hidden, 1 = visible, 2 = minimized extern cvar_t *com_version; extern cvar_t *com_blood; extern cvar_t *com_buildScript; // for building release pak files extern cvar_t *com_journal; extern cvar_t *com_cameraMode; // both client and server must agree to pause extern cvar_t *cl_paused; extern cvar_t *sv_paused; // com_speeds times extern int time_game; extern int time_frontend; extern int time_backend; // renderer backend time extern int com_frameTime; extern int com_frameMsec; extern qboolean com_errorEntered; extern fileHandle_t com_journalFile; extern fileHandle_t com_journalDataFile; typedef enum { TAG_FREE, TAG_GENERAL, TAG_BOTLIB, TAG_RENDERER, TAG_SMALL, TAG_STATIC } memtag_t; /* --- low memory ---- server vm server clipmap ---mark--- renderer initialization (shaders, etc) UI vm cgame vm renderer map renderer models ---free--- temp file loading --- high memory --- */ #if defined(_DEBUG) && !defined(BSPC) #define ZONE_DEBUG #endif #ifdef ZONE_DEBUG #define Z_TagMalloc(size, tag) Z_TagMallocDebug(size, tag, #size, __FILE__, __LINE__) #define Z_Malloc(size) Z_MallocDebug(size, #size, __FILE__, __LINE__) #define S_Malloc(size) S_MallocDebug(size, #size, __FILE__, __LINE__) void *Z_TagMallocDebug( int size, int tag, char *label, char *file, int line ); // NOT 0 filled memory void *Z_MallocDebug( int size, char *label, char *file, int line ); // returns 0 filled memory void *S_MallocDebug( int size, char *label, char *file, int line ); // returns 0 filled memory #else void *Z_TagMalloc( int size, int tag ); // NOT 0 filled memory void *Z_Malloc( int size ); // returns 0 filled memory void *S_Malloc( int size ); // NOT 0 filled memory only for small allocations #endif void Z_Free( void *ptr ); void Z_FreeTags( int tag ); int Z_AvailableMemory( void ); void Z_LogHeap( void ); void Hunk_Clear( void ); void Hunk_ClearToMark( void ); void Hunk_SetMark( void ); qboolean Hunk_CheckMark( void ); void Hunk_ClearTempMemory( void ); void *Hunk_AllocateTempMemory( int size ); void Hunk_FreeTempMemory( void *buf ); int Hunk_MemoryRemaining( void ); void Hunk_Log( void); void Hunk_Trash( void ); void Com_TouchMemory( void ); // commandLine should not include the executable name (argv[0]) void Com_Init( char *commandLine ); void Com_Frame( void ); void Com_Shutdown( void ); /* ============================================================== CLIENT / SERVER SYSTEMS ============================================================== */ // // client interface // void CL_InitKeyCommands( void ); // the keyboard binding interface must be setup before execing // config files, but the rest of client startup will happen later void CL_Init( void ); void CL_Disconnect( qboolean showMainMenu ); void CL_Shutdown( void ); void CL_Frame( int msec ); qboolean CL_GameCommand( void ); void CL_KeyEvent (int key, qboolean down, unsigned time); void CL_CharEvent( int key ); // char events are for field typing, not game control void CL_MouseEvent( int dx, int dy, int time ); void CL_JoystickEvent( int axis, int value, int time ); void CL_PacketEvent( netadr_t from, msg_t *msg ); void CL_ConsolePrint( char *text ); void CL_MapLoading( void ); // do a screen update before starting to load a map // when the server is going to load a new map, the entire hunk // will be cleared, so the client must shutdown cgame, ui, and // the renderer void CL_ForwardCommandToServer( const char *string ); // adds the current command line as a clc_clientCommand to the client message. // things like godmode, noclip, etc, are commands directed to the server, // so when they are typed in at the console, they will need to be forwarded. void CL_CDDialog( void ); // bring up the "need a cd to play" dialog void CL_ShutdownAll( void ); // shutdown all the client stuff void CL_FlushMemory( void ); // dump all memory on an error void CL_StartHunkUsers( void ); // start all the client stuff using the hunk void Key_WriteBindings( fileHandle_t f ); // for writing the config files void S_ClearSoundBuffer( void ); // call before filesystem access void SCR_DebugGraph (float value, int color); // FIXME: move logging to common? // // server interface // void SV_Init( void ); void SV_Shutdown( char *finalmsg ); void SV_Frame( int msec ); void SV_PacketEvent( netadr_t from, msg_t *msg ); qboolean SV_GameCommand( void ); // // UI interface // qboolean UI_GameCommand( void ); qboolean UI_usesUniqueCDKey(); /* ============================================================== NON-PORTABLE SYSTEM SERVICES ============================================================== */ typedef enum { AXIS_SIDE, AXIS_FORWARD, AXIS_UP, AXIS_ROLL, AXIS_YAW, AXIS_PITCH, MAX_JOYSTICK_AXIS } joystickAxis_t; typedef enum { // bk001129 - make sure SE_NONE is zero SE_NONE = 0, // evTime is still valid SE_KEY, // evValue is a key code, evValue2 is the down flag SE_CHAR, // evValue is an ascii char SE_MOUSE, // evValue and evValue2 are reletive signed x / y moves SE_JOYSTICK_AXIS, // evValue is an axis number and evValue2 is the current state (-127 to 127) SE_CONSOLE, // evPtr is a char* SE_PACKET // evPtr is a netadr_t followed by data bytes to evPtrLength } sysEventType_t; typedef struct { int evTime; sysEventType_t evType; int evValue, evValue2; int evPtrLength; // bytes of data pointed to by evPtr, for journaling void *evPtr; // this must be manually freed if not NULL } sysEvent_t; sysEvent_t Sys_GetEvent( void ); void Sys_Init (void); // general development dll loading for virtual machine testing // fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time void * QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...), int (QDECL *systemcalls)(int, ...) ); void Sys_UnloadDll( void *dllHandle ); void Sys_UnloadGame( void ); void *Sys_GetGameAPI( void *parms ); void Sys_UnloadCGame( void ); void *Sys_GetCGameAPI( void ); void Sys_UnloadUI( void ); void *Sys_GetUIAPI( void ); //bot libraries void Sys_UnloadBotLib( void ); void *Sys_GetBotLibAPI( void *parms ); char *Sys_GetCurrentUser( void ); void QDECL Sys_Error( const char *error, ...); void Sys_Quit (void); char *Sys_GetClipboardData( void ); // note that this isn't journaled... void Sys_Print( const char *msg ); // Sys_Milliseconds should only be used for profiling purposes, // any game related timing information should come from event timestamps int Sys_Milliseconds (void); void Sys_SnapVector( float *v ); // the system console is shown when a dedicated server is running void Sys_DisplaySystemConsole( qboolean show ); int Sys_GetProcessorId( void ); void Sys_BeginStreamedFile( fileHandle_t f, int readahead ); void Sys_EndStreamedFile( fileHandle_t f ); int Sys_StreamedRead( void *buffer, int size, int count, fileHandle_t f ); void Sys_StreamSeek( fileHandle_t f, int offset, int origin ); void Sys_ShowConsole( int level, qboolean quitOnClose ); void Sys_SetErrorText( const char *text ); void Sys_SendPacket( int length, const void *data, netadr_t to ); qboolean Sys_StringToAdr( const char *s, netadr_t *a ); //Does NOT parse port numbers, only base addresses. qboolean Sys_IsLANAddress (netadr_t adr); void Sys_ShowIP(void); qboolean Sys_CheckCD( void ); void Sys_Mkdir( const char *path ); char *Sys_Cwd( void ); void Sys_SetDefaultCDPath(const char *path); char *Sys_DefaultCDPath(void); void Sys_SetDefaultInstallPath(const char *path); char *Sys_DefaultInstallPath(void); void Sys_SetDefaultHomePath(const char *path); char *Sys_DefaultHomePath(void); char **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs ); void Sys_FreeFileList( char **list ); void Sys_BeginProfiling( void ); void Sys_EndProfiling( void ); qboolean Sys_LowPhysicalMemory(); unsigned int Sys_ProcessorCount(); int Sys_MonkeyShouldBeSpanked( void ); /* This is based on the Adaptive Huffman algorithm described in Sayood's Data * Compression book. The ranks are not actually stored, but implicitly defined * by the location of a node within a doubly-linked list */ #define NYT HMAX /* NYT = Not Yet Transmitted */ #define INTERNAL_NODE (HMAX+1) typedef struct nodetype { struct nodetype *left, *right, *parent; /* tree structure */ struct nodetype *next, *prev; /* doubly-linked list */ struct nodetype **head; /* highest ranked node in block */ int weight; int symbol; } node_t; #define HMAX 256 /* Maximum symbol */ typedef struct { int blocNode; int blocPtrs; node_t* tree; node_t* lhead; node_t* ltail; node_t* loc[HMAX+1]; node_t** freelist; node_t nodeList[768]; node_t* nodePtrs[768]; } huff_t; typedef struct { huff_t compressor; huff_t decompressor; } huffman_t; void Huff_Compress(msg_t *buf, int offset); void Huff_Decompress(msg_t *buf, int offset); void Huff_Init(huffman_t *huff); void Huff_addRef(huff_t* huff, byte ch); int Huff_Receive (node_t *node, int *ch, byte *fin); void Huff_transmit (huff_t *huff, int ch, byte *fout); void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset); void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset); void Huff_putBit( int bit, byte *fout, int *offset); int Huff_getBit( byte *fout, int *offset); extern huffman_t clientHuffTables; #define SV_ENCODE_START 4 #define SV_DECODE_START 12 #define CL_ENCODE_START 12 #define CL_DECODE_START 4 #endif // _QCOMMON_H_
[ "" ]
07d3a145fe7a311720173102b61fb493ab5698a0
a936bd820013210ee8691e5bdb471dd0901f8ef0
/inc/to_wordtab.h
79ca2febd3dc000b30f6386270fc95e3064f15e7
[]
no_license
ValXp/my_irc
84f32057ac335582f11b1d5add3613df0fe5b6f4
52d6d39226f19e031b0320594b20f49454e83c3b
refs/heads/master
2021-01-23T20:12:47.880339
2015-06-12T17:49:16
2015-06-12T17:49:16
12,162,835
0
0
null
null
null
null
UTF-8
C
false
false
357
h
/* ** to_wordtab.h for my_irc in /home/horner_v/tek2/c/my_irc ** ** Made by Valentin Horner ** Login <horner_v@epitech.net> ** ** Started on Wed Apr 21 17:09:28 2010 Valentin Horner ** Last update Wed Apr 21 17:09:50 2010 Valentin Horner */ #ifndef TO_WORDTAB_H_ # define TO_WORDTAB_H_ char **to_wordtab(char *total_get); #endif /* TO_WORDTAB_H_ */
[ "vhorner@tripadvisor.com" ]
vhorner@tripadvisor.com
7a6936325243ed3e3fb6d0b331e4c6fb4797c8f8
4f1d319133a467466a99c5197b519f73fd73e1f1
/src/osd/sdl/dview.h
488aaa1c61833c18b0c7b6f847698d635ad75fc3
[]
no_license
AltimorTASDK/shmupmametgm
5da401800c7c435b1c3a5a927ba5bc15a6e056cd
2911e3cf43d04a3d1587a48a63352c42647cc9e6
refs/heads/master
2021-01-13T00:50:22.251435
2015-12-13T18:16:27
2015-12-13T18:16:27
47,025,375
3
3
null
2017-02-05T01:09:53
2015-11-28T13:55:58
C
UTF-8
C
false
false
1,332
h
#ifndef DVIEW_H #define DVIEW_H #include <gtk/gtk.h> #include "emu.h" #include "video.h" #include "osdepend.h" #include "debug/debugvw.h" #include "debug/debugcon.h" #include "debug/debugcpu.h" GType dview_get_type(void); #define DVIEW_TYPE (dview_get_type()) #define DVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DVIEW_TYPE, DView)) #define DVIEW_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST((obj), DVIEW, DViewClass)) #define IS_DVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), DVIEW_TYPE)) #define IS_DVIEW_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((obj), DVIEW_TYPE)) #define DVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), DVIEW_TYPE, DViewClass)) typedef struct _DViewClass DViewClass; typedef struct _DView DView; struct _DViewClass { GtkContainerClass parent_class; PangoFontDescription *fixedfont; int fixedfont_width, fixedfont_height; }; struct _DView { GtkContainer parent; GtkAdjustment *hadj, *vadj; GtkWidget *hscrollbar, *vscrollbar; int hsz, vsz; int hs, vs; int tr, tc; gchar *name; PangoLayout *playout; GdkGC *gc; debug_view *view; int dv_type; }; GtkWidget *dview_new(const gchar *widget_name, const gchar *string1, const gchar *string2, gint int1, gint int2); void dview_set_debug_view(DView *dv, running_machine *machine, int type); #endif
[ "altimormc@gmail.com" ]
altimormc@gmail.com
38c8e163af72fa371a2b5581041bfe10f5ba50d6
6fab035296f5122c10bb53eed6591c0bbbbdeeb1
/Conditionally.h
676caf011bf5f17118bf8e39eb08398d66aa3d32
[ "MIT" ]
permissive
robskillington/objc-conditionally
3d32ba7ea80cfb29ef6953929be52057b93cfd27
2e80a6d90c8f8b798714b72f644a1e4a90f4bc5a
refs/heads/master
2021-01-18T23:57:07.647960
2014-08-14T00:14:23
2014-08-14T00:14:23
null
0
0
null
null
null
null
UTF-8
C
false
false
695
h
// // Conditionally.h // MIT License: https://github.com/robskillington/objc-conditionally/blob/master/LICENSE // Rob Skillington // static const NSTimeInterval ConditionalExecuteBlockTestInterval = 0.01; static const NSTimeInterval ConditionalExecuteBlockTimeout = 2.0; typedef BOOL (^ConditionalTestBlock)(); typedef void (^ExecuteBlock)(); typedef ExecuteBlock (^ConditionalExecuteBlock)(ConditionalTestBlock tester, ExecuteBlock exec, id next); // Chaining methods void conditionallyChain(ExecuteBlock first); ExecuteBlock conditionallyNext(ConditionalTestBlock tester, ExecuteBlock exec, ExecuteBlock next); ExecuteBlock conditionally(ConditionalTestBlock tester, ExecuteBlock exec);
[ "rob.skillington@gmail.com" ]
rob.skillington@gmail.com
85ad8d9beff3706cf04f73aa1c60734602694102
fb0669ad61a375ae3bdb9b57bd44c35be14f90d2
/src/listener.h
b5a889fe6377800af9b9aaf80c6586c9165648d2
[]
no_license
saxenasaurabh/indoor-3d-mapping-turtlebot
fd0d94fb0b23a9b0239c850d7c48765aeed2ad54
eb829b21d0c345eaa9684791ed5a670265c08f32
refs/heads/master
2021-01-01T18:49:31.912983
2015-01-13T00:14:03
2015-01-13T00:14:03
29,119,252
2
0
null
null
null
null
UTF-8
C
false
false
46
h
bool get_current_orientation (double arr[4]);
[ "saxena.saurabh90@gmail.com" ]
saxena.saurabh90@gmail.com
cc182956b4c019e247f244dc7f59ac2c66ffa545
818cb9cb4ee6e52db8ded109a198f72cfe1c600c
/stm32f103_i2c1/src/i2c.h
1f1b5b7bbc18602f388e6a8e7c814f78afe5cd18
[]
no_license
Fullmoon12185/HY-MiniSTM32V
927a7da43e3201ac3d7b902ed8c881424859dc8c
98275e8a36007638c6a4028f5e5d23457a6791d1
refs/heads/master
2020-09-29T23:27:31.655936
2019-03-18T19:05:23
2019-03-18T19:05:23
null
0
0
null
null
null
null
UTF-8
C
false
false
182
h
#ifndef _I2C_H_ #define _I2C_H_ #include "stm32f10x_conf.h" void i2c_init(); void write_pcf8574(uint8_t addr, uint8_t data); uint8_t read_pcf8574(uint8_t addr); #endif // _I2C_H_
[ "nils.stec@gmail.com" ]
nils.stec@gmail.com
686197567763009a8812e31185d0c5a2e3bfa9fd
eaef7a8d2241cee298c1e02ffa5aa0a89de1bf08
/Structs/main.c
e82a59d9d33fa713fea2f3b11fa81e6cceddf6f4
[]
no_license
Euby/fCC-Beginners-C
11903eb26791d83ca3952fdbde68aee3e2dfed22
cfe94d1539b12f2404351cb6b1b95a2dcd432061
refs/heads/master
2022-11-23T01:08:36.088252
2020-07-31T06:00:37
2020-07-31T06:00:37
283,830,994
0
0
null
null
null
null
UTF-8
C
false
false
640
c
#include<stdio.h> #include<stdlib.h> #include<string.h> struct Student{ char name[50]; char major[50]; int age; double gpa; }; int main(void){ struct Student student1; student1.age = 18; student1.gpa = 3.2; strcpy(student1.name, "Christopher Euabanks"); strcpy(student1.major, "Computer Science"); struct Student student2; student2.age = 22; student2.gpa = 3.8; strcpy(student2.name, "Yeetboi 2000"); strcpy(student2.major, "Music"); printf("%s has a %f GPA.\n", student1.name, student1.gpa); printf("%s has a %f GPA.\n", student2.name, student2.gpa); return 0; }
[ "ceubanks06@gmail.com" ]
ceubanks06@gmail.com
834f348a38c3f412467849641d2d2a7d144d205c
02a087e8de0a7d0cfed9dba60e8cff5be4ae3be1
/Research_Bucket/Completed_Archived/ConcolicProcess/oracles/Bellon/bellon_benchmark/sourcecode/cook/src/cook/graph/run.h
b8e5449e85054e967c0f0e78f7289b476ca05e53
[]
no_license
dan7800/Research
7baf8d5afda9824dc5a53f55c3e73f9734e61d46
f68ea72c599f74e88dd44d85503cc672474ec12a
refs/heads/master
2021-01-23T09:50:47.744309
2018-09-01T14:56:01
2018-09-01T14:56:01
32,521,867
1
1
null
null
null
null
UTF-8
C
false
false
1,197
h
/* * cook - file construction tool * Copyright (C) 1997 Peter Miller; * 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 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * MANIFEST: interface definition for cook/graph/run.c */ #ifndef COOK_GRAPH_RUN_H #define COOK_GRAPH_RUN_H #include <graph/walk.h> struct graph_ty; /* existence */ struct graph_recipe_ty; /* existence */ graph_walk_status_ty graph_recipe_run _((struct graph_recipe_ty *, struct graph_ty *)); #endif /* COOK_GRAPH_RUN_H */
[ "dxkvse@rit.edu" ]
dxkvse@rit.edu
2a3be8cd6d51e4cdb4c5f4302682cfd0610aa6f9
9e5d4a9ecc98ab56d872e20af63f73765b0fca1f
/Pods/Headers/Build/CoconutKit/NSArray+HLSExtensions.h
59f69b2c8842a31e30f16aa13f610b907ad4d188
[]
no_license
defagos/CoconutKit-BindingsHandsOn
561f1cbb5f761a1896c196ede3b65c8d52424a6f
199c87cf70338cddc86c5117a9582a44f5c139d2
refs/heads/master
2021-01-25T05:22:03.217719
2014-11-26T08:25:01
2014-11-26T08:25:01
null
0
0
null
null
null
null
UTF-8
C
false
false
67
h
../../../CoconutKit/CoconutKit/Sources/Core/NSArray+HLSExtensions.h
[ "defagos@gmail.com" ]
defagos@gmail.com
4fb6e3c034b043fe79aee163bfe5acba1091636c
124654a44848d44db4f190b0f166122184293f24
/C Programms/Fibonacci.c
1f0594d54b1f93650f5d2334d0b048695434c002
[]
no_license
Prachi-2001/github-fest-2021
f1d2083fb4b38914a63fe8d48d3e0fc08c90b98a
66aab9a841d43f92e287bfcd93b160250399736f
refs/heads/main
2023-08-15T21:41:48.181292
2021-10-19T14:55:23
2021-10-19T14:55:23
418,961,435
1
0
null
2021-10-19T14:31:31
2021-10-19T14:31:31
null
UTF-8
C
false
false
246
c
#include<stdio.h> void main() { int a,b,next,n,i; printf("enter number of terms"); scanf("%d",&n); a=0; b=1; for(i=1;i<=n;i++) { next=a+b; a=b; b=next; printf("%d ",a); } }
[ "noreply@github.com" ]
Prachi-2001.noreply@github.com
44ed14cb026c55e84eb1bd55bb2b915b60d953b7
3d7d23cc85221a614cd08bda63121fb56d776aae
/glfw-3.2.1/include/GLFW/glfw3.h
7666ff610f99a56e925d17de28bfa967dd55c913
[]
no_license
wesstr/tessellation
53832badcad9284c0dfd5d8a616c8d208295f100
1d9fc54c320e76c9b302499c377b9064fe341b66
refs/heads/master
2021-08-23T22:07:10.419337
2017-12-06T19:41:23
2017-12-06T19:41:23
113,143,118
3
0
null
null
null
null
UTF-8
C
false
false
131
h
version https://git-lfs.github.com/spec/v1 oid sha256:58cb6576c30b9a4d67f4041ab713da850eabafafb2c14d23e1c5a500654788dd size 152470
[ "wesstr@gmail.com" ]
wesstr@gmail.com
2e1ba944c817047a373ca0105b4ecd2113b66f88
d3712eb8d530dd4eac13eebb8f50e87fc7b36e7e
/PushPillClient/DerivedData/PushPill/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-PushPill.build/DerivedSources/Pods_PushPill_vers.c
e6b1641c4a5bc0814d90a30d7bf3e0f45c1f08a6
[]
no_license
teamsokal/PushPill
9a5e16b87094ad7941a27341aaace75ef7a7d525
066305f05c1e38a53cd6f387bd764e5cac24ce15
refs/heads/master
2021-01-01T05:13:46.183721
2016-04-25T01:47:59
2016-04-25T01:47:59
56,678,919
0
0
null
null
null
null
UTF-8
C
false
false
202
c
const unsigned char Pods_PushPillVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:Pods_PushPill PROJECT:Pods-1" "\n"; const double Pods_PushPillVersionNumber __attribute__ ((used)) = (double)1.;
[ "gaeunkim913@gmail.com" ]
gaeunkim913@gmail.com
5f2197d41d8e2f08a1d32677cfb830c73894103e
aa3183321d2b5ab55df0943070e215af9c69386d
/lab10/macro_func.c
f96b24e975ef2857cc2fa3f4de45aec7d7e19882
[]
no_license
JoosJuliet/c
5d906d7bebf83d49e79f93db35023c2f933fcf42
a667b80419c00428e7b7294b0861c9bf76f2d9fd
refs/heads/master
2021-08-27T22:25:42.593803
2017-12-10T15:05:18
2017-12-10T15:05:18
null
0
0
null
null
null
null
UTF-8
C
false
false
713
c
#include <stdio.h> #define SQUARE(x) ((x)*(x)) #define ADD(x,y,z) ((x)+(y)+(z)) #define MUL(x,y,z) ((x)*(y)*(z)) #define MIN(x,y) (((x)<(y))? (x):(y)) #define MIN4(x,y,z,w) MIN(MIN(x,y), MIN(z,w)) #define WRONG_SQUARE(x) x*x #define PI 3.14159 #define AREA_CIRCLE(x) ((PI)*(x)*(x)) int main(void) { int a= 3,b=4,c=5,d=6; printf("SQUARE(a): %d\n", SQUARE(a)); printf("ADD(a,b,c): %d\n", ADD(a,b,c)); printf("MUL(a,b,c): %d\n", MUL(a,b,c)); printf("MIN(a,b): %d\n", MIN(a,b)); printf("MIN4(a,b,c,d): %d\n", MIN4(a,b,c,d)); printf("WRONG_SQUARE(a+b): %d?\n", WRONG_SQUARE(a+b)); printf("AREA_CIRCLE(1): %f\n", AREA_CIRCLE(1)); printf("AREA_CIRCLE(5): %f\n", AREA_CIRCLE(5)); return 0 ; }
[ "saven7788@gmail.com" ]
saven7788@gmail.com
0825592e53ba7046f2026b08e439232d380ebc0a
c14b295f793b0ea3cdfdfc185c3a4b5a382fb14e
/0x05-pointers_arrays_strings/0-main.c
9938daea095eba90e41bdd3e63f3e79db4cbb93f
[]
no_license
macoyulloa/holbertonschool-low_level_programming
2b87acc374e8d71a8f07eec15e20b4bff2bbe943
291a7290e2144eed0f0c877a8107b0e31d2a69a5
refs/heads/master
2020-04-21T09:02:19.247265
2019-08-29T23:48:08
2019-08-29T23:48:08
169,436,484
0
0
null
null
null
null
UTF-8
C
false
false
356
c
#include "holberton.h" #include <stdio.h> /** * main - check the code for Holberton School students. * * Return: Always 0. */ int main(void) { char s1[98] = "Hello "; char s2[] = "World!\n"; char *p; printf("%s\n", s1); printf("%s", s2); p = _strcat(s1, s2); printf("%s", s1); printf("%s", s2); printf("%s", p); return (0); }
[ "malejacoy@hotmail.com" ]
malejacoy@hotmail.com
f5c51e2a4bac01595de5cebdb3f46d6a3f423a98
2c78de0b151238b1c0c26e6a4d1a36c7fa09268c
/common/components/rtl/external/Embarcadero/DelphiBerlin/cpprtl/Source/startup/rawdll.c
987f7ed5397312653a3a174a65879a6d6b3b7f00
[]
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
443
c
/*-----------------------------------------------------------------------* * filename - rawdll.c * *-----------------------------------------------------------------------*/ /* * C/C++ Run Time Library - Version 24.0 * * Copyright (c) 1995, 2016 by Embarcadero Technologies, Inc. * All Rights Reserved. * */ /* $Revision: 23293 $ */ #include <ntbc.h> BOOL (WINAPI *_pRawDllMain)(HINSTANCE, DWORD, LPVOID);
[ "lulinalex@gmail.com" ]
lulinalex@gmail.com
7e81e080c10c76f97aef06c0a42dbcf598b3d785
4045ca0933bbccd556c8cd251ecba512c8e1383d
/src/include/dare/dare_kvs_sm.h
575f5145386481c76cf628011021617bddc39a6e
[ "BSD-3-Clause-Open-MPI" ]
permissive
wnagchenghku/RDMA-PAXOS
64372cff3c1e658a7c33137f728e0ce8c301a6cd
9fd851b959800aadd8b74ccee61e9d4fc8b34b63
refs/heads/master
2020-05-29T14:04:52.502763
2019-06-07T04:52:49
2019-06-07T04:52:49
189,182,791
0
0
NOASSERTION
2019-05-29T08:24:44
2019-05-29T08:24:44
null
UTF-8
C
false
false
999
h
/** * DARE (Direct Access REplication) * * State machine implementation (KVS) * * Copyright (c) 2014-2015 ETH-Zurich. All rights reserved. * * Author(s): Marius Poke <marius.poke@inf.ethz.ch> * */ #ifndef DARE_KVS_SM_H #define DARE_KVS_SM_H #define __STDC_FORMAT_MACROS #include <inttypes.h> #include "./dare_sm.h" #define DEFAULT_KVS_SIZE 1024 #define KEY_SIZE 64 /* KVS commands */ #define KVS_PUT 1 #define KVS_GET 2 #define KVS_RM 3 /* KVS command */ struct kvs_cmd_t { uint8_t type; // read, write, delete char key[KEY_SIZE]; uint16_t len; uint8_t data[0]; }; typedef struct kvs_cmd_t kvs_cmd_t; struct kvs_blob_t { uint16_t len; void *data; }; typedef struct kvs_blob_t kvs_blob_t; struct kvs_entry_t { char key[KEY_SIZE]; kvs_blob_t blob; }; typedef struct kvs_entry_t kvs_entry_t; #endif /* DARE_KVS_SM_H */
[ "you@example.com" ]
you@example.com
c4fc7f178872d84fa16efb7f9920ad174a396aa9
3ac819ce9d1ac47712238d91e77a47446841821b
/driver/retimer/nb7v904m.c
81fd5abc93be4e3fcde120563625204132869c39
[ "BSD-3-Clause" ]
permissive
platinasystems/chrome-ec
cd638b8f86076cb01e5048ca51a63e4adbfbac85
ce143d577fa85acae86ae372a7521d7def6c2391
refs/heads/master
2021-01-12T13:00:38.698345
2020-02-19T16:48:06
2020-02-27T14:35:48
69,767,954
1
0
null
null
null
null
UTF-8
C
false
false
3,492
c
/* Copyright 2020 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * * ON Semiconductor NB7V904M USB Type-C DisplayPort Alt Mode Redriver */ #include <stdbool.h> #include "common.h" #include "console.h" #include "ec_commands.h" #include "i2c.h" #include "nb7v904m.h" #include "usb_mux.h" #define CPRINTS(format, args...) cprints(CC_USB, format, ## args) #define CPRINTF(format, args...) cprintf(CC_USB, format, ## args) static int nb7v904m_write(int port, int offset, int data) { return i2c_write8(usb_retimers[port].i2c_port, usb_retimers[port].i2c_addr_flags, offset, data); } static int nb7v904m_read(int port, int offset, int *regval) { return i2c_read8(usb_retimers[port].i2c_port, usb_retimers[port].i2c_addr_flags, offset, regval); } static int set_low_power_mode(int port, bool enable) { int regval; int rv; rv = nb7v904m_read(port, NB7V904M_REG_GEN_DEV_SETTINGS, &regval); if (rv) return rv; if (enable) regval |= NB7V904M_CHIP_EN; else regval &= ~NB7V904M_CHIP_EN; return nb7v904m_write(port, NB7V904M_REG_GEN_DEV_SETTINGS, regval); } static int nb7v904m_enter_low_power_mode(int port) { int rv = set_low_power_mode(port, 1); if (rv) CPRINTS("C%d: NB7V904M: Failed to enter low power mode!", port); return rv; } static int nb7v904m_init(int port) { int rv = set_low_power_mode(port, 0); if (rv) CPRINTS("C%d: NB7V904M: init failed!", port); return rv; } static int nb7v904m_set_mux(int port, mux_state_t mux_state) { int rv = EC_SUCCESS; int regval; int flipped = !!(mux_state & USB_PD_MUX_POLARITY_INVERTED); /* Turn off redriver if it's not needed at all. */ if (mux_state == USB_PD_MUX_NONE) return nb7v904m_enter_low_power_mode(port); rv = nb7v904m_init(port); if (rv) return rv; /* Clear operation mode field */ rv = nb7v904m_read(port, NB7V904M_REG_GEN_DEV_SETTINGS, &regval); if (rv) { CPRINTS("C%d %s: Failed to obtain dev settings!", port, __func__); return rv; } regval &= ~NB7V904M_OP_MODE_MASK; if (mux_state & USB_PD_MUX_USB_ENABLED) { /* USB with DP */ if (mux_state & USB_PD_MUX_DP_ENABLED) { if (flipped) regval |= NB7V904M_USB_DP_FLIPPED; else regval |= NB7V904M_USB_DP_NORMAL; } else { /* USB only */ regval |= NB7V904M_USB_ONLY; } } else if (mux_state & USB_PD_MUX_DP_ENABLED) { /* 4 lanes DP */ regval |= NB7V904M_DP_ONLY; } if (mux_state & USB_PD_MUX_DP_ENABLED) { /* Connect AUX */ rv = nb7v904m_write(port, NB7V904M_REG_AUX_CH_CTRL, flipped ? NB7V904M_AUX_CH_FLIPPED : NB7V904M_AUX_CH_NORMAL); /* Enable all channels for DP */ regval |= NB7V904M_CH_EN_MASK; } else { /* Disconnect AUX since it's not being used. */ rv = nb7v904m_write(port, NB7V904M_REG_AUX_CH_CTRL, NB7V904M_AUX_CH_HI_Z); /* Disable the unused channels to save power */ regval &= ~NB7V904M_CH_EN_MASK; if (flipped) { /* Only enable channels A & B */ regval |= NB7V904M_CH_A_EN | NB7V904M_CH_B_EN; } else { /* Only enable channels C & D */ regval |= NB7V904M_CH_C_EN | NB7V904M_CH_D_EN; } } rv |= nb7v904m_write(port, NB7V904M_REG_GEN_DEV_SETTINGS, regval); if (rv) CPRINTS("C%d: %s failed!", port, __func__); return rv; } const struct usb_retimer_driver nb7v904m_usb_redriver_drv = { .enter_low_power_mode = &nb7v904m_enter_low_power_mode, .init = &nb7v904m_init, .set = &nb7v904m_set_mux, };
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
4dac9318871220a7cebdb5c6b01fc08d41dece2c
e4224daa874a49f513999545068e61b990c8df92
/src/main/tunnel/nt_distributor.h
75f2b2412423707750daf9246887c6014b0e51f1
[]
no_license
goldolphin/nettle
4d434f84960d9b74515868d410d705d31af0d279
61913d04c5c3060deac29339e7967d9eea9e1033
refs/heads/master
2021-01-22T22:20:00.836614
2017-03-23T09:10:20
2017-03-23T09:10:20
85,928,401
2
0
null
null
null
null
UTF-8
C
false
false
1,286
h
/** * @author caofuxiang * 2015-07-01 14:44:44. */ #ifndef NETTLE_NT_DISTRIBUTOR_H #define NETTLE_NT_DISTRIBUTOR_H #include <dispatcher/common.h> typedef struct { address_t src; address_t dst; } nt_path_t; const char * parse_address(address_t * address, const char * str); const char * parse_path(nt_path_t * path, const char *str); const char * parse_paths(nt_path_t * paths, int * num /* inout */, const char *str); const char * parse_seq2addr(int *seq2addr, int seq_num, int dup_num, const char * str); bool sbuilder_path(sbuilder_t * builder, const nt_path_t *path); typedef struct { nt_path_t * paths; int path_num; int *seq2addr; int seq_num; int dup_num; } nt_distributor_t; bool nt_distributor_init(nt_distributor_t * distributor, nt_path_t * paths, int path_num, int *seq2addr, int seq_num, int dup_num); static inline nt_path_t * nt_distributor_select(nt_distributor_t * distributor, int seq, int dup) { if(dup >= distributor->dup_num) return NULL; int n = distributor->seq2addr[(seq % distributor->seq_num)*distributor->dup_num + dup]; if (n < 0) return NULL; return &distributor->paths[n]; } bool sbuilder_distributor(sbuilder_t * builder, nt_distributor_t * distributor); #endif //NETTLE_NT_DISTRIBUTOR_H
[ "goldolphin@gmail.com" ]
goldolphin@gmail.com
d373e7b008b57a5ddfcd0659983c420adcfa2941
26340f693988d3ade2b2893a42f2e2776ab8a102
/program/2_19.c
8fad7a325e504fd5486fdcc247bbfb5828101015
[]
no_license
yeon0926/C
c52c5e208ff36040c775e2a9f81c3d639195407b
ba213f8588743e79fffe69d398c92381ada96583
refs/heads/main
2023-03-12T21:33:28.090652
2021-03-06T06:15:05
2021-03-06T06:15:05
344,485,764
0
0
null
null
null
null
UTF-8
C
false
false
244
c
#include <stdio.h> /*함수를 사용하기 위해 정의한다. */ func() { printf("running function\n"); } main() { printf("before function call\n"); func(); /*함수가 실행되도록 호출한다.*/ printf("after function call\n"); }
[ "noreply@github.com" ]
yeon0926.noreply@github.com
73db95df57dfb6f6951433c9fdd550c6cb1fb505
0f4b65bdd99e642402d489fdd662a7dc1d1441f5
/testsuite/EXP_4/test1676.c
ee3deab4c753a012b7401762b3dc944e2d27d143
[ "MIT" ]
permissive
matthiaskrgr/CF3
157e4967f12a6e6a0eee0fa9421f7855d24047c5
981a49c2b1f0fb80e1d1778beb3f3ce8578338c3
refs/heads/master
2021-01-01T06:02:05.773732
2017-07-15T20:15:36
2017-07-15T20:15:36
97,335,407
0
0
null
2017-07-15T18:41:20
2017-07-15T18:41:20
null
UTF-8
C
false
false
52,102
c
/* CF3 Copyright (c) 2015 ishiura-lab. Released under the MIT license. https://github.com/ishiura-compiler/CF3/MIT-LICENSE.md */ #include<stdio.h> #include<stdint.h> #include<stdlib.h> #include"test1.h" volatile uint8_t x5 = 9U; volatile int8_t x8 = 6; static uint32_t x9 = UINT32_MAX; int64_t x11 = -1LL; int64_t x12 = 0LL; uint32_t x13 = UINT32_MAX; int16_t x14 = -7789; int32_t x20 = INT32_MAX; volatile int32_t t5 = -111507; static uint16_t x28 = UINT16_MAX; int16_t x30 = INT16_MIN; static int32_t x32 = INT32_MAX; volatile int8_t x34 = 1; static uint16_t x37 = 12717U; volatile int8_t x40 = -1; int64_t x43 = -3153599649LL; volatile int32_t t11 = -2086931; volatile int16_t x52 = 774; uint8_t x58 = 2U; int32_t t15 = 3; static uint64_t x65 = UINT64_MAX; uint64_t x70 = 13117672427LLU; volatile int32_t t19 = -3; static volatile uint64_t x82 = 3748829082LLU; uint8_t x95 = UINT8_MAX; volatile int32_t t23 = -1; static volatile int32_t t25 = -15; static int64_t x109 = INT64_MIN; volatile uint16_t x111 = 38U; int8_t x116 = 1; int32_t t28 = -1933; static uint16_t x117 = 1684U; uint8_t x119 = 4U; static int8_t x120 = -1; uint32_t x123 = 409007U; volatile int32_t t30 = -1034999; int8_t x125 = INT8_MIN; int32_t x126 = -47489145; volatile int8_t x128 = -1; int8_t x141 = INT8_MIN; volatile int16_t x144 = -1; static volatile int32_t x151 = -1; static int8_t x152 = -14; int32_t x160 = -1; int32_t x165 = INT32_MAX; int64_t x169 = -1LL; int64_t x184 = INT64_MAX; static volatile int32_t t49 = 48069; volatile int32_t t50 = 20; int32_t x208 = INT32_MIN; static volatile int32_t t53 = -110855; uint64_t x217 = 3919100929LLU; uint16_t x219 = 0U; volatile int32_t x231 = INT32_MIN; volatile int32_t t57 = -6979060; int64_t x237 = INT64_MIN; volatile int16_t x244 = 0; int32_t x245 = -1; int64_t x250 = INT64_MAX; int8_t x255 = 1; int32_t x256 = -1; static int16_t x260 = INT16_MIN; static volatile uint32_t x266 = UINT32_MAX; uint16_t x267 = 485U; static int16_t x269 = INT16_MIN; int16_t x276 = INT16_MAX; volatile int32_t t68 = -833; static volatile int32_t t69 = 397436172; volatile int32_t t72 = -28814265; int8_t x293 = -1; uint32_t x294 = 2665U; static int8_t x303 = -1; int8_t x306 = INT8_MIN; static int16_t x310 = 5328; int8_t x313 = -1; uint64_t x314 = 60LLU; static int32_t x316 = INT32_MIN; volatile int32_t t78 = 5353; uint8_t x317 = 0U; int16_t x320 = 968; static volatile int32_t t81 = 2127; uint16_t x331 = 620U; volatile int16_t x332 = INT16_MIN; volatile uint8_t x333 = 4U; int64_t x335 = INT64_MAX; int32_t t83 = 467117646; int16_t x342 = INT16_MIN; int64_t x343 = INT64_MAX; volatile int64_t x347 = INT64_MIN; int32_t t86 = 502983; static int32_t t87 = 31; static int8_t x359 = -1; volatile uint8_t x361 = 32U; int32_t t94 = -22226; int8_t x393 = INT8_MIN; static uint32_t x395 = 11196U; volatile int32_t t98 = 524263516; static int16_t x398 = INT16_MIN; static uint64_t x404 = UINT64_MAX; uint16_t x406 = 1266U; static int64_t x407 = INT64_MIN; static int8_t x410 = INT8_MIN; int32_t t102 = 13912500; int64_t x413 = 0LL; volatile int8_t x420 = -3; static int16_t x421 = INT16_MAX; int16_t x422 = INT16_MIN; volatile int32_t t107 = -270262353; volatile int32_t x433 = INT32_MIN; uint64_t x436 = 9224538193530LLU; int64_t x447 = -1LL; static volatile int32_t t111 = 14945564; uint64_t x453 = UINT64_MAX; volatile int8_t x457 = INT8_MIN; int8_t x458 = INT8_MIN; volatile int8_t x472 = INT8_MIN; int32_t x473 = 231012236; volatile int32_t t118 = -46; uint16_t x477 = 5U; volatile uint16_t x478 = UINT16_MAX; uint16_t x479 = UINT16_MAX; static int64_t x480 = -4076226LL; uint8_t x482 = 2U; volatile int32_t t122 = -15190551; static volatile int16_t x493 = -1; int64_t x499 = INT64_MAX; int8_t x505 = 0; volatile uint32_t x508 = 617749U; volatile int32_t t127 = 1; static int8_t x513 = INT8_MAX; int8_t x514 = INT8_MIN; static int8_t x515 = -1; volatile int64_t x517 = -1LL; static int32_t t129 = 7424489; uint8_t x521 = UINT8_MAX; uint32_t x527 = 43910539U; uint16_t x529 = UINT16_MAX; int16_t x530 = INT16_MIN; int8_t x531 = INT8_MAX; static int32_t x541 = -1; uint32_t x542 = 61U; static int16_t x547 = INT16_MAX; uint16_t x549 = 5335U; uint8_t x557 = UINT8_MAX; uint8_t x567 = 1U; int16_t x568 = INT16_MIN; static int64_t x573 = -1LL; static int16_t x574 = 50; int32_t x575 = INT32_MIN; static uint8_t x579 = 0U; int32_t t144 = -496; uint16_t x587 = 21371U; static int32_t t146 = -335638; int32_t x589 = INT32_MAX; static volatile uint64_t x591 = UINT64_MAX; int16_t x596 = -1; int16_t x601 = -1; int64_t x604 = INT64_MIN; int16_t x608 = INT16_MIN; int32_t t151 = 144; volatile uint8_t x610 = 8U; uint8_t x613 = UINT8_MAX; uint64_t x616 = UINT64_MAX; volatile int64_t x617 = INT64_MAX; uint8_t x620 = 3U; volatile uint64_t x627 = 1LLU; volatile int64_t x635 = 2005095536854097LL; static int64_t x640 = 897924394272LL; int32_t x641 = -1623; uint64_t x642 = 2570932867LLU; int16_t x647 = -1; volatile int32_t x649 = INT32_MAX; volatile int32_t x650 = INT32_MIN; int8_t x652 = INT8_MAX; static int32_t x663 = INT32_MIN; int32_t t166 = 1688; uint8_t x674 = UINT8_MAX; static uint32_t x676 = 14751U; volatile uint32_t x687 = 6U; volatile int32_t t171 = -1; int8_t x693 = INT8_MIN; static uint32_t x694 = 2932081U; int32_t x696 = INT32_MAX; static int32_t t173 = -106709725; int16_t x701 = -178; volatile uint64_t x705 = 5075724031789022123LLU; volatile uint8_t x712 = 21U; volatile int32_t t177 = -663; int32_t x713 = -60; volatile int16_t x720 = INT16_MIN; volatile int32_t x727 = -1; volatile int32_t t181 = 20165; volatile int32_t t182 = 15806; int64_t x734 = INT64_MIN; uint8_t x735 = 6U; static int32_t x736 = INT32_MIN; volatile uint16_t x740 = UINT16_MAX; volatile uint32_t x741 = 1U; int8_t x744 = INT8_MIN; volatile int32_t x747 = -2666; int32_t x748 = -120793564; int16_t x750 = 1199; volatile uint16_t x752 = UINT16_MAX; uint8_t x754 = UINT8_MAX; uint64_t x757 = 112480905402865LLU; volatile int32_t t191 = -12; uint8_t x769 = UINT8_MAX; uint16_t x775 = 2757U; int8_t x780 = INT8_MIN; uint16_t x783 = UINT16_MAX; int16_t x785 = -1; volatile uint64_t x787 = UINT64_MAX; static volatile int16_t x788 = -1; volatile uint64_t x799 = 464088404LLU; volatile uint16_t x800 = 5U; int32_t t199 = 8606; void f0(void) { static int64_t x1 = 14468582744622LL; uint8_t x2 = 3U; int32_t x3 = INT32_MIN; uint8_t x4 = 0U; static int32_t t0 = -2429623; t0 = (x1<=(x2==(x3>x4))); if (t0 != 0) { NG(); } else { ; } } void f1(void) { int32_t x6 = -1; volatile uint32_t x7 = 123U; int32_t t1 = 1226; t1 = (x5<=(x6==(x7>x8))); if (t1 != 0) { NG(); } else { ; } } void f2(void) { uint64_t x10 = UINT64_MAX; volatile int32_t t2 = 374263; t2 = (x9<=(x10==(x11>x12))); if (t2 != 0) { NG(); } else { ; } } void f3(void) { int16_t x15 = -1; uint8_t x16 = 33U; volatile int32_t t3 = 150423846; t3 = (x13<=(x14==(x15>x16))); if (t3 != 0) { NG(); } else { ; } } void f4(void) { volatile uint8_t x17 = 29U; uint32_t x18 = UINT32_MAX; int8_t x19 = INT8_MIN; static int32_t t4 = 270815; t4 = (x17<=(x18==(x19>x20))); if (t4 != 0) { NG(); } else { ; } } void f5(void) { int32_t x21 = INT32_MIN; uint32_t x22 = 73167U; int32_t x23 = -1; uint8_t x24 = 61U; t5 = (x21<=(x22==(x23>x24))); if (t5 != 1) { NG(); } else { ; } } void f6(void) { uint32_t x25 = UINT32_MAX; uint8_t x26 = UINT8_MAX; uint16_t x27 = 12U; volatile int32_t t6 = 1154; t6 = (x25<=(x26==(x27>x28))); if (t6 != 0) { NG(); } else { ; } } void f7(void) { int16_t x29 = INT16_MIN; uint16_t x31 = 7U; int32_t t7 = 10; t7 = (x29<=(x30==(x31>x32))); if (t7 != 1) { NG(); } else { ; } } void f8(void) { uint32_t x33 = UINT32_MAX; volatile int64_t x35 = -206857210LL; int32_t x36 = INT32_MIN; static int32_t t8 = 482; t8 = (x33<=(x34==(x35>x36))); if (t8 != 0) { NG(); } else { ; } } void f9(void) { uint8_t x38 = 112U; static int8_t x39 = 0; int32_t t9 = -98589493; t9 = (x37<=(x38==(x39>x40))); if (t9 != 0) { NG(); } else { ; } } void f10(void) { static int64_t x41 = -6364LL; volatile uint64_t x42 = 37099251760LLU; uint8_t x44 = UINT8_MAX; volatile int32_t t10 = -235276752; t10 = (x41<=(x42==(x43>x44))); if (t10 != 1) { NG(); } else { ; } } void f11(void) { volatile int64_t x45 = -3LL; int8_t x46 = INT8_MAX; int16_t x47 = INT16_MIN; static int8_t x48 = 1; t11 = (x45<=(x46==(x47>x48))); if (t11 != 1) { NG(); } else { ; } } void f12(void) { uint16_t x49 = 8U; uint64_t x50 = UINT64_MAX; volatile int64_t x51 = -1LL; int32_t t12 = 3608412; t12 = (x49<=(x50==(x51>x52))); if (t12 != 0) { NG(); } else { ; } } void f13(void) { uint64_t x53 = UINT64_MAX; static uint64_t x54 = UINT64_MAX; volatile uint16_t x55 = UINT16_MAX; volatile uint32_t x56 = UINT32_MAX; volatile int32_t t13 = -273207231; t13 = (x53<=(x54==(x55>x56))); if (t13 != 0) { NG(); } else { ; } } void f14(void) { static volatile int64_t x57 = INT64_MIN; static int16_t x59 = INT16_MAX; uint32_t x60 = UINT32_MAX; volatile int32_t t14 = 1914; t14 = (x57<=(x58==(x59>x60))); if (t14 != 1) { NG(); } else { ; } } void f15(void) { uint8_t x61 = 124U; int64_t x62 = INT64_MIN; int64_t x63 = -1LL; int32_t x64 = 28; t15 = (x61<=(x62==(x63>x64))); if (t15 != 0) { NG(); } else { ; } } void f16(void) { static volatile int8_t x66 = INT8_MIN; static int32_t x67 = -85; static int32_t x68 = -2436; volatile int32_t t16 = -119; t16 = (x65<=(x66==(x67>x68))); if (t16 != 0) { NG(); } else { ; } } void f17(void) { int16_t x69 = INT16_MIN; uint32_t x71 = 67U; volatile uint16_t x72 = UINT16_MAX; int32_t t17 = -1; t17 = (x69<=(x70==(x71>x72))); if (t17 != 1) { NG(); } else { ; } } void f18(void) { uint32_t x73 = UINT32_MAX; int32_t x74 = 585949010; int8_t x75 = INT8_MAX; uint16_t x76 = UINT16_MAX; volatile int32_t t18 = 16; t18 = (x73<=(x74==(x75>x76))); if (t18 != 0) { NG(); } else { ; } } void f19(void) { int32_t x77 = 865; uint32_t x78 = 3U; uint64_t x79 = 2LLU; static int8_t x80 = -2; t19 = (x77<=(x78==(x79>x80))); if (t19 != 0) { NG(); } else { ; } } void f20(void) { uint8_t x81 = 10U; static int64_t x83 = INT64_MIN; uint32_t x84 = 9U; volatile int32_t t20 = 11248497; t20 = (x81<=(x82==(x83>x84))); if (t20 != 0) { NG(); } else { ; } } void f21(void) { static int32_t x85 = INT32_MIN; int8_t x86 = INT8_MAX; int32_t x87 = -772799014; uint64_t x88 = 29LLU; volatile int32_t t21 = 5991; t21 = (x85<=(x86==(x87>x88))); if (t21 != 1) { NG(); } else { ; } } void f22(void) { uint8_t x89 = 105U; int32_t x90 = INT32_MIN; int8_t x91 = 14; int16_t x92 = INT16_MIN; static volatile int32_t t22 = -5002743; t22 = (x89<=(x90==(x91>x92))); if (t22 != 0) { NG(); } else { ; } } void f23(void) { static uint16_t x93 = UINT16_MAX; static int8_t x94 = INT8_MAX; int32_t x96 = -46385331; t23 = (x93<=(x94==(x95>x96))); if (t23 != 0) { NG(); } else { ; } } void f24(void) { static uint8_t x97 = 121U; volatile uint8_t x98 = 9U; static volatile int32_t x99 = -495; int16_t x100 = 1777; int32_t t24 = 1670384; t24 = (x97<=(x98==(x99>x100))); if (t24 != 0) { NG(); } else { ; } } void f25(void) { int32_t x101 = INT32_MIN; static uint8_t x102 = UINT8_MAX; uint32_t x103 = 29130U; volatile uint64_t x104 = 8747131606LLU; t25 = (x101<=(x102==(x103>x104))); if (t25 != 1) { NG(); } else { ; } } void f26(void) { int32_t x105 = 3850843; int32_t x106 = INT32_MIN; int64_t x107 = INT64_MAX; static uint32_t x108 = 364536U; volatile int32_t t26 = -1; t26 = (x105<=(x106==(x107>x108))); if (t26 != 0) { NG(); } else { ; } } void f27(void) { static int16_t x110 = INT16_MIN; int16_t x112 = -52; int32_t t27 = 381269844; t27 = (x109<=(x110==(x111>x112))); if (t27 != 1) { NG(); } else { ; } } void f28(void) { volatile uint64_t x113 = 6787087354566LLU; int8_t x114 = INT8_MAX; static int64_t x115 = 2LL; t28 = (x113<=(x114==(x115>x116))); if (t28 != 0) { NG(); } else { ; } } void f29(void) { int8_t x118 = 1; int32_t t29 = 663844736; t29 = (x117<=(x118==(x119>x120))); if (t29 != 0) { NG(); } else { ; } } void f30(void) { static volatile int8_t x121 = INT8_MIN; int32_t x122 = -256972; static int8_t x124 = INT8_MIN; t30 = (x121<=(x122==(x123>x124))); if (t30 != 1) { NG(); } else { ; } } void f31(void) { static int64_t x127 = INT64_MIN; volatile int32_t t31 = 59315368; t31 = (x125<=(x126==(x127>x128))); if (t31 != 1) { NG(); } else { ; } } void f32(void) { int32_t x129 = 1515784; volatile int64_t x130 = 131414LL; int32_t x131 = -1; static int64_t x132 = INT64_MAX; int32_t t32 = 357374; t32 = (x129<=(x130==(x131>x132))); if (t32 != 0) { NG(); } else { ; } } void f33(void) { int64_t x133 = INT64_MIN; int64_t x134 = 57LL; static int16_t x135 = INT16_MIN; volatile uint64_t x136 = UINT64_MAX; volatile int32_t t33 = 1; t33 = (x133<=(x134==(x135>x136))); if (t33 != 1) { NG(); } else { ; } } void f34(void) { static int32_t x137 = -98421; int8_t x138 = INT8_MIN; static int32_t x139 = -508; volatile uint8_t x140 = 25U; volatile int32_t t34 = -105; t34 = (x137<=(x138==(x139>x140))); if (t34 != 1) { NG(); } else { ; } } void f35(void) { volatile int8_t x142 = -1; int64_t x143 = INT64_MIN; volatile int32_t t35 = 24; t35 = (x141<=(x142==(x143>x144))); if (t35 != 1) { NG(); } else { ; } } void f36(void) { int64_t x145 = INT64_MIN; static int8_t x146 = INT8_MIN; volatile uint8_t x147 = UINT8_MAX; static volatile uint16_t x148 = 13U; int32_t t36 = -3098; t36 = (x145<=(x146==(x147>x148))); if (t36 != 1) { NG(); } else { ; } } void f37(void) { int16_t x149 = INT16_MAX; uint8_t x150 = 1U; static int32_t t37 = -6661238; t37 = (x149<=(x150==(x151>x152))); if (t37 != 0) { NG(); } else { ; } } void f38(void) { volatile int64_t x153 = 62659813825LL; int32_t x154 = 6265; int64_t x155 = INT64_MAX; uint32_t x156 = UINT32_MAX; int32_t t38 = -11799; t38 = (x153<=(x154==(x155>x156))); if (t38 != 0) { NG(); } else { ; } } void f39(void) { int64_t x157 = INT64_MAX; int8_t x158 = INT8_MAX; int64_t x159 = 1277810818714320LL; static int32_t t39 = 1; t39 = (x157<=(x158==(x159>x160))); if (t39 != 0) { NG(); } else { ; } } void f40(void) { static volatile int8_t x161 = 0; int16_t x162 = -228; int16_t x163 = 238; int64_t x164 = -1LL; int32_t t40 = 231883333; t40 = (x161<=(x162==(x163>x164))); if (t40 != 1) { NG(); } else { ; } } void f41(void) { int64_t x166 = 2052691845351307LL; uint32_t x167 = 211401144U; uint8_t x168 = 2U; int32_t t41 = 239476; t41 = (x165<=(x166==(x167>x168))); if (t41 != 0) { NG(); } else { ; } } void f42(void) { uint16_t x170 = 5929U; static int32_t x171 = INT32_MIN; volatile int64_t x172 = INT64_MIN; static volatile int32_t t42 = -61912291; t42 = (x169<=(x170==(x171>x172))); if (t42 != 1) { NG(); } else { ; } } void f43(void) { static int32_t x173 = 20775; uint8_t x174 = 15U; uint64_t x175 = UINT64_MAX; uint8_t x176 = 9U; volatile int32_t t43 = 37060932; t43 = (x173<=(x174==(x175>x176))); if (t43 != 0) { NG(); } else { ; } } void f44(void) { volatile uint64_t x177 = 35179972LLU; uint32_t x178 = 8284481U; static volatile int32_t x179 = 541154; volatile int16_t x180 = INT16_MIN; volatile int32_t t44 = 194303241; t44 = (x177<=(x178==(x179>x180))); if (t44 != 0) { NG(); } else { ; } } void f45(void) { uint64_t x181 = UINT64_MAX; int64_t x182 = INT64_MIN; int16_t x183 = -5; int32_t t45 = 20; t45 = (x181<=(x182==(x183>x184))); if (t45 != 0) { NG(); } else { ; } } void f46(void) { volatile int32_t x185 = 2; int16_t x186 = -1; volatile int8_t x187 = 0; int64_t x188 = INT64_MIN; volatile int32_t t46 = 430; t46 = (x185<=(x186==(x187>x188))); if (t46 != 0) { NG(); } else { ; } } void f47(void) { int32_t x189 = -1; volatile uint16_t x190 = 3U; int64_t x191 = -1LL; static int8_t x192 = -23; volatile int32_t t47 = 27; t47 = (x189<=(x190==(x191>x192))); if (t47 != 1) { NG(); } else { ; } } void f48(void) { static int64_t x193 = INT64_MIN; volatile int8_t x194 = -1; volatile uint16_t x195 = 159U; static volatile int64_t x196 = INT64_MIN; volatile int32_t t48 = -1; t48 = (x193<=(x194==(x195>x196))); if (t48 != 1) { NG(); } else { ; } } void f49(void) { static int16_t x197 = INT16_MIN; static int32_t x198 = -1; uint32_t x199 = UINT32_MAX; int16_t x200 = INT16_MAX; t49 = (x197<=(x198==(x199>x200))); if (t49 != 1) { NG(); } else { ; } } void f50(void) { int16_t x201 = INT16_MAX; int16_t x202 = INT16_MIN; int32_t x203 = INT32_MAX; volatile int64_t x204 = 2028525390091353335LL; t50 = (x201<=(x202==(x203>x204))); if (t50 != 0) { NG(); } else { ; } } void f51(void) { int8_t x205 = INT8_MIN; uint16_t x206 = UINT16_MAX; int8_t x207 = INT8_MAX; static int32_t t51 = -15739; t51 = (x205<=(x206==(x207>x208))); if (t51 != 1) { NG(); } else { ; } } void f52(void) { uint16_t x209 = 122U; int8_t x210 = INT8_MIN; int16_t x211 = -1; volatile int64_t x212 = INT64_MIN; static volatile int32_t t52 = -8; t52 = (x209<=(x210==(x211>x212))); if (t52 != 0) { NG(); } else { ; } } void f53(void) { volatile int32_t x213 = -1297; int8_t x214 = 2; int64_t x215 = -1LL; volatile int64_t x216 = 10273650LL; t53 = (x213<=(x214==(x215>x216))); if (t53 != 1) { NG(); } else { ; } } void f54(void) { int64_t x218 = 58912834415829LL; static volatile int32_t x220 = INT32_MIN; int32_t t54 = -9923766; t54 = (x217<=(x218==(x219>x220))); if (t54 != 0) { NG(); } else { ; } } void f55(void) { uint64_t x221 = 773092835007LLU; static volatile int16_t x222 = -1; uint16_t x223 = UINT16_MAX; int32_t x224 = INT32_MAX; static volatile int32_t t55 = -219; t55 = (x221<=(x222==(x223>x224))); if (t55 != 0) { NG(); } else { ; } } void f56(void) { static int16_t x225 = 1116; int64_t x226 = INT64_MIN; uint16_t x227 = 2934U; int32_t x228 = INT32_MAX; int32_t t56 = 615119; t56 = (x225<=(x226==(x227>x228))); if (t56 != 0) { NG(); } else { ; } } void f57(void) { int8_t x229 = 1; int32_t x230 = INT32_MAX; int8_t x232 = -1; t57 = (x229<=(x230==(x231>x232))); if (t57 != 0) { NG(); } else { ; } } void f58(void) { int16_t x233 = INT16_MIN; volatile uint8_t x234 = 32U; uint8_t x235 = 82U; int32_t x236 = -672801835; int32_t t58 = 3294; t58 = (x233<=(x234==(x235>x236))); if (t58 != 1) { NG(); } else { ; } } void f59(void) { static int8_t x238 = 16; uint32_t x239 = 2U; volatile uint8_t x240 = 10U; int32_t t59 = 3197; t59 = (x237<=(x238==(x239>x240))); if (t59 != 1) { NG(); } else { ; } } void f60(void) { int32_t x241 = INT32_MIN; volatile int16_t x242 = INT16_MIN; uint8_t x243 = UINT8_MAX; int32_t t60 = -391; t60 = (x241<=(x242==(x243>x244))); if (t60 != 1) { NG(); } else { ; } } void f61(void) { volatile uint32_t x246 = UINT32_MAX; int8_t x247 = INT8_MIN; volatile int8_t x248 = INT8_MAX; volatile int32_t t61 = 433; t61 = (x245<=(x246==(x247>x248))); if (t61 != 1) { NG(); } else { ; } } void f62(void) { int16_t x249 = -840; int32_t x251 = 0; uint64_t x252 = UINT64_MAX; int32_t t62 = -318; t62 = (x249<=(x250==(x251>x252))); if (t62 != 1) { NG(); } else { ; } } void f63(void) { uint32_t x253 = UINT32_MAX; static int16_t x254 = INT16_MIN; int32_t t63 = -87; t63 = (x253<=(x254==(x255>x256))); if (t63 != 0) { NG(); } else { ; } } void f64(void) { uint32_t x257 = 17409743U; uint8_t x258 = UINT8_MAX; int64_t x259 = -1LL; volatile int32_t t64 = 3; t64 = (x257<=(x258==(x259>x260))); if (t64 != 0) { NG(); } else { ; } } void f65(void) { volatile uint64_t x261 = 133877587555140LLU; int64_t x262 = -1LL; volatile uint16_t x263 = 18627U; static int16_t x264 = INT16_MIN; volatile int32_t t65 = 114; t65 = (x261<=(x262==(x263>x264))); if (t65 != 0) { NG(); } else { ; } } void f66(void) { int64_t x265 = INT64_MIN; volatile int64_t x268 = -1LL; static volatile int32_t t66 = -467; t66 = (x265<=(x266==(x267>x268))); if (t66 != 1) { NG(); } else { ; } } void f67(void) { int8_t x270 = -1; uint8_t x271 = 13U; int32_t x272 = INT32_MAX; static int32_t t67 = -11; t67 = (x269<=(x270==(x271>x272))); if (t67 != 1) { NG(); } else { ; } } void f68(void) { static uint8_t x273 = UINT8_MAX; int8_t x274 = 1; int64_t x275 = -1LL; t68 = (x273<=(x274==(x275>x276))); if (t68 != 0) { NG(); } else { ; } } void f69(void) { volatile int16_t x277 = INT16_MIN; int64_t x278 = -6143784LL; int16_t x279 = 22; uint8_t x280 = 23U; t69 = (x277<=(x278==(x279>x280))); if (t69 != 1) { NG(); } else { ; } } void f70(void) { volatile int64_t x281 = -2LL; uint8_t x282 = 0U; uint32_t x283 = 90272143U; uint16_t x284 = 3759U; int32_t t70 = -7527515; t70 = (x281<=(x282==(x283>x284))); if (t70 != 1) { NG(); } else { ; } } void f71(void) { volatile int8_t x285 = INT8_MAX; static uint16_t x286 = 2094U; static int64_t x287 = INT64_MIN; static volatile int16_t x288 = INT16_MAX; volatile int32_t t71 = 380; t71 = (x285<=(x286==(x287>x288))); if (t71 != 0) { NG(); } else { ; } } void f72(void) { int8_t x289 = INT8_MIN; int32_t x290 = -118753; int32_t x291 = -25014650; static uint16_t x292 = UINT16_MAX; t72 = (x289<=(x290==(x291>x292))); if (t72 != 1) { NG(); } else { ; } } void f73(void) { volatile int64_t x295 = INT64_MAX; uint16_t x296 = UINT16_MAX; int32_t t73 = -111469; t73 = (x293<=(x294==(x295>x296))); if (t73 != 1) { NG(); } else { ; } } void f74(void) { uint64_t x297 = 17491340429740LLU; int32_t x298 = 49; static uint8_t x299 = 14U; static uint32_t x300 = UINT32_MAX; int32_t t74 = -55; t74 = (x297<=(x298==(x299>x300))); if (t74 != 0) { NG(); } else { ; } } void f75(void) { volatile uint16_t x301 = UINT16_MAX; int64_t x302 = 126719788144LL; int64_t x304 = INT64_MIN; volatile int32_t t75 = 1; t75 = (x301<=(x302==(x303>x304))); if (t75 != 0) { NG(); } else { ; } } void f76(void) { static uint32_t x305 = UINT32_MAX; volatile int8_t x307 = -1; static volatile uint8_t x308 = 119U; volatile int32_t t76 = -12; t76 = (x305<=(x306==(x307>x308))); if (t76 != 0) { NG(); } else { ; } } void f77(void) { static uint64_t x309 = 2LLU; uint64_t x311 = 19725590723575LLU; int32_t x312 = -1; volatile int32_t t77 = -24; t77 = (x309<=(x310==(x311>x312))); if (t77 != 0) { NG(); } else { ; } } void f78(void) { uint16_t x315 = 1U; t78 = (x313<=(x314==(x315>x316))); if (t78 != 1) { NG(); } else { ; } } void f79(void) { int32_t x318 = INT32_MIN; int8_t x319 = INT8_MAX; int32_t t79 = -170173; t79 = (x317<=(x318==(x319>x320))); if (t79 != 1) { NG(); } else { ; } } void f80(void) { uint32_t x321 = 3471454U; int64_t x322 = -4078621778LL; int8_t x323 = 25; int32_t x324 = -1; volatile int32_t t80 = 122390; t80 = (x321<=(x322==(x323>x324))); if (t80 != 0) { NG(); } else { ; } } void f81(void) { int8_t x325 = -1; volatile int64_t x326 = INT64_MIN; static uint8_t x327 = 3U; int8_t x328 = INT8_MIN; t81 = (x325<=(x326==(x327>x328))); if (t81 != 1) { NG(); } else { ; } } void f82(void) { int32_t x329 = INT32_MAX; static int16_t x330 = 125; volatile int32_t t82 = 0; t82 = (x329<=(x330==(x331>x332))); if (t82 != 0) { NG(); } else { ; } } void f83(void) { volatile uint8_t x334 = UINT8_MAX; int8_t x336 = INT8_MAX; t83 = (x333<=(x334==(x335>x336))); if (t83 != 0) { NG(); } else { ; } } void f84(void) { int64_t x337 = -1LL; volatile int32_t x338 = INT32_MAX; uint64_t x339 = UINT64_MAX; int8_t x340 = -4; static int32_t t84 = -2051880; t84 = (x337<=(x338==(x339>x340))); if (t84 != 1) { NG(); } else { ; } } void f85(void) { volatile int16_t x341 = INT16_MIN; uint32_t x344 = UINT32_MAX; volatile int32_t t85 = 6771; t85 = (x341<=(x342==(x343>x344))); if (t85 != 1) { NG(); } else { ; } } void f86(void) { int8_t x345 = -1; int16_t x346 = INT16_MAX; uint16_t x348 = UINT16_MAX; t86 = (x345<=(x346==(x347>x348))); if (t86 != 1) { NG(); } else { ; } } void f87(void) { volatile int32_t x349 = -1; uint32_t x350 = 7516665U; volatile uint8_t x351 = 6U; static uint16_t x352 = UINT16_MAX; t87 = (x349<=(x350==(x351>x352))); if (t87 != 1) { NG(); } else { ; } } void f88(void) { uint64_t x353 = 351661705692LLU; int8_t x354 = 58; uint16_t x355 = 144U; int32_t x356 = INT32_MAX; int32_t t88 = 90385; t88 = (x353<=(x354==(x355>x356))); if (t88 != 0) { NG(); } else { ; } } void f89(void) { int8_t x357 = 3; static volatile int8_t x358 = -1; int64_t x360 = -1LL; int32_t t89 = -13382; t89 = (x357<=(x358==(x359>x360))); if (t89 != 0) { NG(); } else { ; } } void f90(void) { int64_t x362 = -1LL; int64_t x363 = INT64_MIN; uint32_t x364 = 1411164169U; static volatile int32_t t90 = -129340; t90 = (x361<=(x362==(x363>x364))); if (t90 != 0) { NG(); } else { ; } } void f91(void) { int64_t x365 = INT64_MIN; static uint32_t x366 = 62U; volatile uint16_t x367 = 1669U; volatile uint16_t x368 = 50U; int32_t t91 = -13580290; t91 = (x365<=(x366==(x367>x368))); if (t91 != 1) { NG(); } else { ; } } void f92(void) { int32_t x369 = -1; volatile uint32_t x370 = UINT32_MAX; volatile int16_t x371 = INT16_MAX; int64_t x372 = INT64_MIN; int32_t t92 = 7; t92 = (x369<=(x370==(x371>x372))); if (t92 != 1) { NG(); } else { ; } } void f93(void) { uint16_t x373 = UINT16_MAX; int64_t x374 = INT64_MIN; volatile uint16_t x375 = 6U; static int16_t x376 = INT16_MAX; int32_t t93 = 3393; t93 = (x373<=(x374==(x375>x376))); if (t93 != 0) { NG(); } else { ; } } void f94(void) { uint64_t x377 = 1615874264LLU; uint64_t x378 = 21790644776LLU; uint32_t x379 = UINT32_MAX; int16_t x380 = INT16_MIN; t94 = (x377<=(x378==(x379>x380))); if (t94 != 0) { NG(); } else { ; } } void f95(void) { volatile int16_t x381 = INT16_MAX; int16_t x382 = INT16_MIN; uint64_t x383 = 115014666LLU; static int16_t x384 = -1; int32_t t95 = -188832369; t95 = (x381<=(x382==(x383>x384))); if (t95 != 0) { NG(); } else { ; } } void f96(void) { volatile int32_t x385 = -116; int32_t x386 = 0; int32_t x387 = INT32_MIN; int16_t x388 = INT16_MAX; static int32_t t96 = 25922; t96 = (x385<=(x386==(x387>x388))); if (t96 != 1) { NG(); } else { ; } } void f97(void) { int32_t x389 = -1; int64_t x390 = -1LL; int32_t x391 = 3555; static int64_t x392 = -37794523666996573LL; volatile int32_t t97 = 24; t97 = (x389<=(x390==(x391>x392))); if (t97 != 1) { NG(); } else { ; } } void f98(void) { volatile uint8_t x394 = 60U; int16_t x396 = -1; t98 = (x393<=(x394==(x395>x396))); if (t98 != 1) { NG(); } else { ; } } void f99(void) { int32_t x397 = INT32_MIN; uint64_t x399 = 591699LLU; uint64_t x400 = 1296822821LLU; int32_t t99 = 131991278; t99 = (x397<=(x398==(x399>x400))); if (t99 != 1) { NG(); } else { ; } } void f100(void) { int32_t x401 = INT32_MAX; int32_t x402 = -1; int16_t x403 = 26; volatile int32_t t100 = -51029; t100 = (x401<=(x402==(x403>x404))); if (t100 != 0) { NG(); } else { ; } } void f101(void) { uint32_t x405 = 446U; int64_t x408 = INT64_MIN; volatile int32_t t101 = -369732; t101 = (x405<=(x406==(x407>x408))); if (t101 != 0) { NG(); } else { ; } } void f102(void) { int32_t x409 = INT32_MIN; int16_t x411 = INT16_MIN; int8_t x412 = -1; t102 = (x409<=(x410==(x411>x412))); if (t102 != 1) { NG(); } else { ; } } void f103(void) { int64_t x414 = INT64_MIN; uint64_t x415 = UINT64_MAX; static volatile uint16_t x416 = 0U; static volatile int32_t t103 = 30403262; t103 = (x413<=(x414==(x415>x416))); if (t103 != 1) { NG(); } else { ; } } void f104(void) { uint64_t x417 = 2LLU; static int8_t x418 = INT8_MIN; int64_t x419 = -11280617321297321LL; int32_t t104 = -11; t104 = (x417<=(x418==(x419>x420))); if (t104 != 0) { NG(); } else { ; } } void f105(void) { int64_t x423 = INT64_MIN; uint32_t x424 = 135525956U; int32_t t105 = 2; t105 = (x421<=(x422==(x423>x424))); if (t105 != 0) { NG(); } else { ; } } void f106(void) { int8_t x425 = INT8_MAX; static int8_t x426 = INT8_MIN; uint8_t x427 = 4U; uint16_t x428 = 372U; static int32_t t106 = 54534; t106 = (x425<=(x426==(x427>x428))); if (t106 != 0) { NG(); } else { ; } } void f107(void) { uint16_t x429 = UINT16_MAX; uint16_t x430 = 2058U; int32_t x431 = INT32_MAX; volatile int64_t x432 = INT64_MAX; t107 = (x429<=(x430==(x431>x432))); if (t107 != 0) { NG(); } else { ; } } void f108(void) { int8_t x434 = -1; static uint64_t x435 = 10751104LLU; volatile int32_t t108 = -1113601; t108 = (x433<=(x434==(x435>x436))); if (t108 != 1) { NG(); } else { ; } } void f109(void) { uint32_t x437 = UINT32_MAX; volatile uint16_t x438 = 6604U; int64_t x439 = INT64_MIN; int8_t x440 = INT8_MIN; volatile int32_t t109 = 14824; t109 = (x437<=(x438==(x439>x440))); if (t109 != 0) { NG(); } else { ; } } void f110(void) { uint32_t x441 = UINT32_MAX; int32_t x442 = 211360412; static uint8_t x443 = UINT8_MAX; uint32_t x444 = 2717231U; volatile int32_t t110 = -79; t110 = (x441<=(x442==(x443>x444))); if (t110 != 0) { NG(); } else { ; } } void f111(void) { int32_t x445 = INT32_MIN; uint8_t x446 = 1U; static uint64_t x448 = 16285334870LLU; t111 = (x445<=(x446==(x447>x448))); if (t111 != 1) { NG(); } else { ; } } void f112(void) { volatile uint64_t x449 = UINT64_MAX; uint64_t x450 = 2171089899167648075LLU; int8_t x451 = -1; int8_t x452 = -1; int32_t t112 = 926; t112 = (x449<=(x450==(x451>x452))); if (t112 != 0) { NG(); } else { ; } } void f113(void) { uint8_t x454 = UINT8_MAX; static int8_t x455 = INT8_MIN; uint8_t x456 = 0U; volatile int32_t t113 = 42429899; t113 = (x453<=(x454==(x455>x456))); if (t113 != 0) { NG(); } else { ; } } void f114(void) { static uint64_t x459 = 140287571311311353LLU; int32_t x460 = INT32_MAX; volatile int32_t t114 = 13368; t114 = (x457<=(x458==(x459>x460))); if (t114 != 1) { NG(); } else { ; } } void f115(void) { static uint8_t x461 = UINT8_MAX; int64_t x462 = -32LL; volatile uint32_t x463 = 479856U; int32_t x464 = INT32_MAX; int32_t t115 = 14828; t115 = (x461<=(x462==(x463>x464))); if (t115 != 0) { NG(); } else { ; } } void f116(void) { int32_t x465 = 7248871; int32_t x466 = INT32_MIN; int64_t x467 = 2932242271LL; volatile int16_t x468 = 0; volatile int32_t t116 = 1; t116 = (x465<=(x466==(x467>x468))); if (t116 != 0) { NG(); } else { ; } } void f117(void) { int32_t x469 = -236; static int8_t x470 = INT8_MAX; int16_t x471 = INT16_MAX; int32_t t117 = -15036; t117 = (x469<=(x470==(x471>x472))); if (t117 != 1) { NG(); } else { ; } } void f118(void) { uint64_t x474 = UINT64_MAX; int64_t x475 = -1LL; int32_t x476 = INT32_MIN; t118 = (x473<=(x474==(x475>x476))); if (t118 != 0) { NG(); } else { ; } } void f119(void) { int32_t t119 = 68139; t119 = (x477<=(x478==(x479>x480))); if (t119 != 0) { NG(); } else { ; } } void f120(void) { static volatile uint8_t x481 = 9U; int32_t x483 = -195686; int64_t x484 = INT64_MIN; volatile int32_t t120 = -13792; t120 = (x481<=(x482==(x483>x484))); if (t120 != 0) { NG(); } else { ; } } void f121(void) { int32_t x485 = -1; uint16_t x486 = 9U; int16_t x487 = -1; static int64_t x488 = -1LL; int32_t t121 = 9; t121 = (x485<=(x486==(x487>x488))); if (t121 != 1) { NG(); } else { ; } } void f122(void) { uint8_t x489 = 0U; volatile uint64_t x490 = 1877367LLU; static int8_t x491 = INT8_MIN; int64_t x492 = INT64_MIN; t122 = (x489<=(x490==(x491>x492))); if (t122 != 1) { NG(); } else { ; } } void f123(void) { volatile int64_t x494 = INT64_MAX; int16_t x495 = -78; int64_t x496 = INT64_MIN; int32_t t123 = -22102728; t123 = (x493<=(x494==(x495>x496))); if (t123 != 1) { NG(); } else { ; } } void f124(void) { uint8_t x497 = UINT8_MAX; int32_t x498 = -1; int8_t x500 = INT8_MAX; int32_t t124 = 12567; t124 = (x497<=(x498==(x499>x500))); if (t124 != 0) { NG(); } else { ; } } void f125(void) { int16_t x501 = 230; uint8_t x502 = 93U; int8_t x503 = INT8_MAX; uint64_t x504 = 3451413597541LLU; volatile int32_t t125 = 721057576; t125 = (x501<=(x502==(x503>x504))); if (t125 != 0) { NG(); } else { ; } } void f126(void) { volatile int16_t x506 = INT16_MIN; static int64_t x507 = INT64_MIN; int32_t t126 = -606051874; t126 = (x505<=(x506==(x507>x508))); if (t126 != 1) { NG(); } else { ; } } void f127(void) { volatile int64_t x509 = INT64_MAX; int8_t x510 = INT8_MIN; static int32_t x511 = INT32_MIN; int32_t x512 = 1730; t127 = (x509<=(x510==(x511>x512))); if (t127 != 0) { NG(); } else { ; } } void f128(void) { int16_t x516 = INT16_MIN; int32_t t128 = 7343741; t128 = (x513<=(x514==(x515>x516))); if (t128 != 0) { NG(); } else { ; } } void f129(void) { int64_t x518 = INT64_MAX; static int64_t x519 = INT64_MAX; int16_t x520 = -1; t129 = (x517<=(x518==(x519>x520))); if (t129 != 1) { NG(); } else { ; } } void f130(void) { volatile int8_t x522 = -1; int8_t x523 = -1; static volatile int32_t x524 = 415127711; static volatile int32_t t130 = -42769808; t130 = (x521<=(x522==(x523>x524))); if (t130 != 0) { NG(); } else { ; } } void f131(void) { int16_t x525 = INT16_MIN; int64_t x526 = -107885817680560LL; uint8_t x528 = 61U; static volatile int32_t t131 = -14020891; t131 = (x525<=(x526==(x527>x528))); if (t131 != 1) { NG(); } else { ; } } void f132(void) { uint64_t x532 = 537473LLU; int32_t t132 = 29156; t132 = (x529<=(x530==(x531>x532))); if (t132 != 0) { NG(); } else { ; } } void f133(void) { volatile int8_t x533 = -1; int8_t x534 = 1; uint16_t x535 = UINT16_MAX; volatile int16_t x536 = INT16_MIN; volatile int32_t t133 = -2; t133 = (x533<=(x534==(x535>x536))); if (t133 != 1) { NG(); } else { ; } } void f134(void) { static int16_t x537 = INT16_MIN; volatile int32_t x538 = 177; static uint8_t x539 = UINT8_MAX; static uint8_t x540 = 1U; volatile int32_t t134 = 3227; t134 = (x537<=(x538==(x539>x540))); if (t134 != 1) { NG(); } else { ; } } void f135(void) { int32_t x543 = INT32_MIN; int32_t x544 = INT32_MIN; int32_t t135 = 5112; t135 = (x541<=(x542==(x543>x544))); if (t135 != 1) { NG(); } else { ; } } void f136(void) { volatile int32_t x545 = 13; int32_t x546 = -177396425; volatile uint16_t x548 = 24284U; static int32_t t136 = -171; t136 = (x545<=(x546==(x547>x548))); if (t136 != 0) { NG(); } else { ; } } void f137(void) { static uint16_t x550 = 322U; static uint8_t x551 = 16U; volatile int16_t x552 = INT16_MIN; static volatile int32_t t137 = -1697203; t137 = (x549<=(x550==(x551>x552))); if (t137 != 0) { NG(); } else { ; } } void f138(void) { int64_t x553 = INT64_MIN; uint16_t x554 = 1U; volatile int8_t x555 = -1; uint8_t x556 = 126U; static int32_t t138 = -177; t138 = (x553<=(x554==(x555>x556))); if (t138 != 1) { NG(); } else { ; } } void f139(void) { static int64_t x558 = -1LL; uint64_t x559 = UINT64_MAX; int32_t x560 = 8934; volatile int32_t t139 = 925854; t139 = (x557<=(x558==(x559>x560))); if (t139 != 0) { NG(); } else { ; } } void f140(void) { uint64_t x561 = 52749LLU; uint8_t x562 = UINT8_MAX; int8_t x563 = INT8_MIN; volatile int32_t x564 = -15462255; int32_t t140 = -1734482; t140 = (x561<=(x562==(x563>x564))); if (t140 != 0) { NG(); } else { ; } } void f141(void) { uint8_t x565 = 0U; int16_t x566 = 2; int32_t t141 = -8; t141 = (x565<=(x566==(x567>x568))); if (t141 != 1) { NG(); } else { ; } } void f142(void) { uint16_t x569 = 253U; uint32_t x570 = 440U; int32_t x571 = 76842; uint32_t x572 = 3U; int32_t t142 = -764; t142 = (x569<=(x570==(x571>x572))); if (t142 != 0) { NG(); } else { ; } } void f143(void) { int64_t x576 = -241213LL; int32_t t143 = -2926; t143 = (x573<=(x574==(x575>x576))); if (t143 != 1) { NG(); } else { ; } } void f144(void) { uint32_t x577 = 60129111U; static uint16_t x578 = UINT16_MAX; int8_t x580 = 38; t144 = (x577<=(x578==(x579>x580))); if (t144 != 0) { NG(); } else { ; } } void f145(void) { uint32_t x581 = UINT32_MAX; int32_t x582 = -8; int64_t x583 = -34351621932LL; int64_t x584 = INT64_MIN; int32_t t145 = 1; t145 = (x581<=(x582==(x583>x584))); if (t145 != 0) { NG(); } else { ; } } void f146(void) { static int64_t x585 = -1LL; uint8_t x586 = UINT8_MAX; volatile int64_t x588 = INT64_MIN; t146 = (x585<=(x586==(x587>x588))); if (t146 != 1) { NG(); } else { ; } } void f147(void) { static uint64_t x590 = 259057LLU; static int32_t x592 = INT32_MIN; volatile int32_t t147 = 179712; t147 = (x589<=(x590==(x591>x592))); if (t147 != 0) { NG(); } else { ; } } void f148(void) { int16_t x593 = INT16_MAX; int8_t x594 = INT8_MAX; volatile int16_t x595 = INT16_MAX; int32_t t148 = -38568; t148 = (x593<=(x594==(x595>x596))); if (t148 != 0) { NG(); } else { ; } } void f149(void) { volatile uint32_t x597 = 14381963U; volatile int16_t x598 = 415; int16_t x599 = INT16_MIN; uint32_t x600 = 6147636U; volatile int32_t t149 = -17740; t149 = (x597<=(x598==(x599>x600))); if (t149 != 0) { NG(); } else { ; } } void f150(void) { uint16_t x602 = UINT16_MAX; int32_t x603 = INT32_MIN; static volatile int32_t t150 = -2986; t150 = (x601<=(x602==(x603>x604))); if (t150 != 1) { NG(); } else { ; } } void f151(void) { int8_t x605 = -1; volatile int16_t x606 = -1; static int16_t x607 = 150; t151 = (x605<=(x606==(x607>x608))); if (t151 != 1) { NG(); } else { ; } } void f152(void) { int32_t x609 = INT32_MIN; int32_t x611 = INT32_MIN; static int16_t x612 = INT16_MIN; int32_t t152 = -2050678; t152 = (x609<=(x610==(x611>x612))); if (t152 != 1) { NG(); } else { ; } } void f153(void) { volatile uint16_t x614 = 5465U; int16_t x615 = INT16_MAX; int32_t t153 = -1808; t153 = (x613<=(x614==(x615>x616))); if (t153 != 0) { NG(); } else { ; } } void f154(void) { int64_t x618 = -1LL; static int16_t x619 = 0; int32_t t154 = -7; t154 = (x617<=(x618==(x619>x620))); if (t154 != 0) { NG(); } else { ; } } void f155(void) { int32_t x621 = INT32_MAX; int64_t x622 = INT64_MIN; uint16_t x623 = UINT16_MAX; uint32_t x624 = 473U; volatile int32_t t155 = 91438; t155 = (x621<=(x622==(x623>x624))); if (t155 != 0) { NG(); } else { ; } } void f156(void) { volatile int8_t x625 = INT8_MIN; volatile int64_t x626 = 492598LL; uint8_t x628 = 1U; static int32_t t156 = -47959; t156 = (x625<=(x626==(x627>x628))); if (t156 != 1) { NG(); } else { ; } } void f157(void) { int8_t x629 = 51; int32_t x630 = 912594504; static int16_t x631 = INT16_MAX; int16_t x632 = INT16_MAX; int32_t t157 = -13094; t157 = (x629<=(x630==(x631>x632))); if (t157 != 0) { NG(); } else { ; } } void f158(void) { volatile int8_t x633 = 34; uint16_t x634 = 114U; uint64_t x636 = 7376LLU; int32_t t158 = -540; t158 = (x633<=(x634==(x635>x636))); if (t158 != 0) { NG(); } else { ; } } void f159(void) { int16_t x637 = -1; int64_t x638 = INT64_MAX; uint16_t x639 = 684U; volatile int32_t t159 = 44216775; t159 = (x637<=(x638==(x639>x640))); if (t159 != 1) { NG(); } else { ; } } void f160(void) { uint16_t x643 = UINT16_MAX; volatile uint8_t x644 = 40U; volatile int32_t t160 = -221600860; t160 = (x641<=(x642==(x643>x644))); if (t160 != 1) { NG(); } else { ; } } void f161(void) { int16_t x645 = INT16_MIN; int32_t x646 = INT32_MAX; uint32_t x648 = 1U; volatile int32_t t161 = -961563093; t161 = (x645<=(x646==(x647>x648))); if (t161 != 1) { NG(); } else { ; } } void f162(void) { volatile int16_t x651 = INT16_MIN; static int32_t t162 = -128; t162 = (x649<=(x650==(x651>x652))); if (t162 != 0) { NG(); } else { ; } } void f163(void) { static int16_t x653 = -1; volatile int32_t x654 = INT32_MIN; int64_t x655 = INT64_MIN; static uint64_t x656 = UINT64_MAX; static int32_t t163 = -167327409; t163 = (x653<=(x654==(x655>x656))); if (t163 != 1) { NG(); } else { ; } } void f164(void) { static int32_t x657 = -64165; uint32_t x658 = UINT32_MAX; static uint16_t x659 = UINT16_MAX; int8_t x660 = INT8_MIN; int32_t t164 = 507087; t164 = (x657<=(x658==(x659>x660))); if (t164 != 1) { NG(); } else { ; } } void f165(void) { uint64_t x661 = UINT64_MAX; int16_t x662 = INT16_MIN; int16_t x664 = -1; int32_t t165 = 3; t165 = (x661<=(x662==(x663>x664))); if (t165 != 0) { NG(); } else { ; } } void f166(void) { int64_t x665 = -1LL; static int64_t x666 = 94555907LL; volatile uint32_t x667 = UINT32_MAX; static volatile int8_t x668 = INT8_MIN; t166 = (x665<=(x666==(x667>x668))); if (t166 != 1) { NG(); } else { ; } } void f167(void) { static volatile int8_t x669 = INT8_MIN; int16_t x670 = -2; static int64_t x671 = INT64_MIN; int8_t x672 = INT8_MAX; int32_t t167 = -16876; t167 = (x669<=(x670==(x671>x672))); if (t167 != 1) { NG(); } else { ; } } void f168(void) { volatile int16_t x673 = -56; static volatile int32_t x675 = 15; volatile int32_t t168 = 15700835; t168 = (x673<=(x674==(x675>x676))); if (t168 != 1) { NG(); } else { ; } } void f169(void) { volatile int8_t x677 = -1; int16_t x678 = -1; int8_t x679 = INT8_MAX; volatile uint64_t x680 = UINT64_MAX; volatile int32_t t169 = -11917; t169 = (x677<=(x678==(x679>x680))); if (t169 != 1) { NG(); } else { ; } } void f170(void) { uint64_t x681 = 187055LLU; int64_t x682 = INT64_MIN; volatile uint8_t x683 = 6U; static int32_t x684 = INT32_MIN; volatile int32_t t170 = -457089681; t170 = (x681<=(x682==(x683>x684))); if (t170 != 0) { NG(); } else { ; } } void f171(void) { uint8_t x685 = UINT8_MAX; int32_t x686 = INT32_MAX; uint32_t x688 = 839628U; t171 = (x685<=(x686==(x687>x688))); if (t171 != 0) { NG(); } else { ; } } void f172(void) { volatile uint16_t x689 = 9587U; int16_t x690 = INT16_MIN; int8_t x691 = -1; int32_t x692 = INT32_MIN; int32_t t172 = 79; t172 = (x689<=(x690==(x691>x692))); if (t172 != 0) { NG(); } else { ; } } void f173(void) { uint8_t x695 = 14U; t173 = (x693<=(x694==(x695>x696))); if (t173 != 1) { NG(); } else { ; } } void f174(void) { volatile int32_t x697 = 103969; int8_t x698 = -1; static uint64_t x699 = 49592634895LLU; volatile int16_t x700 = INT16_MAX; volatile int32_t t174 = 2635855; t174 = (x697<=(x698==(x699>x700))); if (t174 != 0) { NG(); } else { ; } } void f175(void) { volatile int8_t x702 = -1; int32_t x703 = -126457327; static volatile int16_t x704 = 10; int32_t t175 = 0; t175 = (x701<=(x702==(x703>x704))); if (t175 != 1) { NG(); } else { ; } } void f176(void) { uint16_t x706 = 1U; static int8_t x707 = INT8_MIN; int32_t x708 = INT32_MAX; static int32_t t176 = -18174157; t176 = (x705<=(x706==(x707>x708))); if (t176 != 0) { NG(); } else { ; } } void f177(void) { static int32_t x709 = 1586; int8_t x710 = 1; static int32_t x711 = -1; t177 = (x709<=(x710==(x711>x712))); if (t177 != 0) { NG(); } else { ; } } void f178(void) { static int16_t x714 = INT16_MIN; static int64_t x715 = 2805496160461452047LL; int8_t x716 = INT8_MAX; static volatile int32_t t178 = -98974252; t178 = (x713<=(x714==(x715>x716))); if (t178 != 1) { NG(); } else { ; } } void f179(void) { volatile uint8_t x717 = 36U; uint16_t x718 = UINT16_MAX; int16_t x719 = INT16_MIN; volatile int32_t t179 = 571755858; t179 = (x717<=(x718==(x719>x720))); if (t179 != 0) { NG(); } else { ; } } void f180(void) { uint64_t x721 = 41966609073324811LLU; int64_t x722 = INT64_MIN; int64_t x723 = -432LL; int8_t x724 = -3; int32_t t180 = 3246943; t180 = (x721<=(x722==(x723>x724))); if (t180 != 0) { NG(); } else { ; } } void f181(void) { static volatile int16_t x725 = INT16_MIN; volatile uint16_t x726 = UINT16_MAX; int16_t x728 = INT16_MIN; t181 = (x725<=(x726==(x727>x728))); if (t181 != 1) { NG(); } else { ; } } void f182(void) { int16_t x729 = INT16_MIN; int16_t x730 = 28; uint64_t x731 = 37054176788071LLU; uint16_t x732 = UINT16_MAX; t182 = (x729<=(x730==(x731>x732))); if (t182 != 1) { NG(); } else { ; } } void f183(void) { int32_t x733 = INT32_MAX; volatile int32_t t183 = 2599915; t183 = (x733<=(x734==(x735>x736))); if (t183 != 0) { NG(); } else { ; } } void f184(void) { static int16_t x737 = INT16_MAX; static volatile int16_t x738 = -5; int8_t x739 = INT8_MAX; volatile int32_t t184 = 14889; t184 = (x737<=(x738==(x739>x740))); if (t184 != 0) { NG(); } else { ; } } void f185(void) { uint8_t x742 = 1U; int8_t x743 = INT8_MIN; int32_t t185 = 160879; t185 = (x741<=(x742==(x743>x744))); if (t185 != 0) { NG(); } else { ; } } void f186(void) { int16_t x745 = -126; volatile uint64_t x746 = 2038LLU; volatile int32_t t186 = -90365344; t186 = (x745<=(x746==(x747>x748))); if (t186 != 1) { NG(); } else { ; } } void f187(void) { static int64_t x749 = -1LL; int16_t x751 = INT16_MIN; int32_t t187 = 78942579; t187 = (x749<=(x750==(x751>x752))); if (t187 != 1) { NG(); } else { ; } } void f188(void) { static volatile uint64_t x753 = 2671LLU; int32_t x755 = -1; static uint64_t x756 = 6LLU; static int32_t t188 = -122074925; t188 = (x753<=(x754==(x755>x756))); if (t188 != 0) { NG(); } else { ; } } void f189(void) { int64_t x758 = -1LL; volatile int32_t x759 = INT32_MAX; int32_t x760 = 32990; int32_t t189 = -2; t189 = (x757<=(x758==(x759>x760))); if (t189 != 0) { NG(); } else { ; } } void f190(void) { uint32_t x761 = UINT32_MAX; static volatile uint16_t x762 = UINT16_MAX; int64_t x763 = -299949576162715LL; uint64_t x764 = 4152014755887018LLU; int32_t t190 = 9974800; t190 = (x761<=(x762==(x763>x764))); if (t190 != 0) { NG(); } else { ; } } void f191(void) { static uint32_t x765 = UINT32_MAX; static uint8_t x766 = 6U; uint32_t x767 = UINT32_MAX; volatile int16_t x768 = INT16_MAX; t191 = (x765<=(x766==(x767>x768))); if (t191 != 0) { NG(); } else { ; } } void f192(void) { static uint64_t x770 = UINT64_MAX; volatile uint64_t x771 = 102LLU; int8_t x772 = INT8_MIN; static volatile int32_t t192 = 893; t192 = (x769<=(x770==(x771>x772))); if (t192 != 0) { NG(); } else { ; } } void f193(void) { volatile int32_t x773 = INT32_MAX; int8_t x774 = INT8_MAX; int32_t x776 = INT32_MIN; volatile int32_t t193 = 4752; t193 = (x773<=(x774==(x775>x776))); if (t193 != 0) { NG(); } else { ; } } void f194(void) { int8_t x777 = INT8_MAX; volatile uint16_t x778 = 92U; int8_t x779 = INT8_MIN; volatile int32_t t194 = 213; t194 = (x777<=(x778==(x779>x780))); if (t194 != 0) { NG(); } else { ; } } void f195(void) { uint32_t x781 = UINT32_MAX; int32_t x782 = 26832; int64_t x784 = 83350619LL; int32_t t195 = -1; t195 = (x781<=(x782==(x783>x784))); if (t195 != 0) { NG(); } else { ; } } void f196(void) { int64_t x786 = INT64_MAX; volatile int32_t t196 = -212; t196 = (x785<=(x786==(x787>x788))); if (t196 != 1) { NG(); } else { ; } } void f197(void) { uint8_t x789 = 63U; volatile int32_t x790 = INT32_MIN; static int32_t x791 = INT32_MIN; uint16_t x792 = 8081U; volatile int32_t t197 = -13; t197 = (x789<=(x790==(x791>x792))); if (t197 != 0) { NG(); } else { ; } } void f198(void) { volatile int32_t x793 = INT32_MAX; int32_t x794 = -1; volatile uint32_t x795 = 3U; volatile int8_t x796 = INT8_MAX; int32_t t198 = -29; t198 = (x793<=(x794==(x795>x796))); if (t198 != 0) { NG(); } else { ; } } void f199(void) { static volatile uint64_t x797 = 8301582259029391LLU; int32_t x798 = 6072317; t199 = (x797<=(x798==(x799>x800))); if (t199 != 0) { NG(); } else { ; } } int main(void) { f0(); f1(); f2(); f3(); f4(); f5(); f6(); f7(); f8(); f9(); f10(); f11(); f12(); f13(); f14(); f15(); f16(); f17(); f18(); f19(); f20(); f21(); f22(); f23(); f24(); f25(); f26(); f27(); f28(); f29(); f30(); f31(); f32(); f33(); f34(); f35(); f36(); f37(); f38(); f39(); f40(); f41(); f42(); f43(); f44(); f45(); f46(); f47(); f48(); f49(); f50(); f51(); f52(); f53(); f54(); f55(); f56(); f57(); f58(); f59(); f60(); f61(); f62(); f63(); f64(); f65(); f66(); f67(); f68(); f69(); f70(); f71(); f72(); f73(); f74(); f75(); f76(); f77(); f78(); f79(); f80(); f81(); f82(); f83(); f84(); f85(); f86(); f87(); f88(); f89(); f90(); f91(); f92(); f93(); f94(); f95(); f96(); f97(); f98(); f99(); f100(); f101(); f102(); f103(); f104(); f105(); f106(); f107(); f108(); f109(); f110(); f111(); f112(); f113(); f114(); f115(); f116(); f117(); f118(); f119(); f120(); f121(); f122(); f123(); f124(); f125(); f126(); f127(); f128(); f129(); f130(); f131(); f132(); f133(); f134(); f135(); f136(); f137(); f138(); f139(); f140(); f141(); f142(); f143(); f144(); f145(); f146(); f147(); f148(); f149(); f150(); f151(); f152(); f153(); f154(); f155(); f156(); f157(); f158(); f159(); f160(); f161(); f162(); f163(); f164(); f165(); f166(); f167(); f168(); f169(); f170(); f171(); f172(); f173(); f174(); f175(); f176(); f177(); f178(); f179(); f180(); f181(); f182(); f183(); f184(); f185(); f186(); f187(); f188(); f189(); f190(); f191(); f192(); f193(); f194(); f195(); f196(); f197(); f198(); f199(); return 0; }
[ "ishiura-compiler@ml.kwansei.ac.jp" ]
ishiura-compiler@ml.kwansei.ac.jp
db376c16e0d821c3c61a42b83b5a7ef7130b6e71
41d0aee2205d1d1d244faf6b72bae5b48d3839af
/kernel/base/include/los_base_pri.h
a43f073a33585280e12c3232407a7083781ec7e4
[ "BSD-3-Clause" ]
permissive
SunnyLy/kernel_liteos_a_note
75d2df014abce78e85722406331343832f74cec4
9c54aa38d2330b365e55e5feff1f808c3b6dba25
refs/heads/master
2023-08-19T13:15:21.905929
2021-10-22T09:26:15
2021-10-22T09:26:15
null
0
0
null
null
null
null
UTF-8
C
false
false
2,093
h
/* * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used * to endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _LOS_BASE_PRI_H #define _LOS_BASE_PRI_H #include "los_base.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ #define OS_GOTO_ERREND() do { \ goto LOS_ERREND; \ } while (0) #ifdef __cplusplus #if __cplusplus } #endif /* __cplusplus */ #endif /* __cplusplus */ #endif /* _LOS_BASE_PRI_H */
[ "kuangyufei@126.com" ]
kuangyufei@126.com
3e9a7de8da5b23a0838793f035eeab54f73477d8
cb6bd0015a08b01c5312ec47ab29a4431f2746a5
/arch/esp32/main/forth_evt.c
5df52a3274ad07fbb32ec7b24bc6db8f6ec42808
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
petarkabashki/punyforth-esp32
9d6e21761b809148410b6073515e27a9fcd1f9d8
590d2b4638ba06eda73376db3445dfc8b5515ffa
refs/heads/main
2022-12-26T14:30:17.531036
2020-10-07T00:19:36
2020-10-07T00:19:36
301,885,440
1
0
null
null
null
null
UTF-8
C
false
false
570
c
// #include "espressif/esp_common.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/queue.h" #include "forth_evt.h" static QueueHandle_t event_queue; void init_event_queue() { event_queue = xQueueCreate(12, sizeof(struct forth_event)); } void forth_add_event_isr(struct forth_event *event) { xQueueSendToBackFromISR(event_queue, event, 0); // queued by copy, not reference } int forth_wait_event(int timeout_ms, void* event) { return (xQueueReceive(event_queue, event, timeout_ms / portTICK_PERIOD_MS) == pdTRUE) ? 1 : 0; }
[ "peter.kabashky@gmail.com" ]
peter.kabashky@gmail.com
8a2eeaaf22f040f7ff7ef70633a970bd89b12dfc
173eb435fef61582ea8b255fe5d1df9dc58f2abc
/slave_srio/se_main.c
8a27127ac123df82391597b161bdc0f2fb27b7c2
[]
no_license
Cai900205/test
6d9e8fe5c7193cdf1e75885d85bc92c67cdb8812
1f9db0fcaa4bdd4f8966e016649a99bb37614808
refs/heads/master
2020-12-25T17:27:05.718094
2016-08-22T13:15:20
2016-08-22T13:15:20
40,888,283
1
0
null
null
null
null
UTF-8
C
false
false
1,694
c
/************************************************************************* > File Name: main.c > Author: > Mail: > Created Time: Wed 12 Aug 2015 05:16:49 PM CST ************************************************************************/ #include "fvl_common.h" #include "fvl_srio.h" #define Buf_num 16 #define Buf_size 0x100000 #define Chan_num 4 #define Port_Num 2 #define Total_Buf_Size (Buf_num*Buf_size*Chan_num) static char channame[]="srio0-chan3"; int main(int argc, char **argv) { fvl_srio_init_param_t srio_init[Port_Num]; fvl_dma_pool_t *port_dma_wr[Port_Num]; fvl_read_rvl_t rlen; char data[Buf_size]; int rvl=0; uint8_t i=0; for(i=0;i<2;i++) { // srio_init[i].buf_num=Buf_num; // srio_init[i].buf_size=Buf_size; srio_init[i].chan_num=Chan_num; // srio_init[i].chan_size=Buf_num*Buf_size; srio_init[i].port_num=i; rvl = dma_pool_init(&port_dma_wr[i],Total_Buf_Size,Total_Buf_Size/2); if(rvl!=0) { FVL_LOG("port %d dma_pool_init failed!\n",i+1); return -errno; } srio_init[i].port_rd_buf=port_dma_wr[i]; rvl=fvl_srio_init(&srio_init[i]); if(rvl!=0) { FVL_LOG("srio init error!\n"); return -errno; } } int fd=0; // open one channel fd=fvl_srio_channel_open(channame); printf("###################fd:%d*****************\n",fd); sleep(3); // while(1) for(i=0;i<32;i++) { // i++; memset(data,i,Buf_size); rvl=fvl_srio_write(fd,data,Buf_size); if(rvl!=0) { printf("error!\n"); } } return 0; }
[ "1198430034@qq.com" ]
1198430034@qq.com
ed87ff9b5427dbc136e373ac6654cc0706ceff7e
c0f4d4f11decef4898ccc0fff95d73c1eb9da83e
/ft_putnbr.c
df4b259333d8fc03f424c97c046115ea68e2a39b
[]
no_license
anthelix/My_libft
36db9dceaa6167046da6bd66b05d95badd074e0b
71aaa9a7dad59e66c77df394b54f723b321849a0
refs/heads/master
2022-04-13T17:00:13.477773
2020-03-28T15:46:50
2020-03-28T15:46:50
159,134,614
0
0
null
null
null
null
UTF-8
C
false
false
1,054
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putnbr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: schatagn <schatagn@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/20 15:56:00 by schatagn #+# #+# */ /* Updated: 2018/11/20 16:53:04 by schatagn ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_putnbr(int n) { if (n / 10) ft_putnbr(n / 10); else if (n < 0) ft_putchar('-'); ft_putchar(n % 10 * (n < 0 ? -1 : 1) + '0'); }
[ "sdulou@free.fr" ]
sdulou@free.fr
156adf484fb8187059cb528e84e178a21a78ae5e
d880bac94871b7d153a8217f0d2423fc018d17df
/fun2.c
7a00e860bcfd7d83ba027c9dc3d316c4f42aa080
[]
no_license
xby999/xby
4a3f9d1d03aa8d09af93ad0a7cda4afc91c149f1
dcc4f940516b0b207e2588176a17f91ab4fbb4f7
refs/heads/master
2020-08-07T22:05:00.563490
2019-10-08T09:23:42
2019-10-08T09:23:42
213,599,788
0
0
null
null
null
null
UTF-8
C
false
false
73
c
#include <stdio.h> int main() { printf("hellow world\n"); return 0; }
[ "1963256383@qq.com" ]
1963256383@qq.com
237456fb780044b87dfaa80455968506fcfd9b79
ad2541550220131170abf20b0074df7e0914805f
/src/includes/routine.h
58d219db97ac38342d93ffd34d73a467a51c9c77
[]
no_license
RRZE-HPC/MPIBench
9c4467df2195c22e3e92c6cac0ecbdb7d38eb5ae
c16dc57a46921b0b93a82a5c229a18071946c926
refs/heads/master
2022-03-04T18:16:22.563839
2019-08-19T08:07:28
2019-08-19T08:07:28
177,814,117
1
0
null
null
null
null
UTF-8
C
false
false
406
h
#ifndef ROUTINE_H #define ROUTINE_H #include <stdio.h> #include <mpi.h> #include <stdlib.h> #include <string.h> #include "overlap_functions.h" void Ibcast(int argc, char * argv[]); void Igather(int argc, char * argv[]); void Ireduce(int argc, char * argv[]); void Iscatter(int argc, char * argv[]); void Isend(int argc, char * argv[]); void Irecv(int argc, char * argv[]); #endif // ROUTINE_H
[ "hassanasghar13@yahoo.com" ]
hassanasghar13@yahoo.com
6949b49baa0e4585eaab17a73f4499beda509f0b
46367579a54a09dd220dd9a678b1452f06897f11
/features/ccp/src/H5Gent.c
3809933b4705b88fa8e5c5702fdc94c2a46233e8
[ "LicenseRef-scancode-llnl", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-hdf4" ]
permissive
TPLink32/hdf5
33ff24c9b6133f0f51cb6cc2b722fba7bb1777dd
0d6987c15284bd9f34c7e44452a152833d42a738
refs/heads/master
2021-05-31T01:15:39.463663
2016-04-14T23:02:09
2016-04-14T23:02:09
null
0
0
null
null
null
null
UTF-8
C
false
false
20,160
c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke <matzke@llnl.gov> * Friday, September 19, 1997 */ /****************/ /* Module Setup */ /****************/ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ /***********/ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ /****************/ /* Local Macros */ /****************/ /******************/ /* Local Typedefs */ /******************/ /********************/ /* Package Typedefs */ /********************/ /********************/ /* Local Prototypes */ /********************/ /*********************/ /* Package Variables */ /*********************/ /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); /*****************************/ /* Library Private Variables */ /*****************************/ /*******************/ /* Local Variables */ /*******************/ /*------------------------------------------------------------------------- * Function: H5G__ent_decode_vec * * Purpose: Same as H5G_ent_decode() except it does it for an array of * symbol table entries. * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * *------------------------------------------------------------------------- */ herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* check arguments */ HDassert(f); HDassert(pp); HDassert(ent); /* decode entries */ for(u = 0; u < n; u++) if(H5G_ent_decode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_decode_vec() */ /*------------------------------------------------------------------------- * Function: H5G_ent_decode * * Purpose: Decodes a symbol table entry pointed to by `*pp'. * * Return: Success: Non-negative with *pp pointing to the first byte * following the symbol table entry. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * *------------------------------------------------------------------------- */ herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) { const uint8_t *p_ret = *pp; uint32_t tmp; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); HDassert(pp); HDassert(ent); /* decode header */ H5F_DECODE_LENGTH(f, *pp, ent->name_off); H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ ent->type = (H5G_cache_type_t)tmp; /* decode scratch-pad */ switch(ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: HDassert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr)); H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr)); break; case H5G_CACHED_SLINK: UINT32DECODE(*pp, ent->cache.slink.lval_offset); break; case H5G_CACHED_ERROR: case H5G_NCACHED: default: HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") } /* end switch */ *pp = p_ret + H5G_SIZEOF_ENTRY_FILE(f); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_decode() */ /*------------------------------------------------------------------------- * Function: H5G__ent_encode_vec * * Purpose: Same as H5G_ent_encode() except it does it for an array of * symbol table entries. * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * *------------------------------------------------------------------------- */ herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* check arguments */ HDassert(f); HDassert(pp); HDassert(ent); /* encode entries */ for(u = 0; u < n; u++) if(H5G_ent_encode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G__ent_encode_vec() */ /*------------------------------------------------------------------------- * Function: H5G_ent_encode * * Purpose: Encodes the specified symbol table entry into the buffer * pointed to by *pp. * * Return: Success: Non-negative, with *pp pointing to the first byte * after the symbol table entry. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * *------------------------------------------------------------------------- */ herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) { uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY_FILE(f); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); HDassert(pp); /* Check for actual entry to encode */ if(ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); H5F_addr_encode(f, pp, ent->header); UINT32ENCODE(*pp, ent->type); UINT32ENCODE(*pp, 0); /*reserved*/ /* encode scratch-pad */ switch(ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: HDassert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: UINT32ENCODE(*pp, ent->cache.slink.lval_offset); break; case H5G_CACHED_ERROR: case H5G_NCACHED: default: HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") } /* end switch */ } /* end if */ else { H5F_ENCODE_LENGTH(f, *pp, 0); H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); UINT32ENCODE(*pp, 0); /*reserved*/ } /* end else */ /* fill with zero */ if(*pp < p_ret) HDmemset(*pp, 0, (size_t)(p_ret - *pp)); *pp = p_ret; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_encode() */ /*------------------------------------------------------------------------- * Function: H5G__ent_copy * * Purpose: Do a deep copy of symbol table entries * * Return: Success: Non-negative * Failure: Negative * * Programmer: Pedro Vicente * pvn@ncsa.uiuc.edu * ???day, August ??, 2002 * * Notes: 'depth' parameter determines how much of the group entry * structure we want to copy. The values are: * H5_COPY_SHALLOW - Copy all the fields from the source * to the destination, including the user path and * canonical path. (Destination "takes ownership" of * user and canonical paths) * H5_COPY_DEEP - Copy all the fields from the source to * the destination, deep copying the user and canonical * paths. * *------------------------------------------------------------------------- */ void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) { FUNC_ENTER_PACKAGE_NOERR /* Check arguments */ HDassert(src); HDassert(dst); HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP); /* Copy the top level information */ HDmemcpy(dst, src, sizeof(H5G_entry_t)); /* Deep copy the names */ if(depth == H5_COPY_DEEP) { /* Nothing currently */ ; } else if(depth == H5_COPY_SHALLOW) { /* Discarding 'const' qualifier OK - QAK */ H5G__ent_reset((H5G_entry_t *)src); } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5G__ent_copy() */ /*------------------------------------------------------------------------- * Function: H5G__ent_reset * * Purpose: Reset a symbol table entry to an empty state * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * ?day, August ??, 2005 * *------------------------------------------------------------------------- */ void H5G__ent_reset(H5G_entry_t *ent) { FUNC_ENTER_PACKAGE_NOERR /* Check arguments */ HDassert(ent); /* Clear the symbol table entry to an empty state */ HDmemset(ent, 0, sizeof(H5G_entry_t)); ent->header = HADDR_UNDEF; FUNC_LEAVE_NOAPI_VOID } /* end H5G__ent_reset() */ /*------------------------------------------------------------------------- * Function: H5G__ent_convert * * Purpose: Convert a link to a symbol table entry * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 20 2005 * *------------------------------------------------------------------------- */ herr_t H5G__ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, const char *name, const H5O_link_t *lnk, H5O_type_t obj_type, const void *crt_info, H5G_entry_t *ent) { size_t name_offset; /* Offset of name in heap */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* check arguments */ HDassert(f); HDassert(heap); HDassert(name); HDassert(lnk); /* Reset the new entry */ H5G__ent_reset(ent); /* * Add the new name to the heap. */ name_offset = H5HL_insert(f, dxpl_id, heap, HDstrlen(name) + 1, name); if(0 == name_offset || (size_t)(-1) == name_offset) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert symbol name into heap") ent->name_off = name_offset; /* Build correct information for symbol table entry based on link type */ switch(lnk->type) { case H5L_TYPE_HARD: if(obj_type == H5O_TYPE_GROUP) { const H5G_obj_create_t *gcrt_info = (const H5G_obj_create_t *)crt_info; ent->type = gcrt_info->cache_type; if(ent->type != H5G_NOTHING_CACHED) ent->cache = gcrt_info->cache; #ifndef NDEBUG else { /* Make sure there is no stab message in the target object */ H5O_loc_t targ_oloc; /* Location of link target */ htri_t stab_exists; /* Whether the target symbol table exists */ /* Build target object location */ if(H5O_loc_reset(&targ_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") targ_oloc.file = f; targ_oloc.addr = lnk->u.hard.addr; /* Check if a symbol table message exists */ if((stab_exists = H5O_msg_exists(&targ_oloc, H5O_STAB_ID, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to check for STAB message") HDassert(!stab_exists); } /* end else */ #endif /* NDEBUG */ } /* end if */ else if(obj_type == H5O_TYPE_UNKNOWN){ /* Try to retrieve symbol table information for caching */ H5O_loc_t targ_oloc; /* Location of link target */ H5O_t *oh; /* Link target object header */ H5O_stab_t stab; /* Link target symbol table */ htri_t stab_exists; /* Whether the target symbol table exists */ /* Build target object location */ if(H5O_loc_reset(&targ_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") targ_oloc.file = f; targ_oloc.addr = lnk->u.hard.addr; /* Get the object header */ if(NULL == (oh = H5O_protect(&targ_oloc, dxpl_id, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, FAIL, "unable to protect target object header") /* Check if a symbol table message exists */ if((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) { if(H5O_unprotect(&targ_oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HERROR(H5E_SYM, H5E_CANTUNPROTECT, "unable to release object header"); HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to check for STAB message") } /* end if */ if(stab_exists) { /* Read symbol table message */ if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_STAB_ID, &stab)) { if(H5O_unprotect(&targ_oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HERROR(H5E_SYM, H5E_CANTUNPROTECT, "unable to release object header"); HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read STAB message") } /* end if */ /* Cache symbol table message */ ent->type = H5G_CACHED_STAB; ent->cache.stab.btree_addr = stab.btree_addr; ent->cache.stab.heap_addr = stab.heap_addr; } /* end if */ else /* No symbol table message, don't cache anything */ ent->type = H5G_NOTHING_CACHED; if(H5O_unprotect(&targ_oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPROTECT, FAIL, "unable to release object header") } /* end else */ else ent->type = H5G_NOTHING_CACHED; ent->header = lnk->u.hard.addr; break; case H5L_TYPE_SOFT: { size_t lnk_offset; /* Offset to sym-link value */ /* Insert link value into local heap */ if((size_t)(-1) == (lnk_offset = H5HL_insert(f, dxpl_id, heap, HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") ent->type = H5G_CACHED_SLINK; ent->cache.slink.lval_offset = lnk_offset; } /* end case */ break; case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: default: HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_convert() */ /*------------------------------------------------------------------------- * Function: H5G__ent_debug * * Purpose: Prints debugging information about a symbol table entry. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 29 1997 * *------------------------------------------------------------------------- */ herr_t H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, const H5HL_t *heap) { const char *lval = NULL; int nested_indent, nested_fwidth; FUNC_ENTER_PACKAGE_NOERR /* Calculate the indent & field width values for nested information */ nested_indent = indent + 3; nested_fwidth = MAX(0, fwidth - 3); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Name offset into private heap:", (unsigned long) (ent->name_off)); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object header address:", ent->header); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cache info type:"); switch(ent->type) { case H5G_NOTHING_CACHED: HDfprintf(stream, "Nothing Cached\n"); break; case H5G_CACHED_STAB: HDfprintf(stream, "Symbol Table\n"); HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached entry information:"); HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, "B-tree address:", ent->cache.stab.btree_addr); HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, "Heap address:", ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: HDfprintf(stream, "Symbolic Link\n"); HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached information:"); HDfprintf(stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth, "Link value offset:", (unsigned long)(ent->cache.slink.lval_offset)); if(heap) { lval = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset); HDfprintf(stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth, "Link value:", lval); } /* end if */ else HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given, name not displayed!"); break; case H5G_CACHED_ERROR: case H5G_NCACHED: default: HDfprintf(stream, "*** Unknown symbol type %d\n", ent->type); break; } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__ent_debug() */
[ "acheng@dab4d1a6-ed17-0410-a064-d1ae371a2980" ]
acheng@dab4d1a6-ed17-0410-a064-d1ae371a2980
0184788893cc48dfd6c8f117c1b22420fafd3dbc
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/linux/drivers/input/keyboard/extr_imx_keypad.c_imx_keypad_irq_handler.c
79547298deed6e0de85cf2822cd92de35ae7cf24
[]
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,642
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 imx_keypad {int /*<<< orphan*/ check_matrix_timer; scalar_t__ stable_count; scalar_t__ enabled; scalar_t__ mmio_base; } ; typedef int /*<<< orphan*/ irqreturn_t ; /* Variables and functions */ int /*<<< orphan*/ IRQ_HANDLED ; unsigned short KBD_STAT_KDIE ; unsigned short KBD_STAT_KPKD ; unsigned short KBD_STAT_KPKR ; unsigned short KBD_STAT_KRIE ; scalar_t__ KPSR ; scalar_t__ jiffies ; int /*<<< orphan*/ mod_timer (int /*<<< orphan*/ *,scalar_t__) ; scalar_t__ msecs_to_jiffies (int) ; unsigned short readw (scalar_t__) ; int /*<<< orphan*/ writew (unsigned short,scalar_t__) ; __attribute__((used)) static irqreturn_t imx_keypad_irq_handler(int irq, void *dev_id) { struct imx_keypad *keypad = dev_id; unsigned short reg_val; reg_val = readw(keypad->mmio_base + KPSR); /* Disable both interrupt types */ reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE); /* Clear interrupts status bits */ reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD; writew(reg_val, keypad->mmio_base + KPSR); if (keypad->enabled) { /* The matrix is supposed to be changed */ keypad->stable_count = 0; /* Schedule the scanning procedure near in the future */ mod_timer(&keypad->check_matrix_timer, jiffies + msecs_to_jiffies(2)); } return IRQ_HANDLED; }
[ "brenocfg@gmail.com" ]
brenocfg@gmail.com
fb7dc7d25f1efec59753dc854065bdd4a57f3719
4bcb76847e10b1cd0a19337715668c65e36337ae
/ios/Pods/Headers/Private/react-native-spinkit/RTSpinKitArcAnimation.h
8469910ed11942b202238fdab1eb297d935a7fce
[ "MIT" ]
permissive
lklima/constru-app
71d8e0e2a471cf2591e5d6b57fa94a8d12afdac3
168078625e77df03e012c33dba06ab0838191154
refs/heads/master
2022-12-26T16:57:59.265702
2020-02-27T01:48:27
2020-02-27T01:48:27
220,639,891
0
1
MIT
2022-12-10T08:21:39
2019-11-09T12:36:17
JavaScript
UTF-8
C
false
false
105
h
../../../../../node_modules/react-native-spinkit/ios/Libraries/SpinKit/Animations/RTSpinKitArcAnimation.h
[ "lkpro2011@gamil.com" ]
lkpro2011@gamil.com
bce5799844b63cfc6d76779fa2b61ace67dd3449
1bf8dbc04a8fd0d9eda69a09c62d4e96073d76f5
/Aps-Jogo/aleatorio.c
8f06fe56b7513a3b65b654d3992d3e9a6bf1638c
[]
no_license
HendricksSumeck/Torre-negra
ce3300e2f72f1a5f91c7dab0d6464af5994637bd
84e9f0b9af99c600cb8993a989c326655335ac93
refs/heads/master
2020-03-18T00:10:45.323911
2018-06-22T20:29:45
2018-06-22T20:29:45
134,081,722
0
0
null
null
null
null
UTF-8
C
false
false
615
c
#include <math.h> #include <stdlib.h> #include <stdio.h> #include "Personagem.h" double randomico_gausiano (double mu, double sigma) { double U1, U2, W, mult; static double X1, X2; static int call = 0; if (call == 1) { call = !call; return (mu + sigma * (double) X2); } do { U1 = -1 + ((double) rand () / RAND_MAX) * 2; U2 = -1 + ((double) rand () / RAND_MAX) * 2; W = pow (U1, 2) + pow (U2, 2); } while (W >= 1 || W == 0); mult = sqrt ((-2 * log (W)) / W); X1 = U1 * mult; X2 = U2 * mult; call = !call; return (mu + sigma * (double) X1); }
[ "hendrick@alunos.utfpr.edu.br" ]
hendrick@alunos.utfpr.edu.br
8e9da1ffe99caaeaeb39586685d5ff95b9e8cad6
30c984ecd771f1aea9000c4b90267f2d75d9a54f
/Embedded_cal_test/ecosystem/stm32f37x/c/cpal/inc/stm32f37x_i2c_cpal.h
3025f777067166c491f7477e9677c5b89ddc1e18
[]
no_license
vincentwenxuan/smores_document
682a491d0e0424ea54ead7aecb897409594a6770
bc1be012bcd10b80df41d3f61fa4aec1238fdcc9
refs/heads/master
2021-01-10T01:27:04.022279
2015-09-09T20:15:03
2015-09-09T20:15:03
36,809,619
0
0
null
null
null
null
WINDOWS-1252
C
false
false
33,136
h
/** ****************************************************************************** * @file stm32f37x_i2c_cpal.h * @author MCD Application Team * @version V1.0.0 * @date 20-September-2012 * @brief This file contains all the functions prototypes for the I2C firmware * layer. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2> * * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 * * 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. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ /*========= CPAL library files includes =========*/ #include "stm32f37x_i2c_cpal_hal.h" // circular dependence #include "stm32f37x_i2c_cpal_conf.h" // circular dependence /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F37X_I2C_CPAL_H #define __STM32F37X_I2C_CPAL_H //#include "common_peripherals.h" #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /*========= CPAL_Dev_TypeDef =========*/ /* CPAL devices enumeration contains the device instances */ typedef enum { CPAL_I2C1 = 0x00, /*!< Use I2C1 device */ CPAL_I2C2 = 0x01 /*!< Use I2C2 device */ }CPAL_DevTypeDef; /*========= CPAL_Direction_TypeDef =========*/ /* CPAL transfer directions enumeration is used to configure DMA channels (TX and RX) if CPAL_PROGMODEL_DMA is selected or TX/RX interrupts if CPAL_PROGMODEL_INTERRUPT is selected: - If CPAL_DIRECTION_TX is selected only TX DMA Channel or TX Interrupt is configured - If CPAL_DIRECTION_RX is selected only RX DMA Channel or RX Interrupt is configured - If CPAL_DIRECTION_TXRX is selected both TX and Rx DMA Channels or Interrupts are configured.*/ typedef enum { CPAL_DIRECTION_TX = 0x01, /*!<Transmitter only direction */ CPAL_DIRECTION_RX = 0x02, /*!<Receiver only direction */ CPAL_DIRECTION_TXRX = 0x03 /*!<Transmitter and Receiver direction */ }CPAL_DirectionTypeDef; /*========= CPAL_Mode_TypeDef =========*/ /* CPAL device Mode enumeration is used to select in which mode the device will proceed : in master mode or slave mode. When an I2C device is used in master mode, it will initiate communication by sending start bit. When it is used in slave mode, it will wait till receiving its own address to start communication.*/ typedef enum { CPAL_MODE_MASTER = 0x00, /*!< Use device as master */ CPAL_MODE_SLAVE = 0x01 /*!< Use device as slave */ }CPAL_ModeTypeDef; /*========= CPAL_ProgModel_TypeDef =========*/ /* CPAL Programming Models enumeration is used to define the programming model of device communication. - CPAL_PROGMODEL_DMA : device is programmed to communicate using DMA. - CPAL_PROGMODEL_INTERRUPT : device is programmed to communicate using interruption ( TXE , RXNE ...) handlers. - CPAL_PROGMODEL_POLLING : device is programmed to communicate using application polling routines (interrupts and DMA will not be used).*/ typedef enum { CPAL_PROGMODEL_INTERRUPT = 0x01, /*!<Interrupt transfer programming model */ CPAL_PROGMODEL_DMA = 0x02 /*!<DMA transfer programming model */ }CPAL_ProgModelTypeDef; /*========= CPAL_Transfer_TypeDef =========*/ /* CPAL Transfer structure contains all transfer parameters which are used in every Read or Write operation.*/ typedef struct { uint8_t* pbBuffer; /*!<The address of the buffer from/to which the transfer should start */ __IO uint32_t wNumData; /*!<Number of data to be transferred for the current transaction */ uint32_t wAddr1; /*!<Contains the Target device Address (optional)*/ uint32_t wAddr2; /*!<Contains the Register/Physical Address into the device (optional) */ } CPAL_TransferTypeDef; /*========= CPAL_State_TypeDef =========*/ /* CPAL global State enumeration contains the current state of CPAL communication. Before starting each operation this state is tested. After each operation CPAL_State is updated with the new value resulting from the relative operation.*/ typedef enum { CPAL_STATE_DISABLED = 0x00, /*!<The Disabled state indicates that the device is not configured.*/ CPAL_STATE_READY = 0x01, /*!<The Ready state indicates that the device is configured correctly and is ready for read or write operation and/or the last transaction has been successfully completed */ CPAL_STATE_READY_TX = 0x03, /*!<The Ready_TX state indicates that the device is ready for transmission operation */ CPAL_STATE_READY_RX = 0x05, /*!<The Ready_RX state indicates that the device is ready for reception operation */ CPAL_STATE_BUSY = 0x02, /*!<The Busy state indicates that a Write or Read operation started */ CPAL_STATE_BUSY_TX = 0x06, /*!<The Busy_TX state indicates that a transmission operation is on going */ CPAL_STATE_BUSY_RX = 0x0A, /*!<The Busy_RX state indicates that a reception operation is on going */ CPAL_STATE_ERROR = 0x10, /*!<The Error state indicates that the last operation failed. To determine which error caused the failure, read the device status structure.*/ }CPAL_StateTypeDef; /*========= CPAL_I2CError_TypeDef =========*/ /* I2C Errors TypeDef */ typedef enum { CPAL_I2C_ERR_NONE = 0x00000000, /*!<No Error: This is the default state for an Idle peripheral */ CPAL_I2C_ERR_TIMEOUT = 0x000000FF, /*!<Timeout error: The specified timeout has been elapsed without any response (expected flag or data didn't happen at expected time).*/ CPAL_I2C_ERR_BERR = 0x00000100, /*!<A bus error is detected when a START or a STOP condition is detected and is not located after a multiple of 9 SCL clock pulses. The bus error flag is set only in case the I2C is involved in the transfer as master or addressed slave. In case of a misplaced START or ReSTART detection, the I2C enters address recognition state as for a correct START condition. When a bus error is detected, BERR flag is set in I2C_ISR register, and an interrupt is generated if ERRIE is set in I2C_CR1 register.*/ CPAL_I2C_ERR_ARLO = 0x00000200, /*!<An arbitration loss is detected when a high level is sent on SDA, but a low level is sampled on the SCL rising edge. - In master mode, the arbitration loss is detected during address phase, data phase and data acknowledge phase. In that case, SDA and SCL lines are released, START control bit is cleared by hardware and the master switches automatically to slave mode. - In slave mode, arbitration loss is detected during data phase and data acknowledge phase. In that case, the transmission is stopped, and SCL and SDA lines are released. When an arbitration loss is detected, ARLO flag is set in I2C_ISR register, and an interrupt is generated if ERRIE is set in I2C_CR1 register.*/ CPAL_I2C_ERR_AF = 0x00000010, /*!<Acknowledge Failure : NACK is considered as error only when this event is set in master mode. - If Master: a Stop or repeated Start condition must be generated by software. When a NACK is detected, NACKF flag is set in I2C_ISR register, and an interrupt is generated if NACKIE is set in I2C_CR1 register.*/ CPAL_I2C_ERR_OVR = 0x00000400, /*!<An overrun or underrun error is detected in slave mode when NOSTRETCH=1 and: - In reception when a new byte is received and the RXDR register has not been read yet New received byte is lost, and a NACK is automatically sent as a response to the new byte. - In transmission : – when STOPF=1 and the first data should be sent. The content of TXDATA is sent. – when a new byte should be sent and the TXDR register has not been written yet. The content of TXDATA is sent (same byte is sent twice) When an overrun or underrun error is detected, OVR flag is set in I2C_ISR register, and an interrupt is generated if ERRIE is set in I2C_CR1 register.*/ }CPAL_I2CErrorTypeDef; /*========= CPAL_Dev_TypeDef =========*/ /* CPAL Device structure definition */ typedef struct { CPAL_DevTypeDef CPAL_Dev; /*!<Instance of the device. This parameter can be one of the following values: CPAL_Dev_TypeDef */ CPAL_DirectionTypeDef CPAL_Direction; /*!<Specifies the direction for the device transfers. It can be one of the following values: CPAL_Direction_TypeDef */ CPAL_ModeTypeDef CPAL_Mode; /*!<Specifies the maser/slave mode of device. It can be one of the following values: CPAL_Mode_TypeDef */ CPAL_ProgModelTypeDef CPAL_ProgModel; /*!<Specifies the programming model for the device transfers. It can be one of the following values: CPAL_ProgModel_Enum */ CPAL_TransferTypeDef* pCPAL_TransferTx; /*!<Pointer on a structure specifying the parameters of the current transmission operations. The structure fields are specified as follows: CPAL_Transfer_TypeDef. Use pNULL value if this direction is not needed.*/ CPAL_TransferTypeDef* pCPAL_TransferRx; /*!<Pointer on a structure specifying the parameters of the current reception operations. The structure fields are specified as follows: CPAL_Transfer_TypeDef. Use pNULL value if this direction is not needed.*/ __IO CPAL_StateTypeDef CPAL_State; /*!<Holds the current State of the CPAL driver relative to the device instantiated by CPAL_Dev field. The state parameter can be one of the following values: CPAL_State_Enum */ __IO uint32_t wCPAL_DevError; /*!<Specifies the error code for the current operation.The error codes are specified for each device type as follows: CPAL_I2CError_Enum for I2C devices */ uint32_t wCPAL_Options; /*!<Bit-field value specifying additional options for the configuration of the device: The bit-field value can be any combination of following values: CPAL_Options_Enum. When a value is not selected the relative feature is disabled */ __IO uint32_t wCPAL_Timeout; /*!<This field is with timeout procedure. its used to detect timeout */ I2C_InitTypeDef* pCPAL_I2C_Struct; /*!<Pointer to a device Initialization structure as described in the standard device library driver. A NULL pointer can be provided for this field and, in this case, the default values will be used for all the device initialization. If only some fields need to be modified for the initialization, one can use the CPAL_PPP_StructInit() function just before setting the needed fields. Example: CPAL_InitTypeDef I2C1_DevStructure; CPAL_I2C_StructInit(&I2C1_DevStructure); I2C1_DevStructure->pI2C_Struct->I2C_Timing= 0x4010000A; CPAL_I2C_Init(&I2C1_DevStructure); */ }CPAL_InitTypeDef; /*========= Table containing all I2C device structures =========*/ extern CPAL_InitTypeDef* I2C_DevStructures[]; /*========= CPAL_Global_Device_Structures =========*/ /* CPAL Global Device Structures are the Global default structures which are used to handle devices configuration and status.*/ #ifdef CPAL_USE_I2C1 extern CPAL_InitTypeDef I2C1_DevStructure; #endif /* CPAL_USE_I2C1 */ #ifdef CPAL_USE_I2C2 extern CPAL_InitTypeDef I2C2_DevStructure; #endif /* CPAL_USE_I2C2 */ /* Exported constants --------------------------------------------------------*/ /*========= CPAL_Options_TypeDef =========*/ /* CPAL Options defines contains configuration options which can be affected to wCPAL_Options which is a bit-field argument so any combination of these parameters can be selected. If one option is not selected then the relative feature is disabled. There are common options and device specific options.*/ #define CPAL_OPT_I2C_DUALADDR ((uint32_t)0x00000001) /*!<Use Dual Address Mode (available in Slave Mode only). To use this option enable it by affecting this define and own address2 to wCPAL_Options */ #define CPAL_OPT_DMATX_HTIT ((uint32_t)0x00000200) /*!<Enable the Transmitter DMA Half Transfer Complete interrupt */ #define CPAL_OPT_DMARX_HTIT ((uint32_t)0x00001000) /*!<Enable the Receiver DMA Half Transfer Complete interrupt */ #define CPAL_OPT_DMATX_CIRCULAR ((uint32_t)0x00004000) /*!<Enable the Circular Mode for DMA Transmitter */ #define CPAL_OPT_DMARX_CIRCULAR ((uint32_t)0x00008000) /*!<Enable the Circular Mode for DMA Receiver */ #define CPAL_OPT_NO_MEM_ADDR ((uint32_t)0x00010000) /*!<Enable No Memory addressing mode: only slave device address sent No Register/Physical address to be sent after slave address */ #define CPAL_OPT_16BIT_REG ((uint32_t)0x00020000) /*!<Enable 16-Bit Register/Physical addressing mode (two bytes, MSB first). This option is supported only when CPAL_OPT_NO_MEM_ADDR option is not set */ #define CPAL_OPT_I2C_GENCALL ((uint32_t)0x00100000) /*!<Use General Call Address Mode (available in Slave Mode only) (General Call Address = 0x00) */ #define CPAL_OPT_I2C_AUTOMATIC_END ((uint32_t)0x00200000) /*!<Enable Automatic end mode of STOP generation for master */ #define CPAL_OPT_I2C_ERRIT_DISABLE ((uint32_t)0x00400000) /*!<Disable I2C Errors interrupt (Bus Error, Arbitration Loss, Acknowledge Failure and Overrun/Underrun Errors). By default, errors interrupt is enabled to manage errors efficiently */ #define CPAL_OPT_I2C_NOSTOP ((uint32_t)0x00800000) /*!<Use communication mode with no STOP generation at the end of data transfer (for multi-read/write operations) */ #define CPAL_OPT_I2C_NOSTOP_MODE ((uint32_t)0x01000000) /*!<Start communication in No STOP generation mode and close communication by Generating stop */ #define CPAL_OPT_I2C_OA2_MASK ((uint32_t)0x0E000000) /*!<Contain Own Address 2 Mask (OA2MSK is coded on 3 bit)*/ #define CPAL_OPT_I2C_10BIT_HEADR ((uint32_t)0x10000000) /*!<Enable the send of slave address-10bit-header only when switching from master transmitter to master receiver mode with No stop generation option enabled */ #define CPAL_OPT_I2C_WAKEUP_STOP ((uint32_t)0x20000000) /*!<Enable the WakeUp from stop capability for the I2C slave device */ #define CPAL_OPT_I2C_NACK_ADD ((uint32_t)0x40000000) /*!<Initialize the I2C Slave device without enabling the acknowledgement of its own address. This option must not be used with No Stop generation mode */ /*========= CPAL_Interne_Defines =========*/ #define CPAL_PASS ((uint32_t)0x00000000) /*!<This value is returned if the last operation succeed */ #define CPAL_FAIL ((uint32_t)0x00000001) /*!<This value is returned if the last operation failed */ #define pNULL (void*)0 /*!<This Value is used to initialise a null pointer */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /*========= CPAL_I2C_Exported_Functions =========*/ /* These functions constitute the main CPAL API interface. All functions take as argument the CPAL_InitTypeDef structure defined in @ref CPAL_Dev_TypeDef. */ uint32_t CPAL_I2C_Init (CPAL_InitTypeDef* pDevInitStruct); /*<!This function Initializes the selected I2C device and all needed resources (GPIOs, clocks, DMA, interrupts …)*/ uint32_t CPAL_I2C_DeInit (CPAL_InitTypeDef* pDevInitStruct); /*<!This function free the resources used by the I2C device (GPIOs, clocks, DMA, interrupts …) and deinitialize the device itself */ uint32_t CPAL_I2C_StructInit (CPAL_InitTypeDef* pDevInitStruct); /*<!This function Initializes I2C device structure by filling all fields with their default values. Warning: Pointer fields are filled with CPAL local variables pointer. To avoid all risks, it is recommended to declare application local variables and fill these fields with their pointers.*/ #if defined (CPAL_I2C_MASTER_MODE) || ! defined (CPAL_I2C_LISTEN_MODE) uint32_t CPAL_I2C_Write (CPAL_InitTypeDef* pDevInitStruct); /*<!This function Writes data to the specified I2C device. All information relative to the write transfer parameters and current status are extracted from pCPAL_TransferTx field defined in @ref CPAL_Transfer_TypeDef */ uint32_t CPAL_I2C_Read (CPAL_InitTypeDef* pDevInitStruct); /*<!This function Read data from the specified I2C device All information relative to the read transfer parameters and current status are extracted from pCPAL_TransferTx field defined in @ref CPAL_Transfer_TypeDef */ #endif /* CPAL_I2C_MASTER_MODE || ! CPAL_I2C_LISTEN_MODE */ #if defined (CPAL_I2C_LISTEN_MODE) && defined (CPAL_I2C_SLAVE_MODE) uint32_t CPAL_I2C_Listen (CPAL_InitTypeDef* pDevInitStruct); /*<!This function allows the specified I2C device to enter listen mode All information relative to the read or write transfer parameters and current status are extracted from fields defined in @ref CPAL_Transfer_TypeDef */ #endif /* CPAL_I2C_LISTEN_MODE && CPAL_I2C_SLAVE_MODE */ uint32_t CPAL_I2C_IsDeviceReady(CPAL_InitTypeDef* pDevInitStruct); /*<!This function can be used to wait until target device is ready for communication (ie. for memories after write operations) */ uint32_t CPAL_I2C_EV_IRQHandler(CPAL_InitTypeDef* pDevInitStruct); /*<!This function manages all I2C device events */ uint32_t CPAL_I2C_ER_IRQHandler(CPAL_InitTypeDef* pDevInitStruct); /*<!This function manages all I2C device errors */ #ifdef CPAL_I2C_DMA_PROGMODEL uint32_t CPAL_I2C_DMA_TX_IRQHandler(CPAL_InitTypeDef* pDevInitStruct); /*<!This function Handles DMA TX Interrupts */ uint32_t CPAL_I2C_DMA_RX_IRQHandler(CPAL_InitTypeDef* pDevInitStruct); /*<!This function Handles DMA RX Interrupts */ #endif /* CPAL_I2C_DMA_PROGMODEL */ void CPAL_HAL_NVICInit(void); /*<! Initialize NVIC Priority Group */ /*========= Local DMA and IT Manager =========*/ //This function Configure I2C DMA and Interrupts before starting uint32_t CPAL_I2C_Enable_DMA_IT (CPAL_InitTypeDef* pDevInitStruct, CPAL_DirectionTypeDef Direction); /*========== CPAL_TIMEOUT_Callback ==========*/ #ifndef CPAL_TIMEOUT_UserCallback uint32_t CPAL_TIMEOUT_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when a Timeout occurs during communication with devices */ #endif /*========= CPAL_I2C_User_Callbacks =========*/ /* These functions prototypes only are declared here. User can (optionally) implement the function body in his own application depending on the application needs. Each callback is called in a particular situation detailed in the callback description.*/ #ifndef CPAL_I2C_TX_UserCallback void CPAL_I2C_TX_UserCallback (CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in Interrupt mode) the peripheral is preparing to send data */ #endif #ifndef CPAL_I2C_RX_UserCallback void CPAL_I2C_RX_UserCallback (CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in Interrupt mode) the peripheral has received data */ #endif #ifndef CPAL_I2C_TXTC_UserCallback void CPAL_I2C_TXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in DMA or Interrupt mode) TX Transfer is complete (to use in DMA mode, Transfer complete interrupt must be enabled) */ #endif #ifndef CPAL_I2C_RXTC_UserCallback void CPAL_I2C_RXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in DMA or Interrupt mode) RX Transfer is complete (to use in DMA mode, Transfer complete interrupt must be enabled) */ #endif #ifndef CPAL_I2C_DMATXTC_UserCallback void CPAL_I2C_DMATXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called (in DMA mode) when DMA Transmission is finished (If Transfer Complete interrupt is enabled) */ #endif #ifndef CPAL_I2C_DMATXHT_UserCallback void CPAL_I2C_DMATXHT_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called (in DMA mode) when the DMA Transmission has reached the half of the buffer (If Half Transfer interrupt is enabled) */ #endif #ifndef CPAL_I2C_DMATXTE_UserCallback void CPAL_I2C_DMATXTE_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in DMA mode) a DMA Transmission transfer error has occurred (If Transfer Error interrupt is enabled ) */ #endif #ifndef CPAL_I2C_DMARXTC_UserCallback void CPAL_I2C_DMARXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in DMA mode) when DMA Reception is finished (If Transfer Complete interrupt is enabled) */ #endif #ifndef CPAL_I2C_DMARXHT_UserCallback void CPAL_I2C_DMARXHT_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in DMA mode) the DMA Reception has reached the half of the buffer (If Half Transfer interrupt is enabled) */ #endif #ifndef CPAL_I2C_DMARXTE_UserCallback void CPAL_I2C_DMARXTE_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when (in DMA mode) a DMA Reception transfer error has occurred (If Transfer Error interrupt is enabled ) */ #endif #ifndef CPAL_I2C_GENCALL_UserCallback void CPAL_I2C_GENCALL_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when General Call mode is set (used in General Call Mode only ) */ #endif #ifndef CPAL_I2C_DUALF_UserCallback void CPAL_I2C_DUALF_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when Slave OA2 Address matched (used in Dual Address Mode only ) */ #endif #ifndef CPAL_I2C_SLAVE_READ_UserCallback void CPAL_I2C_SLAVE_READ_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when a write operation is requested from master in Listen mode only */ #endif #ifndef CPAL_I2C_SLAVE_WRITE_UserCallback void CPAL_I2C_SLAVE_WRITE_UserCallback(CPAL_InitTypeDef* pDevInitStruct); /*<!This function is called when a read operation is requested from master in Listen mode only */ #endif /*========= CPAL_User_ErrorCallback_Prototypes =========*/ /* User can use two types of Callback: - Single Error Callback : All error are handled by one Callback (CPAL_I2C_ERR_UserCallback()). - Multiple Error Callback : Each error has its own Callback ( CPAL_I2C_ERRTYPE_UserCallback () , ERRTYPE : can be one of I2C Errors (BERR, ARLO, OVR and NACK)). To select one of this type, user should comment or uncomment adequate defines in stm32f37x_i2c_cpal_conf.h file. */ #ifdef USE_SINGLE_ERROR_CALLBACK #ifndef CPAL_I2C_ERR_UserCallback void CPAL_I2C_ERR_UserCallback(CPAL_DevTypeDef pDevInstance, uint32_t DeviceError); /*<!This callback is called when an error occurred on the peripheral while transferring (If I2C Error interrupt is enabled). Device instance and error type (DeviceError) are passed as argument. Device_Error value can be one of CPAL_I2CErrorTypeDef enumeration */ #endif #endif /* USE_SINGLE_ERROR_CALLBACK */ #ifdef USE_MULTIPLE_ERROR_CALLBACK #ifndef CPAL_I2C_BERR_UserCallback void CPAL_I2C_BERR_UserCallback(CPAL_DevTypeDef pDevInstance); /*<!This callback is called when an Bus ERROR occurred on the peripheral while transferring (If I2C Error interrupt is enabled) */ #endif #ifndef CPAL_I2C_ARLO_UserCallback void CPAL_I2C_ARLO_UserCallback(CPAL_DevTypeDef pDevInstance); /*<!This callback is called when an Arbitration Lost ERROR occurred on the peripheral while transferring (If I2C Error interrupt is enabled) */ #endif #ifndef CPAL_I2C_OVR_UserCallback void CPAL_I2C_OVR_UserCallback(CPAL_DevTypeDef pDevInstance); /*<!This callback is called when an Overrun/Underrun ERROR occurred on the peripheral while transferring (If I2C Error interrupt is enabled) */ #endif #ifndef CPAL_I2C_AF_UserCallback void CPAL_I2C_AF_UserCallback(CPAL_DevTypeDef pDevInstance); /*<!This callback is called when an Not Acknowledge is received (If I2C NACK interrupt is enabled) */ #endif #endif /* USE_SINGLE_ERROR_CALLBACK */ #ifdef __cplusplus } #endif #endif /*__STM32F37X_I2C_CPAL_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
[ "xiaojun.sun086@gmail.com" ]
xiaojun.sun086@gmail.com
8985a7c98084feb0d19cfafa8616fdc5d8d49507
83aeb5fa926d994985f7dd12d2b5b67b6e83842e
/lib/libustat/ustat.c
238975408fb2ccd66a1ebbc99eb1fceb05eed410
[ "Apache-2.0" ]
permissive
tejasce/dssd
e5f6b97cf4538da625de841ebaf347ad0aae3ce8
fe32ec53fadda654028676bde14760c9f15c4dba
refs/heads/master
2022-11-08T20:35:50.657390
2020-06-26T08:04:28
2020-06-26T08:04:28
274,993,171
0
0
Apache-2.0
2020-06-26T08:04:29
2020-06-25T18:58:25
C
UTF-8
C
false
false
74,585
c
/* * Copyright 2017 Dell Inc. or its subsidiaries. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Userland Statistics * * libustat provides a simple mechanism for clients to declare a namespace of * statistics such as integer counters and strings, and export those stats to * consumers. Statistics can be examined live while the producer is running, * examined post-mortem from an archived file, or even read from a core file. * The ustat facility is inspired by the Solaris kernel kstat facility, with * the benefit of many lessons learned from a decade of experience with kstat. * * 1. Interface Design and Lessons Learned * * The top-level interfaces have been simplified: in particular, the notion * of having separate calls to create and install a stat no longer exists, * and the implementation notion of an update "chain" is removed as well. * * The notion of 'raw' kstats where the entire group itself is raw and has * no apparent structure is entirely removed. However, individual named * elements that are just sequences of bytes are permitted. * * The notion of a 'class' that is a set of #defines is eliminated. Instead, * class is an ops-vector that client programs can use to define their own * customized classes, without needing to modify this library to do so. * * The set of intrinsic types is enriched to include SIZE (formatted with * size suffixes), TOD, CLOCK, and DELTA (formatted as various kinds of time) * and UUID (an RFC 4122-style UUID) and pretty-printing routines are provided. * * The namespace hierarchy is more flexible, but names are validated against * an identifier syntax. kstat enforced a rigid namespace more suited to * the kernel (e.g. an integer 'instance' was mandated), but did not require * that string names conformed to C identifier syntax, which helps debuggers. * * The value structure is now opaque, and updates to values are performed by * an optimized function, not by caller code. This improvement and tradeoffs * associated are discussed in detail in comments for _ustat_atomic_add_int() * below. * * The library provides a mechanism for keeping the previous snapshot of a * group around and accessible, so that a client can easily compute and report * deltas between the latest snapshot of a group and its previous snapshot. * * 2. Namespace * * In the original kstat design, the kstat namespace consisted of the four- * element tuple (module, instance, gname, sname) where module and instance * were not restricted, and instance was an integer (i.e. a driver instance * number), and sname was originally optional in the case of raw kstats. * For the userland design, we simplify this a bit but add restrictions to * make things easier for accessing statistics in a debugger: * * The ustat namespace consists of the triplet (entity, group, name) where * entity is required to be a dot-delimited sequence of identifiers defined * by the caller, group is required to be an identifier, and name is required * to be an identifier. As such, the "full path" to any statistic can be * defined by just concatenating the string to <entity>.<group>.<name> * * The ustat namespace is per-process, but ustats from multiple processes can * be joined by just using the /proc comm name and pid at the top of it. (The * ustat utility uses this form when multiple -p options are specified.) * * The 'entity' is intended to be something that identifies an abstraction in * the caller's program. For example, an ftp server might use an 'entity' * name of "user.mws" for the stats related to my session, and therefore * the full path "user.mws.io.rbytes" might be how many bytes read and the * the full path "user.mws.auth.type" might refer to my authentication model. * * 3. Snapshot Mechanism * * The major challenge in implementing ustat is how to handle snapshots between * producers and consumers, whereby a consumer can get a consistent copy of a * stat group without imposing significant performance penalty on the producer. * This challenge remains unsolved. For the time being, we favor the producer * and permit the consumer to read data that may be inconsistent. * * 4. Data Layout * * Our means of IPC, a shared file in /tmp, is also our data format: if you * simply don't delete your file, then a consumer can read your statistics * post-mortem with the same exact code. And reading stats from a core file * is almost the same code again: instead of reading the file and mmap'ing * pages in order, we traverse the core's ELF Phdrs, find our pages * out-of-order, and map them. * * Every stat group is allocated to a single VM page. If the entity name and * group name total 32 bytes, and the group consists solely of integer * statistics with an average name length of 8 bytes, then a ustat group can * accomodate 80 statistics on a system with a 4K pagesize. The data on each * page is arranged as follows by ustat_insert(): * * +-----------------+ * | ustat_page_t | <-- page magic and metadata * +-----------------+ * | ustat_group_t | <-- stat group metadata * +-----------------+ * | ustat_named_t[] | <-- array of stats as specified by the caller * +-----------------+ * | ustat_value_t[] | <-- array of values, one per stat * +-----------------+ * | string table | <-- array of strings (for ustat_{group,class_named}_t) * +-----------------+ * | byte arrays | <-- array of xlen bytes (for variable-length types) * +-----------------+ * * 5. Other Userland Issues * * libustat must handle fork carefully for two reasons: (1) like any MT-safe * library we have to be sure we grab all our locks and then release them * again in both the parent and the forked child; and (2) we want our child * to copy all of his current statistics out to a new stat file associated * with the child pid, i.e. forking the file as well as the process. * * libustat must handle exec and exit because the default behavior needs to be * that clients do not leave an ever-increasing number of stat files around * the filesystem when they run. Interposing on exit is relatively easy, but * exec is more complicated-- since no atexec(3) exists in UNIX, we have to * interpose on all the exec(2) variants, delete our file before an attempted * exec, and then relink our file if the exec fails. */ #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/param.h> #include <assert.h> #include <signal.h> #include <unistd.h> #include <alloca.h> #include <limits.h> #include <dirent.h> #include <inttypes.h> #include <ucontext.h> #include <fnmatch.h> #include <strings.h> #include <string.h> #include <stdlib.h> #include <stddef.h> #include <stdarg.h> #include <stdio.h> #include <dlfcn.h> #include <fcntl.h> #include <ctype.h> #include <errno.h> #include <elf.h> #include <nelf.h> #include <vmem.h> #include <hrtime.h> #include <ustat_hg.h> #include <ustat_io.h> #include <ustat_ms.h> #include <ustat_impl.h> #include <ucore.h> #include <list.h> #include <bson.h> #define UU_UUID_BIN_LEN 16 #define UU_UUID_STR_LEN 36 #define USTAT_ROOT_PREFIX "/dev/shm/.ustat.%s.%d.%d." #define USTAT_ROOT_PATTERN USTAT_ROOT_PREFIX "XXXXXX" #define USTAT_ROOT_HLEN 211 #define USTAT_ROOT_MODE 0777 #define USTAT_STAT_MODE 0644 #define USTAT_TYPE_BY_VAL(n) ((n)->usn_type < USTAT_TYPE_STRING) #define USTAT_TYPE_BY_REF(n) ((n)->usn_type >= USTAT_TYPE_STRING) #define USTAT_PAGE_RELO(ptr, old, new) \ (ptr = (void *)((uintptr_t)ptr - (uintptr_t)(old) + (uintptr_t)(new))) static int ustat_update_file(ustat_handle_t *); static int ustat_update_core(ustat_handle_t *); static int ustat_misc_export_bson(ustat_struct_t *, int, bson_t *, off_t); static pthread_mutex_t ustat_lock = PTHREAD_MUTEX_INITIALIZER; static ustat_handle_t *ustat_list = NULL; const ustat_class_t ustat_class_misc = { .usc_name = "misc", .usc_ctor = NULL, .usc_dtor = NULL, .usc_bson = ustat_misc_export_bson, }; static __thread int ustat_class_ctor; static const uint8_t ustat_magicstr[] = { USTAT_MAG0, USTAT_MAG1, USTAT_MAG2 }; const ustat_unit_t ustat_unit_size = { 1024, "B\0K\0M\0G\0T\0P\0E\0" }; const ustat_unit_t ustat_unit_time = { 1000, "ns\0us\0ms\0s\0" }; const ustat_unit_t ustat_unit_iops = { 1000, "\0K\0M\0B\0T\0" }; const ustat_unit_t ustat_unit_tput = { 1000, "b/s\0K/s\0M/s\0G/s\0T/s\0P/s\0E/s\0" }; static const char * ustat_strbadid(const char *s, const char *extras) { const char *p; char c; if (s == NULL) return ((char *)-1L); for (p = s; (c = *p) != '\0'; p++) { if (isalpha(c) || c == '_') continue; else if (p > s && (isdigit(c) || strchr(extras, c) != NULL)) continue; else return (p); } if (p == s) return (p); return (NULL); } static uint32_t ustat_strhash(const char *s) { uint32_t g, h = 0; const char *p; for (p = s; *p != '\0'; p++) { h = (h << 4) + *p; if ((g = (h & 0xf0000000)) != 0) { h ^= (g >> 24); h ^= g; } } return (h); } static int ustat_env2flags(const char *v) { int oflags = 0; char *e, *p, *q; size_t len; len = strlen(v); e = alloca(len + 1); (void) strcpy(e, v); for (p = strtok_r(e, ",", &q); p != NULL; p = strtok_r(NULL, ",", &q)) { if (strcmp(p, "abort") == 0) oflags |= USTAT_DEBUG_ABORT; else if (strcmp(p, "verbose") == 0) oflags |= USTAT_DEBUG_VERBOSE; } return (oflags); } static int __attribute__ ((format(printf, 3, 0))) ustat_verror(const ustat_handle_t *h, int err, const char *format, va_list ap) { int flags; char *e; if (h != NULL) flags = h->ush_oflags; else if ((e = getenv("USTAT_DEBUG")) != NULL) flags = ustat_env2flags(e); else flags = 0; #if defined(USTAT_DEBUG) /* * Force verbose mode when the developer has enabled USTAT_DEBUG since * the whole point is to print ustat debugging messages for this state. */ flags |= USTAT_DEBUG_VERBOSE; #endif if (flags & USTAT_DEBUG_VERBOSE) { (void) fprintf(stderr, "ustat error: "); (void) vfprintf(stderr, format, ap); (void) fprintf(stderr, "\n"); } if (flags & USTAT_DEBUG_ABORT) { sigset_t set; (void) sigfillset(&set); (void) sigdelset(&set, SIGABRT); (void) sigprocmask(SIG_SETMASK, &set, NULL); abort(); } errno = err; return (-1); } int __attribute__ ((format(printf, 3, 4))) ustat_error(const ustat_handle_t *h, int err, const char *format, ...) { va_list ap; va_start(ap, format); err = ustat_verror(h, err, format, ap); va_end(ap); return (err); } static inline void ustat_caller_error(const ustat_struct_t *s, const ustat_named_t *n, const char *msg) { const ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); (void) ustat_error(g->usg_handle, EINVAL, "%s.%s: %s\n", g->usg_gname, n->usn_name, msg); } void * __attribute__ ((format(printf, 3, 4))) ustat_null(const ustat_handle_t *h, int err, const char *format, ...) { va_list ap; va_start(ap, format); (void) ustat_verror(h, err, format, ap); va_end(ap); return (NULL); } static bool ustat_is_readonly(ustat_handle_t *h) { return ((h->ush_oflags & O_ACCMODE) == O_RDONLY); } static bool ustat_is_writeonly(ustat_handle_t *h) { return ((h->ush_oflags & O_ACCMODE) == O_WRONLY); } static ustat_page_t * ustat_page_mapin(ustat_handle_t *h, off_t off, size_t len, int map_type) { ustat_page_t *p; int prot, flag; if (ustat_is_readonly(h) || map_type == MAP_PRIVATE) { prot = PROT_READ | PROT_WRITE; flag = MAP_PRIVATE | MAP_POPULATE; } else { prot = PROT_READ | PROT_WRITE; flag = MAP_SHARED; } p = mmap(NULL, len, prot, flag, h->ush_fd, off); return (p == MAP_FAILED ? NULL : p); } /* * We use a freelist to track unused regions of the ustat file. When * inserting a new ustat, we look at the freelist before growing the file. * To keep interactions with asynchronous readers simple, once a region * of the file has been used for a page of a particular size it may only * be reused for new pages of the same size. * * Because most regions will be 1 page long, we maintain two lists, one * for 1 page regions and one for regions of all other sizes. */ static list_t * ustat_freepage_list(ustat_handle_t *h, size_t size) { return (size == h->ush_pgsize ? &h->ush_free_pgsz : &h->ush_free_other); } static void ustat_freepage_put(ustat_handle_t *h, ustat_page_t *p) { list_t *list = ustat_freepage_list(h, p->usp_size); ustat_freepage_t *fp; if ((p->usp_magic[3] & USTAT_MAG3_TYPE) != USTAT_MAG3_GRP) return; fp = vmem_zalloc(vmem_heap, sizeof (ustat_freepage_t), VM_NOFAIL); fp->usfp_off = p->usp_off; fp->usfp_size = p->usp_size; list_insert_head(list, fp); } static ustat_page_t * ustat_freepage_get(ustat_handle_t *h, uint8_t type, size_t size) { list_t *list = ustat_freepage_list(h, size); ustat_freepage_t *fp; ustat_page_t *p; void *s; if (type != USTAT_MAG3_GRP) return (NULL); for (fp = list_head(list); fp != NULL && fp->usfp_size != size; fp = list_next(list, fp)) continue; if (fp == NULL || (p = ustat_page_mapin(h, fp->usfp_off, fp->usfp_size, MAP_SHARED)) == NULL) return (NULL); /* * Rezero the page, as if freshly minted. As the ustat_page_t is * the file's record marking mechanism, it must be left intact. * Re-writing it manually should be a no-op, but is done anyway * to ensure the correctness its primary consumer, our caller. */ s = USTAT_PAGE_TO_DATA(p); memset(s, 0, size - ((char *)s - (char *)p)); p->usp_off = fp->usfp_off; list_delete(list, fp); vmem_free(vmem_heap, fp, sizeof (ustat_freepage_t)); return (p); } static void ustat_freepage_empty(list_t *l) { ustat_freepage_t *fp; while ((fp = list_head(l)) != NULL) { list_delete(l, fp); vmem_free(vmem_heap, fp, sizeof (ustat_freepage_t)); } } /* * Linux strangely does not support fallocate(), their own fancy system call, * on tmpfs. So instead we use the older trick of writing a zero byte at the * end to be sure we can mmap up to a given range, and then attempt a fallocate * anyway, cast to void, to tell any supporting filesystem to alloc space now. */ static int ustat_falloc(int fd, off_t offset, off_t len) { uint8_t z = 0; if (pwrite(fd, &z, sizeof (z), offset + len - sizeof (z)) != sizeof (z)) return (-1); (void) fallocate(fd, 0, offset, len); return (0); } static ustat_page_t * ustat_page_create(ustat_handle_t *h, uint8_t type, size_t size) { ustat_page_t *p; if ((p = ustat_freepage_get(h, type, size)) == NULL) { if (ustat_falloc(h->ush_fd, h->ush_fdlen, size) != 0) return (NULL); if ((p = ustat_page_mapin(h, h->ush_fdlen, size, MAP_SHARED)) == NULL) { (void) ftruncate(h->ush_fd, h->ush_fdlen); return (NULL); } p->usp_off = h->ush_fdlen; h->ush_fdlen += size; } p->usp_magic[0] = USTAT_MAG0; p->usp_magic[1] = USTAT_MAG1; p->usp_magic[2] = USTAT_MAG2; p->usp_magic[3] = USTAT_MAG3 | type; p->usp_addr = p; p->usp_size = size; return (p); } static ustat_page_t * ustat_page_recreate(ustat_handle_t *h, off_t off, size_t lim) { ustat_page_t *p; if ((p = ustat_page_mapin(h, off, h->ush_pgsize, MAP_SHARED)) == NULL) return (NULL); if (bcmp(p->usp_magic, ustat_magicstr, sizeof (ustat_magicstr)) != 0) { (void) munmap(p, h->ush_pgsize); return (ustat_null(h, EINVAL, "not a ustat page: %p", p)); } /* * If the page's encoded size exceeds the caller's predefined limit, * then treat this as if the page could not be mapped. This might * happen (for example) if a core file is truncated after the Phdrs. */ if (p->usp_size > lim) { (void) munmap(p, h->ush_pgsize); return (ustat_null(h, ERANGE, "page %p size %u exceeds limit: %zu", p, p->usp_size, lim)); } /* * If we mapped the page with unknown size, and it appears valid, * resize the mapping according to the saved size if larger than pgsize */ if (p->usp_size > h->ush_pgsize) { ustat_page_t *o = p; p = ustat_page_mapin(h, off, p->usp_size, MAP_SHARED); (void) munmap(o, h->ush_pgsize); } return (p); } static void ustat_page_destroy(ustat_handle_t *h, ustat_page_t *p) { if (p != NULL) (void) munmap(p, p->usp_size); } static ustat_page_t * ustat_page_lookup(const void *data, size_t size) { for (uintptr_t addr = (uintptr_t)data; addr != 0; addr -= size) { ustat_page_t *p = (ustat_page_t *)P2ALIGN(addr, size); if (bcmp(p->usp_magic, ustat_magicstr, sizeof (ustat_magicstr)) == 0) return (p); } return (NULL); } static int ustat_page_rewrite(ustat_handle_t *h, ustat_page_t *dst) { ustat_page_t *src; if (pwrite(h->ush_fd, dst, dst->usp_size, dst->usp_off) != (ssize_t)dst->usp_size) { return (ustat_error(h, errno, "failed to rewrite %p (%s[%zd]): write failed: %s", (void *) dst, h->ush_path, (size_t)dst->usp_off, strerror(errno))); } if ((src = ustat_page_mapin(h, dst->usp_off, dst->usp_size, MAP_SHARED)) == NULL) { return (ustat_error(h, errno, "failed to rewrite %p (%s[%zd]): mapin failed: %s", (void *) dst, h->ush_path, (size_t)dst->usp_off, strerror(errno))); } if (mremap(src, src->usp_size, src->usp_size, MREMAP_FIXED | MREMAP_MAYMOVE, dst) != dst) { ustat_page_destroy(h, src); return (ustat_error(h, errno, "failed to rewrite %p (%s[%zd]): remap failed: %s", dst, h->ush_path, (size_t)dst->usp_off, strerror(errno))); } return (0); } static ustat_root_t * ustat_root_create(ustat_handle_t *h, pid_t pid, const char *p_comm, const char *p_args, size_t hlen) { ustat_page_t *p; ustat_root_t *r; uintptr_t r_end; size_t len; if ((p = ustat_page_create(h, USTAT_MAG3_ROOT, h->ush_pgsize)) == NULL) return (NULL); r = USTAT_PAGE_TO_DATA(p); r_end = (uintptr_t)p + p->usp_size; r->usr_gen = 1; r->usr_pid = pid ? pid : getpid(); r->usr_hash = (ustat_group_t **)(r + 1); r->usr_hlen = hlen; r->usr_comm = (char *)r->usr_hash + sizeof (void *) * r->usr_hlen; if (r->usr_comm >= (char *)r_end) return (ustat_null(h, EOVERFLOW, "hash len exceeds page size")); len = (p_comm != NULL ? strlen(p_comm) : 0) + 1; len = MIN(len, r_end - (uintptr_t)r->usr_comm); if (len != 0) { (void) memcpy(r->usr_comm, p_comm, len - 1); r->usr_comm[len - 1] = '\0'; } r->usr_args = r->usr_comm + len; len = (p_args != NULL ? strlen(p_args) : 0) + 1; len = MIN(len, r_end - (uintptr_t)r->usr_args); if (len != 0) { (void) memcpy(r->usr_args, p_args, len - 1); r->usr_args[len - 1] = '\0'; } return (r); } static void ustat_root_destroy(ustat_handle_t *h, ustat_root_t *r) { size_t i; for (i = 0; i < r->usr_hlen; i++) { while (r->usr_hash[i] != NULL) { ustat_group_t *g = r->usr_hash[i], *p; r->usr_hash[i] = g->usg_next; if ((p = g->usg_prev) != NULL) ustat_page_destroy(h, USTAT_DATA_TO_PAGE(h, p)); ustat_page_destroy(h, USTAT_DATA_TO_PAGE(h, g)); } } ustat_page_destroy(h, USTAT_DATA_TO_PAGE(h, r)); } static ustat_root_t * ustat_root_relocate(ustat_page_t *p) { ustat_root_t *r = USTAT_PAGE_TO_DATA(p); USTAT_PAGE_RELO(r->usr_comm, p->usp_addr, p); USTAT_PAGE_RELO(r->usr_args, p->usp_addr, p); USTAT_PAGE_RELO(r->usr_hash, p->usp_addr, p); memset(r->usr_hash, 0, sizeof (ustat_group_t *) * r->usr_hlen); p->usp_addr = p; return (r); } static ustat_group_t * ustat_group_relocate(ustat_handle_t *h, ustat_page_t *p) { ustat_group_t *g = USTAT_PAGE_TO_DATA(p); ustat_named_t *n; ustat_value_t *v; uint16_t i; g->usg_next = NULL; g->usg_prev = NULL; g->usg_handle = h; g->usg_uarg = NULL; USTAT_PAGE_RELO(g->usg_gname, p->usp_addr, p); USTAT_PAGE_RELO(g->usg_cname, p->usp_addr, p); USTAT_PAGE_RELO(g->usg_statv, p->usp_addr, p); USTAT_PAGE_RELO(g->usg_datav, p->usp_addr, p); USTAT_PAGE_RELO(g->usg_rodata, p->usp_addr, p); USTAT_PAGE_RELO(g->usg_rwdata, p->usp_addr, p); for (n = g->usg_statv, i = 0; i < g->usg_statc; i++, n++) { USTAT_PAGE_RELO(n->usn_name, p->usp_addr, p); USTAT_PAGE_RELO(n->usn_data, p->usp_addr, p); if (USTAT_TYPE_BY_VAL(n)) continue; v = n->usn_data; USTAT_PAGE_RELO(v->usv_buf, p->usp_addr, p); } p->usp_addr = p; return (g); } static int ustat_relink(ustat_handle_t *h, char *pattern) { ustat_root_t *r = h->ush_root; char *old_path = h->ush_path; int old_fd = h->ush_fd; int err = 0; char *new_path; int new_fd; ustat_group_t *g; uint32_t i; new_fd = mkostemp(pattern, h->ush_oflags & ~USTAT_OFLAGS & ~O_ACCMODE); if (new_fd == -1) { return (ustat_error(h, errno, "failed to mkostemp %s: %s", pattern, strerror(errno))); } (void) unlink(pattern); if ((new_path = vmem_strdup(vmem_heap, pattern, VM_NOSLEEP)) == NULL) { (void) close(new_fd); return (ustat_error(h, ENOMEM, "failed to alloc buffer")); } h->ush_path = new_path; h->ush_fd = new_fd; for (i = 0; i < r->usr_hlen; i++) { for (g = r->usr_hash[i]; g != NULL; g = g->usg_next) err |= ustat_page_rewrite(h, USTAT_DATA_TO_PAGE(h, g)); } if (err != 0 || ustat_page_rewrite(h, USTAT_DATA_TO_PAGE(h, r)) != 0) { h->ush_path = old_path; h->ush_fd = old_fd; (void) close(new_fd); vmem_strfree(vmem_heap, new_path); return (-1); } (void) close(old_fd); vmem_strfree(vmem_heap, old_path); return (0); } static int ustat_reopen(ustat_handle_t *h) { const bool gen = (h->ush_oflags & USTAT_PATTERN) == USTAT_PATTERN; struct stat st; int err, fd; fd = gen ? mkostemp(h->ush_path, h->ush_oflags & ~USTAT_OFLAGS & ~O_ACCMODE) : open(h->ush_path, h->ush_oflags & ~USTAT_OFLAGS, USTAT_STAT_MODE); if (fd != -1 && gen) (void) unlink(h->ush_path); if (fd == -1 || fstat(fd, &st) != 0) { err = ustat_error(h, errno, "failed to open %s: %s", h->ush_path, strerror(errno)); if (fd >= 0) (void) close(fd); return (err); } if (h->ush_fd >= 0) (void) close(h->ush_fd); h->ush_fdlen = (size_t)st.st_size; h->ush_fd = fd; return (0); } static void ustat_proc_pattern(pid_t pid, uid_t uid, const char *comm, char *buf, size_t len) { (void) snprintf(buf, len, USTAT_ROOT_PATTERN, comm, uid, pid); } static void ustat_proc_prefix(pid_t pid, uid_t uid, const char *comm, char *buf, size_t len) { (void) snprintf(buf, len, USTAT_ROOT_PREFIX, comm, uid, pid); } static void ustat_fork(ustat_handle_t *h) { ustat_root_t *r = h->ush_root; pid_t self = getpid(); char path[PATH_MAX]; if (ustat_is_readonly(h)) return; /* no changes needed after fork */ ustat_proc_pattern(self, getuid(), r->usr_comm, path, sizeof (path)); (void) ustat_relink(h, path); r->usr_pid = self; } static void ustat_fork_enter(void) { ustat_handle_t *h; (void) pthread_mutex_lock(&ustat_lock); for (h = ustat_list; h != NULL; h = h->ush_link) (void) pthread_rwlock_wrlock(&h->ush_lock); } static void ustat_fork_exit(void) { ustat_handle_t *h; for (h = ustat_list; h != NULL; h = h->ush_link) (void) pthread_rwlock_unlock(&h->ush_lock); (void) pthread_mutex_unlock(&ustat_lock); } static void ustat_fork_child(void) { ustat_handle_t *h; for (h = ustat_list; h != NULL; h = h->ush_link) ustat_fork(h); ustat_fork_exit(); } static void __attribute__ ((constructor)) ustat_init(void) { (void) pthread_atfork(ustat_fork_enter, ustat_fork_exit, ustat_fork_child); } static void __attribute__ ((destructor)) ustat_fini(void) { while (ustat_list != NULL) ustat_close(ustat_list); } static int ustat_proc_open(pid_t pid, const char *proc_file, int flags) { char path[PATH_MAX]; (void) snprintf(path, sizeof (path), "/proc/%d/%s", pid, proc_file); return (open(path, flags)); } static int ustat_proc_read(pid_t pid, const char *proc_file, char *buf, size_t len) { ssize_t rlen; int fd; if ((fd = ustat_proc_open(pid, proc_file, O_RDONLY)) == -1) return (-1); rlen = read(fd, buf, len); buf[rlen > 0 ? rlen - 1 : 0] = '\0'; (void) close(fd); if (rlen <= 0) { return (ustat_error(NULL, ESRCH, "no such process: %d", (int)pid)); } return (0); } static int ustat_proc_uid(pid_t pid, uid_t *uid) { char path[PATH_MAX]; struct stat st; (void) snprintf(path, sizeof (path), "/proc/%d", pid); if (stat(path, &st) != 0) return (-1); *uid = st.st_uid; return (0); } static int ustat_proc_write(pid_t pid, const char *proc_file, const char *buf, size_t len) { ssize_t wlen; int fd; if ((fd = ustat_proc_open(pid, proc_file, O_WRONLY)) == -1) return (-1); wlen = write(fd, buf, len); (void) close(fd); if (wlen <= 0) { return (ustat_error(NULL, errno, "failed to write %s: %s", proc_file, strerror(errno))); } return (0); } /* * We unlink() our ustat files immediately following their creation. This is * the easiest way to avoid leaving files around after an abnormal exit, but * presents a challenge to other processes wishing to open them. Fortunately, * readlink() on an open file descriptor's /proc/pid/fd entry will return the * original name of a deleted file. Here we scan the specified process's * file descriptors for a link target matching the expected name, and return * the corresponding openable /proc/pid/fd path. */ static int ustat_proc_find(pid_t pid, uid_t p_uid, const char *p_comm, char *buf, size_t len) { char fdpath[PATH_MAX], prefix[PATH_MAX], path[PATH_MAX]; struct dirent entry, *result; size_t prefix_len; int err, fd; DIR *dir; ustat_proc_prefix(pid, p_uid, p_comm, prefix, PATH_MAX); prefix_len = strlen(prefix); if ((fd = ustat_proc_open(pid, "fd", O_RDONLY)) == -1) return (-1); if ((dir = fdopendir(fd)) == NULL) { err = errno; (void) close(fd); goto error; } for (;;) { if ((err = readdir_r(dir, &entry, &result)) != 0) goto error; if (result == NULL) { err = ENOENT; goto error; } (void) snprintf(fdpath, PATH_MAX, "/proc/%d/%s/%s", pid, "fd", entry.d_name); if (readlink(fdpath, path, PATH_MAX) == -1) continue; if (strncmp(prefix, path, prefix_len) == 0) { (void) closedir(dir); (void) strncpy(buf, fdpath, len); path[len - 1] = '\0'; return (0); } } error: if (dir != NULL) (void) closedir(dir); return (ustat_error(NULL, err, "process %d: no open ustat files found", pid)); } static int ustat_magic(ustat_handle_t *h, const ustat_page_t *p, uint8_t type) { if (bcmp(p->usp_magic, ustat_magicstr, sizeof (ustat_magicstr)) != 0) { return (ustat_error(h, EINVAL, "ustat page is uninitialized or invalid data format")); } if ((p->usp_magic[3] & USTAT_MAG3_BASE) != USTAT_MAG3) { return (ustat_error(h, EINVAL, "ustat data is not of the expected wordsize/endianness")); } if ((p->usp_magic[3] & USTAT_MAG3_TYPE) != type) { return (ustat_error(h, EINVAL, "ustat data type mismatch: expected %02x, found %02x", type, p->usp_magic[3] & USTAT_MAG3_TYPE)); } return (0); } static ustat_handle_t * ustat_open(int version, const char *path, pid_t pid, const char *p_comm, const char *p_args, int oflags) { ustat_page_t *rp = NULL; ustat_handle_t *h; ustat_root_t *r; int is_file = -1, is_core = -1; char buf[32]; char *e; if (path == NULL && pid <= 0) return (ustat_null(NULL, EINVAL, "no file or pid specified")); if ((oflags & O_ACCMODE) == O_WRONLY) oflags = (oflags & ~O_ACCMODE) | O_RDWR; /* for mmap() */ if ((h = vmem_zalloc(vmem_heap, sizeof (ustat_handle_t), VM_NOSLEEP)) == NULL) return (ustat_null(NULL, ENOMEM, "failed to alloc handle")); (void) pthread_rwlock_init(&h->ush_lock, NULL); h->ush_version = version; h->ush_oflags = oflags | O_CLOEXEC; h->ush_pgsize = sysconf(_SC_PAGESIZE); if (pid != -1) h->ush_self = pid == getpid() && (oflags & O_ACCMODE) != O_RDONLY; else if ((oflags & O_CREAT) == O_CREAT) h->ush_self = 1; /* ustat file created by this pid */ h->ush_fd = -1; list_init(&h->ush_free_pgsz, offsetof(ustat_freepage_t, usfp_node)); list_init(&h->ush_free_other, offsetof(ustat_freepage_t, usfp_node)); if (h->ush_self && (oflags & O_CREAT)) h->ush_oflags |= O_TRUNC; if ((e = getenv("USTAT_DEBUG")) != NULL) h->ush_oflags |= ustat_env2flags(e); if (path == NULL) goto no_path; if ((h->ush_path = vmem_strdup(vmem_heap, path, VM_NOSLEEP)) == NULL) { ustat_close(h); return (ustat_null(NULL, ENOMEM, "failed to alloc path")); } if (ustat_reopen(h) != 0) { ustat_close(h); return (NULL); } no_path: /* * If the file has at least a page worth of data, map in the first * page and sniff it for either our magic bytes or the ELF magic bytes. * If we don't find either or the page is truncated, set rp = NULL. */ if (h->ush_fdlen >= h->ush_pgsize && (rp = ustat_page_mapin(h, 0, h->ush_pgsize, MAP_SHARED)) != NULL && (is_file = ustat_magic(h, rp, USTAT_MAG3_ROOT)) != 0) { is_core = bcmp(rp, ELFMAG, SELFMAG); (void) munmap(USTAT_DATA_TO_PAGE(h, rp), h->ush_pgsize); rp = NULL; } else if (h->ush_fdlen < h->ush_pgsize) { (void) ustat_error(h, EINVAL, "ustat file is empty or truncated"); rp = NULL; } if (rp == NULL && (h->ush_oflags & O_CREAT)) r = ustat_root_create(h, pid, p_comm, p_args, USTAT_ROOT_HLEN); else if (rp != NULL) r = ustat_root_relocate(rp); else r = NULL; if ((h->ush_root = r) == NULL && is_core != 0) { ustat_close(h); return (NULL); } /* * To ensure ustats are retained in core dumps, turn on the * MMF_DUMP_MAPPED_SHARED bit in the core dump filter. Unfortunately * the interface geniuses have (a) provided no interface to this, * and (b) put the MMF_DUMP_* flags under __KERNEL__ in linux/sched.h * despite other flags not being there, so we can't even compile * against it. Thankfully, core(5) tells us "bit 3" is what we want. * That sure makes me feel better about this code being highly stable. */ if (h->ush_self && pid != -1 && ustat_proc_read(pid, "coredump_filter", buf, sizeof (buf)) == 0) { unsigned long f = strtoul(buf, NULL, 16); size_t n = snprintf(buf, sizeof (buf), "0x%lx\n", f | (1 << 3)); (void) ustat_proc_write(pid, "coredump_filter", buf, n); } if (is_core == 0) h->ush_update = ustat_update_core; else h->ush_update = ustat_update_file; (void) pthread_mutex_lock(&ustat_lock); h->ush_link = ustat_list; ustat_list = h; (void) pthread_mutex_unlock(&ustat_lock); return (h); } ustat_handle_t * ustat_open_proc(int version, pid_t pid, int oflags) { pid_t self = getpid(); ustat_handle_t *h = NULL; char p_comm[PATH_MAX]; char p_misc[PATH_MAX]; char p_path[PATH_MAX]; uid_t p_uid; char *p1, *p2; size_t len; if (version != USTAT_VERSION) { return (ustat_null(NULL, EINVAL, "invalid version: " "expected %d, got %d", USTAT_VERSION, version)); } if (pid == 0) pid = self; if (pid != self && (oflags & O_ACCMODE) != O_RDONLY) { return (ustat_null(NULL, EPERM, "cannot open stats for writing: %d", pid)); } if ((oflags & O_ACCMODE) == O_RDONLY && (oflags & O_CREAT) == O_CREAT || (oflags & O_ACCMODE) != O_RDONLY && (oflags & O_CREAT) != O_CREAT) return (ustat_null(NULL, EINVAL, "invalid open flags")); if (ustat_proc_read(pid, "comm", p_comm, sizeof (p_comm)) != 0) { /* * /proc/PID/comm was introduced in a post-2.6.32+ Linux * kernel, so on EL6 we fall back to parsing /proc/PID/stat * to retrieve comm like ps(1) does. */ if (ustat_proc_read(pid, "stat", p_comm, sizeof (p_comm)) != 0) return (ustat_null(NULL, errno, "errno %d @ stat: pid %d", errno, pid)); /* * /proc/stat format (using ps(1) format specifiers) is: * pid (comm) s NNN * with NNN being repeated space-separated numeric strings. * comm is typically limited to 15 characters. */ p1 = strchr(p_comm, '('); p2 = strrchr(p_comm, ')'); if (p1 == NULL || p2 <= p1) return (ustat_null(NULL, EPROTO, "unexpected data format in /proc/%d/stat", pid)); len = p2 - p1; p1 += 1; *p2 = '\0'; (void) memmove(p_comm, p1, len); } if (ustat_proc_uid(pid, &p_uid) != 0) return (ustat_null(NULL, errno, "errno %d @ uid", errno)); if ((oflags & O_ACCMODE) == O_RDONLY) { oflags &= ~USTAT_PATTERN; if (ustat_proc_find(pid, p_uid, p_comm, p_path, sizeof (p_path)) == 0) h = ustat_open_file(version, p_path, oflags); if (h == NULL && errno == ENOENT) { (void) ustat_null(NULL, ENOENT, "process %d has not published any ustats", pid); } return (h); } ustat_proc_pattern(pid, p_uid, p_comm, p_path, sizeof (p_path)); oflags |= USTAT_PATTERN; /* We are opening ourself for writing. */ assert(pid == self); if (ustat_proc_read(pid, "cmdline", p_misc, sizeof (p_misc)) != 0) return (ustat_null(NULL, errno, "errno %d @ cmdline", errno)); return (ustat_open(version, p_path, pid, p_comm, p_misc, oflags)); } ustat_handle_t * ustat_open_file(int version, const char *file, int oflags) { ustat_handle_t *h; if (version != USTAT_VERSION) { return (ustat_null(NULL, EINVAL, "invalid version: " "expected %d, got %d", USTAT_VERSION, version)); } /* * At present we do not support opening a ustat file other than * O_RDONLY and then modifying it. This can be supported with a modest * amount of code but unclear if any use case actually requires it. */ if ((oflags & O_ACCMODE) != O_RDONLY || (oflags & O_CREAT)) { return (ustat_null(NULL, EPERM, "can't open ustat file for writing: use ustat_open_proc")); } if ((h = ustat_open(version, file, -1, NULL, NULL, oflags)) == NULL) return (NULL); /* * Reset ush_fdlen and r->usr_gen in order to force ustat_update() * to discover the entire current hash table of groups. */ h->ush_fdlen = h->ush_pgsize; if (h->ush_root != NULL) h->ush_root->usr_gen = 0; if (ustat_update(h) == 0) return (h); ustat_close(h); return (NULL); } /* * Open a memory-backed ustat instance. 'name' is expected to be a unique * string name for the instance. * * The implementation currently uses a file to back the memory, however this * may change in the future. */ ustat_handle_t * ustat_open_mem(int version, const char *name) { int oflags = O_CREAT | O_RDWR | USTAT_PATTERN; char path[PATH_MAX]; ustat_handle_t *h; if (version != USTAT_VERSION) { return (ustat_null(NULL, EINVAL, "invalid version: " "expected %d, got %d", USTAT_VERSION, version)); } ustat_proc_pattern(getpid(), getuid(), name, path, sizeof (path)); h = ustat_open(version, path, -1, NULL, NULL, oflags); if (h == NULL) return (NULL); h->ush_fdlen = h->ush_pgsize; /* header is present now */ h->ush_ismem = true; return (h); } void ustat_close(ustat_handle_t *h) { ustat_handle_t **p, *q; (void) pthread_mutex_lock(&ustat_lock); for (p = &ustat_list; (q = *p) != NULL; p = &q->ush_link) { if (q == h) { *p = h->ush_link; break; } } (void) pthread_mutex_unlock(&ustat_lock); if (h->ush_root != NULL && !(h->ush_oflags & USTAT_RETAIN_MAPPINGS)) ustat_root_destroy(h, h->ush_root); if (h->ush_fd >= 0) (void) close(h->ush_fd); ustat_freepage_empty(&h->ush_free_pgsz); ustat_freepage_empty(&h->ush_free_other); list_fini(&h->ush_free_pgsz); list_fini(&h->ush_free_other); vmem_strfree(vmem_heap, h->ush_path); vmem_free(vmem_heap, h, sizeof (ustat_handle_t)); } ssize_t ustat_conf(ustat_handle_t *h, ustat_conf_t c) { ssize_t rv; switch (c) { case USTAT_CONF_PATH_MAX: case USTAT_CONF_NAME_MAX: case USTAT_CONF_XLEN_MAX: rv = h->ush_pgsize - sizeof (ustat_group_t) - sizeof (ustat_named_t) - sizeof (ustat_value_t); break; default: rv = ustat_error(h, EINVAL, "invalid conf: %u", c); break; } return (rv); } pid_t ustat_pid(ustat_handle_t *h) { return (h->ush_root->usr_pid); } const char * ustat_comm(ustat_handle_t *h) { return (h->ush_root->usr_comm); } const char * ustat_args(ustat_handle_t *h) { return (h->ush_root->usr_args); } int ustat_walk(ustat_handle_t *h, const char *name, ustat_walk_f *func, void *uarg) { ustat_root_t *r = h->ush_root; int err = 0; ustat_group_t *g; ustat_struct_t *s; uint32_t i; if (ustat_is_writeonly(h)) return (ustat_error(h, EPERM, "ustat handle is write-only")); (void) pthread_rwlock_rdlock(&h->ush_lock); for (i = 0; i < r->usr_hlen; i++) { for (g = r->usr_hash[i]; g != NULL; g = g->usg_next) { if (name != NULL && fnmatch(name, g->usg_gname, 0) != 0) continue; if (!(g->usg_flags & USTAT_F_INSERTED)) continue; s = USTAT_GROUP_TO_STRUCT(g); err = func(h, s, uarg); if (err != 0) goto out; } } out: (void) pthread_rwlock_unlock(&h->ush_lock); return (err); } static ustat_group_t * ustat_lookup_locked(ustat_handle_t *h, const char *ename, const char *gname) { ustat_root_t *r = h->ush_root; ustat_group_t *g; char *buf; size_t len; uint32_t i; len = strlen(ename) + 1 + strlen(gname) + 1; buf = alloca(len); (void) snprintf(buf, len, "%s.%s", ename, gname); i = ustat_strhash(buf) % r->usr_hlen; for (g = r->usr_hash[i]; g != NULL; g = g->usg_next) { if (!(g->usg_flags & USTAT_F_INSERTED)) continue; if (strcmp(g->usg_gname, buf) == 0) break; } return (g); } ustat_named_t * ustat_lookup(ustat_handle_t *h, const char *ename, const char *gname, const char *nname) { ustat_group_t *g; ustat_named_t *n; uint32_t i; if (ename == NULL || gname == NULL) return (ustat_null(h, EINVAL, "invalid ename or gname")); if (ustat_is_writeonly(h)) return (ustat_null(h, EPERM, "ustat handle is write-only")); (void) pthread_rwlock_rdlock(&h->ush_lock); g = ustat_lookup_locked(h, ename, gname); n = g ? g->usg_statv : NULL; if (g == NULL || nname == NULL) goto out; for (i = 0; i < g->usg_statc; i++, n++) { if (strcmp(n->usn_name, nname) == 0) break; } if (i >= g->usg_statc) n = NULL; out: (void) pthread_rwlock_unlock(&h->ush_lock); return (n); } ustat_struct_t *ustat_lookup_struct(ustat_handle_t *h, const char *ename, const char *gname) { return (ustat_lookup(h, ename, gname, NULL)); } static void ustat_insert_locked(ustat_handle_t *h, ustat_group_t *g) { ustat_root_t *r = h->ush_root; uint32_t ghash = ustat_strhash(g->usg_gname) % r->usr_hlen; g->usg_next = r->usr_hash[ghash]; r->usr_hash[ghash] = g; } ustat_struct_t * ustat_insert(ustat_handle_t *h, const char *ename, const char *gname, const ustat_class_t *cp, int statc, const ustat_struct_t *statv, void *uarg) { const ustat_named_t *srcv = statv; ustat_named_t *dstv; ustat_group_t *g; ustat_page_t *p; size_t group_off, statv_off, datav_off, rodat_off, rwdat_off; size_t statv_len, datav_len, rodat_len, rwdat_len, name_len; size_t upage_len; ustat_value_t *v; uint8_t *x; char *s; int i, pad, import = 0; uintptr_t base; if (ustat_strbadid(ename, ".")) { return (ustat_null(h, EINVAL, "invalid ustat entity name: %s", ename)); } if (ustat_strbadid(gname, "")) { return (ustat_null(h, EINVAL, "invalid ustat group name: %s", gname)); } if (statc > UINT16_MAX) { return (ustat_null(h, EOVERFLOW, "too many statistics for group: %d > UINT16_MAX", statc)); } if (ustat_is_readonly(h)) return (ustat_null(h, EPERM, "ustat handle is read-only")); /* * If this group has a constructor, then call it, which will then call * back to ustat_insert() recursively. If we succeed, reset usg_uarg * to be the top-level arg. */ if (cp->usc_ctor != NULL && ustat_class_ctor == 0) { ustat_struct_t *rv; ustat_class_ctor++; rv = cp->usc_ctor(h, ename, gname, statc, statv, uarg); ustat_class_ctor--; if (rv != NULL) USTAT_STRUCT_TO_GROUP(rv)->usg_uarg = uarg; return (rv); } group_off = (size_t)USTAT_PAGE_TO_DATA(NULL); statv_off = (size_t)USTAT_GROUP_TO_STRUCT(group_off); statv_len = sizeof (ustat_named_t) * statc; /* ustat_value_t is required to be 64-bit aligned for correctness */ datav_off = P2ROUNDUP(statv_off + statv_len, sizeof (uint64_t)); datav_len = sizeof (ustat_value_t) * statc; rodat_off = datav_off + datav_len; rodat_len = strlen(ename) + 1 + strlen(gname) + 1 + strlen(cp->usc_name) + 1; rwdat_off = 0; rwdat_len = 0; for (i = 0; i < statc; i++) { if (ustat_strbadid(srcv[i].usn_name, "")) { return (ustat_null(h, EINVAL, "invalid ustat name: %s", srcv[i].usn_name)); } rodat_len += strlen(srcv[i].usn_name) + 1; rwdat_len += srcv[i].usn_xlen; } rwdat_off = rodat_off + rodat_len; upage_len = P2ROUNDUP(rwdat_off + rwdat_len, h->ush_pgsize); (void) pthread_rwlock_wrlock(&h->ush_lock); if (ustat_lookup_locked(h, ename, gname) != NULL) { (void) pthread_rwlock_unlock(&h->ush_lock); return (ustat_null(h, EEXIST, "ustat group %s.%s already exists", ename, gname)); } if ((p = ustat_page_create(h, USTAT_MAG3_GRP, upage_len)) == NULL) { (void) pthread_rwlock_unlock(&h->ush_lock); return (ustat_null(h, errno, "failed to create ustat page for %s.%s", ename, gname)); } base = (uintptr_t)p->usp_addr; g = USTAT_PAGE_TO_DATA(p); g->usg_handle = h; g->usg_carg = g->usg_uarg = uarg; g->usg_ctime = gethrtime(); g->usg_atime = g->usg_ctime; g->usg_statc = (uint16_t)statc; g->usg_statv = dstv = (ustat_named_t *)(base + statv_off); g->usg_datav = v = (ustat_value_t *)(base + datav_off); g->usg_rodata = s = (char *)(base + rodat_off); g->usg_rwdata = x = (uint8_t *)(base + rwdat_off); g->usg_gname = s; s += sprintf(s, "%s.%s", ename, gname) + 1; g->usg_cname = s; s += sprintf(s, "%s", cp->usc_name) + 1; for (i = 0; i < statc; i++) { const ustat_named_t *src = srcv + i; ustat_named_t *dst = dstv + i; if (src->usn_data != NULL) import++; dst->usn_name = s; name_len = strlen(src->usn_name) + 1; bcopy(src->usn_name, s, name_len); dst->usn_type = src->usn_type; dst->usn_xlen = src->usn_xlen; dst->usn_data = v; if (USTAT_TYPE_BY_REF(src)) switch (src->usn_type) { case USTAT_TYPE_ARRAY_U64: pad = P2NPHASE((uintptr_t)x, sizeof (uint64_t)); s += pad; x += pad; v->usv_buf_u64 = (uint64_t *)x; break; default: v->usv_buf = x; } v++; s += name_len; x += src->usn_xlen; } g->usg_flags |= USTAT_F_INSERTED; ustat_insert_locked(h, g); h->ush_root->usr_gen++; (void) pthread_rwlock_unlock(&h->ush_lock); if (import > 0) ustat_importv(USTAT_GROUP_TO_STRUCT(g), statc, statv); return (USTAT_GROUP_TO_STRUCT(g)); } static int ustat_delete_locked(ustat_handle_t *h, ustat_group_t *g) { ustat_root_t *r = h->ush_root; const ustat_class_t *uc; ustat_group_t *q, **qp; uint32_t ghash; ghash = ustat_strhash(g->usg_gname) % r->usr_hlen; for (qp = &r->usr_hash[ghash]; (q = *qp) != NULL; qp = &q->usg_next) { if (q == g) break; } if (q == NULL) { return (ustat_error(h, ESRCH, "stat not found: %p", USTAT_GROUP_TO_STRUCT(g))); } if (h->ush_self) { uc = ustat_cname_to_class(g->usg_cname); if (uc->usc_dtor != NULL && uc->usc_dtor(h, g->usg_carg) != 0) return (-1); } *qp = g->usg_next; return (0); } int ustat_delete(ustat_struct_t *s) { ustat_group_t *g; ustat_handle_t *h; ustat_page_t *p; int err; if (s == NULL) return (0); /* simplify caller code */ g = USTAT_STRUCT_TO_GROUP(s); h = g->usg_handle; p = USTAT_DATA_TO_PAGE(h, g); if (ustat_is_readonly(h)) return (ustat_error(h, EPERM, "ustat handle is read-only")); (void) pthread_rwlock_wrlock(&h->ush_lock); if ((err = ustat_delete_locked(h, g)) == 0) { __sync_fetch_and_and(&g->usg_flags, ~USTAT_F_INSERTED); h->ush_root->usr_gen++; ustat_freepage_put(h, p); } (void) pthread_rwlock_unlock(&h->ush_lock); if (err == 0) ustat_page_destroy(h, p); return (err); } static int ustat_update_page(ustat_handle_t *h, ustat_page_t *p) { ustat_root_t *r = h->ush_root; ustat_group_t *g; uint32_t ghash; if (ustat_magic(h, p, USTAT_MAG3_GRP) != 0) { ustat_page_destroy(h, p); return (-1); } g = USTAT_PAGE_TO_DATA(p); g->usg_atime = gethrtime(); g = ustat_group_relocate(h, p); g->usg_handle = h; if (!(g->usg_flags & USTAT_F_INSERTED)) { ustat_page_destroy(h, p); return (0); } ghash = ustat_strhash(g->usg_gname) % r->usr_hlen; g->usg_next = r->usr_hash[ghash]; r->usr_hash[ghash] = g; return (0); } static int ustat_update_file(ustat_handle_t *h) { ustat_page_t *p = ustat_page_mapin(h, 0, h->ush_pgsize, MAP_SHARED); ustat_root_t *r = USTAT_PAGE_TO_DATA(p); size_t off; if (p == NULL) { return (ustat_error(h, errno, "failed to update root page: %s", strerror(errno))); } if (r->usr_gen <= h->ush_root->usr_gen) { ustat_page_destroy(h, p); return (0); /* no inserts or deletes since last update */ } ustat_root_destroy(h, h->ush_root); h->ush_root = r = ustat_root_relocate(p); for (off = h->ush_pgsize; off < h->ush_fdlen; ) { if ((p = ustat_page_recreate(h, off, h->ush_fdlen - off)) == NULL) { (void) ustat_error(h, errno, "failed to update group " "at %zu: %s", (size_t)off, strerror(errno)); off += h->ush_pgsize; } else { off += p->usp_size; (void) ustat_update_page(h, p); } } return (0); } static ustat_page_t * ustat_mapin_phdr(ustat_handle_t *h, const void *p) { const NElf_Phdr *pp = p; if (pp->p_type != PT_LOAD || pp->p_filesz == 0) return (NULL); if ((pp->p_flags & (PF_R | PF_W | PF_X)) != (PF_R | PF_W)) return (NULL); return (ustat_page_recreate(h, (off_t)pp->p_offset, pp->p_filesz)); } static int ustat_update_core_class(ustat_handle_t *h, off_t e_phoff, size_t e_phentsize, size_t e_phnum, ustat_page_t *(*mapin_phdr)(ustat_handle_t *, const void *)) { ustat_page_t *gp, *rp = NULL; ustat_root_t *r; uint8_t *p, *q; int err = 0; size_t len = e_phentsize * e_phnum; uint8_t *buf = vmem_alloc(vmem_heap, len, VM_NOSLEEP); if (buf == NULL) return (ustat_error(h, ENOMEM, "failed to alloc phdrs buffer")); if (pread(h->ush_fd, buf, len, e_phoff) != (ssize_t)len) { err = ustat_error(h, errno, "failed to read phdrs"); goto out; } for (p = buf, q = buf + len; p < q; p += e_phentsize) { if ((rp = mapin_phdr(h, p)) == NULL) continue; if (ustat_magic(h, rp, USTAT_MAG3_ROOT) == 0) break; ustat_page_destroy(h, USTAT_DATA_TO_PAGE(h, rp)); rp = NULL; } if (rp == NULL) { err = ustat_error(h, ESRCH, "no ustats found in core file"); goto out; } assert(h->ush_root == NULL); h->ush_root = r = ustat_root_relocate(rp); for (p = buf, q = buf + len; p < q; p += e_phentsize) { if ((gp = mapin_phdr(h, p)) != NULL) (void) ustat_update_page(h, gp); } out: vmem_free(vmem_heap, buf, len); return (err); } static int ustat_update_core(ustat_handle_t *h) { const NElf_Ehdr *e; void *ehdr; int err; if (h->ush_root != NULL && h->ush_root->usr_gen != 0) return (0); if ((ehdr = mmap(NULL, h->ush_pgsize, PROT_READ, MAP_PRIVATE, h->ush_fd, 0)) == MAP_FAILED) { return (ustat_error(h, errno, "failed to mapin core header: %s", strerror(errno))); } e = ehdr; if (e->e_ident[EI_CLASS] != NELFCLASS) { (void) munmap(ehdr, h->ush_pgsize); return (ustat_error(h, EINVAL, #if __WORDSIZE == 64 "32-bit ustat required to examine 32-bit core file")); #elif __WORDSIZE == 32 "64-bit ustat required to examine 64-bit core file")); #endif } if (e->e_ident[EI_DATA] != NELFDATA) err = ustat_error(h, EINVAL, "file endian-ness mismatch"); else if (e->e_type != ET_CORE) err = ustat_error(h, EINVAL, "file is not an ELF core file"); else err = ustat_update_core_class(h, e->e_phoff, e->e_phentsize, e->e_phnum, ustat_mapin_phdr); (void) munmap(ehdr, h->ush_pgsize); return (err); } int ustat_update(ustat_handle_t *h) { struct stat st; if (!ustat_is_readonly(h)) return (0); /* nothing to do if this is the live copy */ if (fstat(h->ush_fd, &st) != 0) { return (ustat_error(h, errno, "failed to stat %s: %s", h->ush_path, strerror(errno))); } if (h->ush_fdlen > (size_t)st.st_size) { return (ustat_error(h, ERANGE, "ustat data file truncated: " "old=%zu, new=%zu", h->ush_fdlen, (size_t)st.st_size)); } h->ush_fdlen = (size_t)st.st_size; return (h->ush_update(h)); } ustat_struct_t * ustat_snapshot(ustat_struct_t *s) { ustat_handle_t *h; ustat_page_t *src, *dst; ustat_group_t *old, *old_next, *new; old = USTAT_STRUCT_TO_GROUP(s); old_next = old->usg_next; h = old->usg_handle; if (!(ustat_is_readonly(h) || h->ush_ismem)) return (s); if (h->ush_update == ustat_update_core) return (s); dst = USTAT_DATA_TO_PAGE(h, old); if ((src = ustat_page_mapin(h, dst->usp_off, dst->usp_size, MAP_PRIVATE)) == NULL) { return (ustat_null(h, errno, "failed to snap page for %s (offset %zu): %s", old->usg_gname, (size_t)dst->usp_off, strerror(errno))); } new = USTAT_PAGE_TO_DATA(src); new->usg_atime = gethrtime(); /* * If the page has been deleted or reused, return the old version. * A new occupant won't be seen until the next ustat_update(). */ if (!(new->usg_flags & USTAT_F_INSERTED) || new->usg_ctime != old->usg_ctime) { ustat_page_destroy(h, src); return (s); } /* * Up to this point, we've just been creating mappings that no one * else can see so we don't need any locks. Once we get this far, * we need to hold the hash lock as reader to be sure that no one * can delete the new group we're hashing in while we're busy here. */ (void) pthread_rwlock_rdlock(&h->ush_lock); if (h->ush_oflags & USTAT_RETAIN_DELTA) { (void) ustat_delete_locked(h, old); new = ustat_group_relocate(h, src); ustat_insert_locked(h, new); ustat_page_destroy(h, USTAT_DATA_TO_PAGE(h, old->usg_prev)); old->usg_prev = NULL; new->usg_prev = old; } else if (mremap(src, src->usp_size, src->usp_size, MREMAP_FIXED | MREMAP_MAYMOVE, dst) == dst) { new = ustat_group_relocate(h, dst); new->usg_next = old_next; } else { new = ustat_null(h, errno, "failed to snap page for %s (remap %p to dst=%p): %s", old->usg_gname, (void *)src, (void *)dst, strerror(errno)); ustat_page_destroy(h, src); } (void) pthread_rwlock_unlock(&h->ush_lock); return (new ? USTAT_GROUP_TO_STRUCT(new) : NULL); } ustat_struct_t * ustat_previous(ustat_struct_t *s) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s)->usg_prev; return (g ? USTAT_GROUP_TO_STRUCT(g) : NULL); } const ustat_class_t * ustat_cname_to_class(const char *cname) { if (strcmp(cname, "hg") == 0) return (&ustat_class_hg); else if (strcmp(cname, "io") == 0) return (&ustat_class_io); else if (strcmp(cname, "ms") == 0) return (&ustat_class_ms); return (&ustat_class_misc); } void ustat_import(ustat_struct_t *s, ustat_named_t *dst, void *src) { switch (dst->usn_type) { case USTAT_TYPE_INT8: ustat_atomic_set_i8(s, dst, *(int8_t *)src); break; case USTAT_TYPE_INT16: ustat_atomic_set_i16(s, dst, *(int16_t *)src); break; case USTAT_TYPE_INT32: ustat_atomic_set_i32(s, dst, *(int32_t *)src); break; case USTAT_TYPE_INT64: ustat_atomic_set_i64(s, dst, *(int64_t *)src); break; case USTAT_TYPE_UINT8: ustat_atomic_set_u8(s, dst, *(uint8_t *)src); break; case USTAT_TYPE_UINT16: ustat_atomic_set_u16(s, dst, *(uint16_t *)src); break; case USTAT_TYPE_UINT32: ustat_atomic_set_u32(s, dst, *(uint32_t *)src); break; case USTAT_TYPE_SIZE: case USTAT_TYPE_UINT64: case USTAT_TYPE_DELTA: ustat_atomic_set_u64(s, dst, *(uint64_t *)src); break; case USTAT_TYPE_CLOCK: ustat_atomic_set_clock(s, dst, src); break; case USTAT_TYPE_TOD: ustat_atomic_set_tod(s, dst, src); break; case USTAT_TYPE_STRING: ustat_set_string(s, dst, *(const char **)src); break; case USTAT_TYPE_BYTES: ustat_set_bytes(s, dst, *(const uint8_t **)src, dst->usn_xlen); break; case USTAT_TYPE_ARRAY_U64: ustat_set_array_u64(s, dst, *(const uint64_t **)src, dst->usn_xlen / sizeof (uint64_t)); break; case USTAT_TYPE_UUID: ustat_set_uuid(s, dst, src); break; case USTAT_TYPE_MAX: break; } } void ustat_importv(ustat_struct_t *s, int statc, const ustat_struct_t *statv) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); uint16_t i, n = MIN(statc, g->usg_statc); const ustat_named_t *src = statv; ustat_named_t *dst = g->usg_statv; for (i = 0; i < n; i++, src++, dst++) { if (src->usn_type == dst->usn_type && src->usn_data != NULL) ustat_import(g->usg_statv, dst, src->usn_data); } } void ustat_export(ustat_struct_t *s, const ustat_named_t *src, void *dst) { switch (src->usn_type) { case USTAT_TYPE_INT8: *(int8_t *)dst = ustat_get_i8(s, src); break; case USTAT_TYPE_INT16: *(int16_t *)dst = ustat_get_i16(s, src); break; case USTAT_TYPE_INT32: *(int32_t *)dst = ustat_get_i32(s, src); break; case USTAT_TYPE_INT64: *(int64_t *)dst = ustat_get_i64(s, src); break; case USTAT_TYPE_UINT8: *(uint8_t *)dst = ustat_get_u8(s, src); break; case USTAT_TYPE_UINT16: *(uint16_t *)dst = ustat_get_u16(s, src); break; case USTAT_TYPE_UINT32: *(uint32_t *)dst = ustat_get_u32(s, src); break; case USTAT_TYPE_SIZE: case USTAT_TYPE_UINT64: case USTAT_TYPE_DELTA: *(uint64_t *)dst = ustat_get_u64(s, src); break; case USTAT_TYPE_CLOCK: ustat_get_clock(s, src, dst); break; case USTAT_TYPE_TOD: ustat_get_tod(s, src, dst); break; case USTAT_TYPE_STRING: (void) strncpy(*(char **)dst, ustat_get_str(s, src), src->usn_xlen); break; case USTAT_TYPE_BYTES: bcopy(ustat_get_bytes(s, src), *(uint8_t **)dst, src->usn_xlen); break; case USTAT_TYPE_ARRAY_U64: bcopy((void *)ustat_get_array_u64(s, src), *(uint64_t **)dst, src->usn_xlen); break; case USTAT_TYPE_UUID: ustat_get_uuid(s, src, dst); break; case USTAT_TYPE_MAX: break; } } void ustat_exportv(ustat_struct_t *s, int statc, ustat_struct_t *statv) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); uint16_t i, n = MIN(statc, g->usg_statc); const ustat_named_t *src = g->usg_statv; ustat_named_t *dst = statv; for (i = 0; i < n; i++, src++, dst++) { if (src->usn_type == dst->usn_type && dst->usn_data != NULL) ustat_export(g->usg_statv, src, dst->usn_data); } } int ustat_getnnames(ustat_struct_t *s) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); return ((int)g->usg_statc); } ustat_named_t * ustat_getprev(ustat_struct_t *s, ustat_named_t *n) { ustat_group_t *g; ustat_page_t *p; if (s != NULL) { g = USTAT_STRUCT_TO_GROUP(s); p = USTAT_DATA_TO_PAGE(g->usg_handle, g); } else { p = ustat_page_lookup(n, sysconf(_SC_PAGESIZE)); g = USTAT_PAGE_TO_DATA(p); } if (s == NULL || n == NULL || n == g->usg_statv) return (g->usg_statv); return (n - 1); } ustat_named_t * ustat_getnext(ustat_struct_t *s, ustat_named_t *n) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); if (n == NULL) return (g->usg_statv); if (n < g->usg_statv || n >= g->usg_statv + g->usg_statc - 1) return (NULL); return (n + 1); } const char * ustat_getgname(ustat_struct_t *s) { return (USTAT_STRUCT_TO_GROUP(s)->usg_gname); } const char * ustat_getcname(ustat_struct_t *s) { return (USTAT_STRUCT_TO_GROUP(s)->usg_cname); } void * ustat_getprivate(ustat_struct_t *s) { return (USTAT_STRUCT_TO_GROUP(s)->usg_uarg); } uint64_t ustat_getctime(ustat_struct_t *s) { return (USTAT_STRUCT_TO_GROUP(s)->usg_ctime); } uint64_t ustat_getatime(ustat_struct_t *s) { return (USTAT_STRUCT_TO_GROUP(s)->usg_atime); } void ustat_getmbuf(ustat_struct_t *s, ustat_mbuf_t *m) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); ustat_handle_t *h = g->usg_handle; ustat_page_t *p = USTAT_DATA_TO_PAGE(h, g); m->usm_data = p->usp_addr; m->usm_size = p->usp_size; } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_check_type(const ustat_struct_t *s, const ustat_named_t *n, ustat_type_t min_type, ustat_type_t max_type) { if (n->usn_type < min_type || n->usn_type > max_type) ustat_caller_error(s, n, "ustat_check_type: invalid type"); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_atomic_set_clock(ustat_struct_t *s, ustat_named_t *n, const struct timespec *t) { USTAT_CHECK_TYPE(s, n, USTAT_TYPE_CLOCK, USTAT_TYPE_CLOCK); ustat_atomic_set_u64(s, n, t->tv_sec * U_NANOSEC + t->tv_nsec); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_set_clock(ustat_struct_t *s, ustat_named_t *n, const struct timespec *t) { USTAT_CHECK_TYPE(s, n, USTAT_TYPE_CLOCK, USTAT_TYPE_CLOCK); ustat_set_u64(s, n, t->tv_sec * U_NANOSEC + t->tv_nsec); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_atomic_set_tod(ustat_struct_t *s, ustat_named_t *n, const struct timeval *t) { USTAT_CHECK_TYPE(s, n, USTAT_TYPE_TOD, USTAT_TYPE_TOD); ustat_atomic_set_u64(s, n, t->tv_sec * U_NANOSEC + t->tv_usec * U_NANOSEC / U_MICROSEC); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_set_tod(ustat_struct_t *s, ustat_named_t *n, const struct timeval *t) { USTAT_CHECK_TYPE(s, n, USTAT_TYPE_TOD, USTAT_TYPE_TOD); ustat_set_u64(s, n, t->tv_sec * U_NANOSEC + t->tv_usec * U_NANOSEC / U_MICROSEC); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_set_string(ustat_struct_t *s, ustat_named_t *n, const char *str) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_STRING, USTAT_TYPE_STRING); v->usv_buf[n->usn_xlen - 1] = '\0'; /* stop reader overruns */ (void) strncpy((char *)v->usv_buf, str, n->usn_xlen - 1); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_set_bytes(ustat_struct_t *s, ustat_named_t *n, const uint8_t *buf, size_t len) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_BYTES, USTAT_TYPE_BYTES); bcopy(buf, v->usv_buf, MIN(len, n->usn_xlen)); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_set_array_u64(ustat_struct_t *s, ustat_named_t *n, const uint64_t *buf, size_t count) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_ARRAY_U64, USTAT_TYPE_ARRAY_U64); bcopy(buf, v->usv_buf, MIN(count * sizeof (uint64_t), n->usn_xlen)); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_set_uuid(ustat_struct_t *s, ustat_named_t *n, const uint8_t *u) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_UUID, USTAT_TYPE_UUID); (void) memcpy(v->usv_buf, u, MIN(n->usn_xlen, UU_UUID_BIN_LEN)); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_get_clock(ustat_struct_t *s, const ustat_named_t *n, struct timespec *t) { uint64_t nsec = ustat_get_u64(s, n); USTAT_CHECK_TYPE(s, n, USTAT_TYPE_CLOCK, USTAT_TYPE_CLOCK); t->tv_sec = nsec / U_NANOSEC; t->tv_nsec = nsec % U_NANOSEC; } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_get_tod(ustat_struct_t *s, const ustat_named_t *n, struct timeval *t) { uint64_t usec = ustat_get_u64(s, n) / (U_NANOSEC / U_MICROSEC); USTAT_CHECK_TYPE(s, n, USTAT_TYPE_TOD, USTAT_TYPE_TOD); t->tv_sec = usec / U_MICROSEC; t->tv_usec = usec % U_MICROSEC; } const char * __attribute__ ((optimize("omit-frame-pointer"))) ustat_get_str(ustat_struct_t *s, const ustat_named_t *n) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_STRING, USTAT_TYPE_STRING); return ((const char *)v->usv_buf); } const uint8_t * __attribute__ ((optimize("omit-frame-pointer"))) ustat_get_bytes(ustat_struct_t *s, const ustat_named_t *n) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_BYTES, USTAT_TYPE_BYTES); return (v->usv_buf); } const uint64_t * __attribute__ ((optimize("omit-frame-pointer"))) ustat_get_array_u64(ustat_struct_t *s, const ustat_named_t *n) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_ARRAY_U64, USTAT_TYPE_ARRAY_U64); return (v->usv_buf_u64); } void __attribute__ ((optimize("omit-frame-pointer"))) ustat_get_uuid(ustat_struct_t *s, const ustat_named_t *n, uint8_t *u) { ustat_value_t *v = n->usn_data; USTAT_CHECK_TYPE(s, n, USTAT_TYPE_UUID, USTAT_TYPE_UUID); (void) memcpy(u, v->usv_buf, n->usn_xlen); } int ustat_fprintf_unit(FILE *fp, int width, uint64_t value, const ustat_unit_t *unit) { const char *s = "", *t; char buf[64]; uint64_t u = 1; uint64_t v = value; if (unit == NULL) goto done; for (s = unit->usu_suff; v >= unit->usu_mult; s = t) { t = s + strlen(s) + 1; if (*t == '\0') break; u *= unit->usu_mult; v /= unit->usu_mult; } done: if (unit == NULL || u == 1 || value % u == 0) { (void) snprintf(buf, sizeof (buf), "%" PRIu64 "%s", v, s); } else { (void) snprintf(buf, sizeof (buf), "%.1f%s", (double)value / u, s); } return (fprintf(fp, "%*s", width, buf)); } static int ustat_fprintf_clock(ustat_handle_t *h, FILE *fp, const ustat_named_t *n, const ustat_value_t *v) { uint64_t sec = v->usv_u64 / U_NANOSEC; uint64_t nsec = v->usv_u64 % U_NANOSEC; if (sec != 0 && nsec == 0) return (fprintf(fp, "%" PRIu64 "s", sec)); else if (sec == 0 && nsec != 0) return (fprintf(fp, "%" PRIu64 "ns", nsec)); else return (fprintf(fp, "%" PRIu64 "s %" PRIu64 "ns", sec, nsec)); } static int ustat_sprintf_tod(const ustat_named_t *n, const ustat_value_t *v, char *str, size_t len) { uint64_t tod = v->usv_u64 / (U_NANOSEC / U_MICROSEC); time_t sec = tod / U_MICROSEC; char buf[32]; struct tm tm; if (localtime_r(&sec, &tm) != NULL && strftime(buf, sizeof (buf), "%FT%T", &tm) != 0) return (snprintf(str, len, "%s.%06llu", buf, tod % U_MICROSEC)); else return (snprintf(str, len, "%" PRIu64, tod)); } static int ustat_fprintf_tod(ustat_handle_t *h, FILE *fp, const ustat_named_t *n, const ustat_value_t *v) { char buf[256]; (void) ustat_sprintf_tod(n, v, buf, sizeof (buf)); buf[sizeof (buf) - 1] = '\0'; return (fprintf(fp, "%s", buf)); } static int ustat_fprintf_bytes(ustat_handle_t *h, FILE *fp, const ustat_ifmt_t *f, const ustat_named_t *n, const ustat_value_t *v) { int err, rv = 0; uint32_t i; if (n->usn_xlen != 0) { if ((err = fprintf(fp, f->usf_u8_first, v->usv_buf[0])) < 0) return (err); rv += err; } for (i = 1; i < n->usn_xlen; i++) { if ((err = fprintf(fp, f->usf_u8_rest, v->usv_buf[i])) < 0) return (err); rv += err; } return (rv); } static int ustat_fprintf_array_u64(ustat_handle_t *h, FILE *fp, const ustat_ifmt_t *f, const ustat_named_t *n, const ustat_value_t *v) { int err, rv = 0; uint32_t i; if (n->usn_xlen != 0) { if ((err = fprintf(fp, f->usf_u64_first, v->usv_buf_u64[0])) < 0) return (err); rv += err; } for (i = 1; i < n->usn_xlen; i++) { if ((err = fprintf(fp, f->usf_u64_rest, v->usv_buf_u64[i])) < 0) return (err); rv += err; } return (rv); } static int ustat_fprintf_uuid(ustat_handle_t *h, FILE *fp, const ustat_named_t *n, const ustat_value_t *v) { char buf[UU_UUID_STR_LEN + 1]; #ifdef NOTYET uu_uuid_t u; (void) uu_uuid_from_bin(&u, v->usv_buf, n->usn_xlen); (void) uu_uuid_to_str(&u, buf, sizeof (buf)); #endif return (fprintf(fp, "%s", buf)); } static const ustat_ifmt_t ustat_format_def = { "%" PRId8, "%" PRId16, "%" PRId32, "%" PRId64, "%" PRIu8, "%" PRIu16, "%" PRIu32, "%" PRIu64, "%02" PRIx8, ".%02" PRIx8, "%016" PRIx64, ".%016" PRIx64 }; static const ustat_ifmt_t ustat_format_oct = { "%" PRIo8, "%" PRIo16, "%" PRIo32, "%" PRIo64, "%" PRIo8, "%" PRIo16, "%" PRIo32, "%" PRIo64, "%02" PRIo8, ".%02" PRIo8, "%022" PRIo64, ".%022" PRIo64 }; static const ustat_ifmt_t ustat_format_dec = { "%" PRId8, "%" PRId16, "%" PRId32, "%" PRId64, "%" PRIu8, "%" PRIu16, "%" PRIu32, "%" PRIu64, "%" PRId8, ".%" PRId8, "%020" PRId64, ".%020" PRId64 }; static const ustat_ifmt_t ustat_format_hex = { "%" PRIx8, "%" PRIx16, "%" PRIx32, "%" PRIx64, "%" PRIx8, "%" PRIx16, "%" PRIx32, "%" PRIx64, "%02" PRIx8, ".%02" PRIx8, "%016" PRIx64, ".%016" PRIx64 }; int ustat_fprintf(ustat_handle_t *h, FILE *fp, int radix, const ustat_named_t *n) { ustat_value_t *v = n->usn_data; const ustat_ifmt_t *f; int err = -1; switch (radix) { case 0: f = &ustat_format_def; break; case 8: f = &ustat_format_oct; break; case 10: f = &ustat_format_dec; break; case 16: f = &ustat_format_hex; break; default: f = &ustat_format_dec; break; } switch (n->usn_type) { case USTAT_TYPE_INT8: err = fprintf(fp, f->usf_i8, v->usv_i8); break; case USTAT_TYPE_INT16: err = fprintf(fp, f->usf_i16, v->usv_i16); break; case USTAT_TYPE_INT32: err = fprintf(fp, f->usf_i32, v->usv_i32); break; case USTAT_TYPE_INT64: err = fprintf(fp, f->usf_i64, v->usv_i64); break; case USTAT_TYPE_UINT8: err = fprintf(fp, f->usf_u8, v->usv_u8); break; case USTAT_TYPE_UINT16: err = fprintf(fp, f->usf_u16, v->usv_u16); break; case USTAT_TYPE_UINT32: err = fprintf(fp, f->usf_u32, v->usv_u32); break; case USTAT_TYPE_UINT64: err = fprintf(fp, f->usf_u64, v->usv_u64); break; case USTAT_TYPE_SIZE: if (radix == 0) err = ustat_fprintf_unit(fp, 0, v->usv_u64, &ustat_unit_size); else err = fprintf(fp, f->usf_u64, v->usv_u64); break; case USTAT_TYPE_CLOCK: if (radix == 0) err = ustat_fprintf_clock(h, fp, n, v); else err = fprintf(fp, f->usf_u64, v->usv_u64); break; case USTAT_TYPE_TOD: if (radix == 0) err = ustat_fprintf_tod(h, fp, n, v); else err = fprintf(fp, f->usf_u64, v->usv_u64); break; case USTAT_TYPE_DELTA: if (radix == 0) err = ustat_fprintf_unit(fp, 0, v->usv_u64, &ustat_unit_time); else err = fprintf(fp, f->usf_u64, v->usv_u64); break; case USTAT_TYPE_STRING: err = fprintf(fp, "%s", v->usv_buf); break; case USTAT_TYPE_BYTES: err = ustat_fprintf_bytes(h, fp, f, n, v); break; case USTAT_TYPE_ARRAY_U64: err = ustat_fprintf_array_u64(h, fp, f, n, v); break; case USTAT_TYPE_UUID: err = ustat_fprintf_uuid(h, fp, n, v); break; case USTAT_TYPE_MAX: err = ustat_error(h, EINVAL, "invalid type: %u", n->usn_type); } return (err); } int ustat_printf(ustat_handle_t *h, int radix, const ustat_named_t *n) { return (ustat_fprintf(h, stdout, radix, n)); } /* * Table of string names corresponding to ustat_type_t. This needs to be kept * in sync with the set of enumerators in <ustat.h>. */ static const char *const ustat_typenames[USTAT_TYPE_MAX] = { "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "size", "clock", "tod", "delta", "string", "bytes", "array_u64", "uuid", }; ustat_type_t ustat_str2type(const char *s) { ustat_type_t t; for (t = 0; t < USTAT_TYPE_MAX; t++) { if (strcasecmp(s, ustat_typenames[t]) == 0) return (t); } return (ustat_error(NULL, EINVAL, "invalid type name: %s", s)); } const char * ustat_type2str(ustat_type_t t) { if (t >= USTAT_TYPE_MAX) return (ustat_null(NULL, EINVAL, "invalid type: %d", t)); else return (ustat_typenames[t]); } /* * ustat bson elements are all of type "object", and have two children: * * "type": a bson string object which describes the type of the element, e.g. * the ustat class or canonical type. * * "value": a bson object of type "type" which contains the data. * * Returns 0 on success, -1 on failure. Sets *nd to the "value" offset on * success. */ static int ustat_add_bson_elem(bson_t *b, off_t d, off_t *nd, const char *utype, const char *nname) { off_t o = d; if (bson_exists(b, o, nname, &o, NULL)) ; else if (bson_add_object(b, o, nname, &o, bson_empty) != 0) return (-1); if (!bson_exists(b, o, "type", NULL, NULL)) { if (bson_add_string(b, o, "type", utype) != 0) return (-1); } else if (bson_set_string(b, o, "type", utype) != 0) return (-1); if (nd != NULL) *nd = o; return (0); } /* * Add a ustat bson object, which consists of type and value elements. * If 'nd' is not NULL, it is set to the offset of the 'value' element. */ int ustat_set_bson_object(bson_t *b, off_t d, off_t *nd, const char *utype, const char *nname) { off_t o = d; if (ustat_add_bson_elem(b, o, &o, utype, nname) != 0) return (-1); if (!bson_exists(b, o, "value", &o, NULL)) if (bson_add_object(b, o, "value", &o, bson_empty) != 0) return (-1); if (nd != NULL) *nd = o; return (0); } /* * Adds a ustat group as a tree of bson objects, using '.' as the separator, * and handling the case where any/all bson objects already exist. Returns 0 * on success, -1 on failure. nd is only modified on success. */ int ustat_add_bson_group(ustat_struct_t *s, bson_t *b, off_t d, off_t *nd) { const char *gname = ustat_getgname(s); const char *cname = ustat_getcname(s); const char *delim = "."; size_t slen = strlen(gname) + 1; char *str = alloca(slen); off_t o = d; char *q, *nextp; (void) memcpy(str, gname, slen); for (char *p = strtok_r(str, delim, &q); p != NULL; p = nextp) { nextp = strtok_r(NULL, delim, &q); if (ustat_set_bson_object(b, o, &o, (nextp == NULL ? cname : "object"), p) != 0) return (-1); } if (nd != NULL) *nd = o; return (0); } int ustat_set_bson_i64(bson_t *b, off_t d, const char *utype, const char *nname, int64_t val) { off_t o = d; if (ustat_add_bson_elem(b, o, &o, utype, nname) != 0) return (-1); if (!bson_exists(b, o, "value", &o, NULL)) { if (bson_add_int64(b, o, "value", val) != 0) return (-1); } else if (bson_set_int64(b, o, "value", val) != 0) return (-1); return (0); } int ustat_set_bson_str(bson_t *b, off_t d, const char *utype, const char *nname, const char *str) { off_t o = d; if (ustat_add_bson_elem(b, o, &o, utype, nname) != 0) return (-1); if (!bson_exists(b, o, "value", &o, NULL)) { if (bson_add_string(b, o, "value", str) != 0) return (-1); } else if (bson_set_string(b, o, "value", str) != 0) return (-1); return (0); } int ustat_set_bson_array(ustat_struct_t *s, bson_t *b, off_t d, off_t *nd, const char *utype, const char *nname) { size_t ualen = strlen(utype) + 3; char *uaname = alloca(ualen); off_t o = d; (void) snprintf(uaname, ualen, "%s[]", utype); if (ustat_add_bson_elem(b, o, &o, uaname, nname) != 0) return (-1); if (!bson_exists(b, o, "value", &o, NULL)) if (bson_add_array(b, o, "value", &o, bson_empty) != 0) return (-1); if (nd != NULL) *nd = o; return (0); } int ustat_set_bson_cyctons(ustat_struct_t *s, bson_t *b, off_t d, ustat_named_t *n, uint64_t cycle_mult) { const char *utype = ustat_type2str(n->usn_type); if (n->usn_type != USTAT_TYPE_UINT64) return (-1); return (ustat_set_bson_i64(b, d, utype, n->usn_name, hrcyctonsm(ustat_get_u64(s, n), cycle_mult))); } int ustat_export_bson(ustat_struct_t *s, const ustat_named_t *n, bson_t *b, off_t d) { char uid_str[UU_UUID_STR_LEN+1]; uint8_t uid_bin[UU_UUID_BIN_LEN]; const char *nm = n->usn_name; const uint8_t *bytes; const uint64_t *array_u64; const char *ut = ustat_type2str(n->usn_type); struct timespec ts; char *str = NULL; int alen, used, elts; off_t o = d; if (ustat_add_bson_group(s, b, o, &o) != 0) return (-1); switch (n->usn_type) { case USTAT_TYPE_INT8: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_i8(s, n))); case USTAT_TYPE_INT16: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_i16(s, n))); case USTAT_TYPE_INT32: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_i32(s, n))); case USTAT_TYPE_INT64: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_i64(s, n))); case USTAT_TYPE_UINT8: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_u8(s, n))); case USTAT_TYPE_UINT16: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_u16(s, n))); case USTAT_TYPE_UINT32: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_u32(s, n))); case USTAT_TYPE_SIZE: case USTAT_TYPE_UINT64: case USTAT_TYPE_DELTA: return (ustat_set_bson_i64(b, o, ut, nm, ustat_get_u64(s, n))); case USTAT_TYPE_CLOCK: alen = 256; str = alloca(alen); ustat_get_clock(s, n, &ts); (void) snprintf(str, alen, "%" PRIu64 "s %" PRIu64 "ns", (uint64_t)ts.tv_sec, (uint64_t)ts.tv_nsec); str[alen-1] = '\0'; return (ustat_set_bson_str(b, o, ut, nm, str)); case USTAT_TYPE_TOD: alen = 256; str = alloca(alen); (void) ustat_sprintf_tod(s, n->usn_data, str, alen); str[alen-1] = '\0'; return (ustat_set_bson_str(b, o, ut, nm, str)); case USTAT_TYPE_STRING: return (ustat_set_bson_str(b, o, ut, nm, ustat_get_str(s, n))); case USTAT_TYPE_BYTES: bytes = ustat_get_bytes(s, n); elts = n->usn_xlen; alen = (elts * 3) + 1; str = alloca(alen); str[0] = 0; used = 0; if (elts > 0 && used < alen) used += snprintf(str + used, alen - used, ustat_format_def.usf_u8_first, bytes[0]); for (int i = 1; i < elts && used < alen; i++) used += snprintf(str + used, alen - used, ustat_format_def.usf_u8_rest, bytes[i]); return (ustat_set_bson_str(b, o, ut, nm, str)); case USTAT_TYPE_ARRAY_U64: array_u64 = ustat_get_array_u64(s, n); elts = n->usn_xlen / sizeof (uint64_t); alen = (elts * 17) + 1; str = alloca(alen); str[0] = 0; used = 0; if (elts > 0 && used < alen) used += snprintf(str + used, alen - used, ustat_format_def.usf_u64_first, array_u64[0]); for (int i = 1; i < elts && used < alen; i++) used += snprintf(str + used, alen - used, ustat_format_def.usf_u64_rest, array_u64[i]); return (ustat_set_bson_str(b, o, ut, nm, str)); case USTAT_TYPE_UUID: ustat_get_uuid(s, n, uid_bin); #ifdef NOTYET if (uu_uuid_to_str(&uid, uid_str, UU_UUID_STR_LEN) == UU_UUID_STR_LEN) { uid_str[UU_UUID_STR_LEN] = '\0'; return (ustat_set_bson_str(b, o, ut, nm, uid_str)); } #endif break; case USTAT_TYPE_MAX: break; } return (-1); } /* Exports a ustat struct to BSON using the ustat misc class */ static int ustat_misc_export_bson(ustat_struct_t *s, int statc, bson_t *b, off_t d) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); uint16_t i, n = MIN(statc, g->usg_statc); const ustat_named_t *src = g->usg_statv; for (i = 0; i < n; i++, src++) if (ustat_export_bson(g->usg_statv, src, b, d) != 0) return (-1); return (0); } /* Exports a ustat struct to BSON */ int ustat_exportv_bson(ustat_struct_t *s, int statc, bson_t *b, off_t d) { ustat_group_t *g = USTAT_STRUCT_TO_GROUP(s); const ustat_class_t *uc = ustat_cname_to_class(g->usg_cname); ustat_export_bson_t export_bson; if (uc->usc_bson != NULL) export_bson = uc->usc_bson; else export_bson = ustat_class_misc.usc_bson; /* * allow bson export without detailed knowledge of a ustat's * internal size or structure */ if (uc != &ustat_class_misc) statc = 0; return (export_bson(s, statc, b, d)); }
[ "mike.w.shapiro@gmail.com" ]
mike.w.shapiro@gmail.com
8f0694449339d464aa9309f5a872f652c51c147c
2bbbe579a904fdc6ec06ad6c94237c9d06c58018
/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_068.c
6ced64b9c5d1545f23b4b14a3eb814b41bb3d151
[ "BSD-3-Clause" ]
permissive
zuiaichi/kernel_liteos_a_note
98e622f2ee65ecb0ec987f234767bc5bfdf34262
547a4b3582581da3321c82b7e19114c165db0c94
refs/heads/master
2023-06-08T17:05:22.794654
2021-06-30T02:06:44
2021-06-30T02:06:44
null
0
0
null
null
null
null
UTF-8
C
false
false
3,896
c
/* * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * 3. Neither the name of the copyright holder 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. */ #include "It_posix_pthread.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif /* __cpluscplus */ #endif /* __cpluscplus */ static VOID *PthreadF02(VOID *argument) { UINT32 ret; ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); ret = pthread_cancel(g_newTh); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); g_testCount++; ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. EXIT: return NULL; } static VOID *PthreadF01(VOID *argument) { int oldstate; UINT32 ret; pthread_attr_t attr; g_testCount++; ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT); ret = pthread_attr_init(&attr); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); attr.inheritsched = PTHREAD_EXPLICIT_SCHED; attr.schedparam.sched_priority = 8; // 8, set priority. ret = pthread_create(&g_newTh2, &attr, PthreadF02, NULL); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); #if (LOSCFG_KERNEL_SMP == YES) while (g_testCount < 2) { // 2, delay until g_testCount is equal to 2. TestBusyTaskDelay(1); } TestBusyTaskDelay(1); #else g_testCount++; ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. #endif EXIT: return NULL; } static UINT32 Testcase(VOID) { UINT32 ret; UINTPTR temp = 1; g_testCount = 0; ret = pthread_create(&g_newTh, NULL, PthreadF01, NULL); ICUNIT_ASSERT_EQUAL(ret, 0, ret); TestExtraTaskDelay(10); // 10, delay for Timing control. ret = pthread_join(g_newTh, (void *)&temp); ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp); ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result. ret = pthread_join(g_newTh2, NULL); ICUNIT_ASSERT_EQUAL(ret, 0, ret); return PTHREAD_NO_ERROR; } VOID ItPosixPthread068(VOID) // IT_Layer_ModuleORFeature_No { TEST_ADD_CASE("ItPosixPthread068", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION); } #ifdef __cplusplus #if __cplusplus } #endif /* __cpluscplus */ #endif /* __cpluscplus */
[ "kuangyufei@126.com" ]
kuangyufei@126.com
516c2c91d7cc37c838f7d590864f99176a4e2e04
2a4ef692496bd4904a7d44fa55d966f6ff5b80bf
/src/display_size.c
fd1202d13e2a606aa49b1af223b6745fec243f14
[]
no_license
Geoffrey42/ft_ls
437068af955f326fc5300f0292050225eacbbd52
a89088e2e6151d65d9ca42c186a33f2223ad299f
refs/heads/master
2021-01-13T07:49:48.554266
2017-01-09T09:43:35
2017-01-09T09:43:35
60,631,687
2
0
null
null
null
null
UTF-8
C
false
false
2,338
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* display_size.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ggane <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/09/27 17:25:08 by ggane #+# #+# */ /* Updated: 2016/09/30 11:39:45 by ggane ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_ls.h" int empty_dir(t_data *dir) { struct dirent *file; DIR *dirp; int hidden; int turns; hidden = 0; turns = 0; if (dir->flags & LOW_A_FLAG) return (0); if (!(dirp = opendir(dir->name))) return (1); while ((file = readdir(dirp))) { if (ft_strcmp(file->d_name, ".") == 0 || ft_strcmp(file->d_name, "..") == 0) hidden++; turns++; } closedir(dirp); if (hidden == 2 && turns == 2) return (1); return (0); } void display_size(struct stat file_stat) { ft_putnbr(file_stat.st_size); ft_putchar(' '); } void print_total_size(size_t size) { ft_putstr("total "); ft_putnbr(size); ft_putchar('\n'); } size_t sum_file_sizes(t_data *directory, struct dirent *file) { size_t size; struct stat file_stat; char *file_pathname; size = 0; file_pathname = create_pathname(directory->pathname, file->d_name); lstat(file_pathname, &file_stat); size = file_stat.st_blocks; return (size); } void display_total_size(t_data *directory) { size_t size; struct dirent *file; DIR *dirp; size = 0; if (empty_dir(directory)) return ; if (!(dirp = opendir(directory->name))) return ; while ((file = readdir(dirp))) { if (directory->flags & LOW_A_FLAG) size = size + sum_file_sizes(directory, file); else if ((directory->flags & LOW_A_FLAG) == 0 && file->d_name[0] != '.') size = size + sum_file_sizes(directory, file); } closedir(dirp); print_total_size(size); }
[ "ggane@e1r5p6.42.fr" ]
ggane@e1r5p6.42.fr
93c84d2a4a391b6280a8138e7f0e154e9379678c
ecf37088c1618092ee847cb3bc656fdcf851fc48
/Project/DemoKit/SrcCode/UIApp/UsbCommand/UsbCmdID.c
b1bb5f3a415ef086967e63bffca5950270856a69
[]
no_license
calvinqiu/mygithub
b2ce14f0f6f1d3057517c16f109347d88b4a096d
b16780a2b34ba8e00af39b0fd9ccb4dacf1a0eee
refs/heads/master
2021-05-13T21:55:39.951529
2018-01-08T02:39:35
2018-01-08T02:39:35
116,472,710
0
0
null
null
null
null
UTF-8
C
false
false
883
c
#include "UsbCmdID.h" #include "SysKer.h" #include "UsbCmdInt.h" #include "UsbCmdAPI.h" #include "PrjCfg.h" //#NT#2016/05/31#Ben Wang -begin //#NT#Add UVC multimedia function. #if(UVC_MULTIMEDIA_FUNC == ENABLE) #define PRI_USBCMD 10 #define STKSIZE_USBCMD 4096 #define STKSIZE_USBCMD_DOWNLOAD 2048 UINT32 USBCMDTSK_ID = 0; UINT32 USBCMDTSK2_ID = 0; UINT32 USBCMDDOWNLOADTSK_ID = 0; UINT32 FLG_ID_USBCMD = 0; UINT32 SEMID_USBCMD_1ST_COM = 0; void UsbCmd_InstallID(void) { OS_CONFIG_TASK(USBCMDTSK_ID, PRI_USBCMD, STKSIZE_USBCMD, UsbCmdTsk); OS_CONFIG_TASK(USBCMDTSK2_ID, PRI_USBCMD, STKSIZE_USBCMD, UsbCmdTsk2); OS_CONFIG_TASK(USBCMDDOWNLOADTSK_ID, PRI_USBCMD, STKSIZE_USBCMD_DOWNLOAD, UsbCmdDownloadTsk); OS_CONFIG_FLAG(FLG_ID_USBCMD); OS_CONFIG_SEMPHORE(SEMID_USBCMD_1ST_COM, 0, 1, 1); } #endif //#NT#2016/05/31#Ben Wang -end
[ "hebo@you-qin.com" ]
hebo@you-qin.com
3de87ab597ff5c0105df77469740e9bcd19420e2
a98840211a0a9ae535d35817119f112a462c8143
/appl/static_tunnel/newton_raphson.c
da3d8c5886a4730d82e015920ae2ea3a6f62975c
[]
no_license
mitsuy/C
3160463959d1c8258924048362c0fb63de3b3f14
c623860f30868e3aaf92247c52828f08584c78f2
refs/heads/master
2020-05-24T14:01:12.268935
2020-04-17T07:37:33
2020-04-17T07:37:33
187,300,619
0
0
null
null
null
null
UTF-8
C
false
false
734
c
/* Newton Raphson Method (NRM) for nonlinear equation. Solve velocity within tunnel as below eq. v_new = v_old - J^{-1} * f Written by M.YAGYU, 22 April, 2019 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define MX 20 #define MXB 100 double newton_raphson(int *M,double *v,double (*J_inv)[MX],double *f) { int i,j; double temp[*M],max_err=0.,ierr=0.; for(i=0;i<*M;i++){ temp[i]=v[i]; for(j=0;j<*M;j++){ v[i]+=-J_inv[i][j]*f[j]; } // printf("v[%d]=%lf\n",i+1,v[i]); } for(i=0;i<*M;i++){ ierr=fabs(temp[i]-v[i]); if(ierr>max_err){ max_err=ierr; } } return max_err; }
[ "d.0u.t3jjw2.tj6@icloud.com" ]
d.0u.t3jjw2.tj6@icloud.com
4ef191dbf255612e56b0e976a6b910aa11644202
f15eb31f51ee26de9a161c2950312721ae4acd37
/asm/src/parser.c
8d8453bd61983224b737abdc90ccf1755da7b574
[]
no_license
theocerutti/Corewar
a667f8e4f0e4580bd9d76b6e33fe2d9ca9544b24
541dce938100b7ec24ce48ad38ea6cce37c44d07
refs/heads/master
2020-05-27T20:22:33.832275
2020-04-06T16:00:10
2020-04-06T16:00:10
188,778,697
4
0
null
null
null
null
UTF-8
C
false
false
798
c
/* ** EPITECH PROJECT, 2019 ** parser ** File description: ** parser */ #include "asm.h" void write_instru_token(data_t *data, token_t *token, char *instru, int begin_code_line) { for (int i = 0; instru != NULL && op_tab[i].mnemonique != NULL; i++) { if (!my_strncmp(instru, op_tab[i].mnemonique, my_strlen(instru))) { write_instruction(data, token, &op_tab[i], begin_code_line); break; } } } int parse_token(data_t *data, token_t *token) { int ret = 0; char *instru = token->t_token[0]; int begin_code_line = 0; if (is_flag(instru)) { instru = token->t_token[1]; begin_code_line = 1; } else { begin_code_line = 0; } write_instru_token(data, token, instru, begin_code_line); return (ret); }
[ "theo.cerutti@epitech.eu" ]
theo.cerutti@epitech.eu
15e74a14557572e4c7888b21f619db97c93de545
893ea7cffd4e6fe3fbf38ee488249358e0dc8bd1
/0728/1vital_code/整合的十段代码/3标准IO_文件IO/标准IO/3putc_getc.c
6ec5ed5bec56f8202fa6f1a05a4d15d8dda4d037
[]
no_license
lansplansplansp/0707
b198a2107371c81a12e38a417beb8ea709725d81
6f4b4e31305104a19bcf920e4aceaac8fb83c591
refs/heads/master
2020-06-16T18:27:49.387589
2019-07-28T15:59:05
2019-07-28T15:59:05
195,664,192
0
0
null
null
null
null
UTF-8
C
false
false
202
c
#include<stdio.h> #include<string.h> int main() { char ch; printf("Input a character:"); ch=getc(stdin); //ch=fgetc(stdin); putc(ch,stdout); //fputc(ch,stdout); return 0; }
[ "123456@qq.com" ]
123456@qq.com
a95b3a6a391b957e9b9fdf922550c85be240a516
5683f486a524f0efdb7530849f121b2f0fef9a9b
/tstxtdump.c
0e3bea0e88c05ba7682aa86b02dd56b5f7545404
[]
no_license
fsphil/tstxtdump
9219f8626c9ea70a8e2f333391470a0002cff041
15ca6d7cff9b8d4ef8f8cb068079c2f69692aeee
refs/heads/master
2023-01-31T05:49:39.201064
2020-11-30T18:21:10
2020-11-30T18:21:10
267,302,525
4
0
null
null
null
null
UTF-8
C
false
false
11,050
c
/* tstxtdump */ /*=======================================================================*/ /* Copyright 2020 Philip Heron <phil@sanslogic.co.uk> */ /* */ /* 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 <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <getopt.h> FILE *fout = NULL; int verbose = 0; int olines = 0; int errors = 0; static uint8_t _rev8(uint8_t b) { b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; b = (b & 0xCC) >> 2 | (b & 0x33) << 2; b = (b & 0xAA) >> 1 | (b & 0x55) << 1; return(b); } static void _parse_pes(const uint8_t *pes, size_t pes_len) { const uint8_t *data; size_t data_len; while(pes_len > 0) { if(verbose >= 2) { fprintf(stderr, " Packet start code prefix: 0x%02X%02X%02X\n", pes[0], pes[1], pes[2]); fprintf(stderr, " Stream id: 0x%02X\n", pes[3]); fprintf(stderr, " PES Packet length: %d\n", (pes[4] << 8) | pes[5]); fprintf(stderr, " Marker bits: %d\n", (pes[6] >> 6) & 3); fprintf(stderr, " Scrambling control: %d\n", (pes[6] >> 4) & 3); fprintf(stderr, " Priority: %d\n", (pes[6] >> 3) & 1); fprintf(stderr, " Data alignment indicator: %d\n", (pes[6] >> 2) & 1); fprintf(stderr, " Copyright: %d\n", (pes[6] >> 1) & 1); fprintf(stderr, " Original or Copy: %d\n", (pes[6] >> 0) & 1); fprintf(stderr, " PTS DTS indicator: %d\n", (pes[7] >> 6) & 3); fprintf(stderr, " ESCR flag: %d\n", (pes[7] >> 5) & 1); fprintf(stderr, " ES rate flag: %d\n", (pes[7] >> 4) & 1); fprintf(stderr, " DSM trick mode flag: %d\n", (pes[7] >> 3) & 1); fprintf(stderr, "Additional copy info flag: %d\n", (pes[7] >> 2) & 1); fprintf(stderr, " CRC flag: %d\n", (pes[7] >> 1) & 1); fprintf(stderr, " extension flag: %d\n", (pes[7] >> 0) & 1); fprintf(stderr, " PES header length: %d\n", pes[8]); } /* Validate the start code */ if(pes[0] != 0x00 || pes[1] != 0x00 || pes[2] != 0x01) { if(verbose >= 1) { fprintf(stderr, "Invalid Packet start code prefix 0x%02X%02X%02X - skipping PES packet\n", pes[0], pes[1], pes[2]); } errors++; return; } /* Validate the stream ID */ if(pes[3] != 0xBD) { if(verbose >= 1) { fprintf(stderr, "Invalid Stream id 0x%02X - skipping PES packet\n", pes[3]); } errors++; return; } data = &pes[8 + pes[8] + 1]; data_len = ((pes[4] << 8) | pes[5]) - pes[8] - 3; if(verbose >= 2) { fprintf(stderr, "data_len = %ld\n", data_len); fprintf(stderr, "data_identifier: %02X\n", data[0]); } /* Validate the length */ if(data_len <= 0 || data_len > pes_len) { if(verbose >= 1) { fprintf(stderr, "Invalid PES Packet length: %ld\n", data_len); } errors++; return; } data_len -= 1; data += 1; while(data_len >= 46) { int j; if(verbose >= 2) { //fprintf(stderr, "(%ld)\n", data_len); fprintf(stderr, " data_unit_id: %d\n", data[0]); fprintf(stderr, " data_unit_length: %d\n", data[1]); fprintf(stderr, " reserved_future_use: %d\n", (data[2] >> 6) & 3); fprintf(stderr, " field_parity: %d\n", (data[2] >> 5) & 1); fprintf(stderr, " line_offset: 0x%02X\n", data[2] & 0x1F); fprintf(stderr, " framing_code: %d\n", data[3]); fprintf(stderr, "magazine_and_packet_address: %02X%02X\n", data[4], data[5]); fprintf(stderr, " data: '"); for(j = 0; j < 40; j++) { fprintf(stderr, "%c", _rev8(data[6 + j]) & 0x7F); } fprintf(stderr, "'\n"); } if(data[0] == 0x02 || data[0] == 0x03) { uint8_t rdata[42]; /* Reverse the bytes for output */ for(j = 0; j < 42; j++) { rdata[j] = _rev8(data[4 + j]); } fwrite(rdata, 42, 1, fout); olines++; } data_len -= data[1] + 2; data += data[1] + 2; } data_len = ((pes[4] << 8) | pes[5]) + 6; pes_len -= data_len; pes += data_len; } } static void _print_usage(void) { fprintf(stderr, "Usage: tstxtdump -p <pid> [-v] [-S <bytes>] [-P <bytes] <in.ts> <out.t42>\n" "\n" " -p, --pid <number> Select which PID to dump. Required.\n" " -S, --skip <number> Number of bytes to skip at the beginning of\n" " the file. Default: 0\n" " -P, --pad <number> Number of bytes to skip after each packet.\n" " -v, --verbose Enable verbose output.\n" ); } int main(int argc, char *argv[]) { FILE *fin; uint8_t pkt[188], *payload; uint8_t payload_len; uint8_t counter = 0xFF; uint8_t pes[1024 * 4]; uint16_t pid = 0; int skip = 0; int pad = 0; ssize_t pes_len = -1; int c; int option_index; static struct option long_options[] = { { "pid", required_argument, 0, 'p' }, { "skip", required_argument, 0, 'S' }, { "pad", required_argument, 0, 'P' }, { "verbose", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; opterr = 0; while((c = getopt_long(argc, argv, "p:S:P:v", long_options, &option_index)) != -1) { switch(c) { case 'p': /* -p, --pid <number> */ pid = strtol(optarg, NULL, 0); break; case 'S': /* -S, --skip <bytes> */ skip = strtol(optarg, NULL, 0); break; case 'P': /* -P, --pad <bytes> */ pad = strtol(optarg, NULL, 0); break; case 'v': /* -v, --verbose */ verbose++; break; case '?': _print_usage(); return(0); } } if(argc != optind + 2) { _print_usage(); return(-1); } if(pid == 0 || pid >= 0x2000) { fprintf(stderr, "Invalid PID 0x%X\n", pid); return(-1); } if(pad < 0) { fprintf(stderr, "Invalid pad count %d\n", pad); return(-1); } if(skip < 0) { fprintf(stderr, "Invalid skip count %d\n", skip); return(-1); } fprintf(stderr, "Dumping '%s' (PID 0x%X) > '%s'\n", argv[optind + 0], pid, argv[optind + 1]); fin = fopen(argv[optind + 0], "rb"); if(!fin) { perror(argv[optind + 0]); return(-1); } fout = fopen(argv[optind + 1], "wb"); if(!fout) { perror(argv[optind + 1]); fclose(fin); return(-1); } fseek(fin, skip, SEEK_CUR); while(fread(pkt, 188, 1, fin) == 1) { if(pkt[0] != 0x47) { int i; c = 0; do { for(i = 0; i < 188; i++) { if(pkt[i] == 0x47) break; } c += i; memmove(pkt, &pkt[i], 188 - i); if(fread(&pkt[188 - i], i, 1, fin) != 1) { i = -1; break; } } while(i == 188); if(i == -1) { /* EOF */ break; } if(verbose >= 1) { fprintf(stderr, "Skipped %d bytes\n", c); } } /* Skip PIDs we don't need */ if((((pkt[1] << 8) | pkt[2]) & 0x1FFF) != pid) { fseek(fin, pad, SEEK_CUR); continue; } if(counter != 0xFF && counter != (pkt[3] & 0x0F)) { if(verbose >= 1) { fprintf(stderr, "Continuity counter interruption %d != %d\n", pkt[3] & 0x0F, counter); } errors++; pes_len = -1; } if(verbose >= 2) { /* Dump TS header */ fprintf(stderr, " Transport error indicator (TEI): %d\n", (pkt[1] >> 7) & 1); fprintf(stderr, "Payload unit start indicator (PUSI): %d\n", (pkt[1] >> 6) & 1); fprintf(stderr, " Transport priority: %d\n", (pkt[1] >> 5) & 1); fprintf(stderr, " PID: %d\n", ((pkt[1] << 8) | pkt[2]) & 0x1FFF); fprintf(stderr, " Transport scrambling control (TSC): %d\n", (pkt[3] >> 6) & 3); fprintf(stderr, " Adaptation field control: %d\n", (pkt[3] >> 4) & 3); fprintf(stderr, " Continuity counter: %d\n", pkt[3] & 0x0F); fprintf(stderr, "---------------------------------------\n"); } payload = &pkt[4]; payload_len = 188 - 4; if((pkt[3] >> 5) & 1) { if(verbose >= 2) { /* Dump adaptation field */ fprintf(stderr, " Adaptation field length: %d\n", payload[0]); fprintf(stderr, " Discontinuity indicator: %d\n", (payload[1] >> 7) & 1); fprintf(stderr, " Random access indicator: %d\n", (payload[1] >> 6) & 1); fprintf(stderr, "Elementary stream priority indicator: %d\n", (payload[1] >> 5) & 1); fprintf(stderr, " PCR flag: %d\n", (payload[1] >> 4) & 1); fprintf(stderr, " OPCR flag: %d\n", (payload[1] >> 3) & 1); fprintf(stderr, " Splicing point flag: %d\n", (payload[1] >> 2) & 1); fprintf(stderr, " Transport private data flag: %d\n", (payload[1] >> 1) & 1); fprintf(stderr, " Adaptation field extension flag: %d\n", (payload[1] >> 0) & 1); if((payload[1] >> 4) & 1) { fprintf(stderr, " PCR: -\n"); } if((payload[1] >> 3) & 1) { fprintf(stderr, " OPCR: -\n"); } if((payload[1] >> 2) & 1) { fprintf(stderr, " Splice countdown: -\n"); } if((payload[1] >> 1) & 1) { fprintf(stderr, " Transport private data length: -\n"); } fprintf(stderr, "---------------------------------------\n"); } /* Move payload pointer ahead to actual payload */ payload_len -= payload[0] + 1; payload += payload[0] + 1; } if((pkt[1] >> 6) & 1) { if(pes_len > 0) { _parse_pes(pes, pes_len); } pes_len = 0; } if(pes_len >= 0) { if(pes_len + payload_len >= 1024 * 4) { fprintf(stderr, "PES packet too large\n"); return(-1); } memcpy(&pes[pes_len], payload, payload_len); pes_len += payload_len; } counter = (pkt[3] + ((pkt[3] >> 4) & 1)) & 0x0F; if(verbose >= 2) { fprintf(stderr, "\n"); } fseek(fin, pad, SEEK_CUR); } fclose(fout); fclose(fin); fprintf(stderr, "Dumped %d lines (%d errors)\n", olines, errors); return(0); }
[ "phil@sanslogic.co.uk" ]
phil@sanslogic.co.uk
355173d75180e436786054e2c1b487fca50d48b8
5d417f03f724f4e23000f28cd629c92bc9297a23
/common/services/usb/class/msc/device/udi_msc.h
7a76ad84fc992d9c5f17d5158c0b598cf6025c82
[]
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
13,601
h
/** * \file * * \brief USB Device Mass Storage Class (MSC) interface definitions. * * Copyright (c) 2009-2016 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 * */ /* * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */ #ifndef _UDI_MSC_H_ #define _UDI_MSC_H_ #include "conf_usb.h" #include "usb_protocol.h" #include "usb_protocol_msc.h" #include "udd.h" #include "udc_desc.h" #include "udi.h" #ifdef __cplusplus extern "C" { #endif /** * \addtogroup udi_msc_group_udc * @{ */ //! Global structure which contains standard UDI interface for UDC extern UDC_DESC_STORAGE udi_api_t udi_api_msc; //@} /** * \ingroup udi_msc_group * \defgroup udi_msc_group USB interface descriptors * * The following structures provide predefined USB interface descriptors. * It must be used to define the final USB descriptors. */ //@{ //! Interface descriptor structure for MSC typedef struct { usb_iface_desc_t iface; usb_ep_desc_t ep_in; usb_ep_desc_t ep_out; } udi_msc_desc_t; //! By default no string associated to this interface #ifndef UDI_MSC_STRING_ID #define UDI_MSC_STRING_ID 0 #endif //! MSC endpoints size for full speed #define UDI_MSC_EPS_SIZE_FS 64 //! MSC endpoints size for high speed #define UDI_MSC_EPS_SIZE_HS 512 //! Content of MSC interface descriptor for all speeds #define UDI_MSC_DESC \ .iface.bLength = sizeof(usb_iface_desc_t),\ .iface.bDescriptorType = USB_DT_INTERFACE,\ .iface.bInterfaceNumber = UDI_MSC_IFACE_NUMBER,\ .iface.bAlternateSetting = 0,\ .iface.bNumEndpoints = 2,\ .iface.bInterfaceClass = MSC_CLASS,\ .iface.bInterfaceSubClass = MSC_SUBCLASS_TRANSPARENT,\ .iface.bInterfaceProtocol = MSC_PROTOCOL_BULK,\ .iface.iInterface = UDI_MSC_STRING_ID,\ .ep_in.bLength = sizeof(usb_ep_desc_t),\ .ep_in.bDescriptorType = USB_DT_ENDPOINT,\ .ep_in.bEndpointAddress = UDI_MSC_EP_IN,\ .ep_in.bmAttributes = USB_EP_TYPE_BULK,\ .ep_in.bInterval = 0,\ .ep_out.bLength = sizeof(usb_ep_desc_t),\ .ep_out.bDescriptorType = USB_DT_ENDPOINT,\ .ep_out.bEndpointAddress = UDI_MSC_EP_OUT,\ .ep_out.bmAttributes = USB_EP_TYPE_BULK,\ .ep_out.bInterval = 0, //! Content of MSC interface descriptor for full speed only #define UDI_MSC_DESC_FS {\ UDI_MSC_DESC \ .ep_in.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_FS),\ .ep_out.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_FS),\ } //! Content of MSC interface descriptor for high speed only #define UDI_MSC_DESC_HS {\ UDI_MSC_DESC \ .ep_in.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_HS),\ .ep_out.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_HS),\ } //@} /** * \ingroup udi_group * \defgroup udi_msc_group USB Device Interface (UDI) for Mass Storage Class (MSC) * * Common APIs used by high level application to use this USB class. * * These routines are used by memory to transfer its data * to/from USB MSC endpoints. * * See \ref udi_msc_quickstart. * @{ */ /** * \brief Process the background read/write commands * * Routine called by the main loop */ bool udi_msc_process_trans(void); /** * \brief Transfers data to/from USB MSC endpoints * * * \param b_read Memory to USB, if true * \param block Buffer on Internal RAM to send or fill * \param block_size Buffer size to send or fill * \param callback Function to call at the end of transfer. * If NULL then the routine exit when transfer is finish. * * \return \c 1 if function was successfully done, otherwise \c 0. */ bool udi_msc_trans_block(bool b_read, uint8_t * block, iram_size_t block_size, void (*callback) (udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)); //@} #ifdef __cplusplus } #endif /** * \page udi_msc_quickstart Quick start guide for USB device Mass Storage module (UDI MSC) * * This is the quick start guide for the \ref udi_msc_group * "USB device interface MSC module (UDI MSC)" with step-by-step instructions on * how to configure and use the modules in a selection of use cases. * * The use cases contain several code fragments. The code fragments in the * steps for setup can be copied into a custom initialization function, while * the steps for usage can be copied into, e.g., the main application function. * * \section udi_msc_basic_use_case Basic use case * In this basic use case, the "USB MSC (Single Interface Device)" module is used. * The "USB MSC (Composite Device)" module usage is described in \ref udi_msc_use_cases * "Advanced use cases". * * \section udi_msc_basic_use_case_setup Setup steps * \subsection udi_msc_basic_use_case_setup_prereq Prerequisites * \copydetails udc_basic_use_case_setup_prereq * \subsection udi_msc_basic_use_case_setup_code Example code * \copydetails udc_basic_use_case_setup_code * \subsection udi_msc_basic_use_case_setup_flow Workflow * \copydetails udc_basic_use_case_setup_flow * * \section udi_msc_basic_use_case_usage Usage steps * * \subsection udi_msc_basic_use_case_usage_code Example code * Content of conf_usb.h: * \code #define USB_DEVICE_SERIAL_NAME "12...EF" // Disk SN for MSC #define UDI_MSC_GLOBAL_VENDOR_ID \ 'A', 'T', 'M', 'E', 'L', ' ', ' ', ' ' #define UDI_MSC_GLOBAL_PRODUCT_VERSION \ '1', '.', '0', '0' #define UDI_MSC_ENABLE_EXT() my_callback_msc_enable() extern bool my_callback_msc_enable(void); #define UDI_MSC_DISABLE_EXT() my_callback_msc_disable() extern void my_callback_msc_disable(void); #include "udi_msc_conf.h" // At the end of conf_usb.h file \endcode * * Add to application C-file: * \code static bool my_flag_autorize_msc_transfert = false; bool my_callback_msc_enable(void) { my_flag_autorize_msc_transfert = true; return true; } void my_callback_msc_disable(void) { my_flag_autorize_msc_transfert = false; } void task(void) { udi_msc_process_trans(); } \endcode * * \subsection udi_msc_basic_use_case_setup_flow Workflow * -# Ensure that conf_usb.h is available and contains the following configuration, * which is the USB device MSC configuration: * - \code #define USB_DEVICE_SERIAL_NAME "12...EF" // Disk SN for MSC \endcode * \note The USB serial number is mandatory when a MSC interface is used. * - \code //! Vendor name and Product version of MSC interface #define UDI_MSC_GLOBAL_VENDOR_ID \ 'A', 'T', 'M', 'E', 'L', ' ', ' ', ' ' #define UDI_MSC_GLOBAL_PRODUCT_VERSION \ '1', '.', '0', '0' \endcode * \note The USB MSC interface requires a vendor ID (8 ASCII characters) * and a product version (4 ASCII characters). * - \code #define UDI_MSC_ENABLE_EXT() my_callback_msc_enable() extern bool my_callback_msc_enable(void); \endcode * \note After the device enumeration (detecting and identifying USB devices), * the USB host starts the device configuration. When the USB MSC interface * from the device is accepted by the host, the USB host enables this interface and the * UDI_MSC_ENABLE_EXT() callback function is called and return true. * Thus, when this event is received, the tasks which call * udi_msc_process_trans() must be enabled. * - \code #define UDI_MSC_DISABLE_EXT() my_callback_msc_disable() extern void my_callback_msc_disable(void); \endcode * \note When the USB device is unplugged or is reset by the USB host, the USB * interface is disabled and the UDI_MSC_DISABLE_EXT() callback function * is called. Thus, it is recommended to disable the task which is called udi_msc_process_trans(). * -# The MSC is automatically linked with memory control access component * which provides the memories interfaces. However, the memory data transfers * must be done outside USB interrupt routine. This is done in the MSC process * ("udi_msc_process_trans()") called by main loop: * - \code * void task(void) { udi_msc_process_trans(); } \endcode * -# The MSC speed depends on task periodicity. To get the best speed * the notification callback "UDI_MSC_NOTIFY_TRANS_EXT" can be used to wakeup * this task (Example, through a mutex): * - \code #define UDI_MSC_NOTIFY_TRANS_EXT() msc_notify_trans() void msc_notify_trans(void) { wakeup_my_task(); } \endcode * * \section udi_msc_use_cases Advanced use cases * For more advanced use of the UDI MSC module, see the following use cases: * - \subpage udi_msc_use_case_composite * - \subpage udc_use_case_1 * - \subpage udc_use_case_2 * - \subpage udc_use_case_3 * - \subpage udc_use_case_5 * - \subpage udc_use_case_6 */ /** * \page udi_msc_use_case_composite MSC in a composite device * * A USB Composite Device is a USB Device which uses more than one USB class. * In this use case, the "USB MSC (Composite Device)" module is used to * create a USB composite device. Thus, this USB module can be associated with * another "Composite Device" module, like "USB HID Mouse (Composite Device)". * * Also, you can refer to application note * <A href="http://www.atmel.com/dyn/resources/prod_documents/doc8445.pdf"> * AVR4902 ASF - USB Composite Device</A>. * * \section udi_msc_use_case_composite_setup Setup steps * For the setup code of this use case to work, the * \ref udi_msc_basic_use_case "basic use case" must be followed. * * \section udi_msc_use_case_composite_usage Usage steps * * \subsection udi_msc_use_case_composite_usage_code Example code * Content of conf_usb.h: * \code #define USB_DEVICE_EP_CTRL_SIZE 64 #define USB_DEVICE_NB_INTERFACE (X+1) #define USB_DEVICE_MAX_EP (X+2) #define UDI_MSC_EP_IN (X | USB_EP_DIR_IN) #define UDI_MSC_EP_OUT (Y | USB_EP_DIR_OUT) #define UDI_MSC_IFACE_NUMBER X #define UDI_COMPOSITE_DESC_T \ udi_msc_desc_t udi_msc; \ ... #define UDI_COMPOSITE_DESC_FS \ .udi_msc = UDI_MSC_DESC, \ ... #define UDI_COMPOSITE_DESC_HS \ .udi_msc = UDI_MSC_DESC, \ ... #define UDI_COMPOSITE_API \ &udi_api_msc, \ ... \endcode * * \subsection udi_msc_use_case_composite_usage_flow Workflow * -# Ensure that conf_usb.h is available and contains the following parameters * required for a USB composite device configuration: * - \code // Endpoint control size, This must be: // - 8, 16, 32 or 64 for full speed device (8 is recommended to save RAM) // - 64 for a high speed device #define USB_DEVICE_EP_CTRL_SIZE 64 // Total Number of interfaces on this USB device. // Add 1 for MSC. #define USB_DEVICE_NB_INTERFACE (X+1) // Total number of endpoints on this USB device. // This must include each endpoint for each interface. // Add 2 for MSC. #define USB_DEVICE_MAX_EP (X+2) \endcode * -# Ensure that conf_usb.h contains the description of * composite device: * - \code // The endpoint numbers chosen by you for the MSC. // The endpoint numbers starting from 1. #define UDI_MSC_EP_IN (X | USB_EP_DIR_IN) #define UDI_MSC_EP_OUT (Y | USB_EP_DIR_OUT) // The interface index of an interface starting from 0 #define UDI_MSC_IFACE_NUMBER X \endcode * -# Ensure that conf_usb.h contains the following parameters * required for a USB composite device configuration: * - \code // USB Interfaces descriptor structure #define UDI_COMPOSITE_DESC_T \ ... udi_msc_desc_t udi_msc; \ ... // USB Interfaces descriptor value for Full Speed #define UDI_COMPOSITE_DESC_FS \ ... .udi_msc = UDI_MSC_DESC_FS, \ ... // USB Interfaces descriptor value for High Speed #define UDI_COMPOSITE_DESC_HS \ ... .udi_msc = UDI_MSC_DESC_HS, \ ... // USB Interface APIs #define UDI_COMPOSITE_API \ ... &udi_api_msc, \ ... \endcode * - \note The descriptors order given in the four lists above must be the * same as the order defined by all interface indexes. The interface index * orders are defined through UDI_X_IFACE_NUMBER defines. */ #endif // _UDI_MSC_H_
[ "robksawyer@gmail.com" ]
robksawyer@gmail.com
6d58709375d7563d9c64d0ac73243c6916a56775
9a8367eb15eb43f73f266ad41acc12d0d5c19280
/chardev.c
448d9011e9884cc0d44b6fc63e66bdd43eb89102
[]
no_license
DenisEvteev/chrdev
a522ff6298d22941cf26bc082e25b444b94850fe
cd1dde4e454f11362f742d49436dae444c868109
refs/heads/main
2023-01-10T09:06:25.339523
2020-11-10T10:44:36
2020-11-10T10:44:36
311,614,508
0
0
null
null
null
null
UTF-8
C
false
false
3,860
c
#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/cdev.h> #include <linux/types.h> #include <linux/kdev_t.h> #include <linux/slab.h> #include <linux/uaccess.h> #include <linux/wait.h> #include <linux/mutex.h> #define DEVICE_NAME "echo" #define BUF_SIZE (ssize_t)(PAGE_SIZE * 10) static char *kbuf; // buffer for transfering data static int my_major, my_minor = 0; static const unsigned int count = 1; static dev_t first; static struct cdev *dev; static wait_queue_head_t wq; static size_t writed_bytes = 0; static struct mutex mtx; static int dev_open(struct inode *inode, struct file *filp) { printk(KERN_INFO "Open file device with minor = %d\n", iminor(inode)); return 0; } static int dev_release(struct inode *inode, struct file *filp) { printk(KERN_INFO "Release the file structure\n"); return 0; } static ssize_t dev_read(struct file *filp, char __user *buff, size_t count, loff_t *offp) { int ret; size_t fsize; /** * I need to come up with some idead concerning how to * perform exit in case of writed_bytes is equal zero, but we * don't have any writers. At this moment we should detect * the fact that device file opened for writing was released * At this point we need to go out from sleep instruction below. */ ret = wait_event_interruptible(wq, writed_bytes > 0); if (ret != 0) { printk(KERN_INFO "signal has delivered while waiting\n"); return ret; } mutex_lock(&mtx); fsize = min(writed_bytes - *offp, count); ret = copy_to_user(buff, kbuf + *offp, fsize); if (ret != 0) { printk(KERN_INFO "error: not all bytes have been transferred: %d\n", ret); return -EFAULT; } *offp += fsize; if (*offp == writed_bytes) { writed_bytes = 0; *offp = 0; wake_up_interruptible(&wq); } printk(KERN_INFO "readed: %zd bytes; offset: %d; general_kbuf: %zd\n ", fsize, (int)*offp, writed_bytes); mutex_unlock(&mtx); return fsize; } static ssize_t dev_write(struct file *filp, const char __user *buff, size_t count, loff_t *offp) { int ret; size_t fsize; ret = wait_event_interruptible(wq, writed_bytes < BUF_SIZE); if (ret != 0) { printk(KERN_INFO "signal has delivered while waiting\n"); return ret; } mutex_lock(&mtx); fsize = min(count, BUF_SIZE - writed_bytes); if (copy_from_user(kbuf + writed_bytes, buff, fsize)) return -EFAULT; *offp += fsize; writed_bytes += fsize; printk(KERN_INFO "writed: %zd bytes; offset: %d; bytes_in_kbuf: %zd\n", fsize, (int)*offp, writed_bytes); mutex_unlock(&mtx); wake_up_interruptible(&wq); return fsize; } static struct file_operations fops = { .owner = THIS_MODULE, .read = dev_read, .write = dev_write, .open = dev_open, .release = dev_release }; static int __init chardev_init(void) { int ret; printk(KERN_INFO "device driver (aka module) is loaded\n"); kbuf = kmalloc(BUF_SIZE, GFP_KERNEL); if (!kbuf) { printk(KERN_ERR "kmalloc error!\n"); return -1; } ret = alloc_chrdev_region(&first, my_minor, count, DEVICE_NAME); if (ret < 0) { printk(KERN_ERR "alloc_chrdev_region: %d\n", ret); return -1; } my_major = MAJOR(first); printk(KERN_INFO "major = %d, minor = %d\n", my_major, my_minor); dev = cdev_alloc(); cdev_init(dev, &fops); dev->owner = THIS_MODULE; ret = cdev_add(dev, first, count); if (ret < 0) { printk(KERN_ERR "cdev_add: %d\n", ret); return -1; } mutex_init(&mtx); init_waitqueue_head(&wq); return 0; } /** * Is called just before the module is rmmoded from the kernel */ static void __exit chardev_exit(void) { printk(KERN_INFO "device driver (aka module) is unloaded\n"); unregister_chrdev_region(first, count); cdev_del(dev); kfree(kbuf); } module_init(chardev_init); module_exit(chardev_exit); MODULE_LICENSE("GPL");
[ "evteev.da@phystech.edu" ]
evteev.da@phystech.edu
ef158c11b178e13eb1470ddaaf2592a5278ae6e9
711e5c8b643dd2a93fbcbada982d7ad489fb0169
/XPSP1/NT/sdktools/pdh/pdhlog/log_ctrl.c
d644d226349f859f0458045ab53a1020f4d40c0c
[]
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
42,716
c
/*++ Copyright (C) 1995-1999 Microsoft Corporation Module Name: log_ctrl.c Abstract: Log file control interface helper functions --*/ #include <windows.h> #include <stdlib.h> #include <assert.h> #include <pdh.h> #include "pdhidef.h" #include "pdhmsg.h" #include "strings.h" #define PDH_LOGSVC_CTRL_FNMASK ((DWORD)(PDH_LOGSVC_CTRL_ADD \ | PDH_LOGSVC_CTRL_REMOVE \ | PDH_LOGSVC_CTRL_INFO \ )) // // Internal Logging utility functions // LONG GetCurrentServiceState ( SC_HANDLE hService, BOOL * bStopped, BOOL * bPaused) { SERVICE_STATUS ssData; LONG lStatus = ERROR_SUCCESS; BOOL bServiceStopped = FALSE; BOOL bServicePaused = FALSE; if (ControlService ( hService, SERVICE_CONTROL_INTERROGATE, &ssData)) { switch (ssData.dwCurrentState) { case SERVICE_STOPPED: bServiceStopped = TRUE; bServicePaused = FALSE; break; case SERVICE_START_PENDING: bServiceStopped = TRUE; bServicePaused = FALSE; break; case SERVICE_STOP_PENDING: bServiceStopped = FALSE; bServicePaused = FALSE; break; case SERVICE_RUNNING: bServiceStopped = FALSE; bServicePaused = FALSE; break; case SERVICE_CONTINUE_PENDING: bServiceStopped = FALSE; bServicePaused = FALSE; break; case SERVICE_PAUSE_PENDING: bServiceStopped = FALSE; bServicePaused = FALSE; break; case SERVICE_PAUSED: bServiceStopped = FALSE; bServicePaused = TRUE; break; default: ;// no op } } else { bServiceStopped = TRUE; bServicePaused = TRUE; } *bStopped = bServiceStopped; *bPaused = bServicePaused; return lStatus; } STATIC_PDH_FUNCTION PdhiSetLogQueryState ( IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN DWORD dwFlags ) { DBG_UNREFERENCED_PARAMETER(szMachineName); DBG_UNREFERENCED_PARAMETER(szQueryName); DBG_UNREFERENCED_PARAMETER(dwFlags); return ERROR_SUCCESS; } STATIC_PDH_FUNCTION PdhiGetLogQueryState ( IN SC_HANDLE hService, IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN LPDWORD pdwFlags ) { BOOL bStopped, bPaused; DWORD dwStatus; UNREFERENCED_PARAMETER(szMachineName); UNREFERENCED_PARAMETER(szQueryName); // first get service status GetCurrentServiceState (hService, &bStopped, &bPaused); if (bStopped) { dwStatus = PDH_LOGSVC_STATUS_STOPPED; } else if (bPaused) { dwStatus = PDH_LOGSVC_STATUS_PAUSED; } else { dwStatus = PDH_LOGSVC_STATUS_RUNNING; } if (dwStatus == PDH_LOGSVC_STATUS_RUNNING) { // get status of specific query // connect to machine, if necssary // open registry key of log service // read value of query status // adjust status, if necessary } // return status of query *pdwFlags = dwStatus; return ERROR_SUCCESS; } STATIC_PDH_FUNCTION PdhiLogServiceAddCommandT ( IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN DWORD dwFlags, IN LPVOID pInfoBuffer, IN LPDWORD pdwBufferSize, IN BOOL bWideChar ) { UNREFERENCED_PARAMETER(szMachineName); UNREFERENCED_PARAMETER(szQueryName); UNREFERENCED_PARAMETER(dwFlags); UNREFERENCED_PARAMETER(pInfoBuffer); UNREFERENCED_PARAMETER(pdwBufferSize); UNREFERENCED_PARAMETER(bWideChar); return PDH_NOT_IMPLEMENTED; } STATIC_PDH_FUNCTION PdhiLogServiceRemoveCommandT ( IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN DWORD dwFlags, IN LPVOID pInfoBuffer, IN LPDWORD pdwBufferSize, IN BOOL bWideChar ) { UNREFERENCED_PARAMETER(szMachineName); UNREFERENCED_PARAMETER(szQueryName); UNREFERENCED_PARAMETER(dwFlags); UNREFERENCED_PARAMETER(pInfoBuffer); UNREFERENCED_PARAMETER(pdwBufferSize); UNREFERENCED_PARAMETER(bWideChar); return PDH_NOT_IMPLEMENTED; } STATIC_PDH_FUNCTION PdhiLogServiceInfoCommandT ( IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN DWORD dwFlags, IN LPVOID pInfoBuffer, IN LPDWORD pdwBufferSize, IN BOOL bWideChar ) { LONG lStatus = ERROR_SUCCESS; PDH_STATUS pdhStatus = ERROR_SUCCESS; DWORD dwRegValType; DWORD dwRegValue; DWORD dwRegValueSize; WCHAR szTempFilePath[MAX_PATH]; WCHAR szRegString[MAX_PATH]; WCHAR szDriveName[MAX_PATH]; HKEY hKeyMachine = NULL; HKEY hKeyLogSettings = NULL; HKEY hKeyLogQuery = NULL; CHAR *pNextChar = NULL; WCHAR *pNextWideChar = NULL; DWORD dwCharSize; DWORD dwSize; DWORD dwRequiredSize = sizeof(PDH_LOG_SERVICE_QUERY_INFO_W); DWORD dwRemainingSize = 0; UNREFERENCED_PARAMETER(dwFlags); dwCharSize = bWideChar ? sizeof(WCHAR) : sizeof(CHAR); setlocale( LC_ALL, "" ); // to make wcstombs work predictably if (*pdwBufferSize < sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // then then this is either too small or a size request in either // case we won't copy any data and only estimate the size required dwRemainingSize = 0; } else { dwRemainingSize = *pdwBufferSize - sizeof(PDH_LOG_SERVICE_QUERY_INFO_W); } // get root key to registry if (szMachineName != NULL) { lStatus = RegConnectRegistryW ( (LPWSTR)szMachineName, HKEY_LOCAL_MACHINE, &hKeyMachine); if (lStatus != ERROR_SUCCESS) { pdhStatus = PDH_CANNOT_CONNECT_MACHINE; } } else { // use predefined key handle hKeyMachine = HKEY_LOCAL_MACHINE; lStatus = ERROR_SUCCESS; } if (pInfoBuffer == NULL) { if (pdhStatus == ERROR_SUCCESS) { pdhStatus = PDH_INVALID_ARGUMENT; } lStatus = ERROR_INVALID_PARAMETER; } if (lStatus == ERROR_SUCCESS) { // open registry key to service lStatus = RegOpenKeyExW ( hKeyMachine, cszLogQueries, 0, KEY_READ, &hKeyLogSettings); if (lStatus != ERROR_SUCCESS) { pdhStatus = PDH_LOGSVC_NOT_OPENED; } } if (lStatus == ERROR_SUCCESS) { // open registry to specified log query lStatus = RegOpenKeyExW ( hKeyLogSettings, (szQueryName != NULL ? szQueryName : cszDefault), 0, KEY_READ, &hKeyLogQuery); if (lStatus != ERROR_SUCCESS) { pdhStatus = PDH_LOGSVC_QUERY_NOT_FOUND; } } // continue if (lStatus == ERROR_SUCCESS) { // initialize string pointers if (bWideChar && (pInfoBuffer != NULL)) { pNextWideChar = (WCHAR *)(&((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)[1]); } else { pNextChar = (CHAR *)(&((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)[1]); } // read log file format dwRegValType = 0; dwRegValue = 0; dwRegValueSize = sizeof(DWORD); lStatus = RegQueryValueExW ( hKeyLogQuery, cszLogFileType, NULL, &dwRegValType, (LPBYTE)&dwRegValue, &dwRegValueSize); if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // this data goes into the fixed portion of the structure if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_DWORD)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->dwFileType = dwRegValue; } else { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->dwFileType = PDH_LOG_TYPE_UNDEFINED; } } //read sample interval dwRegValType = 0; dwRegValue = 0; dwRegValueSize = sizeof(DWORD); lStatus = RegQueryValueExW ( hKeyLogQuery, cszAutoNameInterval, NULL, &dwRegValType, (LPBYTE)&dwRegValue, &dwRegValueSize); if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // this data goes into the fixed portion of the structure if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_DWORD)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlAutoNameInterval = dwRegValue; } else { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlAutoNameInterval = 0; dwRegValue = 0; } } if (dwRegValue == 0) { // initialize the rest of the manual name field(s) dwRegValType = 0; dwRegValueSize = MAX_PATH * sizeof(WCHAR); memset (szRegString, 0, dwRegValueSize); lStatus = RegQueryValueExW ( hKeyLogQuery, cszLogFileName, NULL, &dwRegValType, (LPBYTE)&szRegString[0], &dwRegValueSize); if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_SZ)) { dwRequiredSize += dwRegValueSize / (sizeof(WCHAR) / dwCharSize); if (dwRequiredSize <= *pdwBufferSize) { if (bWideChar) { // copy widestrings ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szBaseFileName = pNextWideChar; lstrcpyW (pNextWideChar, szRegString); pNextWideChar += dwRegValueSize / sizeof (WCHAR); } else { // convert to ansi char ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->szBaseFileName = pNextChar; wcstombs (pNextChar, szRegString, (dwRegValueSize /sizeof(WCHAR))); pNextChar += dwRegValueSize / sizeof (WCHAR); } dwRemainingSize -= dwRegValueSize / (sizeof(WCHAR) / dwCharSize); } else if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // no room for this string, but keep the required // total; ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szBaseFileName = NULL; } else { // it's an empty buffer } } else { if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szBaseFileName = NULL; } } // if the filename doesn't specify a directory, then use the lstrcpyW (szTempFilePath, szRegString); _wsplitpath ((LPCWSTR)szTempFilePath, szDriveName, szRegString, NULL, NULL); if ((lstrlenW(szDriveName) == 0) && (lstrlenW(szRegString) == 0)) { // default log file directory dwRegValType = 0; dwRegValueSize = MAX_PATH * sizeof(WCHAR); memset (szRegString, 0, dwRegValueSize); lStatus = RegQueryValueExW ( hKeyLogQuery, cszLogDefaultDir, NULL, &dwRegValType, (LPBYTE)&szRegString[0], &dwRegValueSize); } else { // the file parsing function leaves the trailing backslash // so remove it before concatenating it. dwSize = lstrlenW(szRegString); if (dwSize > 0) { if (szRegString[dwSize-1] == L'\\') { szRegString[dwSize-1] = 0; } lStatus = ERROR_SUCCESS; dwRegValType = REG_SZ; dwRegValueSize = dwSize; } else { lStatus = ERROR_FILE_NOT_FOUND; } } if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_SZ)) { dwRequiredSize += dwRegValueSize / (sizeof(WCHAR) / dwCharSize); if (dwRequiredSize <= *pdwBufferSize) { if (bWideChar) { // copy widestrings ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szDefaultDir = pNextWideChar; lstrcpyW (pNextWideChar, szRegString); pNextWideChar += dwRegValueSize / sizeof (WCHAR); } else { // convert to ansi char ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->szDefaultDir = pNextChar; wcstombs (pNextChar, szRegString, (dwRegValueSize /sizeof(WCHAR))); pNextChar += dwRegValueSize / sizeof (WCHAR); } dwRemainingSize -= dwRegValueSize / (sizeof(WCHAR) / dwCharSize); } else if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // no room for this string, but keep the required // total; ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szDefaultDir = NULL; } else { // no buffer for this } } else { if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szDefaultDir = NULL; } } } else { // get values for controls dwRegValType = 0; dwRegValueSize = MAX_PATH * sizeof(WCHAR); memset (szRegString, 0, dwRegValueSize); lStatus = RegQueryValueExW ( hKeyLogQuery, cszLogDefaultDir, NULL, &dwRegValType, (LPBYTE)&szRegString[0], &dwRegValueSize); if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_SZ)) { dwRequiredSize += dwRegValueSize / (sizeof(WCHAR) / dwCharSize); if (dwRequiredSize <= *pdwBufferSize) { if (bWideChar) { // copy widestrings ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szDefaultDir = pNextWideChar; lstrcpyW (pNextWideChar, szRegString); pNextWideChar += dwRegValueSize / sizeof (WCHAR); } else { // convert to ansi char ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->szDefaultDir = pNextChar; wcstombs (pNextChar, szRegString, (dwRegValueSize/sizeof(WCHAR))); pNextChar += dwRegValueSize / sizeof (WCHAR); } dwRemainingSize -= dwRegValueSize / (sizeof(WCHAR) / dwCharSize); } else if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // no room for this string, but keep the required // total; ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szDefaultDir = NULL; } else { // no room for anything } } else { if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szDefaultDir = NULL; } } // base filename dwRegValType = 0; dwRegValueSize = MAX_PATH * sizeof(WCHAR); memset (szRegString, 0, dwRegValueSize); lStatus = RegQueryValueExW ( hKeyLogQuery, cszBaseFileName, NULL, &dwRegValType, (LPBYTE)&szRegString[0], &dwRegValueSize); if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_SZ)) { dwRequiredSize += dwRegValueSize / (sizeof(WCHAR) / dwCharSize); if (dwRequiredSize <= *pdwBufferSize) { if (bWideChar) { // copy widestrings ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szBaseFileName = pNextWideChar; lstrcpyW (pNextWideChar, szRegString); pNextWideChar += dwRegValueSize / sizeof (WCHAR); } else { // convert to ansi char ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->szBaseFileName = pNextChar; wcstombs (pNextChar, szRegString, (dwRegValueSize/sizeof(WCHAR))); pNextChar += dwRegValueSize / sizeof (WCHAR); } dwRemainingSize -= dwRegValueSize / (sizeof(WCHAR) / dwCharSize); } else if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // no room for this string, but keep the required // total; ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szBaseFileName = NULL; } else { // no buffer } } else { if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->szBaseFileName = NULL; } } // get auto name format dwRegValType = 0; dwRegValue = 0; dwRegValueSize = sizeof(DWORD); lStatus = RegQueryValueExW ( hKeyLogQuery, cszLogFileAutoFormat, NULL, &dwRegValType, (LPBYTE)&dwRegValue, &dwRegValueSize); if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_DWORD)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlAutoNameFormat = dwRegValue; } else { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlAutoNameFormat = PDH_LOGSVC_NAME_UNDEFINED; } } dwRegValType = 0; dwRegValue = 0; dwRegValueSize = sizeof(DWORD); lStatus = RegQueryValueExW ( hKeyLogQuery, cszAutoRenameUnits, NULL, &dwRegValType, (LPBYTE)&dwRegValue, &dwRegValueSize); if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_DWORD)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlAutoNameUnits = dwRegValue; } else { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlAutoNameUnits = PDH_LOGSVC_RENAME_UNDEFINED; } } dwRegValType = 0; dwRegValueSize = MAX_PATH * sizeof(WCHAR); memset (szRegString, 0, dwRegValueSize); lStatus = RegQueryValueExW ( hKeyLogQuery, cszCommandFile, NULL, &dwRegValType, (LPBYTE)&szRegString[0], &dwRegValueSize); if ((lStatus == ERROR_SUCCESS) && (dwRegValType == REG_SZ)) { dwRequiredSize += dwRegValueSize / (sizeof(WCHAR) / dwCharSize); if (dwRequiredSize <= *pdwBufferSize) { if (bWideChar) { // copy widestrings ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlCommandFilename = pNextWideChar; lstrcpyW (pNextWideChar, szRegString); pNextWideChar += dwRegValueSize / sizeof (WCHAR); } else { // convert to ansi char ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->PdlCommandFilename = pNextChar; wcstombs (pNextChar, szRegString, (dwRegValueSize/sizeof(WCHAR))); pNextChar += dwRegValueSize / sizeof (WCHAR); } dwRemainingSize -= dwRegValueSize / (sizeof(WCHAR) / dwCharSize); } else if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // no room for this string, but keep the required // total; ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlCommandFilename = NULL; } else { // no buffer } } else { if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlCommandFilename = NULL; } } } // get counter string! // find out buffer size required dwRegValType = 0; dwRegValue = 0; dwRegValueSize = 0; lStatus = RegQueryValueExW ( hKeyLogQuery, cszCounterList, NULL, &dwRegValType, NULL, &dwRegValueSize); if (dwRegValueSize > 0) { // there's room in the caller's buffer so go ahead and // fill it dwRequiredSize += dwRegValueSize / (sizeof(WCHAR) / dwCharSize); if (dwRequiredSize <= *pdwBufferSize) { dwRegValueSize = dwRemainingSize; dwRegValType = 0; dwRegValue = 0; if (bWideChar) { lStatus = RegQueryValueExW ( hKeyLogQuery, cszCounterList, NULL, &dwRegValType, (LPBYTE)pNextWideChar, &dwRegValueSize); if (lStatus == ERROR_SUCCESS) { // assign pointer to buffer ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlCounterList = pNextWideChar; pNextWideChar += dwRegValueSize / sizeof (WCHAR); dwRemainingSize -= dwRegValueSize; } else { // assign null pointer ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlCounterList = NULL; } } else { lStatus = RegQueryValueExA ( hKeyLogQuery, caszCounterList, NULL, &dwRegValType, (LPBYTE)pNextChar, &dwRegValueSize); if (lStatus == ERROR_SUCCESS) { // assign pointer to buffer ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->PdlCounterList = pNextChar; pNextChar += dwRegValueSize; dwRemainingSize -= dwRegValueSize; } else { // assign null pointer ((PPDH_LOG_SERVICE_QUERY_INFO_A)pInfoBuffer)->PdlCounterList = NULL; } } } else { // no room so don't copy anything } } else if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // no counters defined so return NULL ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->PdlCounterList = NULL; } else { // no buffer } } //end if registry opened ok // close open registry keys if (hKeyMachine != NULL) RegCloseKey (hKeyMachine); if (hKeyLogSettings != NULL) RegCloseKey (hKeyLogSettings); if (hKeyLogQuery != NULL) RegCloseKey (hKeyLogQuery); // test to see if the buffer estimate and pointer location line up // assuming it was big enough in the first place assert ((dwRequiredSize <= *pdwBufferSize) ? ((pNextChar != NULL) ? (dwRequiredSize == ((DWORD)pNextChar - (DWORD)pInfoBuffer)) : (dwRequiredSize == ((DWORD)pNextWideChar - (DWORD)pInfoBuffer))) : TRUE); if (lStatus == ERROR_SUCCESS) { if (*pdwBufferSize >= sizeof(PDH_LOG_SERVICE_QUERY_INFO_W)) { // if there's enough buffer to write this... if (*pdwBufferSize >= dwRequiredSize) { // and there was enough for the requested data ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->dwSize = dwRequiredSize; } else { // return the amount used ((PPDH_LOG_SERVICE_QUERY_INFO_W)pInfoBuffer)->dwSize = *pdwBufferSize; } } } // save required size *pdwBufferSize = dwRequiredSize; return pdhStatus; } PDH_FUNCTION PdhLogServiceCommandA ( IN LPCSTR szMachineName, IN LPCSTR szQueryName, IN DWORD dwFlags, IN LPDWORD pdwStatus ) { LPWSTR wszQueryName = NULL; LPWSTR wszMachineName = NULL; PDH_STATUS pdhStatus = ERROR_SUCCESS; // test access to query name if (szQueryName != NULL) { DWORD dwNameLength = 0; try { CHAR cTest; cTest = szQueryName[0]; dwNameLength = lstrlenA (szQueryName); } except (EXCEPTION_EXECUTE_HANDLER) { // unable to access name argument pdhStatus = PDH_INVALID_ARGUMENT; } if (pdhStatus == ERROR_SUCCESS) { // allocate wide name buffer wszQueryName = G_ALLOC ((dwNameLength + 1) * sizeof (WCHAR)); if (wszQueryName != NULL) { mbstowcs (wszQueryName, szQueryName, dwNameLength); } else { pdhStatus = PDH_MEMORY_ALLOCATION_FAILURE; } } } else { // make a null arg for the function wszQueryName = NULL; } if ((szMachineName != NULL) && (pdhStatus == ERROR_SUCCESS)) { DWORD dwNameLength = 0; try { CHAR cTest; cTest = szMachineName[0]; dwNameLength = lstrlenA (szMachineName); } except (EXCEPTION_EXECUTE_HANDLER) { // unable to access name argument pdhStatus = PDH_INVALID_ARGUMENT; } if (pdhStatus == ERROR_SUCCESS) { // allocate wide name buffer wszMachineName = G_ALLOC ((dwNameLength + 1) * sizeof (WCHAR)); if (wszMachineName != NULL) { mbstowcs (wszMachineName, szMachineName, dwNameLength); } else { pdhStatus = PDH_MEMORY_ALLOCATION_FAILURE; } } } else { // make a null arg for the function wszMachineName = NULL; } if (pdhStatus == ERROR_SUCCESS) { // call wide string version pdhStatus = PdhLogServiceCommandW ( wszMachineName, wszQueryName, dwFlags, pdwStatus); } if (wszQueryName != NULL) G_FREE (wszQueryName); if (wszMachineName != NULL) G_FREE (wszMachineName); return pdhStatus; } PDH_FUNCTION PdhLogServiceCommandW ( IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN DWORD dwFlags, IN LPDWORD pdwStatus ) { SC_HANDLE hSC = NULL; SC_HANDLE hService = NULL; SERVICE_STATUS ssData; DWORD dwTimeout; DWORD dwStatus; BOOL bStopped = FALSE; BOOL bPaused = FALSE; LONG lStatus = ERROR_SUCCESS; BOOL bWait; LPWSTR szLocalQueryName = NULL; // test arguments try { WCHAR wcTest; DWORD dwTest; if (szMachineName != NULL) { wcTest = szMachineName[0]; } // null is valid for the local machine if (szQueryName != NULL) { wcTest = szQueryName[0]; } // null is a valid query name. if (pdwStatus != NULL) { dwTest = *pdwStatus; *pdwStatus = 0; *pdwStatus = dwTest; } } except (EXCEPTION_EXECUTE_HANDLER) { lStatus = PDH_INVALID_ARGUMENT; } if (lStatus == ERROR_SUCCESS) { if ((dwFlags & PDH_LOGSVC_TRACE_LOG) == PDH_LOGSVC_TRACE_LOG) { lStatus = PDH_NOT_IMPLEMENTED; } else { // this must be a perf log command // open SC database hSC = OpenSCManagerW (szMachineName, NULL, SC_MANAGER_ALL_ACCESS); if (hSC == NULL) { // open service hService = OpenServiceW (hSC, cszPerfDataLog, SERVICE_START | SERVICE_STOP | SERVICE_USER_DEFINED_CONTROL); } // else hService will still be NULL so get the last error below if (hService != NULL) { // determine wait flag value bWait = (dwFlags & PDH_LOGSVC_NO_WAIT) ? FALSE : TRUE; if (szQueryName == NULL) { if ((dwFlags & PDH_LOGSVC_ALL_QUERIES) == PDH_LOGSVC_ALL_QUERIES) { // start / stop the service and all log queries if ((dwFlags & PDH_LOGSVC_CMD_START) == PDH_LOGSVC_CMD_START) { // start the service and start all logs set to run StartService (hService, 0, NULL); if ( bWait ) { // wait for the service to start before returning dwTimeout = 20; while (dwTimeout) { GetCurrentServiceState (hService, &bStopped, &bPaused); if (bStopped) { Sleep(500); } else { break; } --dwTimeout; } if (bStopped) { dwStatus = PDH_LOGSVC_STATUS_STOPPED; } else if (bPaused) { dwStatus = PDH_LOGSVC_STATUS_PAUSED; } else { dwStatus = PDH_LOGSVC_STATUS_RUNNING; } } else { dwStatus = PDH_LOGSVC_STATUS_PENDING; } } else if ((dwFlags & PDH_LOGSVC_CMD_STOP) == PDH_LOGSVC_CMD_STOP) { ControlService (hService, SERVICE_CONTROL_STOP, &ssData); if ( bWait ) { // wait for the service to stop before returning dwTimeout = 20; while (dwTimeout) { GetCurrentServiceState (hService, &bStopped, &bPaused); if (!bStopped) { Sleep(500); } else { break; } --dwTimeout; } if (bStopped) { dwStatus = PDH_LOGSVC_STATUS_STOPPED; } else if (bPaused) { dwStatus = PDH_LOGSVC_STATUS_PAUSED; } else { dwStatus = PDH_LOGSVC_STATUS_RUNNING; } } } else { // unknown operation lStatus = PDH_UNKNOWN_LOGSVC_COMMAND; } } else { // this is just a generic log command. szLocalQueryName = (LPWSTR)cszDefault; } } if (szLocalQueryName != NULL) { // then this command is for a named service lStatus = PdhiSetLogQueryState ( szMachineName, szLocalQueryName, (dwFlags & (PDH_LOGSVC_CMD_START | PDH_LOGSVC_CMD_STOP))); if (lStatus == ERROR_SUCCESS) { // service entry was updated to desired status if (!ControlService (hService, SERVICE_CONTROL_PARAMCHANGE, &ssData)) { lStatus = GetLastError (); } lStatus = PdhiGetLogQueryState ( hService, szMachineName, szLocalQueryName, &dwStatus); } } CloseServiceHandle (hService); } else { lStatus = GetLastError(); assert (lStatus != 0); } // close handles if (hSC != NULL) CloseServiceHandle (hSC); } } return lStatus; } PDH_FUNCTION PdhLogServiceControlA ( IN LPCSTR szMachineName, IN LPCSTR szQueryName, IN DWORD dwFlags, IN PPDH_LOG_SERVICE_QUERY_INFO_A pInfoBuffer, IN LPDWORD pdwBufferSize ) { LPWSTR wszQueryName = NULL; LPWSTR wszMachineName = NULL; PDH_STATUS pdhStatus = ERROR_SUCCESS; DWORD dwCmdFn; // test access to query name if (szQueryName != NULL) { DWORD dwNameLength = 0; try { CHAR cTest; cTest = szQueryName[0]; dwNameLength = lstrlenA (szQueryName); } except (EXCEPTION_EXECUTE_HANDLER) { // unable to access name argument pdhStatus = PDH_INVALID_ARGUMENT; } if (pdhStatus == ERROR_SUCCESS) { // allocate wide name buffer wszQueryName = G_ALLOC ((dwNameLength + 1) * sizeof (WCHAR)); if (wszQueryName != NULL) { mbstowcs (wszQueryName, szQueryName, dwNameLength); } else { pdhStatus = PDH_MEMORY_ALLOCATION_FAILURE; } } } else { // make a null arg for the function wszQueryName = NULL; } if ((szMachineName != NULL) && (pdhStatus == ERROR_SUCCESS)) { DWORD dwNameLength = 0; try { CHAR cTest; cTest = szMachineName[0]; dwNameLength = lstrlenA (szMachineName); } except (EXCEPTION_EXECUTE_HANDLER) { // unable to access name argument pdhStatus = PDH_INVALID_ARGUMENT; } if (pdhStatus == ERROR_SUCCESS) { // allocate wide name buffer wszMachineName = G_ALLOC ((dwNameLength + 1) * sizeof (WCHAR)); if (wszMachineName != NULL) { mbstowcs (wszMachineName, szMachineName, dwNameLength); } else { pdhStatus = PDH_MEMORY_ALLOCATION_FAILURE; } } } else { // make a null arg for the function wszMachineName = NULL; } if (pdhStatus == ERROR_SUCCESS) { try { DWORD dwTest; if (pdwBufferSize != NULL) { dwTest = *pdwBufferSize; *pdwBufferSize = 0; *pdwBufferSize = dwTest; } else { // null is NOT valid pdhStatus = PDH_INVALID_ARGUMENT; } } except (EXCEPTION_EXECUTE_HANDLER) { pdhStatus = PDH_INVALID_ARGUMENT; } } if (pdhStatus == ERROR_SUCCESS) { // dispatch to "action" function based on command code dwCmdFn = dwFlags & PDH_LOGSVC_CTRL_FNMASK; switch (dwCmdFn) { case PDH_LOGSVC_CTRL_ADD: // call universal string version pdhStatus = PdhiLogServiceAddCommandT ( wszMachineName, wszQueryName, dwFlags, (LPVOID)pInfoBuffer, pdwBufferSize, FALSE); break; case PDH_LOGSVC_CTRL_REMOVE: // call universal string version pdhStatus = PdhiLogServiceRemoveCommandT ( wszMachineName, wszQueryName, dwFlags, (LPVOID)pInfoBuffer, pdwBufferSize, FALSE); break; case PDH_LOGSVC_CTRL_INFO: // call universal string version pdhStatus = PdhiLogServiceInfoCommandT ( wszMachineName, wszQueryName, dwFlags, (LPVOID)pInfoBuffer, pdwBufferSize, FALSE); break; default: pdhStatus = PDH_INVALID_ARGUMENT; break; } } if (wszQueryName != NULL) G_FREE (wszQueryName); if (wszMachineName != NULL) G_FREE (wszMachineName); return pdhStatus; } PDH_FUNCTION PdhLogServiceControlW ( IN LPCWSTR szMachineName, IN LPCWSTR szQueryName, IN DWORD dwFlags, IN PPDH_LOG_SERVICE_QUERY_INFO_W pInfoBuffer, IN LPDWORD pdwBufferSize ) { PDH_STATUS pdhStatus = ERROR_SUCCESS; DWORD dwCmdFn; // test access to query name if (szQueryName != NULL) { WCHAR cTest; try { cTest = szQueryName[0]; if (cTest == 0) { pdhStatus = PDH_INVALID_ARGUMENT; } } except (EXCEPTION_EXECUTE_HANDLER) { // unable to access name argument pdhStatus = PDH_INVALID_ARGUMENT; } } else { // NULL is OK } // test access to machine name if ((szMachineName != NULL) && (pdhStatus == ERROR_SUCCESS)) { WCHAR cTest; try { cTest = szMachineName[0]; if (cTest == 0) { pdhStatus = PDH_INVALID_ARGUMENT; } } except (EXCEPTION_EXECUTE_HANDLER) { // unable to access name argument pdhStatus = PDH_INVALID_ARGUMENT; } } else { // NULL is OK } if (pdhStatus == ERROR_SUCCESS) { try { DWORD dwTest; if (pdwBufferSize != NULL) { dwTest = *pdwBufferSize; *pdwBufferSize = 0; *pdwBufferSize = dwTest; } else { // null is NOT valid pdhStatus = PDH_INVALID_ARGUMENT; } } except (EXCEPTION_EXECUTE_HANDLER) { pdhStatus = PDH_INVALID_ARGUMENT; } } if (pdhStatus == ERROR_SUCCESS) { // dispatch to "action" function based on command code dwCmdFn = dwFlags & PDH_LOGSVC_CTRL_FNMASK; switch (dwCmdFn) { case PDH_LOGSVC_CTRL_ADD: // call universal string version pdhStatus = PdhiLogServiceAddCommandT ( szMachineName, szQueryName, dwFlags, (LPVOID)pInfoBuffer, pdwBufferSize, TRUE); break; case PDH_LOGSVC_CTRL_REMOVE: // call universal string version pdhStatus = PdhiLogServiceRemoveCommandT ( szMachineName, szQueryName, dwFlags, (LPVOID)pInfoBuffer, pdwBufferSize, TRUE); break; case PDH_LOGSVC_CTRL_INFO: // call universal string version pdhStatus = PdhiLogServiceInfoCommandT ( szMachineName, szQueryName, dwFlags, (LPVOID)pInfoBuffer, pdwBufferSize, TRUE); break; default: pdhStatus = PDH_INVALID_ARGUMENT; break; } } return pdhStatus; }
[ "112426112@qq.com" ]
112426112@qq.com
87523070eb07d2c0a170c717dfc9724d5f371d46
431e9a53feb2af871dbba7a0c73f508a80c09b41
/PDSE02_21000172/PDSE02B_21000172/PDSE02B_21000172/PDSE02B_21000172.c
31f20677f9989d05e9be3a314606565263925d28
[]
no_license
JueunKim/ECE20017_Data_strcuture
f98a4d9fe4aef0f402e941d1ba7b242dd772e202
ca65a0d1b76fd43d94092ff955a3817eed3f5b57
refs/heads/master
2020-03-22T18:34:43.649732
2019-01-07T05:35:02
2019-01-07T05:35:02
140,468,645
0
0
null
null
null
null
UHC
C
false
false
4,244
c
/************************************************************************* 과목명 : 프로그래밍 실습 (월,목 3교시) 학부_전산전자공학부 학번_ 21000172 이름_ 김주은 실습 내용(02B) : 주어진 일련의 양의 정수를 입력순서를 출력하는 프로그램을 큐를 통하여 구현하라. 조건 1)Queue을 Linked List로 구현 2)입력데이터를 파일로 입력하라(inputdata.txt) 3)결과를 출력파일로 출력한다(Result.txt) 작성일 : 2012.09.10(월요일) 알고리즘 : inputdata파일로 부터 값을 읽어들어여와 지정해 놓은 큐2에 값을 넣는다. 기존의 큐1의 값과 큐2의 값을 비교하기 위해 peek의 함수를 사용하여 위치를 반환하고, 같으면 delete되어 while문의 조건이 만족할때까지 next peek로 이동한다. 같으면 true를 출력하고, 같지 않으면 false를 출력한다. 큐 2개를 사용하기 위해, 각각의 큐에 필요한 add와 delete큐를 생성하였다. 독창적 구현함. ***********************************************************************/ #include <stdio.h> #include <malloc.h>  typedef int QueueObject; typedef struct QueueRec { QueueObject item; struct QueueRec *link; } QueueNode; QueueNode *front, *rear; QueueNode *front2, *rear2; void f1_open(); void f2_open(); FILE *f1=NULL; FILE *f2=NULL; int isEmpty(); int isFull(); void addq(QueueObject item); void addq2(QueueObject item); QueueObject deleteq(); QueueObject deleteq2(); int rear; int front; void main() { int i=0; int x,y=0; int var; f1_open(); //inputdata.txt 파일을 연다. f2_open(); //Resutlt.txt 파일을 연다. addq(3); addq(3); addq(5); addq(7); while(!feof(f1)){ //파일포인터 f1이 가리키는 inputdata로 부터 값을 읽어들여 변수에 저장한다. fscanf(f1,"%d",&var); addq2(var); } while(1){ if(peek()==peek2()){ // 두 값이 일치하면 peek이 현재위치를 반환하고 deleteq(); //delete큐하여 다음 위치의 값을 비교한다. deleteq2(); } else { //두 값이 일치하지 않으면 false를 출력 fprintf(f2,"%s","false"); break; } if(isEmpty()&&isEmpty2()){ fprintf(f2,"%s","true\n"); break; } } fclose(f1); fclose(f2); } void f1_open(){ f1=fopen("inputdata.txt","r"); if(f1==NULL) printf("파일을 열 수 없습니다."); } void f2_open(){ f2=fopen("Result.txt","w"); if(f2==NULL) printf("파일을 열 수 없습니다."); } int isEmpty() { return (front==NULL); } int isEmpty2() { return (front2==NULL); } int isFull() { QueueNode *temp = (QueueNode *)malloc(sizeof(QueueNode)); if(temp == NULL ){ free(temp); return 1; } else return 0; } void addq(QueueObject item) { QueueNode *temp = (QueueNode *)malloc(sizeof(QueueNode)); if(temp == NULL ){ printf("메모리를 할당할 수 없습니다.\n"); } else { temp->item = item; temp->link = NULL; if( front ) rear->link = temp; // 큐가 있을때 else front = temp; // 큐가 공백일때 rear = temp; } } void addq2(QueueObject item) { QueueNode *temp = (QueueNode *)malloc(sizeof(QueueNode)); if(temp == NULL ){ printf("메모리를 할당할 수 없습니다.\n"); } else { temp->item = item; temp->link = NULL; if( front2 ) rear2->link = temp; // 큐가 있을때 else front2 = temp; // 큐가 공백일때 rear2 = temp; } } QueueObject deleteq() { QueueNode *temp = front; QueueObject item; if( isEmpty() ){ printf("큐가 비어 있읍니다.\n"); } else { item = temp->item; front = front->link; free(temp); return item; } } QueueObject deleteq2() { QueueNode *temp = front2; QueueObject item; if( isEmpty2() ){ printf("큐가 비어 있읍니다.\n"); } else { item = temp->item; front2 = front2->link; free(temp); return item; } } int peek(){ return front->item; } int peek2(){ return front2->item; }
[ "jueunkim@jueun-mbp.wireless.emory.edu" ]
jueunkim@jueun-mbp.wireless.emory.edu
a197fb3c45780a9b2a04a06af7971a2f9faad6ba
5c255f911786e984286b1f7a4e6091a68419d049
/vulnerable_code/d222fc17-0529-4c3b-846c-e732cdf2d379.c
cde9260751ce014ae8e6aeacc2c844eefd9c85da
[]
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
574
c
#include <string.h> #include <stdio.h> int main() { int i=4; int j=14; int k; int l; k = 53; l = 64; k = i/j; l = i/j; l = l/j; l = i-j; l = k%j; l = i+j; k = k-i*i; //variables //random /* START VULNERABILITY */ int a; int b[87]; int c[82]; a = 0; while (b[a] != 0) { //random /* START BUFFER SET */ *((int *)c + a) = *((int *)b + a); /* END BUFFER SET */ a++; } /* END VULNERABILITY */ printf("%d%d\n",k,l); return 0; }
[ "nharmon8@gmail.com" ]
nharmon8@gmail.com
d09caf25421535e604ce5e6da03014532a38b0bd
ac0936da6729df900b1a3eafe10dd53dcfa3104f
/extlibs/MCU/Examples/C8051F97x/Oscillators/Oscillator_CMOS/src/F970_Oscillator_CMOS.c
9fe0eb4327b7742a6fdb328c53e59c92afee88b0
[]
no_license
dania99/si1000-rf-beacon
272195996c0e491e4177ddac31114edb700fb1c1
ba772d789cde2935fd12e66f7765c6edf1408ce2
refs/heads/master
2022-01-05T04:39:43.174744
2019-05-13T16:59:48
2019-05-13T16:59:48
null
0
0
null
null
null
null
UTF-8
C
false
false
5,170
c
//----------------------------------------------------------------------------- // F97x_Oscillator_CMOS.c //----------------------------------------------------------------------------- // Copyright 2014 Silicon Laboratories, Inc. // http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt // // Program Description: // // This program demonstrates how to configure the oscillator to use an // external CMOS clock. // // // How To Test: // ------------ // 1) Ensure shorting blocks are place on the following: // - J1: 3.3v <> VREG (Power) // - JP3: VDD <> VMCU // 2) Connect the USB Debug Adapter to H8. // 3) Place the VDD SELECT switch (SW1) in the VREG position and power the board. // 4) Compile and download code to the C8051F970-TB by selecting // Run -> Debug from the menus, // or clicking the Debug button in the quick menu, // or pressing F11. // 5) Run the code by selecting // Run -> Resume from the menus, // or clicking the Resume button in the quick menu, // or pressing F8. // 6) Measure the frequency output on P0.1 to be approximately 20 MHz. // // // Target: C8051F97x // Tool chain: Simplicity Studio / Keil C51 9.51 // Command Line: None // // // Release 1.0 // - Initial Revision (CM2/JL) // - 28 MAY 2014 //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <SI_C8051F970_Register_Enums.h> //----------------------------------------------------------------------------- // Global VARIABLES //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Function Prototypes //----------------------------------------------------------------------------- void OSCILLATOR_Init (void); void PORT_Init (void); //----------------------------------------------------------------------------- // main() Routine //----------------------------------------------------------------------------- void main (void) { SFRPAGE = PCA0_PAGE; PCA0MD &= ~PCA0MD_WDTE__ENABLED; // WDTE = 0 (clear watchdog timer // enable) PORT_Init(); // Initialize Port I/O OSCILLATOR_Init (); // Initialize Oscillator while (1); } //----------------------------------------------------------------------------- // Initialization Subroutines //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // OSCILLATOR_Init //----------------------------------------------------------------------------- // // Return Value : None // Parameters : None // // This function initializes the system clock to use the internal low power // oscillator. // //----------------------------------------------------------------------------- void OSCILLATOR_Init (void) { U8 SFRPAGE_save = SFRPAGE; SFRPAGE = LEGACY_PAGE; // If system clock is > 14 MHz, bypass (disable) the one-shot timer FLSCL |= FLSCL_BYPASS__SYSCLK; // Set the BYPASS bit OSCXCN = OSCXCN_XOSCMD__CMOS; // External CMOS mode // In CMOS mode, the XCLKVLD flag will never be set //while ((OSCXCN & OSCXCN_XCLKVLD__BMASK) == OSCXCN_XCLKVLD__NOT_SET); // Switch to EXTOSC CLKSEL = CLKSEL_CLKSL__EXTOSC | CLKSEL_CLKDIV__SYSCLK_DIV_1; // Wait for divider to be applied while ((CLKSEL & CLKSEL_CLKRDY__BMASK) == CLKSEL_CLKRDY__NOT_SET); SFRPAGE = SFRPAGE_save; } //----------------------------------------------------------------------------- // PORT_Init //----------------------------------------------------------------------------- // // Return Value : None // Parameters : None // // This function configures the crossbar and ports pins. // // The oscillator pins should be configured as analog inputs when using the // external oscillator in crystal mode. // // P0.1 digital push-pull /SYSCLK // // P1.1 digital push-pull XTAL2 (CMOS) // //----------------------------------------------------------------------------- void PORT_Init (void) { U8 SFRPAGE_save = SFRPAGE; // Save the current SFRPAGE SFRPAGE = CONFIG_PAGE; P0SKIP = 0x01; // P0.0 has a capacitor on it P0MDOUT |= 0x02; // P0.1 is push-pull // Oscillator Pin P1MDIN |= 0x02; // P1.1 is digital CMOS input P1MDOUT &= ~0x02; // Change mode to open drain P1 |= 0x02; // Disable output drivers XBR0 = XBR0_SYSCKE__ENABLED; XBR1 = XBR1_XBARE__ENABLED | // Enable crossbar XBR1_WEAKPUD__PULL_UPS_ENABLED; // with weak pullups SFRPAGE = SFRPAGE_save; // Restore saved SFRPAGE } //----------------------------------------------------------------------------- // End Of File //-----------------------------------------------------------------------------
[ "vladimir.pinchuk01@gmail.com" ]
vladimir.pinchuk01@gmail.com
0570f6a3a9e16251d586fe37d28cf20995a96004
c0a1d0c3273c0ef64c812e29f3766ebb46f9416e
/src/test/readv.c
57e1b8d06ce63b85bcbe6b35ef66160d824d0bd7
[ "MIT", "BSD-2-Clause" ]
permissive
xs3c/rr
bfcdc7c52b9712e2e8eb7b5c58466e399832d384
832c7f0fea3a56f35a462e70aaff09a15086b949
refs/heads/master
2020-12-25T00:28:49.189848
2016-01-27T00:08:27
2016-01-27T00:08:27
null
0
0
null
null
null
null
UTF-8
C
false
false
1,305
c
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ #include "rrutil.h" static char data[10] = "0123456789"; static void test(int use_preadv) { char name[] = "/tmp/rr-readv-XXXXXX"; int fd = mkstemp(name); struct { char ch[7]; } * part1; struct { char ch[10]; } * part2; struct iovec iovs[2]; ssize_t nread; test_assert(fd >= 0); test_assert(0 == unlink(name)); test_assert(sizeof(data) == write(fd, data, sizeof(data))); ALLOCATE_GUARD(part1, 'x'); ALLOCATE_GUARD(part2, 'y'); iovs[0].iov_base = part1; iovs[0].iov_len = sizeof(*part1); iovs[1].iov_base = part2; iovs[1].iov_len = sizeof(*part2); if (use_preadv) { /* Work around busted preadv prototype in older libcs */ nread = syscall(SYS_preadv, fd, iovs, 2, 0, 0); } else { test_assert(0 == lseek(fd, 0, SEEK_SET)); nread = readv(fd, iovs, 2); } test_assert(sizeof(data) == nread); test_assert(0 == memcmp(part1, data, sizeof(*part1))); test_assert( 0 == memcmp(part2, data + sizeof(*part1), sizeof(data) - sizeof(*part1))); test_assert(part2->ch[sizeof(data) - sizeof(*part1)] == 'y'); VERIFY_GUARD(part1); VERIFY_GUARD(part2); } int main(int argc, char* argv[]) { test(0); test(1); atomic_puts("EXIT-SUCCESS"); return 0; }
[ "robert@ocallahan.org" ]
robert@ocallahan.org
90231e5e25463ff835d4deb6e03f152c1371cd34
af76ebfa7fff99eb831338c9698a571ce718d2d4
/libs/OpenSSL/include/crypto/decoder.h
eb639117c1b237674c26fa984d1645d3f110fbb7
[ "Unlicense" ]
permissive
testcc2c/hvh-cheat
b7e7b9c902d173ad21ece324eb849f9b07e639cd
89c7f394e5e3418bc795c0a1fae097c443c4c748
refs/heads/main
2023-01-31T06:59:46.703401
2020-12-02T17:10:25
2020-12-02T17:10:25
350,192,748
4
1
Unlicense
2021-03-22T03:20:20
2021-03-22T03:20:19
null
UTF-8
C
false
false
1,594
h
/* * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef OSSL_CRYPTO_DECODER_H # define OSSL_CRYPTO_DECODER_H # include <openssl/decoder.h> OSSL_DECODER *ossl_decoder_fetch_by_number(OPENSSL_CTX *libctx, int id, const char *properties); /* * These are specially made for the 'file:' provider-native loader, which * uses this to install a DER to anything decoder, which doesn't do much * except read a DER blob and pass it on as a provider object abstraction * (provider-object(7)). */ void *ossl_decoder_from_dispatch(int id, const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov); OSSL_DECODER_INSTANCE * ossl_decoder_instance_new(OSSL_DECODER *decoder, void *decoderctx); void ossl_decoder_instance_free(OSSL_DECODER_INSTANCE *decoder_inst); int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx, OSSL_DECODER_INSTANCE *di); int ossl_decoder_ctx_setup_for_EVP_PKEY(OSSL_DECODER_CTX *ctx, EVP_PKEY **pkey, OPENSSL_CTX *libctx, const char *propquery); #endif
[ "noreply@github.com" ]
testcc2c.noreply@github.com
1a41a0ea712cd87a29c948e45995a8fe08966ead
ab7d5ec2e40b26c33da957210b5d2da77f9b696d
/repos/sproxel/contents/pyBindings.h
87b7ec998070f5053c589697259e108782507875
[]
no_license
mcclure/bitbucket-backup
e49d280363ff7ef687f03473e463865a7ad8a817
b6a02ca8decf843fa0a765c842c24e7eccf59307
refs/heads/archive
2023-01-24T21:15:14.875131
2020-02-02T20:56:23
2020-02-02T20:56:23
237,833,969
115
6
null
2023-01-07T14:24:14
2020-02-02T20:43:56
C
UTF-8
C
false
false
581
h
#ifndef __SPROXEL_PY_BINDINGS_H__ #define __SPROXEL_PY_BINDINGS_H__ #include "script.h" #include "SproxelProject.h" #include "UndoManager.h" PyObject* sprite_to_py(VoxelGridGroupPtr sprite); PyObject* project_to_py(SproxelProjectPtr proj); PyObject* undo_manager_to_py(UndoManager *); PyObject* PySproxel_registerImporter(PyObject*, PyObject *arg); PyObject* PySproxel_unregisterImporter(PyObject*, PyObject *arg); PyObject* PySproxel_registerExporter(PyObject*, PyObject *arg); PyObject* PySproxel_unregisterExporter(PyObject*, PyObject *arg); #endif
[ "andi.m.mcclure@gmail.com" ]
andi.m.mcclure@gmail.com
6183601b9270a4c6786007d254c909e1b33cf202
92df989889945b7ca7774e65892d75054775d67c
/fort_part_v2.c
72fa5934df0f0fc84dcb0dbb42458498f530353e
[]
no_license
kuechenrole/fesom_TYP
9be318efe8e20b15f3634f2eed0bc3cd66a33e8c
97175d35cca2e7c227ff947943e5f7bf9ab991fb
refs/heads/main
2023-07-14T06:30:57.090285
2021-08-25T09:00:06
2021-08-25T09:00:06
399,754,557
0
0
null
null
null
null
UTF-8
C
false
false
1,999
c
/* * fort_part_v2.c * */ /* a Fortran interface to METIS-5.1 and simple block/range partitioners, adapted by Natalja Rakowsky from fort_part.c of FoSSI, the Family of Simplified Solver Interfaces by Stephan Frickenhaus, Computing-Center, AWI-Bremerhaven, Germany www.awi-bremerhaven.de */ /* SF 06/2001 */ /* NR 07/2014 */ /* The partinioner Interface to METIS-5.1 */ /* n: dimension of system (number of equations=number of variables) */ /* compressed matrix on input: */ /* ptr : rowptr or colptr */ /* adj : colind or rowind */ /* wgt: weights at nodes (FESOM/FVOM: number of levels for each 2D node) */ /* np : partitioning for np processors */ /* part : partitioning vector */ #include "metis.h" #include <stdio.h> #ifdef UNDER_ void partit_block_ #endif #ifdef UPCASE void PARTIT_BLOCK #endif #ifdef MATCH void partit_block #endif (int *n, int *ptr, int *adj, int *np, int *part) { int i ; if (*np==1) { for(i=0;i<*n;i++) part[i]=0; return;} for (i=0;i<*n;i++) { part[i]=*np * i / *n; if (part[i]==*np) part[i]=*np-1; } } #ifdef UNDER_ void partit3_ #endif #ifdef UPCASE void PARTIT3 #endif #ifdef MATCH void partit3 #endif (int *n, int *ptr, int *adj, int *wgt, int *np, int *part) { int i ; //idx_t *null; idx_t opt[METIS_NOPTIONS]; idx_t ec, ncon; idx_t *wgt_2d3d; if (*np==1) { for(i=0;i<*n;i++) part[i]=0; return;} if (sizeof(idx_t) != sizeof(int)){ printf("Problem in partit: Size of int (%d) and Metis' idx_t (%d) differ!",sizeof(idx_t),sizeof(int)); return; } METIS_SetDefaultOptions(opt); opt[METIS_OPTION_NUMBERING]=1; /* Fortran numbering */ printf("Partit %d %d %d %d %d %d\n",*n,*np,ptr[0],ptr[1],adj[0],adj[1]); ncon=2; wgt_2d3d = (idx_t*) malloc(2* *n *sizeof(idx_t)); for (i=0; i<*n; i++){ wgt_2d3d[2*i] = 1; wgt_2d3d[2*i+1] = wgt[i]; } METIS_PartGraphKway(n,&ncon,ptr,adj,wgt_2d3d,NULL,NULL,np,NULL,NULL,opt,&ec,part); printf("Edgecut %d\n", ec); for(i=0;i<*n;i++) part[i]--; free(wgt_2d3d); }
[ "ole.richter@awi.de" ]
ole.richter@awi.de
f475b8e133129ee2030fabda8fa6b5d10adebb8f
93120d6f483e4068e0fb2ab7053b51ffe3cfae2c
/build/sketch/eeprom-service.h
3002a200e89bc394a1c94d22f7ec5d9ce7e18bcc
[]
no_license
morrisdirector/lumenator
297549ff2534897f376099ee99782ecfe6df9718
cc62c01de1e0e48e327f6548e19b6ce64d0aefb5
refs/heads/master
2023-08-27T05:50:43.750009
2021-09-16T00:42:25
2021-09-16T00:42:25
297,648,434
0
0
null
2021-09-16T00:42:27
2020-09-22T12:54:41
C
UTF-8
C
false
false
901
h
#line 1 "/Users/patrickmorris/git/lumenator/eeprom-service.h" #include <Arduino.h> #define EEPROM_SIZE 1000 String readEEPROM() { Serial.println(); Serial.println("Reading device configuration from EEPROM"); String configuration; for (int i = 0; i < EEPROM_SIZE; ++i) { configuration += char(EEPROM.read(i)); } Serial.println(); if (configuration[0] != 0) { Serial.println("Configuration Data: "); Serial.println(configuration); } return configuration; } void clearEEPROM() { Serial.print("Erasing EEPROM contents..."); for (int i = 0; i < EEPROM_SIZE; ++i) { EEPROM.write(i, 0); } EEPROM.commit(); Serial.println("Done"); } void writeEEPROM(char data[CONFIG_DTO_SIZE]) { Serial.print("Writing to EEPROM..."); for (int i = 0; i < strlen(data); ++i) { EEPROM.write(i, data[i]); } EEPROM.commit(); Serial.println("Done"); }
[ "patrick.morris@amobee.com" ]
patrick.morris@amobee.com
c91db683c771e907e23e9403b8f7e540ddb2b2d0
0854453c6d24044420e3cf85f55205f60e062067
/src/test/collection/lfcByteBuffer/spec_lfcByteBuffer_read_uint64.c
c78f143a73b735b0a1062f1b8a7b3f2cd2dfd0d8
[]
no_license
pfke/libForC
f82c00949fce4e57237f82df77d968151577b941
7c5965958e2ad5a843bc14c1f082e95ff44ca20f
refs/heads/master
2023-01-15T20:23:27.410897
2020-11-20T17:44:18
2020-11-20T17:44:18
276,684,658
0
0
null
null
null
null
UTF-8
C
false
false
1,258
c
#include "collection/lfcByteBuffer.h" #include "testing/lfcCriterionHelper.h" #define TEST_SUITE_NAME spec_lfcByteBuffer_read_uint64 Test( TEST_SUITE_NAME, return_0_after_start ) { lfcByteBuffer_t *tto = lfcByteBuffer_ctor(); should_be_same_int(lfcByteBuffer_read_uint64(tto, NULL), 0); delete(tto); } Test( TEST_SUITE_NAME, return_0_if_capacity_is_0 ) { lfcByteBuffer_t *tto = lfcByteBuffer_ctor(); lfcByteBuffer_write_int8(tto, 1); lfcByteBuffer_write_int8(tto, 1); lfcByteBuffer_write_int8(tto, 1); lfcByteBuffer_read_int16(tto, NULL); lfcByteBuffer_read_int8(tto, NULL); should_be_same_int(lfcByteBuffer_read_uint64(tto, NULL), 0); delete(tto); } Test( TEST_SUITE_NAME, return_not_0_if_capacity_is_not0__passNULL ) { lfcByteBuffer_t *tto = lfcByteBuffer_ctor(); lfcByteBuffer_write_uint64(tto, 125); should_be_same_int(lfcByteBuffer_read_uint64(tto, NULL), 8); delete(tto); } Test( TEST_SUITE_NAME, read_correct ) { uint64_t result = 0; lfcByteBuffer_t *tto = lfcByteBuffer_ctor(); lfcByteBuffer_write_uint64(tto, 1145); lfcByteBuffer_read_uint64(tto, &result); should_be_same_int(result, 1145); delete(tto); }
[ "h.blobner@avm.de" ]
h.blobner@avm.de
cac8c41887a3cbb20dd0c764b222f2c3a6b40c4f
1ee0598d0ab1a1eec95c74079ff50d884d1f0989
/code/gcs/src/protonet/include/message/VehicleWaypointCommand.h
bbc1fb2fd445f90e66f638a8a731d36c2537443b
[]
no_license
slothxd/GCS
2a3d95e004ddb1a5da53493b409911c961227451
b1ff1075b8fb052d6cf33c55f8e9808ca0af087e
refs/heads/master
2021-01-23T06:58:51.986574
2015-10-11T20:58:41
2015-10-11T20:58:41
null
0
0
null
null
null
null
UTF-8
C
false
false
899
h
/* This file was autogenerated. All changes will be undone. */ /* Message: Vehicle_Waypoint_Command, ID: 1006*/ #ifndef _VEHICLE_WAYPOINT_COMMAND_H_ #define _VEHICLE_WAYPOINT_COMMAND_H_ #include <protonet_marshal.h> #include <protonet_message.h> typedef struct { float64_t timestamp; uint16_t vehicle_ID; int32_t latitude; int32_t longitude; int32_t altitude; int32_t heading; uint8_t waypoint_ID; uint8_t waypoint_type; } vehicle_waypoint_command_t; msg_offset pack_vehicle_waypoint_command( vehicle_waypoint_command_t* vehicle_waypoint_command, msg_offset offset); msg_offset unpack_vehicle_waypoint_command( msg_offset offset, vehicle_waypoint_command_t* out_ptr); void encode_vehicle_waypoint_command( uint8_t src_id, uint8_t dest_id, uint8_t msg_ttl, uint8_t seq_number, vehicle_waypoint_command_t* tx_msg, proto_msg_t* msg); #endif
[ "ethan.ito.rhs@gmail.com" ]
ethan.ito.rhs@gmail.com
914fbaecd46d1eabd6af5d7103933b06f6f577e1
4483b10028c73fc49a518be4a2bcb56848d8786b
/ios/Google Cardboard Demo/Mecha-Mecha/Classes/Native/mscorlib_System_Array_InternalEnumerator_1_gen_18MethodDeclarations.h
500c69e7ec283d00f4a471094cd86cbea3b996fe
[]
no_license
nchavez324/es50_final_project
aa8202470b59be1ddc25e78a3e1712708f5b00c4
be1b8f9849d1ff4a845a137eefecb49df27f2e1c
refs/heads/master
2021-01-10T07:03:26.885783
2020-12-03T16:02:23
2020-12-03T16:02:23
47,363,409
0
0
null
null
null
null
UTF-8
C
false
false
3,127
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.Array struct Array_t; // System.Object struct Object_t; #include "codegen/il2cpp-codegen.h" #include "mscorlib_System_Array_InternalEnumerator_1_gen_18.h" #include "UnityEngine_UnityEngine_RaycastHit2D.h" // System.Void System.Array/InternalEnumerator`1<UnityEngine.RaycastHit2D>::.ctor(System.Array) extern "C" void InternalEnumerator_1__ctor_m12699_gshared (InternalEnumerator_1_t1944 * __this, Array_t * ___array, const MethodInfo* method); #define InternalEnumerator_1__ctor_m12699(__this, ___array, method) (( void (*) (InternalEnumerator_1_t1944 *, Array_t *, const MethodInfo*))InternalEnumerator_1__ctor_m12699_gshared)(__this, ___array, method) // System.Void System.Array/InternalEnumerator`1<UnityEngine.RaycastHit2D>::System.Collections.IEnumerator.Reset() extern "C" void InternalEnumerator_1_System_Collections_IEnumerator_Reset_m12700_gshared (InternalEnumerator_1_t1944 * __this, const MethodInfo* method); #define InternalEnumerator_1_System_Collections_IEnumerator_Reset_m12700(__this, method) (( void (*) (InternalEnumerator_1_t1944 *, const MethodInfo*))InternalEnumerator_1_System_Collections_IEnumerator_Reset_m12700_gshared)(__this, method) // System.Object System.Array/InternalEnumerator`1<UnityEngine.RaycastHit2D>::System.Collections.IEnumerator.get_Current() extern "C" Object_t * InternalEnumerator_1_System_Collections_IEnumerator_get_Current_m12701_gshared (InternalEnumerator_1_t1944 * __this, const MethodInfo* method); #define InternalEnumerator_1_System_Collections_IEnumerator_get_Current_m12701(__this, method) (( Object_t * (*) (InternalEnumerator_1_t1944 *, const MethodInfo*))InternalEnumerator_1_System_Collections_IEnumerator_get_Current_m12701_gshared)(__this, method) // System.Void System.Array/InternalEnumerator`1<UnityEngine.RaycastHit2D>::Dispose() extern "C" void InternalEnumerator_1_Dispose_m12702_gshared (InternalEnumerator_1_t1944 * __this, const MethodInfo* method); #define InternalEnumerator_1_Dispose_m12702(__this, method) (( void (*) (InternalEnumerator_1_t1944 *, const MethodInfo*))InternalEnumerator_1_Dispose_m12702_gshared)(__this, method) // System.Boolean System.Array/InternalEnumerator`1<UnityEngine.RaycastHit2D>::MoveNext() extern "C" bool InternalEnumerator_1_MoveNext_m12703_gshared (InternalEnumerator_1_t1944 * __this, const MethodInfo* method); #define InternalEnumerator_1_MoveNext_m12703(__this, method) (( bool (*) (InternalEnumerator_1_t1944 *, const MethodInfo*))InternalEnumerator_1_MoveNext_m12703_gshared)(__this, method) // T System.Array/InternalEnumerator`1<UnityEngine.RaycastHit2D>::get_Current() extern "C" RaycastHit2D_t383 InternalEnumerator_1_get_Current_m12704_gshared (InternalEnumerator_1_t1944 * __this, const MethodInfo* method); #define InternalEnumerator_1_get_Current_m12704(__this, method) (( RaycastHit2D_t383 (*) (InternalEnumerator_1_t1944 *, const MethodInfo*))InternalEnumerator_1_get_Current_m12704_gshared)(__this, method)
[ "nchavez324@yahoo.com" ]
nchavez324@yahoo.com
1f595725c2230664f6cf9e1645e6904829584af0
24b123329be9a1bea297b49ed9c2a9d8c4f0cb4d
/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.h
4e1798c5f52f5a19bdcee060d7184849b0210431
[]
no_license
ZiaoChen/React2
5fb0b48c1c39658d1333a4ca6e08c5b12b8d2d28
47a937873482df621b2987bee3f8930aa1c4ec5d
refs/heads/master
2021-02-17T20:19:27.172658
2020-03-05T09:45:42
2020-03-05T09:45:42
245,118,779
0
0
null
null
null
null
UTF-8
C
false
false
129
h
version https://git-lfs.github.com/spec/v1 oid sha256:26d908bd0d853dca549fc68d78ba4c92cc4769d9a333f9bfe8c85abf1c88e9f7 size 1549
[ "466930995@qq.com" ]
466930995@qq.com
cdb8755de1774b838ca1ee2a2045b3bd6f985b81
a3c854b10d49a78da53921c783ee9fb64ad80d4c
/SenzSDKDemo/Pods/Headers/Public/AVOSCloud/AVObject.h
0835a30c4f1e175f93fbd54c245236ebdd028555
[]
no_license
DaiYue/SenzSDK_iOS
abae9fcc59132ffa45ccda085556cad063d5924f
32a8f98e9ffe180e47360111c2fdadb2c98dfe88
refs/heads/master
2016-09-06T05:08:51.121671
2015-06-23T04:12:07
2015-06-23T04:12:07
33,526,398
0
0
null
null
null
null
UTF-8
C
false
false
76
h
../../../AVOSCloud/iOS/release-v3.0.1/AVOSCloud.framework/Headers/AVObject.h
[ "yue.dai@qunar.com" ]
yue.dai@qunar.com
30a5e34715b4d1f54886f02a1fe40cffc4e494b6
d42fa606a26402258bc804332c0bab5d154ba99c
/srslte/lib/phch/cqi.c
ec47fcbd1afde1f9b3cbee0e4e6b6f651541e8d5
[]
no_license
zz4fap/Wireless-Spectrum-Hypervisor
44c2635d7092c65fa932b6b2e9cd1337ebbc4836
24158b45660dd304e6a39a1b318d534c3607bd7c
refs/heads/master
2020-06-18T04:11:00.451308
2019-11-14T17:00:37
2019-11-14T17:00:37
196,159,695
4
2
null
null
null
null
UTF-8
C
false
false
5,540
c
/** * * \section COPYRIGHT * * Copyright 2013-2015 Software Radio Systems Limited * * \section LICENSE * * This file is part of the srsLTE library. * * srsLTE is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * srsLTE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * A copy of the GNU Affero General Public License can be found in * the LICENSE file in the top-level directory of this distribution * and at http://www.gnu.org/licenses/. * */ #include <stdint.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include <stdbool.h> #include <assert.h> #include <math.h> #include "srslte/phch/cqi.h" #include "srslte/common/phy_common.h" #include "srslte/utils/bit.h" #include "srslte/utils/vector.h" #include "srslte/utils/debug.h" int srslte_cqi_hl_subband_pack(srslte_cqi_hl_subband_t *msg, uint8_t buff[SRSLTE_CQI_MAX_BITS]) { uint8_t *body_ptr = buff; srslte_bit_unpack(msg->wideband_cqi, &body_ptr, 4); srslte_bit_unpack(msg->subband_diff_cqi, &body_ptr, 2*msg->N); return 4+2*msg->N; } int srslte_cqi_ue_subband_pack(srslte_cqi_ue_subband_t *msg, uint8_t buff[SRSLTE_CQI_MAX_BITS]) { uint8_t *body_ptr = buff; srslte_bit_unpack(msg->wideband_cqi, &body_ptr, 4); srslte_bit_unpack(msg->subband_diff_cqi, &body_ptr, 2); srslte_bit_unpack(msg->subband_diff_cqi, &body_ptr, msg->L); return 4+2+msg->L; } int srslte_cqi_format2_wideband_pack(srslte_cqi_format2_wideband_t *msg, uint8_t buff[SRSLTE_CQI_MAX_BITS]) { uint8_t *body_ptr = buff; srslte_bit_unpack(msg->wideband_cqi, &body_ptr, 4); return 4; } int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t buff[SRSLTE_CQI_MAX_BITS]) { uint8_t *body_ptr = buff; srslte_bit_unpack(msg->subband_cqi, &body_ptr, 4); srslte_bit_unpack(msg->subband_label, &body_ptr, msg->subband_label_2_bits?2:1); return 4+(msg->subband_label_2_bits)?2:1; } int srslte_cqi_value_pack(srslte_cqi_value_t *value, uint8_t buff[SRSLTE_CQI_MAX_BITS]) { switch(value->type) { case SRSLTE_CQI_TYPE_WIDEBAND: return srslte_cqi_format2_wideband_pack(&value->wideband, buff); case SRSLTE_CQI_TYPE_SUBBAND: return srslte_cqi_format2_subband_pack(&value->subband, buff); case SRSLTE_CQI_TYPE_SUBBAND_UE: return srslte_cqi_ue_subband_pack(&value->subband_ue, buff); case SRSLTE_CQI_TYPE_SUBBAND_HL: return srslte_cqi_hl_subband_pack(&value->subband_hl, buff); } return -1; } bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti) { uint32_t N_p = 0; uint32_t N_offset = 0; if (I_cqi_pmi <= 1) { N_p = 2; N_offset = I_cqi_pmi; } else if (I_cqi_pmi <= 6) { N_p = 5; N_offset = I_cqi_pmi - 2; } else if (I_cqi_pmi <= 16) { N_p = 10; N_offset = I_cqi_pmi - 7; } else if (I_cqi_pmi <= 36) { N_p = 20; N_offset = I_cqi_pmi - 17; } else if (I_cqi_pmi <= 76) { N_p = 40; N_offset = I_cqi_pmi - 37; } else if (I_cqi_pmi <= 156) { N_p = 80; N_offset = I_cqi_pmi - 77; } else if (I_cqi_pmi <= 316) { N_p = 160; N_offset = I_cqi_pmi - 157; } else if (I_cqi_pmi == 317) { return false; } else if (I_cqi_pmi <= 349) { N_p = 32; N_offset = I_cqi_pmi - 318; } else if (I_cqi_pmi <= 413) { N_p = 64; N_offset = I_cqi_pmi - 350; } else if (I_cqi_pmi <= 541) { N_p = 128; N_offset = I_cqi_pmi - 414; } else if (I_cqi_pmi <= 1023) { return false; } if (N_p) { if ((tti-N_offset)%N_p == 0) { return true; } } return false; } /* SNR-to-CQI conversion, got from "Downlink SNR to CQI Mapping for Different Multiple Antenna Techniques in LTE" * Table III. */ // From paper static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29}; // New srsLTE values. Should be tested before using. //static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 20.9, 22.5, 24.75, 25.5, 27.30, 29}; // From experimental measurements @ 5 MHz //static float cqi_to_snr_table[15] = { 1, 1.75, 3, 4, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5}; uint8_t srslte_cqi_from_snr(float snr) { for (int cqi=14;cqi>=0;cqi--) { if (snr >= cqi_to_snr_table[cqi]) { return (uint8_t) cqi+1; } } return 0; } /* Returns the subband size for higher layer-configured subband feedback, * i.e., the number of RBs per subband as a function of the cell bandwidth * (Table 7.2.1-3 in TS 36.213) */ int srslte_cqi_hl_get_subband_size(int nof_prb) { if (nof_prb < 7) { return 0; } else if (nof_prb <= 26) { return 4; } else if (nof_prb <= 63) { return 6; } else if (nof_prb <= 110) { return 8; } else { return -1; } } /* Returns the number of subbands to be reported in CQI measurements as * defined in clause 7.2 in TS 36.213, i.e., the N parameter */ int srslte_cqi_hl_get_no_subbands(int nof_prb) { int hl_size = srslte_cqi_hl_get_subband_size(nof_prb); if (hl_size > 0) { return (int)ceil((float)nof_prb/hl_size); } else { return 0; } }
[ "zz4fap@users.noreply.github.com" ]
zz4fap@users.noreply.github.com
a53b0f9835d960e890945bebccfd9e26bbb4bb53
43c613e3071893640f26425d87c440ec1ed7d298
/Figs/syst/v0/le3j/Btag_gamma_to_dimuon_no_alphaT_Cut_2.C
2716a792bf9e55187eae278e72e6687804ef9277
[ "MIT" ]
permissive
dsmiff/thesis-1
5f09eafdddeddcdc776ae11a2cba19a84ebf1428
e7813b19b8e26b416428994e843ad17b87017e24
refs/heads/master
2021-05-30T09:17:40.998518
2015-11-03T15:47:00
2015-11-03T15:47:00
null
0
0
null
null
null
null
UTF-8
C
false
false
5,466
c
{ //=========Macro generated from canvas: Yields/Yields //========= (Wed Apr 2 22:55:12 2014) by ROOT version5.34/09 TCanvas *Yields = new TCanvas("Yields", "Yields",1,1,900,576); gStyle->SetOptFit(1); Yields->SetHighLightColor(2); Yields->Range(270.7031,-1.25,1276.172,1.25); Yields->SetFillColor(0); Yields->SetBorderMode(0); Yields->SetBorderSize(2); Yields->SetTickx(1); Yields->SetTicky(1); Yields->SetFrameBorderMode(0); Yields->SetFrameBorderMode(0); TGraphAsymmErrors *grae = new TGraphAsymmErrors(12); grae->SetName("Graph"); grae->SetTitle(""); grae->SetFillColor(1); grae->SetLineWidth(3); grae->SetMarkerStyle(20); grae->SetMarkerSize(1.5); grae->SetPoint(0,0,0); grae->SetPointError(0,0,0,0,0); grae->SetPoint(1,0,0); grae->SetPointError(1,0,0,0,0); grae->SetPoint(2,0,0); grae->SetPointError(2,0,0,0,0); grae->SetPoint(3,0,0); grae->SetPointError(3,0,0,0,0); grae->SetPoint(4,425,0.03678666); grae->SetPointError(4,0,0,0.04047791,0.04047791); grae->SetPoint(5,525,-0.05746171); grae->SetPointError(5,0,0,0.06339804,0.06339804); grae->SetPoint(6,625,0.01895703); grae->SetPointError(6,0,0,0.0991817,0.0991817); grae->SetPoint(7,725,0.04699436); grae->SetPointError(7,0,0,0.1554053,0.1554053); grae->SetPoint(8,825,0.2428858); grae->SetPointError(8,0,0,0.2546783,0.2546783); grae->SetPoint(9,925,-0.04258493); grae->SetPointError(9,0,0,0.3181954,0.3181954); grae->SetPoint(10,1025,0.3733366); grae->SetPointError(10,0,0,0.5346002,0.5346002); grae->SetPoint(11,1125,-0.1275969); grae->SetPointError(11,0,0,0.4578779,0.4578779); TH1F *Graph_Graph11 = new TH1F("Graph_Graph11","",100,0,1237.5); Graph_Graph11->SetMinimum(-1); Graph_Graph11->SetMaximum(1); Graph_Graph11->SetDirectory(0); Graph_Graph11->SetStats(0); Int_t ci; // for color index setting ci = TColor::GetColor("#000099"); Graph_Graph11->SetLineColor(ci); Graph_Graph11->GetXaxis()->SetTitle("H_{T} (GeV)"); Graph_Graph11->GetXaxis()->SetRange(31,95); Graph_Graph11->GetXaxis()->SetLabelFont(42); Graph_Graph11->GetXaxis()->SetLabelOffset(0.01); Graph_Graph11->GetXaxis()->SetLabelSize(0.05); Graph_Graph11->GetXaxis()->SetTitleSize(0.06); Graph_Graph11->GetXaxis()->SetTitleFont(42); Graph_Graph11->GetYaxis()->SetTitle("(N_{obs} - N_{pred}) / N_{pred}"); Graph_Graph11->GetYaxis()->SetLabelFont(42); Graph_Graph11->GetYaxis()->SetLabelOffset(0.01); Graph_Graph11->GetYaxis()->SetLabelSize(0.05); Graph_Graph11->GetYaxis()->SetTitleSize(0.035); Graph_Graph11->GetYaxis()->SetTitleOffset(1.1); Graph_Graph11->GetYaxis()->SetTitleFont(42); Graph_Graph11->GetZaxis()->SetLabelFont(42); Graph_Graph11->GetZaxis()->SetLabelOffset(0.01); Graph_Graph11->GetZaxis()->SetLabelSize(0.05); Graph_Graph11->GetZaxis()->SetTitleSize(0.035); Graph_Graph11->GetZaxis()->SetTitleFont(42); grae->SetHistogram(Graph_Graph11); TF1 *fit = new TF1("fit","pol0",375,1175); fit->SetFillColor(19); fit->SetFillStyle(0); fit->SetLineColor(2); fit->SetLineWidth(2); fit->SetChisquare(3.019479); fit->SetNDF(7); fit->GetXaxis()->SetLabelFont(42); fit->GetXaxis()->SetLabelOffset(0.01); fit->GetXaxis()->SetLabelSize(0.05); fit->GetXaxis()->SetTitleSize(0.06); fit->GetXaxis()->SetTitleFont(42); fit->GetYaxis()->SetLabelFont(42); fit->GetYaxis()->SetLabelOffset(0.01); fit->GetYaxis()->SetLabelSize(0.05); fit->GetYaxis()->SetTitleSize(0.035); fit->GetYaxis()->SetTitleFont(42); fit->SetParameter(0,0.01549628); fit->SetParError(0,0.03107218); fit->SetParLimits(0,0,0); grae->GetListOfFunctions()->Add(fit); TPaveStats *ptstats = new TPaveStats(0.62,0.815,0.98,0.935,"brNDC"); ptstats->SetName("stats"); ptstats->SetBorderSize(1); ptstats->SetFillColor(0); ptstats->SetTextAlign(12); ptstats->SetTextFont(42); TText *text = ptstats->AddText("#chi^{2} / ndf = 3.019 / 7"); text = ptstats->AddText("p0 = 0.0155 #pm 0.03107 "); ptstats->SetOptStat(0); ptstats->SetOptFit(111); ptstats->Draw(); grae->GetListOfFunctions()->Add(ptstats); ptstats->SetParent(grae->GetListOfFunctions()); grae->Draw("ap"); TF1 *fit = new TF1("fit","pol0",375,1175); fit->SetFillColor(19); fit->SetFillStyle(0); fit->SetLineColor(2); fit->SetLineWidth(2); fit->SetChisquare(3.019479); fit->SetNDF(7); fit->GetXaxis()->SetLabelFont(42); fit->GetXaxis()->SetLabelOffset(0.01); fit->GetXaxis()->SetLabelSize(0.05); fit->GetXaxis()->SetTitleSize(0.06); fit->GetXaxis()->SetTitleFont(42); fit->GetYaxis()->SetLabelFont(42); fit->GetYaxis()->SetLabelOffset(0.01); fit->GetYaxis()->SetLabelSize(0.05); fit->GetYaxis()->SetTitleSize(0.035); fit->GetYaxis()->SetTitleFont(42); fit->SetParameter(0,0.01549628); fit->SetParError(0,0.03107218); fit->SetParLimits(0,0,0); fit->Draw("SAME"); tex = new TLatex(0.12,0.84,"CMS, 18.493 fb^{-1}, #sqrt{s} = 8 TeV"); tex->SetNDC(); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); TPaveText *pt = new TPaveText(0.12,0.9,0.5,0.95,"blNDC"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetTextSize(0.04); text = pt->AddText("#gamma + jets #rightarrow #mu#mu + jets "); pt->Draw(); Yields->Modified(); Yields->cd(); Yields->SetSelected(Yields); }
[ "chris.lucas@bristol.ac.uk" ]
chris.lucas@bristol.ac.uk
21c653d8636ead97fd4471b49c154fff25981340
1a028bca5636cea6fe447b5537c258ea0b724f69
/lab4_fract/app_software/mandlebrot_C/basic_io.h
d0ac201126b2d0cba246ec56d8c874d08b20dc3e
[]
no_license
TomDuo/ECE5760_Epiphyte
eae6a3f2dcc909c32c50c8dcf99d8cc0f72d0645
db2ce591a7dc7c9a8b09476d6a87deb17378f406
refs/heads/master
2020-05-03T03:19:01.028459
2016-05-17T17:42:08
2016-05-17T17:42:08
null
0
0
null
null
null
null
UTF-8
C
false
false
1,943
h
#ifndef __basic_io_H__ #define __basic_io_H__ #include <io.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include "system.h" #include "sys/alt_irq.h" // for GPIO #define inport(base) IORD(base, 0) #define outport(base, data) IOWR(base, 0, data) #define get_pio_dir(base) IORD(base, 1) #define set_pio_dir(base, data) IOWR(base, 1, data) #define get_pio_irq_mask(base) IORD(base, 2) #define set_pio_irq_mask(base, data) IOWR(base, 2, data) #define get_pio_edge_cap(base) IORD(base, 3) #define set_pio_edge_cap(base, data) IOWR(base, 3, data) // for SEG7 Display #define seg7_show(base,data) IOWR(base, 0, data) // for Time Delay #define msleep(msec) usleep(1000*msec); #define Sleep(sec) msleep(1000*sec); // for Switch #define SWITCH_PIO_NAME "/dev/switch_pio" #define SWITCH_PIO_TYPE "altera_avalon_pio" #define SWITCH_PIO_BASE 0x00681090 //#define SWITCH_PIO_DO_TEST_BENCH_WIRING 1 #define SWITCH_PIO_DRIVEN_SIM_VALUE 0x0000 #define SWITCH_PIO_HAS_TRI 0 #define SWITCH_PIO_HAS_OUT 0 #define SWITCH_PIO_HAS_IN 1 #define SWITCH_PIO_CAPTURE 0 #define SWITCH_PIO_EDGE_TYPE "NONE" #define SWITCH_PIO_IRQ_TYPE "NONE" //#define SWITCH_PIO_FREQ 50000000 // for key #define BUTTON_PIO_NAME "/dev/button_pio" #define BUTTON_PIO_TYPE "altera_avalon_pio" #define BUTTON_PIO_BASE 0x00681080 //#define BUTTON_PIO_IRQ 2 //#define BUTTON_PIO_DO_TEST_BENCH_WIRING 1 #define BUTTON_PIO_DRIVEN_SIM_VALUE 0x0000 #define BUTTON_PIO_HAS_TRI 0 #define BUTTON_PIO_HAS_OUT 0 #define BUTTON_PIO_HAS_IN 1 #define BUTTON_PIO_CAPTURE 1 #define BUTTON_PIO_EDGE_TYPE "FALLING" #define BUTTON_PIO_IRQ_TYPE "EDGE" //#define BUTTON_PIO_FREQ 50000000 #endif
[ "carchard0@gmail.com" ]
carchard0@gmail.com
a65b1a0164d3e2322c0fa6dd7199889dfd3e1f15
b349fab20bc5057f13e9f35e06abfb5111fe62bc
/homme1_3_6/libs/metis/Lib/estmem.c
48385af5cbd3e1519b57eb88b3ee15dc5b2e0d74
[]
no_license
hadimoghaddam/Coral-benchmark
3f157f0cd331ecf0c591561bac5896c4bf389aec
15107b51113acbcad95e76a59a0f18c17460e9f0
refs/heads/master
2021-05-15T16:36:13.840714
2017-10-27T00:37:38
2017-10-27T00:37:38
107,469,706
1
1
null
null
null
null
UTF-8
C
false
false
4,157
c
/* * Copyright 1997, Regents of the University of Minnesota * * estmem.c * * This file contains code for estimating the amount of memory required by * the various routines in METIS * * Started 11/4/97 * George * * $Id: estmem.c,v 2.0 2003/09/03 21:03:02 dennis Exp $ * */ #include <metis.h> /************************************************************************* * This function computes how much memory will be required by the various * routines in METIS **************************************************************************/ void METIS_EstimateMemory(int *nvtxs, idxtype *xadj, idxtype *adjncy, int *numflag, int *optype, int *nbytes) { int i, j, k, nedges, nlevels; float vfraction, efraction, vmult, emult; int coresize, gdata, rdata; if (*numflag == 1) Change2CNumbering(*nvtxs, xadj, adjncy); nedges = xadj[*nvtxs]; InitRandom(-1); EstimateCFraction(*nvtxs, xadj, adjncy, &vfraction, &efraction); /* Estimate the amount of memory for coresize */ if (*optype == 2) coresize = nedges; else coresize = 0; coresize += nedges + 11*(*nvtxs) + 4*1024 + 2*(NEG_GAINSPAN+PLUS_GAINSPAN+1)*(sizeof(ListNodeType *)/sizeof(idxtype)); coresize += 2*(*nvtxs); /* add some more fore other vectors */ gdata = nedges; /* Assume that the user does not pass weights */ nlevels = (int)(log(100.0/(*nvtxs))/log(vfraction) + .5); vmult = 0.5 + (1.0 - pow(vfraction, nlevels))/(1.0 - vfraction); emult = 1.0 + (1.0 - pow(efraction, nlevels+1))/(1.0 - efraction); gdata += vmult*4*(*nvtxs) + emult*2*nedges; if ((vmult-1.0)*4*(*nvtxs) + (emult-1.0)*2*nedges < 5*(*nvtxs)) rdata = 0; else rdata = 5*(*nvtxs); *nbytes = sizeof(idxtype)*(coresize+gdata+rdata+(*nvtxs)); if (*numflag == 1) Change2FNumbering2(*nvtxs, xadj, adjncy); } /************************************************************************* * This function finds a matching using the HEM heuristic **************************************************************************/ void EstimateCFraction(int nvtxs, idxtype *xadj, idxtype *adjncy, float *vfraction, float *efraction) { int i, ii, j, cnvtxs, cnedges, maxidx; idxtype *match, *cmap, *perm; cmap = idxmalloc(nvtxs, "cmap"); match = idxsmalloc(nvtxs, UNMATCHED, "match"); perm = idxmalloc(nvtxs, "perm"); RandomPermute(nvtxs, perm, 1); cnvtxs = 0; for (ii=0; ii<nvtxs; ii++) { i = perm[ii]; if (match[i] == UNMATCHED) { /* Unmatched */ maxidx = i; /* Find a random matching, subject to maxvwgt constraints */ for (j=xadj[i]; j<xadj[i+1]; j++) { if (match[adjncy[j]] == UNMATCHED) { maxidx = adjncy[j]; break; } } cmap[i] = cmap[maxidx] = cnvtxs++; match[i] = maxidx; match[maxidx] = i; } } cnedges = ComputeCoarseGraphSize(nvtxs, xadj, adjncy, cnvtxs, cmap, match, perm); *vfraction = (1.0*cnvtxs)/(1.0*nvtxs); *efraction = (1.0*cnedges)/(1.0*xadj[nvtxs]); GKfree(&cmap, &match, &perm, LTERM); } /************************************************************************* * This function computes the size of the coarse graph **************************************************************************/ int ComputeCoarseGraphSize(int nvtxs, idxtype *xadj, idxtype *adjncy, int cnvtxs, idxtype *cmap, idxtype *match, idxtype *perm) { int i, j, k, istart, iend, nedges, cnedges, v, u; idxtype *htable; htable = idxsmalloc(cnvtxs, -1, "htable"); cnvtxs = cnedges = 0; for (i=0; i<nvtxs; i++) { v = perm[i]; if (cmap[v] != cnvtxs) continue; htable[cnvtxs] = cnvtxs; u = match[v]; istart = xadj[v]; iend = xadj[v+1]; for (j=istart; j<iend; j++) { k = cmap[adjncy[j]]; if (htable[k] != cnvtxs) { htable[k] = cnvtxs; cnedges++; } } if (v != u) { istart = xadj[u]; iend = xadj[u+1]; for (j=istart; j<iend; j++) { k = cmap[adjncy[j]]; if (htable[k] != cnvtxs) { htable[k] = cnvtxs; cnedges++; } } } cnvtxs++; } GKfree(&htable, LTERM); return cnedges; }
[ "asghari2@illinois.edu" ]
asghari2@illinois.edu
727a289a92137609f9d4d1184a311e2d9926a4d3
21c09799d006ed6bede4123d57d6d54d977c0b63
/fits_2018_10/PFNo10Dijet2016bgCSVv21b221Scan/corrHist.C
b65377cd85dbace30661b9460da333322794fbe8
[]
no_license
corvettettt/DijetRootTreeAnalyzer
68cb12e6b280957e1eb22c9842b0b9b30ae2c779
e65624ffc105798209436fc80fb82e2c252c6344
refs/heads/master
2021-05-06T09:57:12.816787
2019-04-18T15:32:38
2019-04-18T15:32:38
114,043,763
1
0
null
2017-12-12T22:02:46
2017-12-12T22:02:46
null
UTF-8
C
false
false
4,898
c
void corrHist() { //=========Macro generated from canvas: c/c //========= (Thu Dec 13 10:29:53 2018) by ROOT version6.02/05 TCanvas *c = new TCanvas("c", "c",0,0,500,500); gStyle->SetOptStat(0); c->SetHighLightColor(2); c->Range(-0.5333333,-0.5,4.8,4.5); c->SetFillColor(0); c->SetBorderMode(0); c->SetBorderSize(2); c->SetRightMargin(0.15); c->SetFrameBorderMode(0); c->SetFrameBorderMode(0); TH2D *correlation_matrix = new TH2D("correlation_matrix","correlation_matrix",4,0,4,4,0,4); correlation_matrix->SetBinContent(8,-0.991517); correlation_matrix->SetBinContent(9,0.9995474); correlation_matrix->SetBinContent(10,1); correlation_matrix->SetBinContent(14,-0.9948967); correlation_matrix->SetBinContent(15,1); correlation_matrix->SetBinContent(16,0.9995474); correlation_matrix->SetBinContent(20,1); correlation_matrix->SetBinContent(21,-0.9948967); correlation_matrix->SetBinContent(22,-0.991517); correlation_matrix->SetBinContent(25,1); correlation_matrix->SetBinError(8,0.991517); correlation_matrix->SetBinError(9,0.9995474); correlation_matrix->SetBinError(10,1); correlation_matrix->SetBinError(14,0.9948967); correlation_matrix->SetBinError(15,1); correlation_matrix->SetBinError(16,0.9995474); correlation_matrix->SetBinError(20,1); correlation_matrix->SetBinError(21,0.9948967); correlation_matrix->SetBinError(22,0.991517); correlation_matrix->SetBinError(25,1); correlation_matrix->SetMinimum(-1); correlation_matrix->SetMaximum(1); correlation_matrix->SetEntries(16); correlation_matrix->SetStats(0); correlation_matrix->SetContour(20); correlation_matrix->SetContourLevel(0,-1); correlation_matrix->SetContourLevel(1,-0.9); correlation_matrix->SetContourLevel(2,-0.8); correlation_matrix->SetContourLevel(3,-0.7); correlation_matrix->SetContourLevel(4,-0.6); correlation_matrix->SetContourLevel(5,-0.5); correlation_matrix->SetContourLevel(6,-0.4); correlation_matrix->SetContourLevel(7,-0.3); correlation_matrix->SetContourLevel(8,-0.2); correlation_matrix->SetContourLevel(9,-0.1); correlation_matrix->SetContourLevel(10,0); correlation_matrix->SetContourLevel(11,0.1); correlation_matrix->SetContourLevel(12,0.2); correlation_matrix->SetContourLevel(13,0.3); correlation_matrix->SetContourLevel(14,0.4); correlation_matrix->SetContourLevel(15,0.5); correlation_matrix->SetContourLevel(16,0.6); correlation_matrix->SetContourLevel(17,0.7); correlation_matrix->SetContourLevel(18,0.8); correlation_matrix->SetContourLevel(19,0.9); TPaletteAxis *palette = new TPaletteAxis(4.026667,0,4.266667,4,correlation_matrix); palette->SetLabelColor(1); palette->SetLabelFont(42); palette->SetLabelOffset(0.005); palette->SetLabelSize(0.035); palette->SetTitleOffset(1); palette->SetTitleSize(0.035); palette->SetFillColor(100); palette->SetFillStyle(1001); correlation_matrix->GetListOfFunctions()->Add(palette,"br"); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); correlation_matrix->SetLineColor(ci); correlation_matrix->GetXaxis()->SetBinLabel(1,"Ntot_bkg_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetXaxis()->SetBinLabel(2,"p1_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetXaxis()->SetBinLabel(3,"p2_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetXaxis()->SetBinLabel(4,"p3_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetXaxis()->SetLabelFont(42); correlation_matrix->GetXaxis()->SetLabelSize(0.035); correlation_matrix->GetXaxis()->SetTitleSize(0.035); correlation_matrix->GetXaxis()->SetTitleFont(42); correlation_matrix->GetYaxis()->SetBinLabel(4,"Ntot_bkg_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetYaxis()->SetBinLabel(3,"p1_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetYaxis()->SetBinLabel(2,"p2_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetYaxis()->SetBinLabel(1,"p3_PFNo10Dijet2016bgCSVv21b221"); correlation_matrix->GetYaxis()->SetLabelFont(42); correlation_matrix->GetYaxis()->SetLabelSize(0.035); correlation_matrix->GetYaxis()->SetTitleSize(0.035); correlation_matrix->GetYaxis()->SetTitleFont(42); correlation_matrix->GetZaxis()->SetLabelFont(42); correlation_matrix->GetZaxis()->SetLabelSize(0.035); correlation_matrix->GetZaxis()->SetTitleSize(0.035); correlation_matrix->GetZaxis()->SetTitleFont(42); correlation_matrix->Draw("colztext"); TPaveText *pt = new TPaveText(0.2793145,0.9365254,0.7206855,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("correlation_matrix"); pt->Draw(); c->Modified(); c->cd(); c->SetSelected(c); }
[ "zhixing.wang@ttu.edu" ]
zhixing.wang@ttu.edu
bff86db252c29bc5d22f88367e17e6e81a82784a
3cc3d4a83e8263ebe0a9ba6dea4e7bdfbf5cb3a7
/Software/Libraries/ABCC/abcc_adapt/GLCD_16bitIF_STM32F4xx.c
ed29961399435f00bb14c3a5e2d487a6948a5183
[]
no_license
zwxwill/FlowCtrl
c1d296576751c657d1475dbb94ca2420b47ec696
17dbe3a2b639a71e01446d4e8b9a149e23e292b0
refs/heads/master
2020-06-16T15:38:14.690145
2019-08-28T14:02:50
2019-08-28T14:02:50
195,624,932
0
1
null
null
null
null
UTF-8
C
false
false
42,698
c
/******************************************************************************* ******************************************************************************** ** ** ** ABCC Starter Kit version 3.02.02 (2016-11-10) ** ** ** ** Delivered with: ** ** ABP 7.31.01 (2016-09-16) ** ** ABCC Driver 5.02.01 (2016-11-02) ** ** */ /******************************************************************************/ /* GLCD_16bitIF_STM32F4xx.c: STM32F4xx low level Graphic LCD (320x240 pixels) */ /* with 16-bit parallel interface */ /******************************************************************************/ /* This file is part of the uVision/ARM development tools. */ /* Copyright (c) 2005-2011 Keil - An ARM Company. All rights reserved. */ /* This software may only be used under the terms of a valid, current, */ /* end user licence from KEIL for a compatible version of KEIL software */ /* development tools. Nothing else gives you the right to use this software. */ /******************************************************************************/ #include <stm32f4xx.h> /* STM32F4xx Definitions */ #include "GLCD.h" #include "Font_6x8_h.h" #include "Font_16x24_h.h" /************************** Orientation configuration ************************/ #define LANDSCAPE 1 /* 1 for landscape, 0 for portrait */ #define ROTATE180 0 /* 1 to rotate the screen for 180 deg */ /*********************** Hardware specific configuration **********************/ /*------------------------- Speed dependant settings -------------------------*/ /* If processor works on high frequency delay has to be increased, it can be increased by factor 2^N by this constant */ #define DELAY_2N 18 /*---------------------- Graphic LCD size definitions ------------------------*/ #if (LANDSCAPE == 1) #define WIDTH 320 /* Screen Width (in pixels) */ #define HEIGHT 240 /* Screen Hight (in pixels) */ #else #define WIDTH 240 /* Screen Width (in pixels) */ #define HEIGHT 320 /* Screen Hight (in pixels) */ #endif #define BPP 16 /* Bits per pixel */ #define BYPP ((BPP+7)/8) /* Bytes per pixel */ /*--------------- Graphic LCD interface hardware definitions -----------------*/ #ifdef __STM_EVAL /* STM3220G-EVAL and STM3240G-EVAL */ /* LCD /CS is NE3 - Bank 3 of NOR/SRAM Bank 1~4 */ #define LCD_BASE (0x60000000UL | 0x08000000UL) #else /* MCBSTM32F200 and MCBSTMF400 board */ /* LCD /CS is NE4 - Bank 4 of NOR/SRAM Bank 1~4 */ #define LCD_BASE (0x60000000UL | 0x0C000000UL) #endif #define LCD_REG16 (*((volatile unsigned short *)(LCD_BASE ))) #define LCD_DAT16 (*((volatile unsigned short *)(LCD_BASE+2))) #define BG_COLOR 0 /* Background color */ #define TXT_COLOR 1 /* Text color */ /*---------------------------- Global variables ------------------------------*/ /******************************************************************************/ static volatile unsigned short Color[2] = {White, Black}; static unsigned char Himax; /************************ Local auxiliary functions ***************************/ /******************************************************************************* * Delay in while loop cycles * * Parameter: cnt: number of while cycles to delay * * Return: * *******************************************************************************/ static void delay (int cnt) { cnt <<= DELAY_2N; while (cnt--); } /******************************************************************************* * Write a command the LCD controller * * Parameter: cmd: command to be written * * Return: * *******************************************************************************/ static __inline void wr_cmd (unsigned char cmd) { LCD_REG16 = cmd; } /******************************************************************************* * Write data to the LCD controller * * Parameter: dat: data to be written * * Return: * *******************************************************************************/ static __inline void wr_dat (unsigned short dat) { LCD_DAT16 = dat; } /******************************************************************************* * Start of data writing to the LCD controller * * Parameter: * * Return: * *******************************************************************************/ static __inline void wr_dat_start (void) { /* only used for SPI interface */ } /******************************************************************************* * Stop of data writing to the LCD controller * * Parameter: * * Return: * *******************************************************************************/ static __inline void wr_dat_stop (void) { /* only used for SPI interface */ } /******************************************************************************* * Data writing to the LCD controller * * Parameter: dat: data to be written * * Return: * *******************************************************************************/ static __inline void wr_dat_only (unsigned short dat) { LCD_DAT16 = dat; } /******************************************************************************* * Read data from the LCD controller * * Parameter: * * Return: read data * *******************************************************************************/ static __inline unsigned short rd_dat (void) { return (LCD_DAT16); /* return value */ } /******************************************************************************* * Write a value to the to LCD register * * Parameter: reg: register to be written * * val: value to write to the register * *******************************************************************************/ static __inline void wr_reg (unsigned char reg, unsigned short val) { wr_cmd(reg); wr_dat(val); } /******************************************************************************* * Read from the LCD register * * Parameter: reg: register to be read * * Return: value read from the register * *******************************************************************************/ static unsigned short rd_reg (unsigned char reg) { wr_cmd(reg); return(rd_dat()); } /************************ Exported functions **********************************/ /******************************************************************************* * Initialize the Graphic LCD controller * * Parameter: * * Return: * *******************************************************************************/ void GLCD_Init (void) { unsigned short driverCode; /* Configure the LCD Control pins --------------------------------------------*/ RCC->AHB1ENR |=((1UL << 0) | /* Enable GPIOA clock */ #ifndef __STM_EVAL /* MCBSTM32F200 and MCBSTMF400 board */ (1UL << 2) | /* Enable GPIOC clock */ #endif (1UL << 3) | /* Enable GPIOD clock */ (1UL << 4) | /* Enable GPIOE clock */ (1UL << 5) | /* Enable GPIOF clock */ (1UL << 6)); /* Enable GPIOG clock */ /* PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE) */ /* PD.08(D13), PD.09(D14), PD.10(D15), PD.14(D0), PD.15(D1) */ GPIOD->MODER &= ~0xF03F0F0F; /* Clear Bits */ GPIOD->MODER |= 0xA02A0A0A; /* Alternate Function mode */ GPIOD->OSPEEDR &= ~0xF03F0F0F; /* Clear Bits */ GPIOD->OSPEEDR |= 0xA02A0A0A; /* 50 MHz Fast speed */ GPIOD->AFR[0] &= ~0x00FF00FF; /* Clear Bits */ GPIOD->AFR[0] |= 0x00CC00CC; /* Alternate Function mode AF12 */ GPIOD->AFR[1] &= ~0xFF000FFF; /* Clear Bits */ GPIOD->AFR[1] |= 0xCC000CCC; /* Alternate Function mode AF12 */ /* PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8) */ /* PE.12(D9), PE.13(D10), PE.14(D11), PE.15(D12) */ GPIOE->MODER &= ~0xFFFFC000; /* Clear Bits */ GPIOE->MODER |= 0xAAAA8000; /* Alternate Function mode */ GPIOE->OSPEEDR &= ~0xFFFFC000; /* Clear Bits */ GPIOE->OSPEEDR |= 0xAAAA8000; /* 50 MHz Fast speed */ GPIOE->AFR[0] &= ~0xF0000000; /* Clear Bits */ GPIOE->AFR[0] |= 0xC0000000; /* Alternate Function mode AF12 */ GPIOE->AFR[1] &= ~0xFFFFFFFF; /* Clear Bits */ GPIOE->AFR[1] |= 0xCCCCCCCC; /* Alternate Function mode AF12 */ /* PF.00(A0 (RS)) */ GPIOF->MODER &= ~0x00000003; /* Clear Bits */ GPIOF->MODER |= 0x00000002; /* Alternate Function mode */ GPIOF->OSPEEDR &= ~0x00000003; /* Clear Bits */ GPIOF->OSPEEDR |= 0x00000002; /* 50 MHz Fast speed */ GPIOF->AFR[0] &= ~0x0000000F; /* Clear Bits */ GPIOF->AFR[0] |= 0x0000000C; /* Alternate Function mode AF12 */ #ifdef __STM_EVAL /* STM3220G-EVAL and STM3240G-EVAL */ /* PG.10(NE4 (LCD/CS)) - CE1(LCD /CS) */ GPIOG->MODER &= ~0x00300000; /* Clear Bits */ GPIOG->MODER |= 0x00200000; /* Alternate Function mode */ GPIOG->OSPEEDR &= ~0x00300000; /* Clear Bits */ GPIOG->OSPEEDR |= 0x00200000; /* 50 MHz Fast speed */ GPIOG->AFR[1] &= ~0x00000F00; /* Clear Bits */ GPIOG->AFR[1] |= 0x00000C00; /* Alternate Function mode AF12 */ /* PA.08(LCD Backlight */ GPIOA->BSRR &= ~(1UL << 8); /* Backlight off */ GPIOA->MODER &= ~(3UL << 2*8); /* Clear Bits */ GPIOA->MODER |= (1UL << 2*8); /* PA.9 is output */ GPIOA->OTYPER &= ~(1UL << 8); /* PA.9 is output Push-Pull */ GPIOA->OSPEEDR &= ~(3UL << 2*8); /* Clear Bits */ GPIOA->OSPEEDR |= (2UL << 2*8); /* PA.9 is 50MHz Fast Speed */ #else /* MCBSTM32F200 and MCBSTMF400 board */ /* PG.12(NE4 (LCD/CS)) - CE1(LCD /CS) */ GPIOG->MODER &= ~0x03000000; /* Clear Bits */ GPIOG->MODER |= 0x02000000; /* Alternate Function mode */ GPIOG->OSPEEDR &= ~0x03000000; /* Clear Bits */ GPIOG->OSPEEDR |= 0x02000000; /* 50 MHz Fast speed */ GPIOG->AFR[1] &= ~0x000F0000; /* Clear Bits */ GPIOG->AFR[1] |= 0x000C0000; /* Alternate Function mode AF12 */ /* PC.07(LCD Backlight */ GPIOC->BSRRH |= (1UL << 7); /* Backlight off */ GPIOC->MODER &= ~(3UL << 2*7); /* Clear Bits */ GPIOC->MODER |= (1UL << 2*7); /* PC.7 is output */ GPIOC->OTYPER &= ~(1UL << 7); /* PC.7 is output Push-Pull */ GPIOC->OSPEEDR &= ~(3UL << 2*7); /* Clear Bits */ GPIOC->OSPEEDR |= (2UL << 2*7); /* PC.7 is 50MHz Fast Speed */ #endif /*-- FSMC Configuration ------------------------------------------------------*/ RCC->AHB3ENR |= (1UL << 0); /* Enable FSMC clock */ #ifdef __STM_EVAL /* STM3220G-EVAL and STM3240G-EVAL */ FSMC_Bank1->BTCR[(3-1)*2 + 1] = /* Bank3 NOR/SRAM timing register */ /* configuration */ #else /* MCBSTM32F200 and MCBSTMF400 board */ FSMC_Bank1->BTCR[(4-1)*2 + 1] = /* Bank4 NOR/SRAM timing register */ /* configuration */ #endif (0 << 28) | /* FSMC AccessMode A */ (0 << 24) | /* Data Latency */ (0 << 20) | /* CLK Division */ (0 << 16) | /* Bus Turnaround Duration */ (9 << 8) | /* Data SetUp Time */ (0 << 4) | /* Address Hold Time */ (1 << 0); /* Address SetUp Time */ #ifdef __STM_EVAL /* STM3220G-EVAL and STM3240G-EVAL */ FSMC_Bank1->BTCR[(3-1)*2 + 0] = #else /* MCBSTM32F200 and MCBSTMF400 board */ FSMC_Bank1->BTCR[(4-1)*2 + 0] = /* Control register */ #endif (0 << 19) | /* Write burst disabled */ (0 << 15) | /* Async wait disabled */ (0 << 14) | /* Extended mode disabled */ (0 << 13) | /* NWAIT signal is disabled */ (1 << 12) | /* Write operation enabled */ (0 << 11) | /* NWAIT signal is active one data */ /* cycle before wait state */ (0 << 10) | /* Wrapped burst mode disabled */ (0 << 9) | /* Wait signal polarity active low */ (0 << 8) | /* Burst access mode disabled */ (1 << 4) | /* Memory data bus width is 16 bits */ (0 << 2) | /* Memory type is SRAM */ (0 << 1) | /* Address/Data Multiplexing disable */ (1 << 0); /* Memory Bank enable */ delay(5); /* Delay 50 ms */ driverCode = rd_reg(0x00); if (driverCode == 0x47) { /* LCD with HX8347-D LCD Controller */ Himax = 1; /* Set Himax LCD controller flag */ /* Driving ability settings ----------------------------------------------*/ wr_reg(0xEA, 0x00); /* Power control internal used (1) */ wr_reg(0xEB, 0x20); /* Power control internal used (2) */ wr_reg(0xEC, 0x0C); /* Source control internal used (1) */ wr_reg(0xED, 0xC7); /* Source control internal used (2) */ wr_reg(0xE8, 0x38); /* Source output period Normal mode */ wr_reg(0xE9, 0x10); /* Source output period Idle mode */ wr_reg(0xF1, 0x01); /* RGB 18-bit interface ;0x0110 */ wr_reg(0xF2, 0x10); /* Adjust the Gamma Curve ------------------------------------------------*/ wr_reg(0x40, 0x01); wr_reg(0x41, 0x00); wr_reg(0x42, 0x00); wr_reg(0x43, 0x10); wr_reg(0x44, 0x0E); wr_reg(0x45, 0x24); wr_reg(0x46, 0x04); wr_reg(0x47, 0x50); wr_reg(0x48, 0x02); wr_reg(0x49, 0x13); wr_reg(0x4A, 0x19); wr_reg(0x4B, 0x19); wr_reg(0x4C, 0x16); wr_reg(0x50, 0x1B); wr_reg(0x51, 0x31); wr_reg(0x52, 0x2F); wr_reg(0x53, 0x3F); wr_reg(0x54, 0x3F); wr_reg(0x55, 0x3E); wr_reg(0x56, 0x2F); wr_reg(0x57, 0x7B); wr_reg(0x58, 0x09); wr_reg(0x59, 0x06); wr_reg(0x5A, 0x06); wr_reg(0x5B, 0x0C); wr_reg(0x5C, 0x1D); wr_reg(0x5D, 0xCC); /* Power voltage setting -------------------------------------------------*/ wr_reg(0x1B, 0x1B); wr_reg(0x1A, 0x01); wr_reg(0x24, 0x2F); wr_reg(0x25, 0x57); wr_reg(0x23, 0x88); /* Power on setting ------------------------------------------------------*/ wr_reg(0x18, 0x36); /* Internal oscillator frequency adj */ wr_reg(0x19, 0x01); /* Enable internal oscillator */ wr_reg(0x01, 0x00); /* Normal mode, no scrool */ wr_reg(0x1F, 0x88); /* Power control 6 - DDVDH Off */ delay(20); wr_reg(0x1F, 0x82); /* Power control 6 - Step-up: 3 x VCI */ delay(5); wr_reg(0x1F, 0x92); /* Power control 6 - Step-up: On */ delay(5); wr_reg(0x1F, 0xD2); /* Power control 6 - VCOML active */ delay(5); /* Color selection -------------------------------------------------------*/ wr_reg(0x17, 0x55); /* RGB, System interface: 16 Bit/Pixel*/ wr_reg(0x00, 0x00); /* Scrolling off, no standby */ /* Interface config ------------------------------------------------------*/ wr_reg(0x2F, 0x11); /* LCD Drive: 1-line inversion */ wr_reg(0x31, 0x00); wr_reg(0x32, 0x00); /* DPL=0, HSPL=0, VSPL=0, EPL=0 */ /* Display on setting ----------------------------------------------------*/ wr_reg(0x28, 0x38); /* PT(0,0) active, VGL/VGL */ delay(20); wr_reg(0x28, 0x3C); /* Display active, VGL/VGL */ #if (LANDSCAPE == 1) #if (ROTATE180 == 0) wr_reg (0x16, 0xA8); #else wr_reg (0x16, 0x68); #endif #else #if (ROTATE180 == 0) wr_reg (0x16, 0x08); #else wr_reg (0x16, 0xC8); #endif #endif /* Display scrolling settings --------------------------------------------*/ wr_reg(0x0E, 0x00); /* TFA MSB */ wr_reg(0x0F, 0x00); /* TFA LSB */ wr_reg(0x10, 320 >> 8); /* VSA MSB */ wr_reg(0x11, 320 & 0xFF); /* VSA LSB */ wr_reg(0x12, 0x00); /* BFA MSB */ wr_reg(0x13, 0x00); /* BFA LSB */ } else { Himax = 0; /* This is not Himax LCD controller */ /* Start Initial Sequence ------------------------------------------------*/ #if (ROTATE180 == 1) wr_reg(0x01, 0x0000); /* Clear SS bit */ #else wr_reg(0x01, 0x0100); /* Set SS bit */ #endif wr_reg(0x02, 0x0700); /* Set 1 line inversion */ wr_reg(0x04, 0x0000); /* Resize register */ wr_reg(0x08, 0x0207); /* 2 lines front, 7 back porch */ wr_reg(0x09, 0x0000); /* Set non-disp area refresh cyc ISC */ wr_reg(0x0A, 0x0000); /* FMARK function */ wr_reg(0x0C, 0x0000); /* RGB interface setting */ wr_reg(0x0D, 0x0000); /* Frame marker Position */ wr_reg(0x0F, 0x0000); /* RGB interface polarity */ /* Power On sequence -----------------------------------------------------*/ wr_reg(0x10, 0x0000); /* Reset Power Control 1 */ wr_reg(0x11, 0x0000); /* Reset Power Control 2 */ wr_reg(0x12, 0x0000); /* Reset Power Control 3 */ wr_reg(0x13, 0x0000); /* Reset Power Control 4 */ delay(20); /* Discharge cap power voltage (200ms)*/ wr_reg(0x10, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ wr_reg(0x11, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ delay(5); /* Delay 50 ms */ wr_reg(0x12, 0x01BD); /* VREG1OUT voltage */ delay(5); /* Delay 50 ms */ wr_reg(0x13, 0x1400); /* VDV[4:0] for VCOM amplitude */ wr_reg(0x29, 0x000E); /* VCM[4:0] for VCOMH */ delay(5); /* Delay 50 ms */ wr_reg(0x20, 0x0000); /* GRAM horizontal Address */ wr_reg(0x21, 0x0000); /* GRAM Vertical Address */ /* Adjust the Gamma Curve ------------------------------------------------*/ switch (driverCode) { case 0x5408: /* LCD with SPFD5408 LCD Controller */ wr_reg(0x30, 0x0B0D); wr_reg(0x31, 0x1923); wr_reg(0x32, 0x1C26); wr_reg(0x33, 0x261C); wr_reg(0x34, 0x2419); wr_reg(0x35, 0x0D0B); wr_reg(0x36, 0x1006); wr_reg(0x37, 0x0610); wr_reg(0x38, 0x0706); wr_reg(0x39, 0x0304); wr_reg(0x3A, 0x0E05); wr_reg(0x3B, 0x0E01); wr_reg(0x3C, 0x010E); wr_reg(0x3D, 0x050E); wr_reg(0x3E, 0x0403); wr_reg(0x3F, 0x0607); break; case 0x9325: /* LCD with RM68050 LCD Controller */ wr_reg(0x0030,0x0000); wr_reg(0x0031,0x0607); wr_reg(0x0032,0x0305); wr_reg(0x0035,0x0000); wr_reg(0x0036,0x1604); wr_reg(0x0037,0x0204); wr_reg(0x0038,0x0001); wr_reg(0x0039,0x0707); wr_reg(0x003C,0x0000); wr_reg(0x003D,0x000F); break; case 0x9320: /* LCD with ILI9320 LCD Controller */ default: /* LCD with other LCD Controller */ wr_reg(0x30, 0x0006); wr_reg(0x31, 0x0101); wr_reg(0x32, 0x0003); wr_reg(0x35, 0x0106); wr_reg(0x36, 0x0B02); wr_reg(0x37, 0x0302); wr_reg(0x38, 0x0707); wr_reg(0x39, 0x0007); wr_reg(0x3C, 0x0600); wr_reg(0x3D, 0x020B); break; } /* Set GRAM area ---------------------------------------------------------*/ wr_reg(0x50, 0x0000); /* Horizontal GRAM Start Address */ wr_reg(0x51, (HEIGHT-1)); /* Horizontal GRAM End Address */ wr_reg(0x52, 0x0000); /* Vertical GRAM Start Address */ wr_reg(0x53, (WIDTH-1)); /* Vertical GRAM End Address */ /* Set Gate Scan Line ----------------------------------------------------*/ switch (driverCode) { case 0x5408: /* LCD with SPFD5408 LCD Controller */ case 0x9325: /* LCD with RM68050 LCD Controller */ #if (LANDSCAPE ^ ROTATE180) wr_reg(0x60, 0x2700); #else wr_reg(0x60, 0xA700); #endif break; case 0x9320: /* LCD with ILI9320 LCD Controller */ default: /* LCD with other LCD Controller */ #if (LANDSCAPE ^ ROTATE180) wr_reg(0x60, 0xA700); #else wr_reg(0x60, 0x2700); #endif break; } wr_reg(0x61, 0x0001); /* NDL,VLE, REV */ wr_reg(0x6A, 0x0000); /* Set scrolling line */ /* Partial Display Control -----------------------------------------------*/ wr_reg(0x80, 0x0000); wr_reg(0x81, 0x0000); wr_reg(0x82, 0x0000); wr_reg(0x83, 0x0000); wr_reg(0x84, 0x0000); wr_reg(0x85, 0x0000); /* Panel Control ---------------------------------------------------------*/ wr_reg(0x90, 0x0010); wr_reg(0x92, 0x0000); wr_reg(0x93, 0x0003); wr_reg(0x95, 0x0110); wr_reg(0x97, 0x0000); wr_reg(0x98, 0x0000); /* Set GRAM write direction I/D=11 (Horizontal : increment, Vertical : increment) */ #if (LANDSCAPE == 1) /* AM=1 (address is updated in vertical writing direction) */ wr_reg(0x03, 0x1038); #else /* AM=0 (address is updated in horizontal writing direction) */ wr_reg(0x03, 0x1030); #endif wr_reg(0x07, 0x0137); /* 262K color and display ON */ } #ifdef __STM_EVAL /* STM3220G-EVAL and STM3240G-EVAL */ GPIOA->BSRR |= (1UL << 8); /* Backlight on */ #else /* MCBSTM32F200 and MCBSTMF400 board */ GPIOC->BSRRL |= (1UL << 7); /* Backlight on */ #endif } /******************************************************************************* * Set draw window region * * Parameter: x: horizontal position * * y: vertical position * * w: window width in pixel * * h: window height in pixels * * Return: * *******************************************************************************/ void GLCD_SetWindow (unsigned int x, unsigned int y, unsigned int w, unsigned int h) { unsigned int xe, ye; if (Himax) { xe = x+w-1; ye = y+h-1; wr_reg(0x02, x >> 8); /* Column address start MSB */ wr_reg(0x03, x & 0xFF); /* Column address start LSB */ wr_reg(0x04, xe >> 8); /* Column address end MSB */ wr_reg(0x05, xe & 0xFF); /* Column address end LSB */ wr_reg(0x06, y >> 8); /* Row address start MSB */ wr_reg(0x07, y & 0xFF); /* Row address start LSB */ wr_reg(0x08, ye >> 8); /* Row address end MSB */ wr_reg(0x09, ye & 0xFF); /* Row address end LSB */ } else { #if (LANDSCAPE == 1) wr_reg(0x50, y); /* Vertical GRAM Start Address */ wr_reg(0x51, y+h-1); /* Vertical GRAM End Address (-1) */ wr_reg(0x52, x); /* Horizontal GRAM Start Address */ wr_reg(0x53, x+w-1); /* Horizontal GRAM End Address (-1) */ wr_reg(0x20, y); wr_reg(0x21, x); #else wr_reg(0x50, x); /* Horizontal GRAM Start Address */ wr_reg(0x51, x+w-1); /* Horizontal GRAM End Address (-1) */ wr_reg(0x52, y); /* Vertical GRAM Start Address */ wr_reg(0x53, y+h-1); /* Vertical GRAM End Address (-1) */ wr_reg(0x20, x); wr_reg(0x21, y); #endif } } /******************************************************************************* * Set draw window region to whole screen * * Parameter: * * Return: * *******************************************************************************/ void GLCD_WindowMax (void) { GLCD_SetWindow (0, 0, WIDTH, HEIGHT); } /******************************************************************************* * Draw a pixel in foreground color * * Parameter: x: horizontal position * * y: vertical position * * Return: * *******************************************************************************/ void GLCD_PutPixel (unsigned int x, unsigned int y) { if (Himax) { wr_reg(0x02, x >> 8); /* Column address start MSB */ wr_reg(0x03, x & 0xFF); /* Column address start LSB */ wr_reg(0x04, x >> 8); /* Column address end MSB */ wr_reg(0x05, x & 0xFF); /* Column address end LSB */ wr_reg(0x06, y >> 8); /* Row address start MSB */ wr_reg(0x07, y & 0xFF); /* Row address start LSB */ wr_reg(0x08, y >> 8); /* Row address end MSB */ wr_reg(0x09, y & 0xFF); /* Row address end LSB */ } else { #if (LANDSCAPE == 1) wr_reg(0x20, y); wr_reg(0x21, x); #else wr_reg(0x20, x); wr_reg(0x21, y); #endif } wr_cmd(0x22); wr_dat(Color[TXT_COLOR]); } /******************************************************************************* * Set foreground color * * Parameter: color: foreground color * * Return: * *******************************************************************************/ void GLCD_SetTextColor (unsigned short color) { Color[TXT_COLOR] = color; } /******************************************************************************* * Set background color * * Parameter: color: background color * * Return: * *******************************************************************************/ void GLCD_SetBackColor (unsigned short color) { Color[BG_COLOR] = color; } /******************************************************************************* * Clear display * * Parameter: color: display clearing color * * Return: * *******************************************************************************/ void GLCD_Clear (unsigned short color) { unsigned int i; GLCD_WindowMax(); wr_cmd(0x22); wr_dat_start(); for(i = 0; i < (WIDTH*HEIGHT); i++) wr_dat_only(color); wr_dat_stop(); } /******************************************************************************* * Draw character on given position * * Parameter: x: horizontal position * * y: vertical position * * cw: character width in pixel * * ch: character height in pixels * * c: pointer to character bitmap * * Return: * *******************************************************************************/ void GLCD_DrawChar (unsigned int x, unsigned int y, unsigned int cw, unsigned int ch, unsigned char *c) { unsigned int i, j, k, pixs; GLCD_SetWindow(x, y, cw, ch); wr_cmd(0x22); wr_dat_start(); k = (cw + 7)/8; if (k == 1) { for (j = 0; j < ch; j++) { pixs = *(unsigned char *)c; c += 1; for (i = 0; i < cw; i++) { wr_dat_only (Color[(pixs >> i) & 1]); } } } else if (k == 2) { for (j = 0; j < ch; j++) { pixs = *(unsigned short *)c; c += 2; for (i = 0; i < cw; i++) { wr_dat_only (Color[(pixs >> i) & 1]); } } } wr_dat_stop(); } /******************************************************************************* * Disply character on given line * * Parameter: ln: line number * * col: column number * * fi: font index (0 = 6x8, 1 = 16x24) * * c: ascii character * * Return: * *******************************************************************************/ void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char fi, unsigned char c) { c -= 32; switch (fi) { case 0: /* Font 6 x 8 */ GLCD_DrawChar(col * 6, ln * 8, 6, 8, (unsigned char *)&Font_6x8_h [c * 8]); break; case 1: /* Font 16 x 24 */ GLCD_DrawChar(col * 16, ln * 24, 16, 24, (unsigned char *)&Font_16x24_h[c * 24]); break; } } /******************************************************************************* * Disply string on given line * * Parameter: ln: line number * * col: column number * * fi: font index (0 = 6x8, 1 = 16x24) * * s: pointer to string * * Return: * *******************************************************************************/ void GLCD_DisplayString (unsigned int ln, unsigned int col, unsigned char fi, unsigned char *s) { while (*s) { GLCD_DisplayChar(ln, col++, fi, *s++); } } /******************************************************************************* * Clear given line * * Parameter: ln: line number * * fi: font index (0 = 6x8, 1 = 16x24) * * Return: * *******************************************************************************/ void GLCD_ClearLn (unsigned int ln, unsigned char fi) { unsigned char i; unsigned char buf[60]; GLCD_WindowMax(); switch (fi) { case 0: /* Font 6 x 8 */ for (i = 0; i < (WIDTH+5)/6; i++) buf[i] = ' '; buf[i+1] = 0; break; case 1: /* Font 16 x 24 */ for (i = 0; i < (WIDTH+15)/16; i++) buf[i] = ' '; buf[i+1] = 0; break; } GLCD_DisplayString (ln, 0, fi, buf); } /******************************************************************************* * Draw bargraph * * Parameter: x: horizontal position * * y: vertical position * * w: maximum width of bargraph (in pixels) * * h: bargraph height * * val: value of active bargraph (in 1/1024) * * Return: * *******************************************************************************/ void GLCD_Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val) { int i,j; val = (val * w) >> 10; /* Scale value */ GLCD_SetWindow(x, y, w, h); wr_cmd(0x22); wr_dat_start(); for (i = 0; i < h; i++) { for (j = 0; j <= w-1; j++) { if(j >= val) { wr_dat_only(Color[BG_COLOR]); } else { wr_dat_only(Color[TXT_COLOR]); } } } wr_dat_stop(); } /******************************************************************************* * Display graphical bitmap image at position x horizontally and y vertically * * (This function is optimized for 16 bits per pixel format, it has to be * * adapted for any other bits per pixel format) * * Parameter: x: horizontal position * * y: vertical position * * w: width of bitmap * * h: height of bitmap * * bitmap: address at which the bitmap data resides * * Return: * *******************************************************************************/ void GLCD_Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap) { int i, j; unsigned short *bitmap_ptr = (unsigned short *)bitmap; GLCD_SetWindow (x, y, w, h); wr_cmd(0x22); wr_dat_start(); for (i = (h-1)*w; i > -1; i -= w) { for (j = 0; j < w; j++) { wr_dat_only (bitmap_ptr[i+j]); } } wr_dat_stop(); } /******************************************************************************* * Scroll content of the whole display for dy pixels vertically * * Parameter: dy: number of pixels for vertical scroll * * Return: * *******************************************************************************/ void GLCD_ScrollVertical (unsigned int dy) { #if (LANDSCAPE == 0) static unsigned int y = 0; y = y + dy; while (y >= HEIGHT) y -= HEIGHT; if (Himax) { wr_reg(0x01, 0x08); wr_reg(0x14, y>>8); /* VSP MSB */ wr_reg(0x15, y&0xFF); /* VSP LSB */ } else { wr_reg(0x6A, y); wr_reg(0x61, 3); } #endif } /******************************************************************************* * Write a command to the LCD controller * * Parameter: cmd: command to write to the LCD * * Return: * *******************************************************************************/ void GLCD_WrCmd (unsigned char cmd) { wr_cmd (cmd); } /******************************************************************************* * Write a value into LCD controller register * * Parameter: reg: lcd register address * * val: value to write into reg * * Return: * *******************************************************************************/ void GLCD_WrReg (unsigned char reg, unsigned short val) { wr_reg (reg, val); } /******************************************************************************/
[ "zwxwill@qq.com" ]
zwxwill@qq.com
45e84bd4e88d6f3a5db96c030b8c4abc4aedb445
d1abd2209bd8626fb0753efbb2a6a253f9d31d58
/clear_cache.c
1ca017cc89d13d58b8a1376f8a6ad85aef81f5fe
[]
no_license
hkumar43/estimate-l1-cache
adfbec0b43cdc173c5b25a0b716dde1d468f0721
60529ffbabbec3d9f0e7e6619c11bd6c57a03bd7
refs/heads/main
2023-07-10T09:47:47.899725
2021-08-30T18:33:36
2021-08-30T18:33:36
398,549,035
0
0
null
null
null
null
UTF-8
C
false
false
313
c
#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include<linux/slab.h> static int __init start_clear(void){ asm volatile ( "WBINVD\n\t" ); return 0; } static void __exit end_clear(void){ printk(KERN_INFO "CACHE CLEARED"); } module_init(start_clear); module_exit(end_clear);
[ "hemant.kr.dev@gmail.com" ]
hemant.kr.dev@gmail.com
11cde50b90107f0e2b5995bb4e34acbe2bf2358e
65f9576021285bc1f9e52cc21e2d49547ba77376
/adsp_proc/core/storage/tftp/common/inc/tftp_config_i.h
79c69c2bdf23cb1a605852d91055f4b13d9c2357
[]
no_license
AVCHD/qcs605_root_qcom
183d7a16e2f9fddc9df94df9532cbce661fbf6eb
44af08aa9a60c6ca724c8d7abf04af54d4136ccb
refs/heads/main
2023-03-18T21:54:11.234776
2021-02-26T11:03:59
2021-02-26T11:03:59
null
0
0
null
null
null
null
UTF-8
C
false
false
2,368
h
/*********************************************************************** * tftp_config_i.h * * Short description * Copyright (c) 2013-2014 Qualcomm Technologies, Inc. All Rights Reserved. * Qualcomm Technologies Proprietary and Confidential. * * Verbose description. * ***********************************************************************/ /*=========================================================================== EDIT HISTORY FOR MODULE This section contains comments describing changes made to the module. Notice that changes are listed in reverse chronological order. $Header: //components/rel/core.qdsp6/2.1/storage/tftp/common/inc/tftp_config_i.h#1 $ $DateTime: 2017/07/21 22:10:47 $ $Author: pwbldsvc $ when who what, where, why ---------- --- --------------------------------------------------------- 2014-01-05 rp In logs do not print full-paths just file-name portion. 2014-12-30 dks Fixes to config and log modules. 2014-07-28 rp Move log-buffer from global to stack. 2014-06-04 rp Switch to IPCRouter sockets. 2014-01-20 dks Configure message printing. 2013-12-05 nr Separate the socket type from the build flavour. 2013-11-14 rp Create ===========================================================================*/ #ifndef __TFTP_CONFIG_I_H__ #define __TFTP_CONFIG_I_H__ #include "tftp_config.h" #if defined (FEATURE_TFTP_SERVER_BUILD) #if defined (TFTP_LA_BUILD) #define TFTP_USE_IPCR_LA_SOCKETS #define TFTP_USE_POSIX_THREADS #define TFTP_SERVER_NO_FOLDER_ABSTRACTION #elif defined (TFTP_WINDOWS_BUILD) #define TFTP_USE_IPCR_WINDOWS_SOCKETS #define TFTP_USE_WINDOWS_THREADS #define TFTP_SERVER_NO_FOLDER_ABSTRACTION #elif defined (TFTP_NHLOS_BUILD) #define TFTP_USE_IPCR_MODEM_SOCKETS #define TFTP_USE_REX_THREADS #else #error "Server-build : unknown config" #endif #elif defined (FEATURE_TFTP_CLIENT_BUILD) #if defined (TFTP_NHLOS_BUILD) #define TFTP_USE_IPCR_MODEM_SOCKETS #define TFTP_USE_REX_THREADS #else #error "Client-build : unknown config" #endif #else #error "Configure build for either Client or Server" #endif #if defined (__FILENAME__) #define TFTP_SOURCE_FILE_NAME __FILENAME__ #else #define TFTP_SOURCE_FILE_NAME __FILE__ #endif #endif /* not __TFTP_CONFIG_I_H__ */
[ "jagadeshkumar.s@pathpartnertech.com" ]
jagadeshkumar.s@pathpartnertech.com
c104be1c37f865bcdd3ae533ae81a131f52b7e34
17ee514db94b7a1932e37073491e59c67114e4aa
/plugins/QGames/jpeg/jconfig.h
89c2cd483b4220a9432c08d7d56ee53b148036d7
[ "MIT" ]
permissive
joeriedel/Tread3.0A2
024ab01fbce9b33fb39d5987483dd740ed34aad7
9ce31695bd02f30f07464d18dbbfbf5d4d7fccf9
refs/heads/master
2023-03-15T15:30:05.499251
2023-03-04T04:01:11
2023-03-04T04:01:11
196,284,234
6
0
null
null
null
null
UTF-8
C
false
false
1,281
h
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ /* see jconfig.doc for explanations */ #define HAVE_PROTOTYPES #define HAVE_UNSIGNED_CHAR #define HAVE_UNSIGNED_SHORT /* #define void char */ /* #define const */ #undef CHAR_IS_UNSIGNED #define HAVE_STDDEF_H #define HAVE_STDLIB_H #undef NEED_BSD_STRINGS #undef NEED_SYS_TYPES_H #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ #undef NEED_SHORT_EXTERNAL_NAMES #undef INCOMPLETE_TYPES_BROKEN /* Define "jp_bool" as unsigned char, not int, per Windows custom */ typedef unsigned char jp_bool; #ifndef _MSC_VER #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #endif #ifdef JPEG_INTERNALS #undef RIGHT_SHIFT_IS_UNSIGNED #endif /* JPEG_INTERNALS */ #ifdef JPEG_CJPEG_DJPEG #define BMP_SUPPORTED /* BMP image file format */ #define GIF_SUPPORTED /* GIF image file format */ #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ #undef RLE_SUPPORTED /* Utah RLE image file format */ #define TARGA_SUPPORTED /* Targa image file format */ #define TWO_FILE_COMMANDLINE /* optional */ #undef USE_SETMODE /* Microsoft has setmode() */ #undef NEED_SIGNAL_CATCHER #undef DONT_USE_B_MODE #undef PROGRESS_REPORT /* optional */ #endif /* JPEG_CJPEG_DJPEG */
[ "joeriedel@hotmail.com" ]
joeriedel@hotmail.com
e923d0118caed8f77739c72b671ebad997688e37
f4dc3450a1cfedf352774cba95dc68b32cbfbf11
/Sources/Emulator/src/mess/machine/ecbbus.c
6fcdc78ff1f530cba0db4df372754544d30e752d
[]
no_license
Jaku2k/MAMEHub
ae85696aedf3f1709b98090c843c752d417874a9
faa98abc278cd52dd599584f7de5e2dd39cf6f87
refs/heads/master
2021-01-18T07:48:32.570205
2013-10-10T01:42:06
2013-10-10T01:42:06
null
0
0
null
null
null
null
UTF-8
C
false
false
6,693
c
/********************************************************************** Conitec Datensysteme ECB Bus emulation Copyright MESS Team. Visit http://mamedev.org for licensing and usage restrictions. **********************************************************************/ #include "ecbbus.h" //************************************************************************** // GLOBAL VARIABLES //************************************************************************** const device_type ECBBUS_SLOT = &device_creator<ecbbus_slot_device>; //************************************************************************** // LIVE DEVICE //************************************************************************** //------------------------------------------------- // ecbbus_slot_device - constructor //------------------------------------------------- ecbbus_slot_device::ecbbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, ECBBUS_SLOT, "ECB bus slot", tag, owner, clock), device_slot_interface(mconfig, *this) { } //------------------------------------------------- // static_set_ecbbus_slot - //------------------------------------------------- void ecbbus_slot_device::static_set_ecbbus_slot(device_t &device, const char *tag, int num) { ecbbus_slot_device &ecbbus_card = dynamic_cast<ecbbus_slot_device &>(device); ecbbus_card.m_bus_tag = tag; ecbbus_card.m_bus_num = num; } //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void ecbbus_slot_device::device_start() { m_bus = machine().device<ecbbus_device>(m_bus_tag); device_ecbbus_card_interface *dev = dynamic_cast<device_ecbbus_card_interface *>(get_card_device()); if (dev) m_bus->add_ecbbus_card(dev, m_bus_num); } //************************************************************************** // GLOBAL VARIABLES //************************************************************************** const device_type ECBBUS = &device_creator<ecbbus_device>; void ecbbus_device::static_set_cputag(device_t &device, const char *tag) { ecbbus_device &ecbbus = downcast<ecbbus_device &>(device); ecbbus.m_cputag = tag; } //------------------------------------------------- // device_config_complete - perform any // operations now that the configuration is // complete //------------------------------------------------- void ecbbus_device::device_config_complete() { // inherit a copy of the static data const ecbbus_interface *intf = reinterpret_cast<const ecbbus_interface *>(static_config()); if (intf != NULL) { *static_cast<ecbbus_interface *>(this) = *intf; } // or initialize to defaults if none provided else { memset(&m_out_int_cb, 0, sizeof(m_out_int_cb)); memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb)); } } //************************************************************************** // DEVICE ECBBUS CARD INTERFACE //************************************************************************** //------------------------------------------------- // device_ecbbus_card_interface - constructor //------------------------------------------------- device_ecbbus_card_interface::device_ecbbus_card_interface(const machine_config &mconfig, device_t &device) : device_slot_card_interface(mconfig, device) { m_slot = dynamic_cast<ecbbus_slot_device *>(device.owner()); } //------------------------------------------------- // ~device_ecbbus_card_interface - destructor //------------------------------------------------- device_ecbbus_card_interface::~device_ecbbus_card_interface() { } //************************************************************************** // LIVE DEVICE //************************************************************************** //------------------------------------------------- // ecbbus_device - constructor //------------------------------------------------- ecbbus_device::ecbbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, ECBBUS, "ECB bus", tag, owner, clock) { for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) m_ecbbus_device[i] = NULL; } //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void ecbbus_device::device_start() { m_maincpu = machine().device<cpu_device>(m_cputag); // resolve callbacks m_out_int_func.resolve(m_out_int_cb, *this); m_out_nmi_func.resolve(m_out_nmi_cb, *this); } //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- void ecbbus_device::device_reset() { } //------------------------------------------------- // add_ecbbus_card - add ECB bus card //------------------------------------------------- void ecbbus_device::add_ecbbus_card(device_ecbbus_card_interface *card, int pos) { m_ecbbus_device[pos] = card; } //------------------------------------------------- // mem_r - //------------------------------------------------- READ8_MEMBER( ecbbus_device::mem_r ) { UINT8 data = 0; for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) { if (m_ecbbus_device[i] != NULL) { data |= m_ecbbus_device[i]->ecbbus_mem_r(offset); } } return data; } //------------------------------------------------- // mem_w - //------------------------------------------------- WRITE8_MEMBER( ecbbus_device::mem_w ) { for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) { if (m_ecbbus_device[i] != NULL) { m_ecbbus_device[i]->ecbbus_mem_w(offset, data); } } } //------------------------------------------------- // io_r - //------------------------------------------------- READ8_MEMBER( ecbbus_device::io_r ) { UINT8 data = 0; for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) { if (m_ecbbus_device[i] != NULL) { data |= m_ecbbus_device[i]->ecbbus_io_r(offset); } } return data; } //------------------------------------------------- // io_w - //------------------------------------------------- WRITE8_MEMBER( ecbbus_device::io_w ) { for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) { if (m_ecbbus_device[i] != NULL) { m_ecbbus_device[i]->ecbbus_io_w(offset, data); } } } //------------------------------------------------- // int_w - //------------------------------------------------- WRITE_LINE_MEMBER( ecbbus_device::int_w ) { m_out_int_func(state); } //------------------------------------------------- // nmi_w - //------------------------------------------------- WRITE_LINE_MEMBER( ecbbus_device::nmi_w ) { m_out_nmi_func(state); }
[ "jgmath2000@gmail.com" ]
jgmath2000@gmail.com
44207efa1f272b306b9f0a210295e2b556389d9b
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/reactos/base/services/dhcpcsvc/dhcp/extr_options.c_pretty_print_option.c
4f18a8356d7e200f69e9f7b4fbf6e83a4835b0d0
[]
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
6,453
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 in_addr {int /*<<< orphan*/ s_addr; } ; typedef int /*<<< orphan*/ optbuf ; struct TYPE_2__ {char* format; int /*<<< orphan*/ name; } ; /* Variables and functions */ char ANSI_NULL ; int _snprintf (char*,int,char*,char) ; TYPE_1__* dhcp_options ; int /*<<< orphan*/ error (char*,unsigned int) ; scalar_t__ getLong (unsigned char*) ; char getShort (unsigned char*) ; scalar_t__ getULong (unsigned char*) ; char getUShort (unsigned char*) ; int /*<<< orphan*/ htonl (scalar_t__) ; char* inet_ntoa (struct in_addr) ; int /*<<< orphan*/ isascii (unsigned char) ; int /*<<< orphan*/ isprint (unsigned char) ; int strlen (char*) ; int /*<<< orphan*/ strncpy (char*,char*,int) ; int /*<<< orphan*/ warning (char*,...) ; char * pretty_print_option(unsigned int code, unsigned char *data, int len, int emit_commas, int emit_quotes) { static char optbuf[32768]; /* XXX */ int hunksize = 0, numhunk = -1, numelem = 0; char fmtbuf[32], *op = optbuf; int i, j, k, opleft = sizeof(optbuf); unsigned char *dp = data; struct in_addr foo; char comma; /* Code should be between 0 and 255. */ if (code > 255) error("pretty_print_option: bad code %d", code); if (emit_commas) comma = ','; else comma = ' '; /* Figure out the size of the data. */ for (i = 0; dhcp_options[code].format[i]; i++) { if (!numhunk) { warning("%s: Excess information in format string: %s", dhcp_options[code].name, &(dhcp_options[code].format[i])); break; } numelem++; fmtbuf[i] = dhcp_options[code].format[i]; switch (dhcp_options[code].format[i]) { case 'A': --numelem; fmtbuf[i] = 0; numhunk = 0; break; case 'X': for (k = 0; k < len; k++) if (!isascii(data[k]) || !isprint(data[k])) break; if (k == len) { fmtbuf[i] = 't'; numhunk = -2; } else { fmtbuf[i] = 'x'; hunksize++; comma = ':'; numhunk = 0; } fmtbuf[i + 1] = 0; break; case 't': fmtbuf[i] = 't'; fmtbuf[i + 1] = 0; numhunk = -2; break; case 'I': case 'l': case 'L': hunksize += 4; break; case 's': case 'S': hunksize += 2; break; case 'b': case 'B': case 'f': hunksize++; break; case 'e': break; default: warning("%s: garbage in format string: %s", dhcp_options[code].name, &(dhcp_options[code].format[i])); break; } } /* Check for too few bytes... */ if (hunksize > len) { warning("%s: expecting at least %d bytes; got %d", dhcp_options[code].name, hunksize, len); return ("<error>"); } /* Check for too many bytes... */ if (numhunk == -1 && hunksize < len) warning("%s: %d extra bytes", dhcp_options[code].name, len - hunksize); /* If this is an array, compute its size. */ if (!numhunk) numhunk = len / hunksize; /* See if we got an exact number of hunks. */ if (numhunk > 0 && numhunk * hunksize < len) warning("%s: %d extra bytes at end of array", dhcp_options[code].name, len - numhunk * hunksize); /* A one-hunk array prints the same as a single hunk. */ if (numhunk < 0) numhunk = 1; /* Cycle through the array (or hunk) printing the data. */ for (i = 0; i < numhunk; i++) { for (j = 0; j < numelem; j++) { int opcount; switch (fmtbuf[j]) { case 't': if (emit_quotes) { *op++ = '"'; opleft--; } for (; dp < data + len; dp++) { if (!isascii(*dp) || !isprint(*dp)) { if (dp + 1 != data + len || *dp != 0) { _snprintf(op, opleft, "\\%03o", *dp); op += 4; opleft -= 4; } } else if (*dp == '"' || *dp == '\'' || *dp == '$' || *dp == '`' || *dp == '\\') { *op++ = '\\'; *op++ = *dp; opleft -= 2; } else { *op++ = *dp; opleft--; } } if (emit_quotes) { *op++ = '"'; opleft--; } *op = 0; break; case 'I': foo.s_addr = htonl(getULong(dp)); strncpy(op, inet_ntoa(foo), opleft - 1); op[opleft - 1] = ANSI_NULL; opcount = strlen(op); if (opcount >= opleft) goto toobig; opleft -= opcount; dp += 4; break; case 'l': opcount = _snprintf(op, opleft, "%ld", (long)getLong(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 4; break; case 'L': opcount = _snprintf(op, opleft, "%ld", (unsigned long)getULong(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 4; break; case 's': opcount = _snprintf(op, opleft, "%d", getShort(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 2; break; case 'S': opcount = _snprintf(op, opleft, "%d", getUShort(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 2; break; case 'b': opcount = _snprintf(op, opleft, "%d", *(char *)dp++); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; break; case 'B': opcount = _snprintf(op, opleft, "%d", *dp++); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; break; case 'x': opcount = _snprintf(op, opleft, "%x", *dp++); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; break; case 'f': opcount = (size_t) strncpy(op, *dp++ ? "true" : "false", opleft - 1); op[opleft - 1] = ANSI_NULL; if (opcount >= opleft) goto toobig; opleft -= opcount; break; default: warning("Unexpected format code %c", fmtbuf[j]); } op += strlen(op); opleft -= strlen(op); if (opleft < 1) goto toobig; if (j + 1 < numelem && comma != ':') { *op++ = ' '; opleft--; } } if (i + 1 < numhunk) { *op++ = comma; opleft--; } if (opleft < 1) goto toobig; } return (optbuf); toobig: warning("dhcp option too large"); return ("<error>"); }
[ "brenocfg@gmail.com" ]
brenocfg@gmail.com
fd50ecf5d6d0bec0c640938fc848235e2844e5a8
05e39c1c07a7aa03c3328ac53cd419efa8828c51
/Code/cube/i2c.h
16737a62241b80e5238a5f2732d13a10ea6097a1
[]
no_license
ikbenali/CubeSat
baa0631772bb8709c2674040fedc32d1a07ebbca
ce08c42ff3f57b65926b896a6c077e6e0cf48bdf
refs/heads/master
2021-01-22T06:28:31.199242
2017-02-13T13:23:04
2017-02-13T13:23:04
81,766,618
2
0
null
null
null
null
UTF-8
C
false
false
1,350
h
#include <avr/io.h> #include <util/delay.h> #define TWI_BAUD(F_SYS, F_TWI) ((F_SYS / (2 * F_TWI)) - 5) #define I2C_ACK 0 #define I2C_NACK 1 #define I2C_READ 1 #define I2C_WRITE 0 #define I2C_STATUS_OK 0 #define I2C_STATUS_BUSY 1 #define I2C_STATUS_NO_ACK 2 void i2c_init(TWI_t *twi, uint8_t baudRateRegisterSetting); uint8_t i2c_start(TWI_t *twi, uint8_t address, uint8_t rw); uint8_t i2c_restart(TWI_t *twi, uint8_t address, uint8_t rw); void i2c_stop(TWI_t *twi); uint8_t i2c_write(TWI_t *twi, uint8_t data); uint8_t i2c_read(TWI_t *twi, uint8_t ack); int8_t mpu6050_readBytes(uint8_t regDevice, uint8_t regAddr, uint8_t length, uint8_t *data); int8_t mpu6050_readByte(uint8_t regDevice, uint8_t regAddr, uint8_t *data); void mpu6050_writeBytes(uint8_t regDevice, uint8_t regAddr, uint8_t length, uint8_t* data); void mpu6050_writeByte(uint8_t regDevice, uint8_t regAddr, uint8_t data); int8_t mpu6050_readBits(uint8_t regDevice, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); int8_t mpu6050_readBit(uint8_t regDevice, uint8_t regAddr, uint8_t bitNum, uint8_t *data); void mpu6050_writeBits(uint8_t regDevice, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); void mpu6050_writeBit(uint8_t regDevice, uint8_t regAddr, uint8_t bitNum, uint8_t data);
[ "aliulhaq@outlook.com" ]
aliulhaq@outlook.com
fd97ff5f63671d97fcb124723bdf077f0581bb90
c4afbfe1885e8d0c7a1c8b928563f7bb8ab6a683
/GreenDemonstrator/MEN_demonstrator_stubs/KCG-MEN-train/CAST_M_ERROR_to_int_TM_conversions.c
8d5f47ee7ee9ec1b312f71f327ac4ec0f4e2dc07
[]
no_license
VladislavLasmann/srcAndBinary
cd48ebaa2f1f7f697ba5df9f38abb9ed50658e10
13aa76e545b9596f6dac84fb20480dffae7584d8
refs/heads/master
2021-05-08T15:04:05.709079
2016-01-22T12:40:10
2016-01-22T12:40:10
null
0
0
null
null
null
null
UTF-8
C
false
false
4,581
c
/* $*************** KCG Version 6.1.3 (build i6) **************** ** Command: s2c613 -config C:/GITHUB/modeling/model/Scade/System/MEN_demonstrator/KCG-MEN\kcg_s2c_config.txt ** Generation date: 2015-10-19T14:37:59 *************************************************************$ */ #include "kcg_consts.h" #include "kcg_sensors.h" #include "CAST_M_ERROR_to_int_TM_conversions.h" /* TM_conversions::CAST_M_ERROR_to_int */ kcg_int CAST_M_ERROR_to_int_TM_conversions( /* TM_conversions::CAST_M_ERROR_to_int::m_error */M_ERROR m_error) { /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else */ kcg_bool _7_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else::else */ kcg_bool _5_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else::else::else::else */ kcg_bool _3_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else::else::else::else::else::else */ kcg_bool _1_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else::else::else::else::else::else::else */ kcg_bool else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else::else::else::else::else */ kcg_bool _2_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else::else::else */ kcg_bool _4_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1::else::else */ kcg_bool _6_else_clock_IfBlock1; /* TM_conversions::CAST_M_ERROR_to_int::IfBlock1 */ kcg_bool IfBlock1_clock; /* TM_conversions::CAST_M_ERROR_to_int::m_error_int */ kcg_int m_error_int; IfBlock1_clock = m_error == ENUM_M_ERROR_balise_group_linking_conistency_TM_conversions; if (IfBlock1_clock) { m_error_int = INT_M_ERROR_balise_group_linking_conistency_TM_conversions; } else { _7_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Double_linking_error_TM_conversions; if (_7_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Double_linking_error_TM_conversions; } else { _6_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Double_repositioning_error_TM_conversions; if (_6_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Double_repositioning_error_TM_conversions; } else { _5_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Linked_balise_group_message_consistency_erro_TM_conversions; if (_5_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Linked_balise_group_message_consistency_error_TM_conversions; } else { _4_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Radio_message_consistency_error_TM_conversions; if (_4_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Radio_message_consistency_error_TM_conversions; } else { _3_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Radio_safe_radio_connection_error_TM_conversions; if (_3_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Radio_safe_radio_connection_error_TM_conversions; } else { _2_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Radio_sequence_error_TM_conversions; if (_2_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Radio_sequence_error_TM_conversions; } else { _1_else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Safety_critical_failure_TM_conversions; if (_1_else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Safety_critical_failure_TM_conversions; } else { else_clock_IfBlock1 = m_error == ENUM_M_ERROR_Unlinked_balise_group_message_consistency_error_TM_conversions; if (else_clock_IfBlock1) { m_error_int = INT_M_ERROR_Unlinked_balise_group_message_consistency_error_TM_conversions; } else { m_error_int = INT_M_ERROR_Safety_critical_failure_TM_conversions; } } } } } } } } } return m_error_int; } /* $*************** KCG Version 6.1.3 (build i6) **************** ** CAST_M_ERROR_to_int_TM_conversions.c ** Generation date: 2015-10-19T14:37:59 *************************************************************$ */
[ "info@stefankarg-it.de" ]
info@stefankarg-it.de
30dd3f844560a1ed2b4abe2d3936ca9592a22ddd
e2e8d3c97155003038ea55fcb7f0247438b8aff9
/C语言学习17/2/queue.h
edb8097835f44dcde7f9109bc05e225c710e3ee8
[]
no_license
Hyuga-Hinata/C-learning
a5f62bdfa585ee815e71ab0c0ce7f34f26faa44d
e91311e3dd5870e7a5ca93f1c27cef2c3af33141
refs/heads/master
2021-05-06T06:01:27.276058
2018-03-31T16:49:49
2018-03-31T16:49:49
115,264,606
0
0
null
null
null
null
GB18030
C
false
false
2,300
h
//队列接口 #pragma c9x on #ifndef _QUEUE_H_ #define _QUEUE_H_ #include<stdbool.h> //在此处插入Item的类型定义 //例如 typedef int Item; //或: typedef struct item{int gumption;int charisma; } Item; #define MAXQUEUE 10 typedef struct node { Item item; struct node * next; }Node; typedef struct queue { Node * front; //指向队列首的指针 Node * rear; //指向队列尾的指针 int items; //队列中项目的个数 }Queue; //操作: 初始化队列 //操作前:pq指向一个队列 //操作后:该队列被初始化为空队列 void InitializeQueue(Queue * pq); //操作: 初始化队列 //操作前: pq指向一个队列 //操作后:该队列被初始化为空队列 void InitializeQueue(Queue * pq); //操作: 检查队列是否已满 //操作前:pq指向一个先前已初始化过的队列 //操作后:如果该队列已满,则返回True;否则返回False bool QueueIsFull(const Queue * pq); //操作:检查队列是否为空 //操作前:pq指向一个先前已初始化过的队列 //操作后:如果该队列为空,则返回True;否则返回False bool QueueIsEmpty(const Queue *pq); //操作:确定队列中项目的个数 //操作前:pq指向一个先前已初始化过的队列 //操作后:返回队列中项目的个数 int QueueItemCount(const Queue * pq); //操作:向队列尾端添加项目 //操作前:pq指向一个先前已初始化过的队列 // item是要添加到队列尾端的项目 //操作后:如果队列未满,item被添加到 // 队列尾部,函数返回True;否则, // 不改变队列,函数返回False bool EnQueue(Item item,Queue * pq); //操作: 从队列首端删除项目 //操作前: pq指向一个先前已初始化过的队列 //操作后:如果队列非空,队列首端的项目 // 被复制到*pitem,并被从队列中删除, // 函数返回值True;如果这个操作 // 使队列为空,把队列重置为空队列 // 如果队列开始时为空, // 不改变队列,函数返回False bool DeQueue(Item *pitem,Queue * pq); //操作: 清空队列 //操作前:pq指向一个先前已初始化过的队列 //操作后:队列被清空 void EmptyTheQueue(Queue * pq); #endif
[ "1159902606@qq.com" ]
1159902606@qq.com
4411d4ba2f90b7ca6d4d07da663dfad4b51b5393
7d792544345c3c20cf9c63674ad79a4eab10e895
/src/sbbs3/sbbsexec.c
862497054273a56a3167265a48ff97c7195fbdd0
[ "Artistic-2.0" ]
permissive
mattzorzin/synchronet
5d7dfddb8b067daa202e54f53e932a29eb02847e
b975055ea71a337a1bd63dd128995016f482c689
refs/heads/master
2021-01-11T01:33:28.835494
2014-09-19T02:40:49
2014-09-19T02:40:49
24,213,567
1
1
null
null
null
null
UTF-8
C
false
false
21,263
c
/* sbbsexec.c */ /* Synchronet Windows NT/2000 VDD for FOSSIL and DOS I/O Interrupts */ /* $Id: sbbsexec.c,v 1.40 2011/12/06 20:49:20 rswindell Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * See the GNU General Public License for more details: gpl.txt or * * http://www.fsf.org/copyleft/gpl.html * * * * Anonymous FTP access to the most recent released source is available at * * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * * * * Anonymous CVS access to the development source and modification history * * is available at cvs.synchro.net:/cvsroot/sbbs, example: * * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login * * (just hit return, no password is necessary) * * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src * * * * For Synchronet coding style and modification guidelines, see * * http://www.synchro.net/source.html * * * * You are encouraged to submit any modifications (preferably in Unix diff * * format) via e-mail to mods@synchro.net * * * * Note: If this box doesn't appear square, then you need to fix your tabs. * ****************************************************************************/ #include <windows.h> #include <stdio.h> #include <vddsvc.h> #include "uartdefs.h" #include "vdd_func.h" #include "ringbuf.h" #include "genwrap.h" #include "dirwrap.h" #include "threadwrap.h" #include "ini_file.h" #define INI_FILENAME "sbbsexec.ini" #define RINGBUF_SIZE_IN 10000 #define DEFAULT_MAX_MSG_SIZE 4000 #define LINEAR_RX_BUFLEN 10000 /* UART Parameters and virtual registers */ WORD uart_io_base = UART_COM1_IO_BASE; /* COM1 */ BYTE uart_irq = UART_COM1_IRQ; BYTE uart_ier_reg = 0; BYTE uart_lcr_reg = UART_LCR_8_DATA_BITS; BYTE uart_mcr_reg = UART_MCR_RTS | UART_MCR_DTR; BYTE uart_lsr_reg = UART_LSR_EMPTY_DATA | UART_LSR_EMPTY_XMIT; BYTE uart_msr_reg = UART_MSR_CTS | UART_MSR_DSR; BYTE uart_scratch_reg = 0; BYTE uart_divisor_latch_lsb = 0x03; /* 38400 */ BYTE uart_divisor_latch_msb = 0x00; #if defined (_DEBUG) int log_level = LOG_DEBUG; #else int log_level = LOG_WARNING; #endif BOOL virtualize_uart=TRUE; double yield_interval=1.0; BOOL hangup_supported=TRUE; HANDLE hangup_event=NULL; HANDLE hungup_event=NULL; HANDLE interrupt_event=NULL; HANDLE rdslot=INVALID_HANDLE_VALUE; HANDLE wrslot=INVALID_HANDLE_VALUE; RingBuf rdbuf; str_list_t ini; char ini_fname[MAX_PATH+1]; char revision[16]; void lputs(int level, char* msg) { char buf[1024]; if(level > log_level) return; SAFEPRINTF(buf,"SBBS: %s\r\n", msg); OutputDebugString(buf); } static void lprintf(int level, const char *fmt, ...) { char sbuf[1024]; va_list argptr; if(level > log_level) return; va_start(argptr,fmt); _vsnprintf(sbuf,sizeof(sbuf),fmt,argptr); sbuf[sizeof(sbuf)-1]=0; va_end(argptr); lputs(level,sbuf); } void hangup() { if(hangup_supported && hangup_event!=NULL) { lprintf(LOG_DEBUG,"Hanging-up at application request"); SetEvent(hangup_event); } } void parse_ini(char* program) { char section[MAX_PATH+1]; if(ini==NULL) /* no initialization file */ return; /* Read the root section of the sbbsexec.ini file */ log_level=iniGetLogLevel(ini,program,"LogLevel",log_level); if(iniGetBool(ini,program,"Debug",FALSE)) log_level=LOG_DEBUG; yield_interval=iniGetFloat(ini,program,"YieldInterval",yield_interval); hangup_supported=iniGetBool(ini,program,"CanDisconnect",hangup_supported); lprintf(LOG_INFO,"Parsed %s section of %s" ,program==ROOT_SECTION ? "root" : program ,ini_fname); /* [UART] section */ if(program==ROOT_SECTION) SAFECOPY(section,"UART"); else SAFEPRINTF(section,"%s.UART",program); virtualize_uart=iniGetBool(ini,section,"Virtualize",virtualize_uart); switch(iniGetInteger(ini,section,"ComPort",0)) { case 1: /* COM1 */ uart_irq =UART_COM1_IRQ; uart_io_base =UART_COM1_IO_BASE; break; case 2: /* COM2 */ uart_irq =UART_COM2_IRQ; uart_io_base =UART_COM2_IO_BASE; break; case 3: /* COM3 */ uart_irq =UART_COM3_IRQ; uart_io_base =UART_COM3_IO_BASE; break; case 4: /* COM4 */ uart_irq =UART_COM4_IRQ; uart_io_base =UART_COM4_IO_BASE; break; } uart_irq=(BYTE)iniGetShortInt(ini,section,"IRQ",uart_irq); uart_io_base=iniGetShortInt(ini,section,"Address",uart_io_base); lprintf(LOG_INFO,"Parsed %s section of %s" ,section ,ini_fname); } /* Mutex-protected pending interrupt "queue" */ int pending_interrupts = 0; CRITICAL_SECTION interrupt_mutex; void set_interrupt_pending(BYTE intr, BOOL assert) { EnterCriticalSection(&interrupt_mutex); lprintf(LOG_DEBUG,"%sasserting interrupt %02X (pending: %02X, IER: %02X)" ,assert ? "" : "de-", intr ,pending_interrupts ,uart_ier_reg); if(assert) { if(uart_ier_reg&intr) { /* is interrupt enabled? */ pending_interrupts |= intr; /* flag as pending */ SetEvent(interrupt_event); } } else /* de-assert */ pending_interrupts &= ~intr; /* remove as pending */ LeaveCriticalSection(&interrupt_mutex); } #define assert_interrupt(i) set_interrupt_pending(i, TRUE) #define deassert_interrupt(i) set_interrupt_pending(i, FALSE) void _cdecl interrupt_thread(void *arg) { while(1) { if(WaitForSingleObject(interrupt_event,INFINITE)!=WAIT_OBJECT_0) break; if((uart_ier_reg&pending_interrupts) != 0) { lprintf(LOG_DEBUG,"VDDSimulateInterrupt (pending: %02X) - IER: %02X" ,pending_interrupts, uart_ier_reg); VDDSimulateInterrupt(ICA_MASTER, uart_irq, /* count: */1); } #if 0 /* "Real 16550s should always reassert * this interrupt whenever the transmitter is idle and * the interrupt is enabled." */ if(pending_interrupts==0 && uart_ier_reg&UART_IER_TX_EMPTY) pending_interrupts|=UART_IER_TX_EMPTY; #endif } } void _cdecl input_thread(void* arg) { char buf[LINEAR_RX_BUFLEN]; int count; lprintf(LOG_DEBUG,"input_thread: started"); while(1) { count=RingBufFree(&rdbuf); if(count<1) { lprintf(LOG_WARNING,"input_thread: input buffer full!"); YIELD(); continue; } if(count>sizeof(buf)) count=sizeof(buf); if(!ReadFile(rdslot,buf,count,&count,NULL)) { if(GetLastError()==ERROR_HANDLE_EOF) { /* closed by VDD_CLOSE */ lprintf(LOG_INFO,"input_thread: ReadFile returned EOF"); break; } lprintf(LOG_ERR,"!input_thread: ReadFile Error %d (size=%d)" ,GetLastError(),count); continue; } if(count==0) { lprintf(LOG_ERR,"!input_thread: ReadFile read 0"); continue; } RingBufWrite(&rdbuf,buf,count); if(virtualize_uart) { /* Set the "Data ready" bit in the LSR */ uart_lsr_reg |= UART_LSR_DATA_READY; assert_interrupt(UART_IER_RX_DATA); /* assert rx data interrupt */ } } lprintf(LOG_DEBUG,"input_thread: terminated"); } unsigned vdd_read(BYTE* p, unsigned count) { sem_wait(rdbuf.sem); count=RingBufRead(&rdbuf,p,count); if(count==0) lprintf(LOG_ERR,"!VDD_READ: RingBufRead read 0"); return(count); } unsigned yields=0; void yield() { yields++; lprintf(LOG_DEBUG,"Yielding (yields=%u)", yields); Sleep(1); } long double last_yield=0; void maybe_yield() { long double t; t=xp_timer(); if(yield_interval && (t-last_yield)*1000.0 >= yield_interval) { yield(); last_yield=t; } } void reset_yield() { last_yield=xp_timer(); } /***********************/ /* UART Virtualization */ /***********************/ static char *chr(uchar ch) { static char str[25]; if(ch>=' ' && ch<='~') sprintf(str,"'%c' (%02Xh)",ch,ch); else if(ch<' ') sprintf(str,"^%c (%02Xh)",'@'+ch,ch); else sprintf(str,"%u (%02Xh)",ch,ch); return(str); } VOID uart_wrport(WORD port, BYTE data) { int reg = port - uart_io_base; int retval; lprintf(LOG_DEBUG,"write of port: %x (%s) <- %02X", port, uart_reg_desc[reg], data); switch(reg) { case UART_BASE: if(uart_lcr_reg&UART_LCR_DLAB) { uart_divisor_latch_lsb = data; lprintf(LOG_DEBUG,"set divisor latch low byte: %02X", data); } else { lprintf(LOG_DEBUG,"WRITE DATA: %s", chr(data)); if(!WriteFile(wrslot,&data,sizeof(BYTE),&retval,NULL)) { lprintf(LOG_ERR,"!VDD_WRITE: WriteFile Error %d (size=%d)" ,GetLastError(),retval); } else { assert_interrupt(UART_IER_TX_EMPTY); reset_yield(); } } break; case UART_IER: if(uart_lcr_reg&UART_LCR_DLAB) { uart_divisor_latch_msb = data; lprintf(LOG_DEBUG,"set divisor latch high byte: %02X", data); } else uart_ier_reg = data; assert_interrupt(UART_IER_TX_EMPTY); /* should this be re-asserted for all writes? */ break; case UART_IIR: /* FCR not supported */ break; case UART_LCR: uart_lcr_reg = data; break; case UART_MCR: uart_mcr_reg = data; if((uart_mcr_reg&UART_MCR_DTR) == 0) /* Dropping DTR (i.e. "hangup") */ hangup(); break; case UART_SCRATCH: uart_scratch_reg = data; break; default: lprintf(LOG_ERR,"UNSUPPORTED register: %u", reg); break; } } VOID uart_rdport(WORD port, PBYTE data) { int reg = port - uart_io_base; DWORD avail; lprintf(LOG_DEBUG,"read of port: %x (%s)", port, uart_reg_desc[reg]); switch(reg) { case UART_BASE: if(uart_lcr_reg&UART_LCR_DLAB) { lprintf(LOG_DEBUG,"reading divisor latch LSB"); *data = uart_divisor_latch_lsb; break; } if((avail=RingBufFull(&rdbuf))!=0) { vdd_read(data,sizeof(BYTE)); lprintf(LOG_DEBUG,"READ DATA: %s", chr(*data)); avail--; reset_yield(); } else *data=0; if(avail==0) { lprintf(LOG_DEBUG,"No more data"); /* Clear the data ready bit in the LSR */ uart_lsr_reg &= ~UART_LSR_DATA_READY; /* Clear data ready interrupt identification in IIR */ deassert_interrupt(UART_IER_RX_DATA); } else /* re-assert RX data (increment the semaphore) */ assert_interrupt(UART_IER_RX_DATA); break; case UART_IER: if(uart_lcr_reg&UART_LCR_DLAB) { lprintf(LOG_DEBUG,"reading divisor latch MSB"); *data = uart_divisor_latch_msb; } else *data = uart_ier_reg; break; case UART_IIR: /* Report IIR based on *priority* of pending interrupts */ if(pending_interrupts & UART_IER_LINE_STATUS) *data = UART_IIR_LINE_STATUS; else if(pending_interrupts & UART_IER_RX_DATA) *data = UART_IIR_RX_DATA; else if(pending_interrupts & UART_IER_TX_EMPTY) { *data = UART_IIR_TX_EMPTY; /* "Transmit Holding Register Empty" interrupt */ /* is reset on read of IIR */ deassert_interrupt(UART_IER_TX_EMPTY); } else if(pending_interrupts & UART_IER_MODEM_STATUS) *data = UART_IIR_MODEM_STATUS; else *data = UART_IIR_NONE; break; case UART_LCR: *data = uart_lcr_reg; break; case UART_MCR: *data = uart_mcr_reg; break; case UART_LSR: *data = uart_lsr_reg; maybe_yield(); /* Clear line status interrupt pending */ deassert_interrupt(UART_IER_LINE_STATUS); break; case UART_MSR: if(WaitForSingleObject(hungup_event,0)==WAIT_OBJECT_0) uart_msr_reg &=~ UART_MSR_DCD; else uart_msr_reg |= UART_MSR_DCD; *data = uart_msr_reg; maybe_yield(); /* Clear modem status interrupt pending */ deassert_interrupt(UART_IER_MODEM_STATUS); break; case UART_SCRATCH: *data = uart_scratch_reg; break; default: lprintf(LOG_ERR,"UNSUPPORTED register: %u", reg); break; } if(reg!=UART_BASE) lprintf(LOG_DEBUG, "returning 0x%02X", *data); } /* VDD DOS Interface (mainly for FOSSIL driver in dosxtrn.exe) */ __declspec(dllexport) void __cdecl VDDDispatch(void) { char str[512]; DWORD count; DWORD msgs; int retval; int node_num; BYTE* p; vdd_status_t* status; static DWORD writes; static DWORD bytes_written; static DWORD reads; static DWORD bytes_read; static DWORD inbuf_poll; static DWORD online_poll; static DWORD status_poll; static DWORD vdd_yields; static DWORD vdd_calls; VDD_IO_HANDLERS IOHandlers = { NULL }; static VDD_IO_PORTRANGE PortRange; retval=0; node_num=getBH(); lprintf(LOG_DEBUG,"VDD_OP: (handle=%d) %d (arg=%X)", getAX(),getBL(),getCX()); vdd_calls++; switch(getBL()) { case VDD_OPEN: sscanf("$Revision: 1.40 $", "%*s %s", revision); lprintf(LOG_INFO,"Synchronet Virtual Device Driver, rev %s %s %s" ,revision, __DATE__, __TIME__); #if 0 sprintf(str,"sbbsexec%d.log",node_num); fp=fopen(str,"wb"); #endif sprintf(str,"\\\\.\\mailslot\\sbbsexec\\wr%d",node_num); rdslot=CreateMailslot(str ,0 //LINEAR_RX_BUFLEN /* Max message size (0=any) */ ,MAILSLOT_WAIT_FOREVER /* Read timeout */ ,NULL); if(rdslot==INVALID_HANDLE_VALUE) { lprintf(LOG_ERR,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); retval=1; break; } sprintf(str,"\\\\.\\mailslot\\sbbsexec\\rd%d",node_num); wrslot=CreateFile(str ,GENERIC_WRITE ,FILE_SHARE_READ ,NULL ,OPEN_EXISTING ,FILE_ATTRIBUTE_NORMAL ,(HANDLE) NULL); if(wrslot==INVALID_HANDLE_VALUE) { lprintf(LOG_ERR,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); retval=2; break; } if(RingBufInit(&rdbuf, RINGBUF_SIZE_IN)!=0) { retval=3; break; } sprintf(str,"sbbsexec_hungup%d",node_num); hungup_event=OpenEvent( EVENT_ALL_ACCESS, /* access flag */ FALSE, /* inherit flag */ str); /* pointer to event-object name */ if(hungup_event==NULL) { lprintf(LOG_ERR,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); retval=4; break; } sprintf(str,"sbbsexec_hangup%d",node_num); hangup_event=OpenEvent( EVENT_ALL_ACCESS, /* access flag */ FALSE, /* inherit flag */ str); /* pointer to event-object name */ if(hangup_event==NULL) { lprintf(LOG_WARNING,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); } status_poll=0; inbuf_poll=0; online_poll=0; yields=0; lprintf(LOG_INFO,"Yield interval: %f milliseconds", yield_interval); if(virtualize_uart) { lprintf(LOG_INFO,"Virtualizing UART (0x%x, IRQ %u)" ,uart_io_base, uart_irq); IOHandlers.inb_handler = uart_rdport; IOHandlers.outb_handler = uart_wrport; PortRange.First=uart_io_base; PortRange.Last=uart_io_base + UART_IO_RANGE; VDDInstallIOHook((HANDLE)getAX(), 1, &PortRange, &IOHandlers); interrupt_event=CreateEvent(NULL,FALSE,FALSE,NULL); InitializeCriticalSection(&interrupt_mutex); _beginthread(interrupt_thread, 0, NULL); } lprintf(LOG_DEBUG,"VDD_OPEN: Opened successfully (wrslot=%p)", wrslot); _beginthread(input_thread, 0, NULL); retval=0; break; case VDD_CLOSE: lprintf(LOG_INFO,"VDD_CLOSE: rdbuf=%u " "status_poll=%u inbuf_poll=%u online_poll=%u yields=%u vdd_yields=%u vdd_calls=%u" ,RingBufFull(&rdbuf),status_poll,inbuf_poll,online_poll ,yields,vdd_yields,vdd_calls); lprintf(LOG_INFO," read=%u bytes (in %u calls)",bytes_read,reads); lprintf(LOG_INFO," wrote=%u bytes (in %u calls)",bytes_written,writes); if(virtualize_uart) { lprintf(LOG_INFO,"Uninstalling Virtualizaed UART IO Hook"); VDDDeInstallIOHook((HANDLE)getAX(), 1, &PortRange); } CloseHandle(rdslot); CloseHandle(wrslot); if(hungup_event!=NULL) CloseHandle(hungup_event); if(hangup_event!=NULL) CloseHandle(hangup_event); #if 0 /* This isn't strictly necessary... and possibly the cause of a NULL dereference in the input_thread */ RingBufDispose(&rdbuf); #endif status_poll=0; retval=0; break; case VDD_READ: count = getCX(); if(count != 1) lprintf(LOG_DEBUG,"VDD_READ of %d",count); p = (BYTE*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); retval=vdd_read(p, count); reads++; bytes_read+=retval; reset_yield(); break; case VDD_PEEK: count = getCX(); if(count != 1) lprintf(LOG_DEBUG,"VDD_PEEK of %d",count); p = (BYTE*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); retval=RingBufPeek(&rdbuf,p,count); reset_yield(); break; case VDD_WRITE: count = getCX(); if(count != 1) lprintf(LOG_DEBUG,"VDD_WRITE of %d",count); p = (BYTE*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); if(!WriteFile(wrslot,p,count,&retval,NULL)) { lprintf(LOG_ERR,"!VDD_WRITE: WriteFile Error %d (size=%d)" ,GetLastError(),retval); retval=0; } else { writes++; bytes_written+=retval; reset_yield(); } break; case VDD_STATUS: status_poll++; count = getCX(); if(count != sizeof(vdd_status_t)) { lprintf(LOG_DEBUG,"!VDD_STATUS: wrong size (%d!=%d)",count,sizeof(vdd_status_t)); retval=sizeof(vdd_status_t); break; } status = (vdd_status_t*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); status->inbuf_size=RINGBUF_SIZE_IN; status->inbuf_full=RingBufFull(&rdbuf); msgs=0; /* OUTBUF FULL/SIZE */ if(!GetMailslotInfo( wrslot, /* mailslot handle */ &status->outbuf_size, /* address of maximum message size */ &status->outbuf_full, /* address of size of next message */ &msgs, /* address of number of messages */ NULL /* address of read time-out */ )) { lprintf(LOG_ERR,"!VDD_STATUS: GetMailSlotInfo(%p) failed, error %u (msgs=%u, inbuf_full=%u, inbuf_size=%u)" ,wrslot ,GetLastError(), msgs, status->inbuf_full, status->inbuf_size); status->outbuf_full=0; status->outbuf_size=DEFAULT_MAX_MSG_SIZE; } else lprintf(LOG_DEBUG,"VDD_STATUS: MailSlot maxmsgsize=%u, nextmsgsize=%u, msgs=%u" ,status->outbuf_size ,status->outbuf_full ,msgs); if(status->outbuf_full==MAILSLOT_NO_MESSAGE) status->outbuf_full=0; status->outbuf_full*=msgs; /* ONLINE */ if(WaitForSingleObject(hungup_event,0)==WAIT_OBJECT_0) status->online=0; else status->online=1; retval=0; /* success */ break; case VDD_INBUF_PURGE: RingBufReInit(&rdbuf); retval=0; break; case VDD_OUTBUF_PURGE: lprintf(LOG_WARNING,"!VDD_OUTBUF_PURGE: NOT IMPLEMENTED"); retval=0; break; case VDD_INBUF_FULL: retval=RingBufFull(&rdbuf); inbuf_poll++; break; case VDD_INBUF_SIZE: retval=RINGBUF_SIZE_IN; break; case VDD_OUTBUF_FULL: if(!GetMailslotInfo( wrslot, /* mailslot handle */ NULL, /* address of maximum message size */ &retval, /* address of size of next message */ &msgs, /* address of number of messages */ NULL /* address of read time-out */ )) retval=0; if(retval==MAILSLOT_NO_MESSAGE) retval=0; retval*=msgs; break; case VDD_OUTBUF_SIZE: if(!GetMailslotInfo( wrslot, /* mailslot handle */ &retval, /* address of maximum message size */ NULL, /* address of size of next message */ NULL, /* address of number of messages */ NULL /* address of read time-out */ )) retval=DEFAULT_MAX_MSG_SIZE; break; case VDD_ONLINE: if(WaitForSingleObject(hungup_event,0)==WAIT_OBJECT_0) retval=0; else retval=1; online_poll++; break; case VDD_YIELD: /* forced yield */ vdd_yields++; yield(); break; case VDD_MAYBE_YIELD: /* yield if YieldInterval is enabled and expired */ maybe_yield(); break; case VDD_LOAD_INI_FILE: /* Load and parse settings file */ { FILE* fp; char cwd[MAX_PATH+1]; /* Load exec/sbbsexec.ini first (setting default values) */ count = getCX(); p = (BYTE*)GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); iniFileName(ini_fname, sizeof(ini_fname), p, INI_FILENAME); if((fp=fopen(ini_fname,"r"))!=NULL) { ini=iniReadFile(fp); fclose(fp); parse_ini(ROOT_SECTION); } /* Load cwd/sbbsexec.ini second (over-riding default values) */ GetCurrentDirectory(sizeof(cwd),cwd); iniFileName(ini_fname, sizeof(ini_fname), cwd, INI_FILENAME); if((fp=fopen(ini_fname,"r"))!=NULL) { ini=iniReadFile(fp); fclose(fp); parse_ini(ROOT_SECTION); } } break; case VDD_LOAD_INI_SECTION: /* Parse (program-specific) sub-section of settings file */ count = getCX(); p = (BYTE*)GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); parse_ini(p); break; case VDD_DEBUG_OUTPUT: /* Send string to debug output */ count = getCX(); p = (BYTE*)GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); lputs(LOG_INFO, p); break; case VDD_HANGUP: hangup(); break; default: lprintf(LOG_ERR,"!UNKNOWN VDD_OP: %d",getBL()); break; } setAX((WORD)retval); }
[ "matt.zorzin@sendgrid.com" ]
matt.zorzin@sendgrid.com
1e2b0141c90643c7b43ebc9e4ccf4bb94e909c74
f86cae6a2f19c312db63468b11f869a812cd2b16
/platform-xmega/eeprom.h
9487863f441083fa6af3aa6dd9aa70a2036de63e
[]
no_license
north-x/platform-xmega
6c4677c5065e002107aa089da16692fa5155dbcf
fd7f6e0d0fd55286947ace7b17645755f625f9ee
refs/heads/master
2023-08-08T13:56:24.188226
2023-07-25T09:08:27
2023-07-25T09:08:27
26,126,815
0
0
null
2023-07-02T11:18:25
2014-11-03T16:10:08
C
UTF-8
C
false
false
3,504
h
/* * Copyright (c) 2014, Manuel Vetterli * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef EEPROM_H #define EEPROM_H #define EEPROM_MAGIC_BYTE 0xAA #define EEPROM_STORAGE_ENTRY_COUNT 2UL #define EEPROM_STATUS_ENTRY_COUNT ((EEPROM_SIZE-(EEPROM_STORAGE_ENTRY_COUNT*sizeof (t_eeprom_storage_aligned)))/sizeof (t_eeprom_status_aligned)) typedef struct { uint8_t version; uint16_t sv_serial_number; uint16_t sv_destination_id; #define EEPROM_CFG #include "config.h" #undef EEPROM_CFG } t_eeprom_storage; typedef struct { uint8_t flags; #define EEPROM_STATUS_CFG #include "config.h" #undef EEPROM_STATUS_CFG } t_eeprom_status; typedef struct { t_eeprom_storage eeprom; t_eeprom_status eeprom_status; } t_eeprom_default; typedef struct { uint8_t magic; uint8_t version; uint16_t checksum; } t_eeprom_info; typedef struct { t_eeprom_info info; t_eeprom_storage data; char _padding[EEPROM_PAGE_SIZE * ((sizeof (t_eeprom_storage) + sizeof (t_eeprom_info) + EEPROM_PAGE_SIZE - 1) / EEPROM_PAGE_SIZE) - sizeof (t_eeprom_storage) - sizeof (t_eeprom_info)]; } t_eeprom_storage_aligned; typedef struct { t_eeprom_info info; t_eeprom_status data; char _padding[EEPROM_PAGE_SIZE * ((sizeof (t_eeprom_status) + sizeof (t_eeprom_info) + EEPROM_PAGE_SIZE - 1) / EEPROM_PAGE_SIZE) - sizeof (t_eeprom_status) - sizeof (t_eeprom_info)]; } t_eeprom_status_aligned; void eeprom_init(void); uint16_t eeprom_checksum(const void *data, uint16_t length); void eeprom_write_block(const void *src, void *dst, uint16_t length); void eeprom_write_page(uint16_t addr); void * eeprom_read_block(void *dst, void *src, uint16_t length); void eeprom_load_storage(void); void eeprom_sync_storage(void); void eeprom_load_status(void); void eeprom_sync_status(void); void eeprom_load_defaults(void); extern t_eeprom_storage_aligned eeprom; extern t_eeprom_status_aligned eeprom_status; extern t_eeprom_storage_aligned eeprom_eemem[]; extern t_eeprom_status_aligned eeprom_status_eemem[]; #endif /* EEPROM_H */
[ "north-x@users.noreply.github.com" ]
north-x@users.noreply.github.com
19b0fefc4ca98caebaf79cd534c70e8b2951ffe2
32ac6dabcc8b2c872e03a8fedf2801dba76863ea
/Src/Sensors/Archief/lidar/UDP_Server/src/mavlink/common/version.h
b03d37d8cd8161d6b36b4bee9696456103485052
[]
no_license
CharanKoyalkar484/RoboRescueCproject
cf061e063942514062c06633922872f1dc84e032
f5e658468f4f3282f045e3afb60e944255adc06d
refs/heads/master
2021-02-18T04:03:29.210397
2020-04-13T07:14:40
2020-04-13T07:14:40
245,157,866
0
0
null
2020-04-13T07:14:41
2020-03-05T12:30:08
C++
UTF-8
C
false
false
321
h
/** @file * @brief MAVLink comm protocol built from common.xml * @see http://mavlink.org */ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H #define MAVLINK_BUILD_DATE "Thu Mar 26 19:49:30 2015" #define MAVLINK_WIRE_PROTOCOL_VERSION "1.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 #endif // MAVLINK_VERSION_H
[ "daan.leijen@student.hu.nl" ]
daan.leijen@student.hu.nl
be5037be93ea24f44bb583d94cee9d3f27a36120
4a684c82e20f6821d49d5e460e2c48c3929a2b37
/ch04.1.c
7e0378484d89b15b57e95c8ce42d9dd96de016c2
[]
no_license
fengyinxqy/-C-Programming-Language
94d8e8511ca042f2806e6a690ffb28f1f74112f2
b9ecdaffb753054e99ae9940ff3c157d6d017e2b
refs/heads/master
2023-02-23T08:43:01.612677
2023-02-12T12:02:36
2023-02-12T12:02:36
262,251,212
0
0
null
null
null
null
UTF-8
C
false
false
534
c
#include<stdio.h> #include<stdlib.h> void fun(int a[],int n,int x) { int b[n]; int i,j,k; j=n; for (i=0;i<n;i++) if (a[i]!=x) b[n-j]=a[i]; else { j++; } for (i=j;i<n;i++) b[i]=" "; for (i=0;i<n;i++) a[i]=b[i]; for(i=0;i<5-n;i++) { printf("%d ",a[i]); } } int main() { int x,n=0; int a[5]={1,2,3,4,5}; printf("Enter x:\n"); scanf("%d",&x); fun(a,n,x); return 0; }
[ "noreply@github.com" ]
fengyinxqy.noreply@github.com
aa53ed5f6179f4d4093f7fdbcad7f7821e0d8a48
b035f127f53e8634a46f17c8bb632888f70714f5
/resize/less/resize.c
4d6458f1c765330d7dc43d23f4728fb855842ae9
[]
no_license
volodymyrkochyn/cs50
ca80e47be85f3d387f4d874ba331487e5ce51152
678840c2fad14a16e0c75fab78b86f2d5df57832
refs/heads/master
2020-05-19T07:03:22.032150
2019-05-04T12:04:29
2019-05-04T12:04:29
184,888,899
0
0
null
null
null
null
UTF-8
C
false
false
4,003
c
#include "bmp.h" #include "stdio.h" #include "cs50.h" #include "string.h" #define SUCCESS 0 #define FAILURE 1 typedef struct { uint8_t result; uint8_t n; char *in; char *out; } UserInput; UserInput* validateInput(int args, const char ** argv) { UserInput *input = (UserInput*)malloc(sizeof(UserInput)); input->result = FAILURE; input->in = NULL; input->out = NULL; if (args == 4) { int n = atoi(argv[1]); if (n >= 1 && n <= 100) { input->result = SUCCESS; input->n = n; input->in = (char*)malloc(sizeof(char)*strlen(argv[2])+1); input->out = (char*)malloc(sizeof(char)*strlen(argv[3])+1); memcpy(input->in, argv[2], strlen(argv[2])+1); memcpy(input->out, argv[3], strlen(argv[3])+1); } } return input; } void freeUserInput(UserInput **pIn) { if (*pIn != NULL) { if ((*pIn)->in != NULL) free((*pIn)->in); if ((*pIn)->out != NULL) free((*pIn)->out); free(*pIn); } } void resize(BITMAPINFOHEADER *ri, int n) { ri->biWidth *= n; ri->biHeight *= n; int padding = (4 - (ri->biWidth * sizeof(RGBTRIPLE)) % 4) % 4; ri->biSizeImage = abs(ri->biHeight) * ((ri->biWidth * 3) + padding); } int main(int args, const char ** argv) { UserInput *in = validateInput(args, argv); if (in->result == FAILURE) { printf("Usage: ./resize n infile outfile\n"); freeUserInput(&in); return 1; } // remember filenames char *infile = in->in; char *outfile = in->out; // open input file FILE *inptr = fopen(infile, "r"); if (inptr == NULL) { fprintf(stderr, "Could not open %s.\n", infile); return 2; } // open output file FILE *outptr = fopen(outfile, "w"); if (outptr == NULL) { fclose(inptr); fprintf(stderr, "Could not create %s.\n", outfile); return 3; } // read infile's BITMAPFILEHEADER BITMAPFILEHEADER bf; fread(&bf, sizeof(BITMAPFILEHEADER), 1, inptr); // read infile's BITMAPINFOHEADER BITMAPINFOHEADER bi; fread(&bi, sizeof(BITMAPINFOHEADER), 1, inptr); // ensure infile is (likely) a 24-bit uncompressed BMP 4.0 if (bf.bfType != 0x4d42 || bf.bfOffBits != 54 || bi.biSize != 40 || bi.biBitCount != 24 || bi.biCompression != 0) { fclose(outptr); fclose(inptr); fprintf(stderr, "Unsupported file format.\n"); return 4; } BITMAPINFOHEADER ri = bi; resize(&ri, in->n); // resize bf.bfSize int rgbSize = ri.biSizeImage + bi.biSize + 14; bf.bfSize = rgbSize; // write outfile's BITMAPFILEHEADER fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr); // write outfile's BITMAPINFOHEADER fwrite(&ri, sizeof(BITMAPINFOHEADER), 1, outptr); // determine padding for scanlines int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; int outPadding = (4 - (ri.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; RGBTRIPLE triple[abs(bi.biHeight)][bi.biWidth]; // iterate over infile's scanlines for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++) { // iterate over pixels in scanline for (int j = 0; j < bi.biWidth; j++) { // read RGB triple from infile fread(&triple[i][j], sizeof(RGBTRIPLE), 1, inptr); } // skip over padding, if any fseek(inptr, padding, SEEK_CUR); } for (int h = 0, riHeight = abs(ri.biHeight); h < riHeight; ++h) { for (int w = 0; w < ri.biWidth; ++w) { fwrite(&triple[h/in->n][w/in->n], sizeof(RGBTRIPLE), 1, outptr); } for (int k = 0; k < outPadding; k++) { fputc(0x00, outptr); } } // close infile fclose(inptr); // close outfile fclose(outptr); freeUserInput(&in); return 0; }
[ "noreply@github.com" ]
volodymyrkochyn.noreply@github.com
b8040a6d22d28b859f96dbe24c195c5c55e1b121
6f224b734744e38062a100c42d737b433292fb47
/clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
1aaf01d82011bce65a8f53b863af419a71d9e1a9
[ "Apache-2.0", "LLVM-exception", "NCSA" ]
permissive
smeenai/llvm-project
1af036024dcc175c29c9bd2901358ad9b0e6610e
764287f1ad69469cc264bb094e8fcdcfdd0fcdfb
refs/heads/main
2023-09-01T04:26:38.516584
2023-08-29T21:11:41
2023-08-31T22:16:12
216,062,316
0
0
Apache-2.0
2019-10-18T16:12:03
2019-10-18T16:12:03
null
UTF-8
C
false
false
359
c
// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s int a[][0]; // expected-warning {{tentative array definition assumed to have one element}} void gh64564_1(void) { int b = a[0x100000000][0]; } typedef struct {} S; S s[]; // expected-warning {{tentative array definition assumed to have one element}} void gh64564_2(void) { S t = s[0x100000000]; }
[ "fding@feysh.com" ]
fding@feysh.com
b6b87f6f7f21ea45862e2adca8ab04c9beb0d38b
ce5b68831a37d94115b0bc6a9cbdeb0c1482f612
/LOG/LOG.h
1d3739fedd4754e36cd50e3f495cccdeee174b07
[]
no_license
PixelRetroGames/Engine2
8d8bc969c4db246e111b1f54ddae9cf8da44437c
37ecca1b08afec26a65abdecf67a86a2cd07373f
refs/heads/master
2020-05-24T22:12:15.858471
2020-02-25T09:36:42
2020-02-25T09:36:42
187,493,013
0
1
null
null
null
null
UTF-8
C
false
false
74
h
#ifndef LOG_H #define LOG_H #include "include/Logger.h" #endif // LOG_H
[ "pixelretrogames@github.com" ]
pixelretrogames@github.com
8744f02bff723a701d4b7d7e669dbd3e836b848a
524591f2c4f760bc01c12fea3061833847a4ff9a
/arm/usr/include/Poco/Net/SocketDefs.h
bf35fe2a51a3315420fdf5ee047e05c8d36ef532
[ "BSD-3-Clause" ]
permissive
Roboy/roboy_plexus
6f78d45c52055d97159fd4d0ca8e0f32f1fbd07e
1f3039edd24c059459563cb81d194326fe824905
refs/heads/roboy3
2023-03-10T15:01:34.703853
2021-08-16T13:42:54
2021-08-16T13:42:54
101,666,005
2
4
BSD-3-Clause
2022-10-22T13:43:45
2017-08-28T16:53:52
C++
UTF-8
C
false
false
7,005
h
// // SocketDefs.h // // $Id: //poco/1.3/Net/include/Poco/Net/SocketDefs.h#3 $ // // Library: Net // Package: NetCore // Module: SocketDefs // // Include platform-specific header files for sockets. // // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. // and Contributors. // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // #ifndef Net_SocketDefs_INCLUDED #define Net_SocketDefs_INCLUDED #if defined(POCO_OS_FAMILY_WINDOWS) #include "Poco/UnWindows.h" #include <winsock2.h> #include <ws2tcpip.h> #define POCO_INVALID_SOCKET INVALID_SOCKET #define poco_socket_t SOCKET #define poco_socklen_t int #define poco_closesocket(s) closesocket(s) #define POCO_EINTR WSAEINTR #define POCO_EACCES WSAEACCES #define POCO_EFAULT WSAEFAULT #define POCO_EINVAL WSAEINVAL #define POCO_EMFILE WSAEMFILE #define POCO_EAGAIN WSAEWOULDBLOCK #define POCO_EWOULDBLOCK WSAEWOULDBLOCK #define POCO_EINPROGRESS WSAEINPROGRESS #define POCO_EALREADY WSAEALREADY #define POCO_ENOTSOCK WSAENOTSOCK #define POCO_EDESTADDRREQ WSAEDESTADDRREQ #define POCO_EMSGSIZE WSAEMSGSIZE #define POCO_EPROTOTYPE WSAEPROTOTYPE #define POCO_ENOPROTOOPT WSAENOPROTOOPT #define POCO_EPROTONOSUPPORT WSAEPROTONOSUPPORT #define POCO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT #define POCO_ENOTSUP WSAEOPNOTSUPP #define POCO_EPFNOSUPPORT WSAEPFNOSUPPORT #define POCO_EAFNOSUPPORT WSAEAFNOSUPPORT #define POCO_EADDRINUSE WSAEADDRINUSE #define POCO_EADDRNOTAVAIL WSAEADDRNOTAVAIL #define POCO_ENETDOWN WSAENETDOWN #define POCO_ENETUNREACH WSAENETUNREACH #define POCO_ENETRESET WSAENETRESET #define POCO_ECONNABORTED WSAECONNABORTED #define POCO_ECONNRESET WSAECONNRESET #define POCO_ENOBUFS WSAENOBUFS #define POCO_EISCONN WSAEISCONN #define POCO_ENOTCONN WSAENOTCONN #define POCO_ESHUTDOWN WSAESHUTDOWN #define POCO_ETIMEDOUT WSAETIMEDOUT #define POCO_ECONNREFUSED WSAECONNREFUSED #define POCO_EHOSTDOWN WSAEHOSTDOWN #define POCO_EHOSTUNREACH WSAEHOSTUNREACH #define POCO_ESYSNOTREADY WSASYSNOTREADY #define POCO_ENOTINIT WSANOTINITIALISED #define POCO_HOST_NOT_FOUND WSAHOST_NOT_FOUND #define POCO_TRY_AGAIN WSATRY_AGAIN #define POCO_NO_RECOVERY WSANO_RECOVERY #define POCO_NO_DATA WSANO_DATA #elif defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_VMS) #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #if POCO_OS != POCO_OS_HPUX #include <sys/select.h> #endif #include <sys/ioctl.h> #if defined(POCO_OS_FAMILY_VMS) #include <inet.h> #else #include <arpa/inet.h> #endif #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> #if defined(POCO_OS_FAMILY_UNIX) #include <net/if.h> #endif #if defined(sun) || defined(__APPLE__) #include <sys/sockio.h> #include <sys/filio.h> #endif #define POCO_INVALID_SOCKET -1 #define poco_socket_t int #define poco_socklen_t socklen_t #define poco_closesocket(s) ::close(s) #define POCO_EINTR EINTR #define POCO_EACCES EACCES #define POCO_EFAULT EFAULT #define POCO_EINVAL EINVAL #define POCO_EMFILE EMFILE #define POCO_EAGAIN EAGAIN #define POCO_EWOULDBLOCK EWOULDBLOCK #define POCO_EINPROGRESS EINPROGRESS #define POCO_EALREADY EALREADY #define POCO_ENOTSOCK ENOTSOCK #define POCO_EDESTADDRREQ EDESTADDRREQ #define POCO_EMSGSIZE EMSGSIZE #define POCO_EPROTOTYPE EPROTOTYPE #define POCO_ENOPROTOOPT ENOPROTOOPT #define POCO_EPROTONOSUPPORT EPROTONOSUPPORT #if defined(ESOCKTNOSUPPORT) #define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT #else #define POCO_ESOCKTNOSUPPORT -1 #endif #define POCO_ENOTSUP ENOTSUP #define POCO_EPFNOSUPPORT EPFNOSUPPORT #define POCO_EAFNOSUPPORT EAFNOSUPPORT #define POCO_EADDRINUSE EADDRINUSE #define POCO_EADDRNOTAVAIL EADDRNOTAVAIL #define POCO_ENETDOWN ENETDOWN #define POCO_ENETUNREACH ENETUNREACH #define POCO_ENETRESET ENETRESET #define POCO_ECONNABORTED ECONNABORTED #define POCO_ECONNRESET ECONNRESET #define POCO_ENOBUFS ENOBUFS #define POCO_EISCONN EISCONN #define POCO_ENOTCONN ENOTCONN #if defined(ESHUTDOWN) #define POCO_ESHUTDOWN ESHUTDOWN #else #define POCO_ESHUTDOWN -2 #endif #define POCO_ETIMEDOUT ETIMEDOUT #define POCO_ECONNREFUSED ECONNREFUSED #if defined(EHOSTDOWN) #define POCO_EHOSTDOWN EHOSTDOWN #else #define POCO_EHOSTDOWN -3 #endif #define POCO_EHOSTUNREACH EHOSTUNREACH #define POCO_ESYSNOTREADY -4 #define POCO_ENOTINIT -5 #define POCO_HOST_NOT_FOUND HOST_NOT_FOUND #define POCO_TRY_AGAIN TRY_AGAIN #define POCO_NO_RECOVERY NO_RECOVERY #define POCO_NO_DATA NO_DATA #endif #if defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_TRU64) || (POCO_OS == POCO_OS_AIX) || (POCO_OS == POCO_OS_IRIX) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_VXWORKS) #define POCO_HAVE_SALEN 1 #endif #if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS) #define POCO_BROKEN_TIMEOUTS 1 #endif #if defined(POCO_HAVE_SALEN) #define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len) #define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in) #if defined(POCO_HAVE_IPv6) #define poco_set_sin6_len(pSA) (pSA)->sin6_len = sizeof(struct sockaddr_in6) #endif #else #define poco_set_sa_len(pSA, len) (void) 0 #define poco_set_sin_len(pSA) (void) 0 #define poco_set_sin6_len(pSA) (void) 0 #endif #ifndef INADDR_NONE #define INADDR_NONE 0xFFFFFFFF #endif #endif // Net_SocketDefs_INCLUDED
[ "simon.trendel@tum.de" ]
simon.trendel@tum.de
467900f8852a36a8bc70010d68d08fa2ed44a474
6f35b2705109d1b6105a5dfe7877dff621f9936b
/libftprintfgnl/ft_printf/src/utils/min.c
47dbcbf1bf588c964760b799122f039a8843942b
[ "MIT" ]
permissive
almayor/ft_select
f79b2af972358fa3478a0ecade402907035954cd
56756281464bf3b49cbb8f9cc51f112843f308ed
refs/heads/master
2023-07-16T21:45:58.254387
2021-08-28T10:51:59
2021-08-28T10:51:59
299,352,168
0
0
null
null
null
null
UTF-8
C
false
false
991
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* min_size.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: unite <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/03/31 17:47:18 by unite #+# #+# */ /* Updated: 2020/03/31 17:52:31 by unite ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf_private.h" inline size_t min(size_t a, size_t b) { return (a < b ? a : b); }
[ "mayorovme@gmail.com" ]
mayorovme@gmail.com
454b39b7d60dbb86f5aedab2321e9c600ebb2071
e60547640edc55a41013b2fc0692a83b574e1c88
/conf/conf_ja2104.h
efad6db6bcca389e2bce08f444cd562224baf55b
[]
no_license
shiv50084/hidvr-git
62eb4eb123866edc7bf7375a8470b13470802996
964b61408f8c0a3751eeaa168c600ef9735073aa
refs/heads/master
2021-03-23T19:55:00.073788
2015-09-02T08:39:16
2015-09-02T08:39:16
null
0
0
null
null
null
null
UTF-8
C
false
false
1,408
h
#ifndef __MODEL_CONF_H__ #define __MODEL_CONF_H__ #include "version.h" #include "ui_sel.h" #define _JA2104 #define SN_HEAD "I6" #define _EXT_EFFIO #define SDK_PLATFORM_HI3521 #define _HI3520A_EXT #define GPIO_PLAT_TYPE6 #define GPIO_KEYPAD_MATRIX #define HD_DISPLAY_SIZE_OPTIMISED #define HWVER_MAJ (1) #define HWVER_MIN (0) #define HWVER_REV (0) #define HWVER_EXT "" #define MAX_REF_CH (32) #define MAX_CAM_CH (4) #define ALL_CAM_BITMASK (0xf) #define MAX_AUD_CH (2) #define ALL_AUD_BITMASK (0x3) #define MAX_SENSOR_CH (4) #define ALL_SENSOR_BITMASK (0xf) #define MAX_ALARM_CH (1) #define ALL_ALARM_BITMASK (0x1) #define MAX_HDD_CNT (4) #define MAX_TELECTRL_CH (4) #define MAX_CIF_CNT (4) #define MAX_D1_CNT (4) #define MAX_D1_LIVE_FPS (30) #define MAX_CIF_LIVE_FPS (30) #define MAX_D1_ENC_FPS (30) #define MAX_CIF_ENC_FPS (30) #define MAX_NET_ENC_FPS (16) #define MAX_D1_ENC_BPS (2048) #define MAX_CIF_ENC_BPS (512) #define MAX_ENC_CH (4) #define MAX_DEC_CH (4) #define MAX_PLAYBACK_CH (4) #if defined(_EXT_JUANOEM) #define FIRMWARE_MAGIC "JUAN HI3521 JA-R2104 FIRMWARE COPYRIGHT BY JUAN" #define FIRMWARE_FILE_NAME_PREFIX "FWHJ2104_" #else #define FIRMWARE_MAGIC "JUAN HI3521 JA2104 FIRMWARE DESIGNED BY LAW" #define FIRMWARE_FILE_NAME_PREFIX "FWHI2104_" #endif #define DEVICE_FEATURE_NO "112226" #endif //__MODEL_CONF_H__
[ "johanan.lee@gmail.com" ]
johanan.lee@gmail.com
639b274c34757b192706be28a8398628a174fb8a
21c09799d006ed6bede4123d57d6d54d977c0b63
/fits_2018_10/PFNo11Dijet2017bbCSVv22b152Scan/corrHist.C
2b4fb8905a3381ca61fe0b178cc84874c1c365bb
[]
no_license
corvettettt/DijetRootTreeAnalyzer
68cb12e6b280957e1eb22c9842b0b9b30ae2c779
e65624ffc105798209436fc80fb82e2c252c6344
refs/heads/master
2021-05-06T09:57:12.816787
2019-04-18T15:32:38
2019-04-18T15:32:38
114,043,763
1
0
null
2017-12-12T22:02:46
2017-12-12T22:02:46
null
UTF-8
C
false
false
4,902
c
void corrHist() { //=========Macro generated from canvas: c/c //========= (Fri Dec 14 08:46:12 2018) by ROOT version6.02/05 TCanvas *c = new TCanvas("c", "c",0,0,500,500); gStyle->SetOptStat(0); c->SetHighLightColor(2); c->Range(-0.5333333,-0.5,4.8,4.5); c->SetFillColor(0); c->SetBorderMode(0); c->SetBorderSize(2); c->SetRightMargin(0.15); c->SetFrameBorderMode(0); c->SetFrameBorderMode(0); TH2D *correlation_matrix = new TH2D("correlation_matrix","correlation_matrix",4,0,4,4,0,4); correlation_matrix->SetBinContent(8,-0.9808662); correlation_matrix->SetBinContent(9,0.9985653); correlation_matrix->SetBinContent(10,1); correlation_matrix->SetBinContent(14,-0.9896813); correlation_matrix->SetBinContent(15,1); correlation_matrix->SetBinContent(16,0.9985653); correlation_matrix->SetBinContent(20,1); correlation_matrix->SetBinContent(21,-0.9896813); correlation_matrix->SetBinContent(22,-0.9808662); correlation_matrix->SetBinContent(25,1); correlation_matrix->SetBinError(8,0.9808662); correlation_matrix->SetBinError(9,0.9985653); correlation_matrix->SetBinError(10,1); correlation_matrix->SetBinError(14,0.9896813); correlation_matrix->SetBinError(15,1); correlation_matrix->SetBinError(16,0.9985653); correlation_matrix->SetBinError(20,1); correlation_matrix->SetBinError(21,0.9896813); correlation_matrix->SetBinError(22,0.9808662); correlation_matrix->SetBinError(25,1); correlation_matrix->SetMinimum(-1); correlation_matrix->SetMaximum(1); correlation_matrix->SetEntries(16); correlation_matrix->SetStats(0); correlation_matrix->SetContour(20); correlation_matrix->SetContourLevel(0,-1); correlation_matrix->SetContourLevel(1,-0.9); correlation_matrix->SetContourLevel(2,-0.8); correlation_matrix->SetContourLevel(3,-0.7); correlation_matrix->SetContourLevel(4,-0.6); correlation_matrix->SetContourLevel(5,-0.5); correlation_matrix->SetContourLevel(6,-0.4); correlation_matrix->SetContourLevel(7,-0.3); correlation_matrix->SetContourLevel(8,-0.2); correlation_matrix->SetContourLevel(9,-0.1); correlation_matrix->SetContourLevel(10,0); correlation_matrix->SetContourLevel(11,0.1); correlation_matrix->SetContourLevel(12,0.2); correlation_matrix->SetContourLevel(13,0.3); correlation_matrix->SetContourLevel(14,0.4); correlation_matrix->SetContourLevel(15,0.5); correlation_matrix->SetContourLevel(16,0.6); correlation_matrix->SetContourLevel(17,0.7); correlation_matrix->SetContourLevel(18,0.8); correlation_matrix->SetContourLevel(19,0.9); TPaletteAxis *palette = new TPaletteAxis(4.026667,0,4.266667,4,correlation_matrix); palette->SetLabelColor(1); palette->SetLabelFont(42); palette->SetLabelOffset(0.005); palette->SetLabelSize(0.035); palette->SetTitleOffset(1); palette->SetTitleSize(0.035); palette->SetFillColor(100); palette->SetFillStyle(1001); correlation_matrix->GetListOfFunctions()->Add(palette,"br"); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); correlation_matrix->SetLineColor(ci); correlation_matrix->GetXaxis()->SetBinLabel(1,"Ntot_bkg_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetXaxis()->SetBinLabel(2,"p1_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetXaxis()->SetBinLabel(3,"p2_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetXaxis()->SetBinLabel(4,"p3_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetXaxis()->SetLabelFont(42); correlation_matrix->GetXaxis()->SetLabelSize(0.035); correlation_matrix->GetXaxis()->SetTitleSize(0.035); correlation_matrix->GetXaxis()->SetTitleFont(42); correlation_matrix->GetYaxis()->SetBinLabel(4,"Ntot_bkg_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetYaxis()->SetBinLabel(3,"p1_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetYaxis()->SetBinLabel(2,"p2_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetYaxis()->SetBinLabel(1,"p3_PFNo11Dijet2017bbCSVv22b152"); correlation_matrix->GetYaxis()->SetLabelFont(42); correlation_matrix->GetYaxis()->SetLabelSize(0.035); correlation_matrix->GetYaxis()->SetTitleSize(0.035); correlation_matrix->GetYaxis()->SetTitleFont(42); correlation_matrix->GetZaxis()->SetLabelFont(42); correlation_matrix->GetZaxis()->SetLabelSize(0.035); correlation_matrix->GetZaxis()->SetTitleSize(0.035); correlation_matrix->GetZaxis()->SetTitleFont(42); correlation_matrix->Draw("colztext"); TPaveText *pt = new TPaveText(0.2793145,0.9365254,0.7206855,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("correlation_matrix"); pt->Draw(); c->Modified(); c->cd(); c->SetSelected(c); }
[ "zhixing.wang@ttu.edu" ]
zhixing.wang@ttu.edu
3b23f559a235d60cdcef369fea7ba035d126b282
a9949b7fd6b7e83b73ecd447721b5942f7c77f82
/Unused/MkFat/MkFat.h
33af861f747cf81ff3036b4a5b0a37644be5bb91
[]
no_license
gigaherz/KOS
d4df6e2aec3dbb3616a1e33f7b59131b5e330e99
c7730125239ab57e93aabfd41c3c77671660b843
refs/heads/master
2021-08-07T22:40:52.586557
2021-03-25T21:09:35
2021-03-25T21:09:35
42,005,986
1
1
null
null
null
null
UTF-8
C
false
false
3,136
h
/* Based on code from the Microsoft Invisible Computing Project released under the Microsoft Shared Source License 1.0 as seen: http://research.microsoft.com/en-us/um/redmond/projects/invisible/EULA.htm Original code Copyright (c) Microsoft Corporation. All rights reserved. */ #pragma once #define DOS_ALIGN 512 typedef unsigned int uint; #pragma pack(1) /* * Information in a directory entry */ struct FatDirectoryRecord { char name[8]; /* file name */ char ext[3]; /* file extension */ char attr; /* attribute byte */ #define FAT_ATTR_RONLY 0x01 #define FAT_ATTR_HIDDEN 0x02 #define FAT_ATTR_SYS 0x04 #define FAT_ATTR_LABEL 0x08 /* optional entry, only in rootdir */ #define FAT_ATTR_DIR 0x10 #define FAT_ATTR_ARCHIVE 0x20 /* e.g. dirty bit */ #define FAT_ATTR_xxx 0xc0 char reserved[10]; /* mbz */ char time[2]; /* time stamp */ char date[2]; /* date stamp */ short start; /* starting cluster number */ int size; /* size of the file */ }; /* * Information contained in sector zero of a FAT filesystem */ struct BiosPartitionEntry { char bootid; /* bootable or not */ #define BIOS_BOOTABLE 128 char beghead; /* beginning head, sector, cylinder */ char begsect; /* begcyl is a 10-bit number. High 2 bits */ char begcyl; /* are in begsect. */ char systid; /* filesystem type */ #define SYS_FAT 6 #define SYS_EXT 5 char endhead; /* ending head, sector, cylinder */ char endsect; /* endcyl is a 10-bit number. High 2 bits */ char endcyl; /* are in endsect. */ int offset; int n_sectors; }; struct BiosPartitionTable{ BiosPartitionEntry partitions[4]; /* alignment !! */ char magic[2]; #define BIOS_PARTITION_TABLE_MAGIC ((short)0xaa55) }; struct FatLabel { char jump[3]; /* Jump to boot code */ char banner[8]; /* OEM name & version */ short secsiz; /* Bytes per sector */ char clsiz; /* Cluster size in sectors */ short nrsvsect; /* Number of reserved (boot) sectors */ char nfat; /* Number of FAT tables hopefully 2 */ short dirents; /* Number of root directory entries */ short psect; /* Total sectors on disk */ char descr; /* Media descriptor=first byte of FAT */ short fatlen; /* Sectors in FAT */ short nsect; /* Sectors/track */ short nheads; /* Heads */ int nhs; /* number of hidden sectors */ int bigsect; /* big total sectors */ char driveno; /* drive number */ char reserved; char bsigrec; /* ext boot signature record (x29) */ char volid[4]; /* 32bit volume id */ char volume_label[11]; /* */ char res1[8]; /* actually, "FATnn " nn=12/16 */ char bootcode[384]; /* boot code */ BiosPartitionTable label; /* right at the end */ }; #define BLOCK_SIZE (64*1024) /* Better be a power of 2 or else */ #ifndef MY_SECTOR_SIZE #define MY_SECTOR_SIZE 512/*128*/ #endif
[ "gigaherz@gmail.com" ]
gigaherz@gmail.com
17d4edb1bf8656342f6e9d76531082ba45bfb22f
0e4519d3a94157a419e56576875aec1da906f578
/DSA_DOIT/08/0812/Q12.c
85b28077df3357681ba3ed38925613b61bd11a68
[]
no_license
ivorymood/TIL
0de3b92861e345375e87d01654d1fddf940621cd
1f09e8b1f4df7c205c68eefd9ab02d17a85d140a
refs/heads/master
2021-02-23T17:30:50.406370
2020-10-02T06:43:25
2020-10-02T06:43:25
245,388,390
0
0
null
null
null
null
UHC
C
false
false
1,727
c
// 답안 소스 거의 그대로 가져옴 #include <stdio.h> #include <string.h> #include <limits.h> int _print(const char txt[], const char pat[], int txt_len, int pat_len, int pt, int pp) { int i = 0, k = 0; if (pp != pat_len - 1) printf(" "); else { printf("%2d ", pt - pp); k = pt - pp; } for (i = 0; i < txt_len; i++) printf("%c ", txt[i]); putchar('\n'); printf("%*s%c\n", pt * 2 + 4, "", (txt[pt] == pat[pp]) ? '+' : '|'); printf("%*s", (pt - pp) * 2 + 4, ""); for (i = 0; i < pat_len; i++) printf("%c ", pat[i]); printf("\n\n"); } int bm_match(const char txt[], const char pat[]) { int pt; // txt 커서 int pp; // pat 커서 int txt_len = strlen(txt); int pat_len = strlen(pat); int skip[UCHAR_MAX + 1]; // 건너뛰기 표 만들기 for (pt = 0; pt <= UCHAR_MAX; ++pt) { skip[pt] = pat_len; } for (pt = 0; pt <= pat_len - 1; pt++) { skip[pat[pt]] = pat_len - pt - 1; } // Boyer-Moore법으로 검사하기 while (pt < txt_len) { pp = pat_len - 1; while (_print(txt, pat, txt_len, pat_len, pt, pp), txt[pt] == pat[pp]) { if (pp == 0) { return pt; } pp--; pt--; } pt += (skip[txt[pt]] > pat_len - pp) ? skip[txt[pt]] : pat_len - pp; } return -1; } int main(void) { int idx; char s1[256]; /* 텍스트 */ char s2[256]; /* 패턴 */ puts("Boyer-Moore법"); printf("텍스트 : "); scanf_s("%s", s1, 256); printf("패턴 : "); scanf_s("%s", s2, 256); idx = bm_match(s1, s2); /* 문자열 s1에서 문자열 s2를 Boyer-Moore법을 사용해 검색합니다. */ if (idx == -1) { puts("텍스트에 패턴이 없습니다."); } else { printf("%d번째 문자부터 match합니다.\n", idx + 1); } return 0; }
[ "ivorymood@gmail.com" ]
ivorymood@gmail.com
7a43fa21b788837dc29ce6aff0099718709d468d
6872ebc5025d704aa3d1135d3319c06240cbabe0
/pisoThermalFoam/T1Eqn.H
5d62a3dac0112549e5c489f3cf76ca4e4e4358d5
[]
no_license
ykanani/of-solvers-5.0
9d58508762930f9a37b902b04c902be86edcf3c0
63d778472b92b82ddbcf483cf33839a1aeac89bd
refs/heads/master
2022-02-19T13:06:54.820482
2019-09-18T14:57:08
2019-09-18T14:57:08
110,478,440
0
0
null
null
null
null
UTF-8
C
false
false
786
h
{ //alphat = turbulence->nut()/Prt; //alphat.correctBoundaryConditions(); //const volScalarField& alphat = time_.lookupObject<volVectorField>("alphat"); alphat = turbulence->nut()/Prt; /// const GeometricField<scalar, fvPatchField, volMesh>& alphat1 = /// U.db().objectRegistry:: /// lookupObject<GeometricField<scalar, fvPatchField, volMesh> > /// ( /// "alphat1" /// ); Info << max(laminarTransport.alpha()) << endl; Info << min(laminarTransport.alpha()) << endl; Info << max(T1) << endl; Info << min(T1) << endl; laminarTransport.correct(); volScalarField alphaEff1("alphaEff1", laminarTransport.alpha() + alphat); fvScalarMatrix T1Eqn ( fvm::ddt(T1) + fvm::div(phi, T1) - fvm::laplacian(alphaEff1, T1) ); T1Eqn.relax(); T1Eqn.solve(); }
[ "kanani@h2ologin2.ncsa.illinois.edu" ]
kanani@h2ologin2.ncsa.illinois.edu