blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
357
content_id
stringlengths
40
40
detected_licenses
listlengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
4
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-14 21:31:45
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-01 00:00:00
2023-09-05 23:26:37
committer_date
timestamp[ns]date
1970-01-01 00:00:00
2023-09-05 23:26:37
github_id
int64
966
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
24 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-02-03 21:17:16
2023-08-24 19:49:39
gha_language
stringclasses
180 values
src_encoding
stringclasses
35 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
6
10.4M
extension
stringclasses
121 values
filename
stringlengths
1
148
content
stringlengths
6
10.4M
6e5216951a54d6f2e81526f07249957f62745786
0caaff3eae80bc4b09dd58e20bd5df96a9346076
/src/str/ft_strcmp.c
789e8ae3fc3bb05ad978a148ecaf20c788c98677
[]
no_license
Uchronie/Libft
0fcc7ba768b549f16a7e3fd44d4edfab219a1b95
eedf5f6e7872a78a2c7f05224623716866d34fe8
refs/heads/master
2020-03-19T02:00:37.910265
2018-05-31T14:01:56
2018-05-31T14:01:56
135,590,654
0
0
null
null
null
null
UTF-8
C
false
false
1,215
c
ft_strcmp.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lmartin- <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 15:40:16 by lmartin- #+# #+# */ /* Updated: 2016/11/16 00:02:07 by lmartin- ### ########.fr */ /* */ /* ************************************************************************** */ int ft_strcmp(const char *s1, const char *s2) { int n; n = 0; while (s1[n] && s2[n]) { if (s1[n] != s2[n]) return ((unsigned char)s1[n] - (unsigned char)s2[n]); n++; } if (!s1[n] || !s2[n]) { if (!s1[n]) return (-(unsigned char)s2[n]); if (!s2[n]) return ((unsigned char)s1[n]); } return (0); }
c0bba7c570b71734381b3a10765d331004fe8523
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/net/ipsec/ipseccmd/ipseccmd.h
006871eb526bca0ceb7b3bc6ffab1bf08848a216
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C
false
false
2,210
h
ipseccmd.h
///////////////////////////////////////////////////////////// // Copyright(c) 1998, Microsoft Corporation // // ipseccmd.h // // Created on 4/5/98 by Randyram // Revisions: // // Includes all the necessary header files and definitions // for the policy automation tool. // ///////////////////////////////////////////////////////////// #ifndef _IPSECCMD_H_ #define _IPSECCMD_H_ #include <windows.h> #include <tchar.h> #include <iostream.h> #include <stdio.h> #include <stdlib.h> #include <winsock2.h> #include <assert.h> #include <limits.h> #include <objbase.h> #include <ipexport.h> #include <time.h> #include "t2pmsgs.h" extern "C" { #include <dsgetdc.h> #include <lm.h> #include <rpc.h> #include <winldap.h> #include <time.h> #include "winipsec.h" #include <ipsec.h> #include <oakdefs.h> #include "polstore2.h" } // my includes #include "text2pol.h" #include "pol2stor.h" #include "usepa.h" #include "print.h" #include "query.h" #include "externs.h" // my constants #define IPSECCMD_USAGE (-1) // used for printing in PrintFilter #define DebugPrint(X) _tprintf(TEXT("%s\n"),X) // this is for calling HrSetActivePolicy explicitly typedef HRESULT (*LPHRSETACTIVEPOLICY)(GUID *); const char POTF_VERSION[] = "v1.51 Copyright(c) 1998-2001, Microsoft Corporation"; // XX todo: make these real hresults const HRESULT POTF_NO_FILTERS = 0x80001102; const HRESULT POTF_STORAGE_OPEN_FAILED = 0x80001103; const BSTR POTF_DEFAULT_POLNAME = L"ipseccmd"; // sleep time to wait for PA RPC to come up, in milliseconds const UINT POTF_PARPC_SLEEPTIME = 60000; // starting GUID for policies // {fa56f258-f6ac-11d1-92a3-0000f806bfbc} const GUID POTF_START_GUID = { 0xfa56f258, // Data1 0xf6ac, // Data2 0x0, // Data3 for our own use { // Data4 0x92, 0xa3, 0x0, 0x0, 0xf8, 0x06, 0xbf, 0xbc } }; const unsigned short MAX_GUID_DATA3 = USHRT_MAX; // forward declarations void usage(FILE *, bool bExtendedUsage = false); HRESULT StorePolicy( IN STORAGE_INFO StoreInfo, IN IPSEC_IKE_POLICY PolicyToStore ); int InitWinsock( WORD wVersionRequested ); #endif 
d8309a9f57c916cae948e12a73295e87a60e3720
95dada2bf60b82bce1ce6d1307051de42e722816
/Source/1602.c
73161174449763b8eb1e6b9b17728ff3b3354976
[]
no_license
CikyYin/hello-world
f8563d1c205418f8e890e863d66421da16b7b56f
a67575dd4e75a665398acd17fa950adaec2f75cb
refs/heads/master
2021-09-08T11:24:02.825332
2021-08-27T08:02:27
2021-08-27T08:02:27
53,716,492
0
0
null
2016-03-12T06:15:29
2016-03-12T06:09:27
null
GB18030
C
false
false
8,001
c
1602.c
#include "1602.h" #include <intrins.h> //包含_nop_()函数定义的头文件 TDISPLAY Display; //显示常量 code uchar DisNum[] = {"0123456789."}; code uchar WelScreen[2][16] = {{"Welcome To Use"},{"Please Wait..."}}; code uchar Screen0[2][16] = {{"SN: HR: "},{"DS: m T: C"}}; //第一屏显示 code uchar Screen1[2][16] = {{"Date:20 - - "},{"Time: : : "}}; //第二屏显示 code uchar Screen2[2][16] = {{"Length: cm"},{" "}}; //第三屏显示 /***************************************************** 函数功能:判断液晶模块的忙碌状态 入口参数:无 返回值:result。result=1,忙碌;result=0,不忙 ***************************************************/ bit BusyTest(void) { bit result; RS=0; //根据规定,RS为低电平,RW为高电平时,可以读状态 RW=1; E=1; //E=1,才允许读写 _nop_(); //空操作 _nop_(); _nop_(); _nop_(); //空操作四个机器周期,给硬件反应时间 result=BF; //将忙碌标志电平赋给result E=0; return result; } /***************************************************** 函数功能:将模式设置指令或显示地址写入液晶模块 入口参数:dictate ***************************************************/ void WriteCmd (unsigned char dictate) { while(BusyTest()==1); //如果忙就等待 RS=0; //根据规定,RS和R/W同时为低电平时,可以写入指令 RW=0; E=0; //E置低电平(写指令时, // 就是让E从0到1发生正跳变,所以应先置"0" _nop_(); //空操作两个机器周期,给硬件反应时间 DAT= dictate; //将数据送入P0口,即写入指令或地址 _nop_(); //空操作四个机器周期,给硬件反应时间 E=1; //E置高电平 _nop_(); //空操作四个机器周期,给硬件反应时间 E=0; //当E由高电平跳变成低电平时,液晶模块开始执行命令 } /***************************************************** 函数功能:指定字符显示的实际地址 入口参数:x-行,y-列 返回值: ***************************************************/ void WriteAddress(uchar x,uchar y) { if(x == 0) { WriteCmd(y|0x80); //显示位置的确定方法规定为"80H+地址码x" } else if(x == 1) { WriteCmd(y|0xC0); //显示位置的确定方法规定为"80H+地址码x" 1100 } } /***************************************************** 函数功能:将数据(字符的标准ASCII码)写入液晶模块 入口参数:y(为字符常量) 返回值:无 ***************************************************/ void WriteData(unsigned char y) { while(BusyTest()==1); RS=1; //RS为高电平,RW为低电平时,可以写入数据 RW=0; E=0; //E置低电平(写指令时,, // 就是让E从0到1发生正跳变,所以应先置"0" DAT=y; //将数据送入P0口,即将数据写入液晶模块 _nop_(); //空操作四个机器周期,给硬件反应时间 E=1; //E置高电平 _nop_(); //空操作四个机器周期,给硬件反应时间 E=0; //当E由高电平跳变成低电平时,液晶模块开始执行命令 } /************************************************************** 函数功能:显示字符串 入口参数:字符串首地址 返回值:无 **************************************************************/ void Print(uchar *str) { while(*str!='\0') { WriteData(*str); str++; } } /***************************************************** 函数功能:对LCD的显示模式进行初始化设置 ***************************************************/ void Init1602(void) { Delay1ms(15); //延时15ms,首次写指令时应给LCD一段较长的反应时间 WriteCmd(0x38); //显示模式设置:16×2显示,5×7点阵,8位数据接口 Delay1ms(5); //延时5ms  WriteCmd(0x38); Delay1ms(5); WriteCmd(0x38); //3次写 设置模式 Delay1ms(5); WriteCmd(0x0C); //显示模式设置:显示开,有光标,光标闪烁 Delay1ms(5); WriteCmd(0x06); //显示模式设置:光标右移,字符不移 Delay1ms(5); WriteCmd(0x01); //清屏幕指令,将以前的显示内容清除 Delay1ms(5); } /************************************************************** 函数功能:显示数字 入口参数:Row:地址行 Column:地址列 Num:待显示的数字 最多显示99 返回值:无 **************************************************************/ void ShowNum(uchar Row, uchar Column, uint Num, uchar Len) { WriteAddress(Row, Column); switch(Len) { case 4: WriteData(DisNum[Num/1000]); case 3: WriteData(DisNum[Num%1000/100]); case 2: WriteData(DisNum[Num%100/10]); case 1: WriteData(DisNum[Num%10]); break; default: break; } } /************************************************************** 函数功能:显示字母 入口参数:Row:地址行 Column:地址列 str:待显示的字符首地址 返回值:无 **************************************************************/ void ShowChar(uchar Row, uchar Column, uchar *str) { WriteAddress(Row, Column); Print(str); } /************************************************************** 函数功能:显示处理函数 入口参数:无 返回值:无 **************************************************************/ void ProcDisplay(void) { if(DisplayFlag == 0) //没到显示刷新时间 返回 { return; } if(Display.DisNum == 0xFF) { if(Display.DisTimer != 0) { if(Display.LastDisNum != 0xFF) { ShowChar(0, 0, WelScreen[0]); //不需要动态刷新的显示 只有切换显示屏时才刷新 ShowChar(1, 0, WelScreen[1]); Display.LastDisNum = 0xFF; } } else { Display.DisNum = 0; //切换到第一屏 } } else if(Display.DisNum == 0) { if(Display.LastDisNum != 0) { ShowChar(0, 0, Screen0[0]); //不需要动态刷新的显示 只有切换显示屏时才刷新 ShowChar(1, 0, Screen0[1]); Display.LastDisNum = 0; } //显示步数 0~9999 ShowNum(0, 3 , Step.Num, 4); //显示心率 0~99 ShowNum(0, 12 , HeartRate.Num, 3); //显示距离 0~9999 ShowNum(1, 3 , Step.Distance/100, 4); //显示温度 if(Temp.Flag == BELOW_ZERO) //零下显示符号 { ShowChar(1, 11, "-"); } else { ShowChar(1, 11, " "); } ShowNum(1, 12, Temp.Value/10, 2); } else if(Display.DisNum == 1) { if(Display.LastDisNum != 1) { ShowChar(0, 0, Screen1[0]); //不需要动态刷新的显示 只有切换显示屏时才刷新 ShowChar(1, 0, Screen1[1]); Display.LastDisNum = 1; } //日期刷新 if((SysSetFlag == 0) || ((SysSetFlag == 1) && (Timer.T500msCounter%2))) { ShowNum(0, 7, DateTime.Year, 2); ShowNum(0, 10, DateTime.Mon, 2); ShowNum(0, 13, DateTime.Day, 2); //时间刷新 ShowNum(1, 5, DateTime.Hour, 2); ShowNum(1, 8, DateTime.Min, 2); ShowNum(1, 11, DateTime.Sec, 2); } else { switch(SetDS1302Pointer) { case 1: ShowChar(0, 7, " "); //显示空 break; case 2: ShowChar(0, 10, " "); //显示空 break; case 3: ShowChar(0, 13, " "); //显示空 break; case 4: ShowChar(1, 5, " "); //显示空 break; case 5: ShowChar(1, 8, " "); //显示空 break; case 6: ShowChar(1, 11, " "); //显示空 break; default: break; } } } else if(Display.DisNum == 2) { if(Display.LastDisNum != 2) { ShowChar(0, 0, Screen2[0]); //不需要动态刷新的显示 只有切换显示屏时才刷新 ShowChar(1, 0, Screen2[1]); Display.LastDisNum = 2; } if(SysSetFlag == 0) { ShowNum(0, 8, Step.Length, 4); } else { if(Timer.T500msCounter%2) { ShowNum(0, 8, Step.Length, 4); } else { ShowChar(0, 8, " "); //显示空 } } } DisplayFlag = 0; //清零刷新标志 }
39967936978894c08f0a6e0b51bea379e65a662c
eeae36adfb767734f81871996991c7b69ea111ba
/analog.c
78f620b9623e937bd17f788a281d4e413fd804ab
[]
no_license
Sciumo/SoupCup_Firmware
d548718570bb44c5d85b0bb5b9c5f5a004055a48
d959fba9ace2ee2dfa9aec05670c5fb1f3369d31
refs/heads/master
2021-01-18T10:59:51.864460
2011-05-10T12:21:11
2011-05-10T12:21:11
null
0
0
null
null
null
null
UTF-8
C
false
false
1,949
c
analog.c
#include "analog.h" /** \file \brief Analog subsystem */ #include <avr/interrupt.h> #include "arduino.h" /* OR-combined mask of all channels */ static const uint8_t analog_mask = 0; static uint8_t adc_counter; static volatile uint16_t adc_result[8] __attribute__ ((__section__ (".bss"))); //! Configure all registers, start interrupt loop void analog_init() { if (analog_mask > 0) { #ifdef PRR PRR &= ~MASK(PRADC); #elif defined PRR0 PRR0 &= ~MASK(PRADC); #endif ADMUX = REFERENCE; // ADC frequency must be less than 200khz or we lose precision. At 16MHz system clock, we must use the full prescale value of 128 to get an ADC clock of 125khz. ADCSRA = MASK(ADEN) | MASK(ADPS2) | MASK(ADPS1) | MASK(ADPS0); adc_counter = 0; AIO0_DDR &= ~analog_mask; DIDR0 = analog_mask & 0x3F; // now we start the first conversion and leave the rest to the interrupt ADCSRA |= MASK(ADIE) | MASK(ADSC); } /* analog_mask > 0 */ } /*! Analog Interrupt This is where we read our analog value and store it in an array for later retrieval */ ISR(ADC_vect, ISR_NOBLOCK) { // emulate free-running mode but be more deterministic about exactly which result we have, since this project has long-running interrupts if (analog_mask > 0) { adc_result[ADMUX & 0x0F] = ADC; // find next channel do { adc_counter++; adc_counter &= 0x07; } while ((analog_mask & (1 << adc_counter)) == 0); // start next conversion ADMUX = (adc_counter) | REFERENCE; ADCSRA |= MASK(ADSC); } } /*! Read analog value from saved result array \param channel Channel to be read \return analog reading, 10-bit right aligned */ uint16_t analog_read(uint8_t channel) { if (analog_mask > 0) { uint16_t r; uint8_t sreg; // save interrupt flag sreg = SREG; // disable interrupts cli(); // atomic 16-bit copy r = adc_result[channel]; // restore interrupt flag SREG = sreg; return r; } else { return 0; } }
c23652661d5c59c5bc2676d3a7888b8a5d159d0e
db798847ce02bbbdff7d779a81685bcf72741c87
/schoolwork/spring2013/cscs2650s13/logic/test.c
4dac9f7d981dc0702633cbcaf1ef1edd421acb28
[]
no_license
Shawn5961/src
b301d276cfba987bff4a06fd5ab72ca0d220ec11
2d974036907114ceac9312babdb52eb4577203a8
refs/heads/master
2020-04-13T21:10:24.458967
2015-02-24T21:12:25
2015-02-24T21:12:25
9,043,364
0
0
null
null
null
null
UTF-8
C
false
false
2,351
c
test.c
#include <stdio.h> #include <stdlib.h> #include "LOGIC.h" int main(int argc, char* argv[]) { char input1, input2, carry, choice, result; printf("Choose your desired operation\n"); printf("1: NOT\n"); printf("2: AND\n"); printf("3: OR\n"); printf("4: XOR\n"); printf("5: HALFSUM\n"); printf("6: HALFCARRY\n"); printf("7: FULLSUM\n"); printf("8: FULLCARRY\n"); printf("9: EXIT\n"); choice = getchar(); getchar(); printf("\nThis program is set to work with the following states:\n"); printf("TRUE: %c\n", TRUESTATE); printf("FALSE: %c\n", FALSESTATE); if (choice == '1') { printf("\nWhat is the input state to be operated on?\n"); input1 = getchar(); getchar(); } else if (choice == '7' || choice == '8') { printf("\nWhat is the first input state to be operated on?\n"); input1 = getchar(); getchar(); printf("What is the second input state to be operated on?\n"); input2 = getchar(); getchar(); printf("What is the carry state to be operated on?\n"); carry = getchar(); getchar(); } else if (choice != '9' && choice != '8') { printf("\nWhat is the first input state to be operated on?\n"); input1 = getchar(); getchar(); printf("What is the second input state to be operated on?\n"); input2 = getchar(); getchar(); } else { printf("\nThank you for using the program\n"); exit(0); } switch(choice) { case '1': result = NOT(input1); printf("NOT %c = %c\n", input1, result); break; case '2': result = AND(input1, input2); printf("%c AND %c = %c\n", input1, input2, result); break; case '3': result = OR(input1, input2); printf("%c OR %c = %c\n", input1, input2, result); break; case '4': result = XOR(input1, input2); printf("%c XOR %c = %c\n", input1, input2, result); break; case '5': result = HALFSUM(input1, input2); printf("%c HALFSUM %c = %c\n", input1, input2, result); break; case '6': result = HALFCARRY(input1, input2); printf("%c AND %c = %c\n", input1, input2, result); break; case '7': result = FULLSUM(input1, input2, carry); printf("%c FULLSUM %c CIN %c = %c\n",input1, input2, carry, result); break; case '8': result = FULLCARRY(input1, input2, carry); printf("%c FULLCARRY %c CIN %c = %c\n",input1, input2, carry, result); break; } return 0; }
cc0b1b087ee8ef70f887969715d6e87c52c05ce9
45b8ea7cb0418935aa250ec452287911df1fe74d
/python/lib/py_rf_write_hdf5.c
d6c7eb54ef469b2c72fb4b39b38e3d702c83cdb0
[ "BSD-3-Clause" ]
permissive
MITHaystack/digital_rf
91d77a0b2d3e8f8a94cb7ff0336fce765a3de52d
4ff1d4f96cc7dffc58811dbd6b2b21504900fa90
refs/heads/master
2023-06-22T08:01:25.779848
2023-06-21T19:53:05
2023-06-21T19:53:05
94,592,436
82
23
NOASSERTION
2023-06-21T19:53:06
2017-06-17T01:11:05
Python
UTF-8
C
false
false
18,469
c
py_rf_write_hdf5.c
/* * Copyright (c) 2017 Massachusetts Institute of Technology (MIT) * All rights reserved. * * Distributed under the terms of the BSD 3-clause license. * * The full license is in the LICENSE file, distributed with this software. */ /* The Python C extension for the rf_write_hdf5 C library * * $Id$ * * This file exports the following methods to python * init * rf_write * free */ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include <Python.h> #include <numpy/arrayobject.h> #include "digital_rf.h" #include "hdf5.h" // declarations void init_py_rf_write_hdf5(void); hid_t get_hdf5_data_type(char byteorder, char dtype_char, int bytecount); static PyObject * _py_rf_write_hdf5_get_version(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_get_version returns the library version as a string */ { PyObject *retObj = Py_BuildValue("s", digital_rf_get_version()); return(retObj); } void free_py_rf_write_hdf5(PyObject *capsule) /* free_py_rf_write_hdf5 frees all C references * * Input: PyObject pointer to _py_rf_write_hdf5 PyCapsule object */ { Digital_rf_write_object * hdf5_write_data_object; /* get C pointer to Digital_rf_write_object */ hdf5_write_data_object = (Digital_rf_write_object *)PyCapsule_GetPointer(capsule, NULL); digital_rf_close_write_hdf5(hdf5_write_data_object); } static PyObject * _py_rf_write_hdf5_init(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_init returns a pointer as a PyCObject to the Digital_rf_write_object struct created * * Inputs: python list with * 1. directory - python string where Hdf5 files will be written * 2. byteorder - python string of 'big' or 'little' describing the data format * 3. dtype_char - python string with one character representing data type (i,u,b,B,f,d) * 4. bytecount - python int giving the number of bytes in the data * 5. subdir_cadence_secs - python int giving the number of seconds of data per subdirectory * 6. file_cadence_millisecs - python int giving milliseconds of data per file * 7. start_global_index - python int giving start time in samples since 1970 (unix_timestamp * sample rate) * 8. sample_rate_numerator - python long giving the sample rate numerator * 9. sample_rate_denominator - python long giving the sample rate denominator * 10. uuid_str - python string representing the uuid * 11. compression_level - python int representing the compression level (0-9) * 12. checksum - 1 if checksums set, 0 if no checksum * 13. is_complex - 1 if complex (I and Q) samples, 0 if single valued * 14. num_subchannels - number of subchannels in data. Must be at least 1 (int) * 15. is_continuous - 1 is continuous data (allows faster write/read if no compression or checksum), 0 is with gaps * 16. marching_periods - 1 for marching periods, 0 for none * * Returns PyObject representing pointer to malloced struct if success, NULL pointer if not */ { // input arguments char * directory = NULL; char * byteorder = NULL; char * dtype_char = NULL; int bytecount = 0; uint64_t subdir_cadence_secs = 0; uint64_t file_cadence_millisecs = 0; uint64_t start_global_index = 0; uint64_t sample_rate_numerator = 0; uint64_t sample_rate_denominator = 0; char * uuid_str = NULL; int compression_level = 0; int checksum = 0; int is_complex = 0; int num_subchannels = 0; int is_continuous = 0; int marching_periods = 0; // local variables PyObject *retObj; hid_t hdf5_dtype; Digital_rf_write_object * hdf5_write_data_object; // parse input arguments if (!PyArg_ParseTuple(args, "sssiKKKKKsiiiiii", &directory, &byteorder, &dtype_char, &bytecount, &subdir_cadence_secs, &file_cadence_millisecs, &start_global_index, &sample_rate_numerator, &sample_rate_denominator, &uuid_str, &compression_level, &checksum, &is_complex, &num_subchannels, &is_continuous, &marching_periods)) { return NULL; } // find out what Hdf5 data type to use hdf5_dtype = get_hdf5_data_type(byteorder[0], dtype_char[0], bytecount); if (hdf5_dtype == -1) { fprintf(stderr, "Failed to find datatype for %c, %c, %i\n", byteorder[0], dtype_char[0], bytecount); PyErr_SetString(PyExc_RuntimeError, "Failed to find datatype for %c, %c, %i\n"); return(NULL); } // create needed object (for now, we always get matching periods) hdf5_write_data_object = digital_rf_create_write_hdf5(directory, hdf5_dtype, subdir_cadence_secs, file_cadence_millisecs, start_global_index, sample_rate_numerator, sample_rate_denominator, uuid_str, compression_level, checksum, is_complex, num_subchannels, is_continuous, marching_periods); if (!hdf5_write_data_object) { PyErr_SetString(PyExc_RuntimeError, "Failed to create Digital_rf_write_object\n"); return(NULL); } // create python wrapper around a pointer to return retObj = PyCapsule_New((void *)hdf5_write_data_object, NULL, free_py_rf_write_hdf5); //return pointer; return(retObj); } static PyObject * _py_rf_write_hdf5_rf_write(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_rf_write writes a block of continous data to an Hdf5 channel * * Inputs: python list with * 1. PyCObject containing pointer to data structure * 2. numpy array of data to write * 3. next_sample - long long containing where sample id to be written (globally) * * Returns next available global sample if success, 0 if not * */ { // input arguments PyObject * pyCObject; PyArrayObject * pyNumArr; uint64_t next_sample; // local variables Digital_rf_write_object * hdf5_write_data_object; void * data; /* will point to numpy array's data block */ uint64_t vector_length; /* will be set to length of data */ int result; PyObject *retObj; // parse input arguments if (!PyArg_ParseTuple(args, "OOK", &pyCObject, &pyNumArr, &next_sample)) { return(NULL); } /* get C pointer to Digital_rf_write_object */ hdf5_write_data_object = (Digital_rf_write_object *)PyCapsule_GetPointer(pyCObject, NULL); /* get C pointer to numpy array data */ data = PyArray_DATA(pyNumArr); vector_length = (uint64_t)(PyArray_DIMS(pyNumArr)[0]); result = digital_rf_write_hdf5(hdf5_write_data_object, next_sample, data, vector_length); if (result) { PyErr_SetString(PyExc_RuntimeError, "Failed to write data\n"); return(NULL); } /* success */ retObj = Py_BuildValue("K", hdf5_write_data_object->global_index); return(retObj); } static PyObject * _py_rf_write_hdf5_rf_block_write(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_rf_block_write writes a block of data with gaps to an Hdf5 channel * * Inputs: python list with * 1. PyCObject containing pointer to data structure * 2. numpy array of data to write - must be 2-D with shape * (length, num_subchannels) and a dtype giving the size of the complete * sample, whether complex or real * 3. numpy array of global sample count - must by array of type np.uint64 * 4. numpy array of block sample count - gives the position in each data arr of the * global sample given in the global sample count array above. Len of this * array must be the same as the one before, and it must also be an array * of type np.uint64 * * Returns next available global sample if success, 0 if not */ { // input arguments PyObject * pyCObject; PyArrayObject * pyNumArr; PyArrayObject * pyGlobalArr; PyArrayObject * pyBlockArr; // local variables Digital_rf_write_object * hdf5_write_data_object; void * data; /* will point to numpy array's data block */ uint64_t * global_arr; /* will point to numpy pyGlobalArr's data block */ uint64_t * block_arr; /* will point to numpy pyGlobalArr's data block */ uint64_t vector_length; uint64_t index_length; uint64_t i; uint64_t block_length; uint64_t block_index; uint64_t next_block_index; uint64_t next_sample; int result; PyObject *retObj; // parse input arguments if (!PyArg_ParseTuple(args, "OOOO", &pyCObject, &pyNumArr, &pyGlobalArr, &pyBlockArr)) { return(NULL); } /* get C pointer to Digital_rf_write_object */ hdf5_write_data_object = (Digital_rf_write_object *)PyCapsule_GetPointer(pyCObject, NULL); /* get lengths */ vector_length = (uint64_t)(PyArray_DIMS(pyNumArr)[0]); index_length = (uint64_t)(PyArray_DIMS(pyGlobalArr)[0]); if (hdf5_write_data_object->is_continuous && index_length > 1) { /* write each block in separate calls since digital_rf_write_blocks_hdf5 * requires a single continuous block per call with is_continuous */ for (i=0; i<index_length; i++) { block_index = *((uint64_t *)PyArray_GETPTR1(pyBlockArr, i)); if (i + 1 == index_length) next_block_index = vector_length; else next_block_index = *((uint64_t *)PyArray_GETPTR1(pyBlockArr, i+1)); block_length = next_block_index - block_index; data = PyArray_GETPTR2(pyNumArr, block_index, 0); next_sample = *((uint64_t *)PyArray_GETPTR1(pyGlobalArr, i)); result = digital_rf_write_hdf5(hdf5_write_data_object, next_sample, data, block_length); if (result) { PyErr_SetString(PyExc_RuntimeError, "Failed to write data\n"); return(NULL); } } } else { /* get C pointers to numpy arrays */ data = PyArray_DATA(pyNumArr); global_arr = PyArray_DATA(pyGlobalArr); block_arr = PyArray_DATA(pyBlockArr); result = digital_rf_write_blocks_hdf5(hdf5_write_data_object, global_arr, block_arr, index_length, data, vector_length); if (result) { PyErr_SetString(PyExc_RuntimeError, "Failed to write data\n"); return(NULL); } } /* success */ retObj = Py_BuildValue("K", hdf5_write_data_object->global_index); return(retObj); } static PyObject * _py_rf_write_hdf5_get_last_file_written(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_get_last_file_written returns last file written as string * * Inputs: python list with * 1. PyCObject containing pointer to data structure * * Returns python string of full path to last file written */ { // input arguments PyObject * pyCObject; // local variables Digital_rf_write_object * hdf5_write_data_object; PyObject *retObj; char * last_file_written; // parse input arguments if (!PyArg_ParseTuple(args, "O", &pyCObject)) { return(NULL); } /* get C pointer to Digital_rf_write_object */ hdf5_write_data_object = (Digital_rf_write_object *)PyCapsule_GetPointer(pyCObject, NULL); last_file_written = digital_rf_get_last_file_written(hdf5_write_data_object); /* success */ retObj = Py_BuildValue("s", last_file_written); free(last_file_written); return(retObj); } static PyObject * _py_rf_write_hdf5_get_last_dir_written(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_get_last_dir_written returns last directory (full path to dir) written as string * * Inputs: python list with * 1. PyCObject containing pointer to data structure * * Returns python string of full path to last directory written */ { // input arguments PyObject * pyCObject; // local variables Digital_rf_write_object * hdf5_write_data_object; PyObject *retObj; char * last_dir_written; // parse input arguments if (!PyArg_ParseTuple(args, "O", &pyCObject)) { return(NULL); } /* get C pointer to Digital_rf_write_object */ hdf5_write_data_object = (Digital_rf_write_object *)PyCapsule_GetPointer(pyCObject, NULL); last_dir_written = digital_rf_get_last_dir_written(hdf5_write_data_object); /* success */ retObj = Py_BuildValue("s", last_dir_written); free(last_dir_written); return(retObj); } static PyObject * _py_rf_write_hdf5_get_last_utc_timestamp(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_get_last_utc_timestamp returns utc timestamp at time of last write as uint_64 * * Inputs: python list with * 1. PyCObject containing pointer to data structure * * Returns python int of utc timestamp at time of last write */ { // input arguments PyObject * pyCObject; // local variables Digital_rf_write_object * hdf5_write_data_object; PyObject *retObj; uint64_t last_timestamp; // parse input arguments if (!PyArg_ParseTuple(args, "O", &pyCObject)) { return(NULL); } /* get C pointer to Digital_rf_write_object */ hdf5_write_data_object = (Digital_rf_write_object *)PyCapsule_GetPointer(pyCObject, NULL); last_timestamp = digital_rf_get_last_write_time(hdf5_write_data_object); /* success */ retObj = Py_BuildValue("K", last_timestamp); return(retObj); } /********** helper methods ******************************/ hid_t get_hdf5_data_type(char byteorder, char dtype_char, int bytecount) /* get_hdf5_data_type returns an Hdf5 datatype that corresponds to the arguments * * Inputs: * char byteorder - char representing byteorder according to np.dtype * (< little-endian, > big-endian, | not applicable) * char dtype_char - i int, u - unsigned int, f - float * (also accepts d for double for legacy, ignoring bytecount, assuming 8) * int bytecount - bytecount * * Returns hid_t HDF% datatype if recognized, -1 if not * */ { if (byteorder == '<') { if (dtype_char == 'f' && bytecount == 4) return(H5T_IEEE_F32LE); else if (dtype_char == 'f' && bytecount == 8) return(H5T_IEEE_F64LE); else if (dtype_char == 'd') return(H5T_IEEE_F64LE); else if (dtype_char == 'i' && bytecount == 1) return(H5T_STD_I8LE); else if (dtype_char == 'i' && bytecount == 2) return(H5T_STD_I16LE); else if (dtype_char == 'i' && bytecount == 4) return(H5T_STD_I32LE); else if (dtype_char == 'i' && bytecount == 8) return(H5T_STD_I64LE); else if (dtype_char == 'u' && bytecount == 1) return(H5T_STD_U8LE); else if (dtype_char == 'u' && bytecount == 2) return(H5T_STD_U16LE); else if (dtype_char == 'u' && bytecount == 4) return(H5T_STD_U32LE); else if (dtype_char == 'u' && bytecount == 8) return(H5T_STD_U64LE); } else if (byteorder == '>') { if (dtype_char == 'f' && bytecount == 4) return(H5T_IEEE_F32BE); else if (dtype_char == 'f' && bytecount == 8) return(H5T_IEEE_F64BE); else if (dtype_char == 'd') return(H5T_IEEE_F64BE); else if (dtype_char == 'i' && bytecount == 1) return(H5T_STD_I8BE); else if (dtype_char == 'i' && bytecount == 2) return(H5T_STD_I16BE); else if (dtype_char == 'i' && bytecount == 4) return(H5T_STD_I32BE); else if (dtype_char == 'i' && bytecount == 8) return(H5T_STD_I64BE); else if (dtype_char == 'u' && bytecount == 1) return(H5T_STD_U8BE); else if (dtype_char == 'u' && bytecount == 2) return(H5T_STD_U16BE); else if (dtype_char == 'u' && bytecount == 4) return(H5T_STD_U32BE); else if (dtype_char == 'u' && bytecount == 8) return(H5T_STD_U64BE); } else if (dtype_char == 'i') return(H5T_STD_I8LE); else if (dtype_char == 'u') return(H5T_STD_U8LE); // error if we got here return(-1); } static PyObject * _py_rf_write_hdf5_get_unix_time(PyObject * self, PyObject * args) /* _py_rf_write_hdf5_get_unix_time returns a tuple of (year,month,day,hour,minute,second,picosecond) * given an input unix_sample_index and sample_rate * * Inputs: python list with * 1. unix_sample_index - python int representing number of samples at given sample rate since UT midnight 1970-01-01 * 2. sample_rate_numerator - python int sample rate numerator in Hz * 3. sample_rate_denominator - python int sample rate denominator in Hz * * Returns tuple with (year,month,day,hour,minute,second,picosecond) if success, NULL pointer if not */ { // input arguments uint64_t unix_sample_index = 0; uint64_t sample_rate_numerator = 0; uint64_t sample_rate_denominator = 0; // local variables PyObject *retObj; int year, month, day; int hour, minute, second; uint64_t picosecond; int result; // parse input arguments if (!PyArg_ParseTuple(args, "KKK", &unix_sample_index, &sample_rate_numerator, &sample_rate_denominator)) { return NULL; } // call underlying method result = digital_rf_get_unix_time_rational( unix_sample_index, sample_rate_numerator, sample_rate_denominator, &year, &month, &day, &hour, &minute, &second, &picosecond); if (result != 0) return(NULL); // create needed object retObj = Py_BuildValue("iiiiiiK", year, month, day, hour, minute, second, picosecond); //return tuple; return(retObj); } /********** Initialization code for module ******************************/ static PyMethodDef _py_rf_write_hdf5Methods[] = { {"init", _py_rf_write_hdf5_init, METH_VARARGS}, {"rf_write", _py_rf_write_hdf5_rf_write, METH_VARARGS}, {"rf_block_write", _py_rf_write_hdf5_rf_block_write, METH_VARARGS}, {"get_last_file_written", _py_rf_write_hdf5_get_last_file_written, METH_VARARGS}, {"get_last_dir_written", _py_rf_write_hdf5_get_last_dir_written, METH_VARARGS}, {"get_last_utc_timestamp", _py_rf_write_hdf5_get_last_utc_timestamp,METH_VARARGS}, {"get_unix_time", _py_rf_write_hdf5_get_unix_time, METH_VARARGS}, {"get_version", _py_rf_write_hdf5_get_version, METH_NOARGS}, {NULL, NULL} /* Sentinel */ }; #if PY_MAJOR_VERSION >= 3 #define MOD_ERROR_VAL NULL #define MOD_SUCCESS_VAL(val) val #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) #define MOD_DEF(ob, name, doc, methods) \ static struct PyModuleDef moduledef = { \ PyModuleDef_HEAD_INIT, \ name, /* m_name */ \ doc, /* m_doc */ \ -1, /* m_size */ \ methods, /* m_methods */ \ NULL, /* m_reload */ \ NULL, /* m_traverse */ \ NULL, /* m_clear */ \ NULL, /* m_free */ \ }; \ ob = PyModule_Create(&moduledef); #else #define MOD_ERROR_VAL #define MOD_SUCCESS_VAL(val) #define MOD_INIT(name) void init##name(void) #define MOD_DEF(ob, name, doc, methods) \ ob = Py_InitModule3(name, methods, doc); #endif MOD_INIT(_py_rf_write_hdf5) { PyObject *m; MOD_DEF( m, /* module object */ "_py_rf_write_hdf5", /* module name */ "Python extension for the Digital RF rf_write_hdf5 C library", /* module doc */ _py_rf_write_hdf5Methods /* module methods */ ) if (m == NULL) return MOD_ERROR_VAL; // needed to initialize numpy C api and not have segfaults import_array(); return MOD_SUCCESS_VAL(m); }
9cbfc6a9e016f8daa890486983eb08fdc6e689e3
361859c981cb1ca25dc8d9d588a796aef9fc5b00
/src/prj/app/demo/dvbs/sabbat_dual/osd_apple/rsc/bmp/Im_Game.h
5deea8c261c349a8a6afe3e69001617fbea1bb67
[]
no_license
digrobot/ali3606
649de041ab8ac45f22fae78628efae65510d37fc
5e1b2eef06c1861a7c413760544f51fc612535fe
refs/heads/master
2016-08-03T12:37:31.007998
2014-11-04T07:39:13
2014-11-04T07:39:13
null
0
0
null
null
null
null
UTF-8
C
false
false
8,190
h
Im_Game.h
/* D:\project\doc\Project reference\3602 clut8\resouse\Sabbat256\Bitmap\Im_Game.h bmp file size: 7064 bmp data offset: 1078 bmp data width: 88 bmp data height: 68 bmp data size: 5984 RLE bmp data size: 1560 */ const unsigned char Im_Game[] __attribute__((section(".flash"))) = { 0x7f,0xaa,0x7f,0xaa,0x7f,0xaa,0x7f,0xaa,0x7f,0xaa,0x7f,0xaa,0x3d,0xaa,0x85,0xa3, 0xa3,0x9d,0xa3,0xa3,0x11,0xaa,0x88,0xc2,0xcf,0xd6,0xe1,0xdc,0xd6,0xcf,0xc2,0x37, 0xaa,0x8a,0xa3,0x9d,0x89,0x89,0x95,0x9d,0x95,0x89,0x89,0x9d,0x0d,0xaa,0x84,0xc2, 0xdc,0xe8,0xe9,0x04,0xeb,0x84,0xe5,0xe1,0xd3,0xc2,0x34,0xaa,0x84,0x9d,0x89,0x9d, 0xc2,0x05,0xcf,0x84,0xc2,0x9a,0x89,0x9d,0x0a,0xaa,0x84,0xcd,0xe5,0xe9,0xec,0x05, 0xef,0x85,0xec,0xeb,0xe5,0xd6,0xc9,0x32,0xaa,0x83,0x95,0x85,0xaa,0x09,0xcd,0x83, 0xaa,0x85,0x95,0x08,0xaa,0x83,0xcd,0xe5,0xeb,0x06,0xef,0x87,0xec,0xec,0xeb,0xe9, 0xe5,0xd6,0xc9,0x30,0xaa,0x83,0x9a,0x89,0xc2,0x07,0xc9,0x04,0xc2,0x83,0xaa,0x85, 0x9a,0x06,0xaa,0x83,0xc2,0xe5,0xeb,0x07,0xef,0x87,0xec,0xec,0xeb,0xe9,0xe5,0xe5, 0xcf,0x2f,0xaa,0x83,0x9d,0x7e,0xa3,0x06,0xc2,0x83,0xaa,0xaa,0xaa,0x04,0xa3,0x83, 0x9d,0x7e,0xa3,0x05,0xaa,0x82,0xdc,0xe8,0x08,0xef,0x88,0xec,0xec,0xeb,0xe9,0xe5, 0xe5,0xe2,0xc2,0x2e,0xaa,0x82,0x7e,0x95,0x08,0xa3,0x89,0x9d,0x9d,0x9a,0x9a,0x95, 0x95,0x95,0x85,0x85,0x04,0xaa,0x83,0xc9,0xe2,0xec,0x07,0xef,0x8a,0xec,0xec,0xeb, 0xeb,0xe9,0xe5,0xe5,0xe5,0xd6,0xa3,0x2c,0xaa,0x82,0xa3,0x74,0x07,0x9d,0x85,0x9a, 0x95,0x89,0x85,0x85,0x05,0x7e,0x87,0x6e,0xa3,0xaa,0xaa,0xaa,0xcf,0xe2,0x08,0xef, 0x85,0xec,0xec,0xeb,0xeb,0xe9,0x04,0xe5,0x81,0xa3,0x2c,0xaa,0x8e,0x89,0x74,0x9a, 0x9a,0x9a,0x95,0x95,0x89,0x85,0x85,0x7e,0x74,0x74,0x74,0x06,0x6e,0x86,0x95,0xaa, 0xaa,0xaa,0xd6,0xe8,0x07,0xef,0x86,0xec,0xec,0xeb,0xeb,0xe9,0xe8,0x04,0xe5,0x82, 0xc9,0xa3,0x2b,0xaa,0x8c,0x74,0x7e,0x89,0x89,0x85,0x85,0x7e,0x7e,0x74,0x6e,0x6e, 0x6e,0x08,0x66,0x86,0x7e,0xaa,0xaa,0xaa,0xd6,0xeb,0x06,0xef,0x86,0xec,0xec,0xec, 0xeb,0xeb,0xe9,0x05,0xe5,0x82,0xcf,0xa3,0x2b,0xaa,0x8c,0x6e,0x74,0x7e,0x7e,0x74, 0x74,0x6e,0x6e,0x66,0x60,0x60,0x60,0x05,0x5e,0x89,0x60,0x60,0x60,0x74,0xaa,0xaa, 0xaa,0xd3,0xeb,0x06,0xef,0x8d,0xec,0xec,0xeb,0xeb,0xe9,0xe8,0xe5,0xe2,0xe2,0xe2, 0xe5,0xd3,0xa3,0x2b,0xaa,0x88,0x6e,0x6e,0x74,0x6e,0x6e,0x66,0x60,0x5e,0x0c,0x5c, 0x86,0x6e,0xaa,0xaa,0xaa,0xcf,0xe8,0x05,0xef,0x8e,0xec,0xec,0xeb,0xeb,0xe9,0xe5, 0xe5,0xe2,0xe1,0xdc,0xe1,0xe5,0xcf,0xa3,0x2b,0xaa,0x86,0x6e,0x60,0x66,0x60,0x5e, 0x5c,0x0e,0x5b,0x86,0x74,0xaa,0xaa,0xaa,0xc9,0xe2,0x04,0xef,0x8f,0xec,0xec,0xeb, 0xe9,0xe8,0xe5,0xe2,0xe1,0xdc,0xdc,0xdc,0xe1,0xe5,0xaa,0xa3,0x2b,0xaa,0x84,0x7e, 0x5b,0x5c,0x5b,0x10,0x55,0x98,0x89,0xaa,0xaa,0xaa,0xc2,0xcd,0xef,0xef,0xef,0xec, 0xeb,0xeb,0xe8,0xe5,0xe2,0xe1,0xdc,0xdc,0xd6,0xdc,0xdc,0xe1,0xe2,0x95,0x2c,0xaa, 0x81,0xa3,0x13,0x51,0x81,0xa3,0x04,0xaa,0x93,0xc2,0xe5,0xef,0xec,0xeb,0xe9,0xe5, 0xe2,0xe1,0xdc,0xdc,0xd6,0xd6,0xd3,0xd6,0xdc,0xe2,0xcf,0x9a,0x2d,0xaa,0x81,0x66, 0x11,0x4e,0x81,0x6e,0x05,0xaa,0x93,0xa3,0xc9,0xec,0xeb,0xe9,0xe5,0xe1,0xdc,0xd6, 0xd3,0xcf,0xcf,0xcd,0xcf,0xd3,0xdc,0xe1,0x95,0xa3,0x2d,0xaa,0x82,0x9d,0x4e,0x0f, 0x4b,0x82,0x51,0xa3,0x06,0xaa,0x88,0xa3,0xcd,0xe9,0xe5,0xdc,0xd3,0xcf,0xcd,0x04, 0xc9,0x85,0xcd,0xd6,0xe1,0x9d,0x9d,0x2f,0xaa,0x81,0x85,0x0f,0x46,0x81,0x89,0x07, 0xaa,0x90,0xa3,0x9d,0xc2,0xdc,0xcf,0xc9,0xc2,0xc2,0xaa,0xaa,0xaa,0xc2,0xcd,0xd3, 0x9d,0x95,0x31,0xaa,0x81,0x7e,0x0c,0x46,0x82,0x4b,0x85,0x09,0xaa,0x85,0xa3,0x9d, 0x9d,0xaa,0xaa,0x05,0xa3,0x84,0xc2,0xaa,0x89,0x9a,0x33,0xaa,0x82,0x9a,0x51,0x09, 0x46,0x82,0x55,0x9d,0x0c,0xaa,0x83,0x9d,0x95,0x95,0x04,0x9a,0x84,0x95,0x85,0x89, 0xa3,0x36,0xaa,0x82,0x85,0x5c,0x04,0x46,0x83,0x4b,0x5e,0x89,0x10,0xaa,0x87,0xa3, 0x9a,0x9a,0x95,0x9a,0x9d,0xa3,0x7f,0xaa,0x7f,0xaa,0x89,0xaa,0xa3,0x9d,0x9d,0x9a, 0x9a,0x9d,0x9d,0xa3,0x3c,0xaa,0x81,0xc2,0x11,0xaa,0x8c,0xa3,0x9a,0x89,0x89,0x89, 0x95,0x9a,0x95,0x89,0x89,0x95,0xa3,0x36,0xaa,0x89,0xc9,0xd6,0xe2,0xe5,0xe5,0xe5, 0xe1,0xd6,0xc9,0x0c,0xaa,0x8e,0x9d,0x89,0x89,0x9a,0xaa,0xcd,0xcf,0xcf,0xcf,0xcd, 0xaa,0x9a,0x89,0x9d,0x33,0xaa,0x8d,0xc2,0xdc,0xe8,0xe9,0xec,0xec,0xec,0xeb,0xe9, 0xe5,0xdc,0xd3,0xc2,0x09,0xaa,0x84,0x9d,0x85,0x85,0xaa,0x09,0xc9,0x83,0xaa,0x85, 0x95,0x31,0xaa,0x83,0xc9,0xe2,0xeb,0x06,0xef,0x86,0xec,0xec,0xe9,0xdc,0xd3,0xc2, 0x07,0xaa,0x84,0x9d,0x7e,0x85,0xaa,0x05,0xc2,0x89,0xaa,0xaa,0xaa,0xc2,0xc2,0xc2, 0xaa,0x85,0x9d,0x2f,0xaa,0x83,0xc2,0xe2,0xeb,0x07,0xef,0x87,0xec,0xeb,0xeb,0xe8, 0xdc,0xcf,0xc2,0x06,0xaa,0x83,0x7e,0x7e,0x9d,0x0d,0xa3,0x83,0x9d,0x7e,0xa3,0x2e, 0xaa,0x82,0xdc,0xeb,0x07,0xef,0x88,0xec,0xec,0xeb,0xeb,0xe8,0xe5,0xd6,0xc9,0x05, 0xaa,0x83,0x9a,0x74,0x89,0x04,0x9d,0x83,0x9a,0x9a,0x9a,0x05,0x95,0x85,0x9a,0x9a, 0x9d,0x89,0x89,0x2d,0xaa,0x82,0xcd,0xe5,0x08,0xef,0x88,0xec,0xec,0xeb,0xeb,0xe8, 0xe5,0xe5,0xcd,0x05,0xaa,0x89,0x7e,0x6e,0x95,0x95,0x95,0x89,0x89,0x85,0x85,0x06, 0x7e,0x85,0x85,0x85,0x85,0x89,0x74,0x2d,0xaa,0x82,0xdc,0xec,0x07,0xef,0x96,0xec, 0xec,0xec,0xeb,0xe9,0xe8,0xe5,0xe5,0xdc,0xaa,0xa3,0xaa,0xaa,0xaa,0x6e,0x74,0x85, 0x85,0x7e,0x7e,0x74,0x74,0x08,0x6e,0x85,0x74,0x74,0x74,0x6e,0xa3,0x2b,0xaa,0x82, 0xc2,0xe2,0x08,0xef,0x95,0xec,0xec,0xeb,0xeb,0xe9,0xe8,0xe5,0xe5,0xe5,0xc2,0xa3, 0xa3,0xa3,0x9d,0x60,0x74,0x74,0x74,0x6e,0x6e,0x6e,0x0b,0x66,0x83,0x6e,0x66,0x9a, 0x2b,0xaa,0x82,0xc9,0xe5,0x07,0xef,0x95,0xec,0xec,0xec,0xeb,0xeb,0xe9,0xe8,0xe5, 0xe5,0xe5,0xcd,0x9d,0x9d,0x9d,0x95,0x5e,0x6e,0x6e,0x66,0x60,0x60,0x0e,0x5e,0x81, 0x95,0x2b,0xaa,0x82,0xc9,0xe9,0x06,0xef,0x87,0xec,0xec,0xec,0xeb,0xeb,0xe9,0xe8, 0x04,0xe5,0x89,0xd3,0x9d,0x89,0x89,0x89,0x5c,0x60,0x60,0x5e,0x10,0x5c,0x81,0x95, 0x2b,0xaa,0x82,0xc9,0xe9,0x06,0xef,0x90,0xec,0xec,0xeb,0xeb,0xe9,0xe8,0xe5,0xe5, 0xe2,0xe5,0xe5,0xd6,0x9a,0x74,0x74,0x74,0x05,0x5b,0x0f,0x55,0x83,0x9d,0xa3,0xa3, 0x29,0xaa,0x82,0xc2,0xe5,0x05,0xef,0x92,0xec,0xeb,0xeb,0xeb,0xe9,0xe5,0xe5,0xe2, 0xe2,0xe1,0xe2,0xe5,0xcf,0x89,0x60,0x5e,0x5e,0x55,0x12,0x51,0x85,0x5c,0x9d,0xa3, 0xa3,0xa3,0x29,0xaa,0x81,0xdc,0x04,0xef,0x8f,0xec,0xeb,0xeb,0xe9,0xe8,0xe5,0xe5, 0xe2,0xe1,0xdc,0xdc,0xe2,0xe5,0xc2,0x74,0x04,0x51,0x82,0x4e,0x51,0x10,0x4e,0x86, 0x66,0x89,0x9d,0x9d,0xa3,0xa3,0x28,0xaa,0x8b,0xc2,0xef,0xef,0xef,0xec,0xeb,0xe9, 0xe5,0xe5,0xe2,0xe1,0x05,0xdc,0x84,0xe2,0xe5,0x95,0x5c,0x04,0x46,0x11,0x4b,0x88, 0x4e,0x6e,0x7e,0x89,0x9a,0x9d,0xa3,0xa3,0x28,0xaa,0x8a,0xe2,0xef,0xec,0xeb,0xe9, 0xe5,0xe2,0xdc,0xdc,0xdc,0x04,0xd6,0x84,0xdc,0xe2,0xcf,0x7e,0x06,0x3c,0x10,0x46, 0x88,0x51,0x5e,0x6e,0x7e,0x89,0x9d,0xa3,0xa3,0x29,0xaa,0x91,0xeb,0xeb,0xe8,0xe2, 0xdc,0xd6,0xd3,0xcf,0xcf,0xcf,0xcd,0xcf,0xd6,0xdc,0xdc,0x89,0x55,0x07,0x3c,0x0f, 0x46,0x88,0x4e,0x55,0x5e,0x6e,0x7e,0x95,0x9d,0xa3,0x28,0xaa,0x88,0xa3,0xaa,0xe5, 0xe2,0xdc,0xcf,0xcd,0xcd,0x04,0xc9,0x85,0xcd,0xd6,0xdc,0x9d,0x66,0x09,0x3c,0x0c, 0x46,0x8a,0x3c,0x46,0x46,0x51,0x5c,0x6e,0x7e,0x89,0x9d,0xa3,0x28,0xaa,0x87,0xa3, 0x9d,0xa3,0xd3,0xcf,0xc9,0xc2,0x04,0xaa,0x85,0xc2,0xcd,0xcf,0x9a,0x6e,0x0c,0x3c, 0x08,0x46,0x8c,0x3c,0x3c,0x3c,0x46,0x4b,0x51,0x5c,0x6e,0x7e,0x95,0x9d,0xa3,0x28, 0xaa,0x84,0xa3,0xa3,0x9a,0x95,0x07,0xa3,0x84,0xaa,0xa3,0x85,0x5e,0x16,0x3c,0x8b, 0x46,0x46,0x4b,0x4e,0x55,0x60,0x6e,0x85,0x95,0x9d,0xa3,0x28,0xaa,0x86,0xa3,0xa3, 0x9d,0x95,0x85,0x89,0x04,0x95,0x86,0x89,0x85,0x66,0x4e,0x46,0x46,0x10,0x3c,0x05, 0x46,0x8b,0x4b,0x51,0x55,0x5c,0x60,0x6e,0x7e,0x89,0x9d,0xa3,0xa3,0x29,0xaa,0x92, 0xa3,0xa3,0x9d,0x95,0x85,0x74,0x74,0x6e,0x6e,0x5e,0x5b,0x51,0x51,0x4e,0x4e,0x4b, 0x4b,0x4b,0x0a,0x46,0x92,0x4b,0x4b,0x4b,0x4e,0x4e,0x51,0x51,0x55,0x5b,0x5e,0x66, 0x6e,0x74,0x7e,0x89,0x9a,0x9d,0xa3,0x2b,0xaa,0x8f,0xa3,0xa3,0x9d,0x95,0x89,0x7e, 0x74,0x6e,0x6e,0x66,0x60,0x5e,0x5c,0x5c,0x5b,0x04,0x55,0x07,0x51,0x93,0x55,0x55, 0x55,0x5b,0x5c,0x5c,0x5e,0x60,0x66,0x6e,0x6e,0x74,0x7e,0x85,0x95,0x9d,0x9d,0xa3, 0xa3,0x2c,0xaa,0x8e,0xa3,0xa3,0x9d,0x9d,0x9a,0x89,0x85,0x85,0x7e,0x74,0x74,0x6e, 0x6e,0x6e,0x04,0x66,0x07,0x60,0x93,0x66,0x66,0x66,0x6e,0x6e,0x6e,0x74,0x74,0x7e, 0x7e,0x85,0x89,0x9a,0x9d,0x9d,0xa3,0xa3,0xaa,0xa3,0x2d,0xaa,0x04,0xa3,0x88,0x9d, 0x9d,0x9a,0x95,0x89,0x89,0x85,0x85,0x05,0x7e,0x05,0x74,0x06,0x7e,0x8c,0x85,0x85, 0x89,0x89,0x95,0x9a,0x9d,0x9d,0x9d,0xa3,0xa3,0xa3,0x33,0xaa,0x04,0xa3,0x05,0x9d, 0x82,0x9a,0x9a,0x0c,0x95,0x82,0x9a,0x9a,0x05,0x9d,0x04,0xa3,0x3a,0xaa,0x08,0xa3, 0x0a,0x9d,0x09,0xa3,0x43,0xaa,0x0e,0xa3,0x83,0xaa,0xa3,0xa3,0x7f,0xaa,0x7f,0xaa, 0x7f,0xaa,0x7f,0xaa,0x7f,0xaa,0x0b,0xaa };
644146006c60e705e8196d95452976f50e3f115a
77ce42bceabfa44c612a3be0989664a6631c497c
/server.c
78da498b7f88ced59d704b495da34f473eedd622
[]
no_license
OliveLake/RealTime-Chatroom
f25988ccc692c750af3eaf46eecee5ace73db20a
cf183f69b632cc1b03a5df7c1b5fa402f2861dc9
refs/heads/master
2023-06-30T15:01:19.687518
2021-08-02T08:28:24
2021-08-02T08:28:24
391,867,922
0
0
null
null
null
null
UTF-8
C
false
false
6,542
c
server.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <pthread.h> #include "server.h" #define LENGTH_NAME 31 #define LENGTH_MSG 101 #define LENGTH_SEND 201 //首先跟client一樣先定義要用到的全域變數 int server_sockfd = 0, client_sockfd = 0; ClientList *root, *now; void clientController(void *p_client); void breakPoint(int sig); void sendAll(ClientList *np, char tmp_buffer[]); int main() { signal(SIGINT, breakPoint); //建立一個socket server_sockfd = socket(AF_INET , SOCK_STREAM , 0); if (server_sockfd == -1) { printf("Fail to create a socket."); exit(EXIT_FAILURE); } // 建立Socket所用到的資訊 struct sockaddr_in server_info, client_info; int s_addrlen = sizeof(server_info); int c_addrlen = sizeof(client_info); memset(&server_info, 0, s_addrlen); memset(&client_info, 0, c_addrlen); server_info.sin_family = PF_INET; server_info.sin_addr.s_addr = INADDR_ANY; server_info.sin_port = htons(8888); // Bind and Listen bind(server_sockfd, (struct sockaddr *)&server_info, s_addrlen); listen(server_sockfd, 5); //這裡是用來將Server的IP輸出 getsockname(server_sockfd, (struct sockaddr*) &server_info, (socklen_t*) &s_addrlen); printf("Start! Server is on %s:%d\n", inet_ntoa(server_info.sin_addr), ntohs(server_info.sin_port)); //初始化linklist讓client運用 root = newNode(server_sockfd, inet_ntoa(server_info.sin_addr)); now = root; while (1) { client_sockfd = accept(server_sockfd, (struct sockaddr*) &client_info, (socklen_t*) &c_addrlen); //這裡是用來將Client的IP輸出 getpeername(client_sockfd, (struct sockaddr*) &client_info, (socklen_t*) &c_addrlen); printf("Client %s:%d come in room.\n", inet_ntoa(client_info.sin_addr), ntohs(client_info.sin_port)); //將新的client insert到 client 的linklist中 ClientList *c = newNode(client_sockfd, inet_ntoa(client_info.sin_addr)); c->prev = now; now->link = c; now = c; pthread_t id; if (pthread_create(&id, NULL, (void *)clientController, (void *)c) != 0) { perror("Create pthread error!\n"); exit(EXIT_FAILURE); } } return 0; } void clientController(void *p_client) { //初始化一些會用到的資料 int leave_flag = 0; char nickname[LENGTH_NAME] = {}; char recv_buffer[LENGTH_MSG] = {}; char send_buffer[LENGTH_SEND] = {}; ClientList *np = (ClientList *)p_client; //把client的名字傳送到時,如果名字長度等小於2或大於30則不執行,也就是可以解釋成沒有收到input //經socket接收的名字小於等於0也不執行,也就是可以解釋成沒有收到input //recv是用新的套接字来接收遠端主機傳來的數據,並把數據存到由参数 buf 指向的内存空間 if (recv(np->data, nickname, LENGTH_NAME, 0) <= 0 || strlen(nickname) < 2 || strlen(nickname) >= LENGTH_NAME-1) { printf("%s didn't input name.\n", np->ip); leave_flag = 1; } else { strncpy(np->name, nickname, LENGTH_NAME); printf("%s(%s)(%d) join the chatroom.\n", np->name, np->ip, np->data); sprintf(send_buffer, "%s(%s) join the chatroom.", np->name, np->ip); } // Conversation while (1) { if (leave_flag) { break; } if (!strcmp(recv_buffer, "/nick")){ //connecting:client itself show socketfd sprintf(send_buffer, "new nickname : "); send(np->data, send_buffer, LENGTH_SEND, 0); strncpy(np->name, nickname, LENGTH_NAME); sprintf(send_buffer, "%s is your new name.\n", np->name); send(np->data, send_buffer, LENGTH_SEND, 0); } if (!strcmp(recv_buffer, "/connecting")){ //connecting:client itself show socketfd sprintf(send_buffer, "Successfully connected. socketfd: %d", root->data); send(np->data, send_buffer, LENGTH_SEND, 0); } if (!strcmp(recv_buffer, "/help")){ //help:all client show help sprintf(send_buffer, "<< /help Show help\r\n"); send(np->data, send_buffer, LENGTH_SEND, 0); sprintf(send_buffer, "<< /exit Quit chatroom\r\n"); send(np->data, send_buffer, LENGTH_SEND, 0); sprintf(send_buffer, "<< /connecting Server test\r\n"); send(np->data, send_buffer, LENGTH_SEND, 0); } //如果client 有傳 message 則server會顯示出把這個message傳到其餘每個client socket //並且顯示出 IP 位置和 client 名稱 //若有client離開聊天室則顯示出是哪個client離開聊天室 int receive = recv(np->data, recv_buffer, LENGTH_MSG, 0); if (receive > 0) { if (strlen(recv_buffer) == 0) { continue; } sprintf(send_buffer, "%s:%s from %s", np->name, recv_buffer, np->ip); } else if (receive == 0 || strcmp(recv_buffer, "/exit") == 0) { printf("%s(%s)(%d) leaves the chatroom.\n", np->name, np->ip, np->data); sprintf(send_buffer, "%s(%s) leaves the chatroom.", np->name, np->ip); leave_flag = 1; } else { printf("Fatal Error: -1\n"); leave_flag = 1; } sendAll(np, send_buffer); } //這個部分是在把 node 移除 close(np->data); if (np == now) { // remove an edge node now = np->prev; now->link = NULL; } else { // remove a middle node np->prev->link = np->link; np->link->prev = np->prev; } free(np); } void breakPoint(int sig) { ClientList *tmp; while (root != NULL) { printf("\nClose socketfd: %d\t Bye!", root->data); close(root->data); // close all socket include server_sockfd tmp = root; root = root->link; free(tmp); } exit(EXIT_SUCCESS); } void sendAll(ClientList *np, char tmp_buffer[]) { ClientList *tmp = root->link; while (tmp != NULL) { if (np->data != tmp->data) { // all clients except itself. printf("Send to sockfd... %d: \"%s\" \n", tmp->data, tmp_buffer); send(tmp->data, tmp_buffer, LENGTH_SEND, 0); } tmp = tmp->link; } }
f60db18fecf930ab288f164a47587d2fe7ae4d47
f473c6afff2ffb09dbef991575737cb23c964e3b
/old_sources/controller/version.h
d7f6cfd40560e8b2adb28a7fca4024984a5f4d8c
[]
no_license
bogamct/All-files-of-Giraff
9563dd7858ab25f937537b73fe7f9be6f4c9527b
a8bba26e1a0e2ca06345fd9d2bb0a70af7c1f480
refs/heads/master
2016-09-06T13:30:02.353010
2015-05-16T13:08:16
2015-05-16T13:08:16
null
0
0
null
null
null
null
UTF-8
C
false
false
402
h
version.h
#ifdef UNIT_TEST #define MYPROG #else #define MYPROG PROGMEM #endif char MYPROG CONTROLLER_PREFIX []="# Giraf "; char MYPROG CONTROLLER_VERSION []="1.2.196"; char MYPROG CONTROLLER_DATE []="2013-01-14"; char MYPROG CONTROLLER_USER_NAME []="Patrik"; char MYPROG CONTROLLER_USER_ABBREV[]="p"; char MYPROG CONTROLLER_COMMA []=", "; char MYPROG CONTROLLER_CRLF []="\r\n";
11e4135b9d80bb3ccc3ae9b0c4efa42079b4c875
b6de03d101fcfdb83f6b16f1783385e48bfdb584
/rtc/thirdparty/hisilicon/include/drv_gpio_ioctl.h
4d8616fba5c325aebc756a2b69b5c8220f67fb55
[]
no_license
Romantic-LiXuefeng/StudyProgram
b173308171895e118ae27bab96566a9d6b38f1e5
03a36009c8917cdc9f6dde39bc681d263bc1b3cc
refs/heads/master
2021-12-23T06:02:12.776062
2017-11-05T08:56:52
2017-11-05T08:56:52
null
0
0
null
null
null
null
UTF-8
C
false
false
1,894
h
drv_gpio_ioctl.h
/****************************************************************************** Copyright (C), 2001-2011, Hisilicon Tech. Co., Ltd. ****************************************************************************** File Name : drv_gpio_ioctl.h Version : Initial Draft Author : Hisilicon multimedia software group Created : 2010/07/07 Description : History : 1.Date : 2010/07/07 Author : j40671 Modification: Created file ******************************************************************************/ #ifndef __DRV_GPIO_IOCTL_H__ #define __DRV_GPIO_IOCTL_H__ #include "hi_drv_gpio.h" typedef struct hiGPIO_OUTPUT_TYPE_S { HI_U32 u32GpioNo; HI_UNF_GPIO_OUTPUTTYPE_E enOutputType; }GPIO_OUTPUT_TYPE_S; typedef struct hiGPIO_DIRECT_S { HI_U32 u32GpioNo; HI_BOOL bInput; } GPIO_DIRECT_S; typedef struct hiGPIO_VALUE_S { HI_U32 u32GpioNo; HI_BOOL bHighVolt; } GPIO_VALUE_S; /* Ioctl definitions */ #define CMD_GPIO_SET_INT_TYPE _IOW(HI_ID_GPIO, 0x1, GPIO_DATA_S) /*set interruput condition*/ #define CMD_GPIO_SET_INT_ENABLE _IOW(HI_ID_GPIO, 0x2, GPIO_DATA_S) /*set interruput enable or disable*/ #define CMD_GPIO_GET_INT _IOR(HI_ID_GPIO, 0x3, GPIO_INT_S) /*get interruput occur*/ #define CMD_GPIO_GET_GPIONUM _IOR(HI_ID_GPIO, 0x4, GPIO_GET_GPIONUM_S) /*get gpio max number and group number*/ #define CMD_GPIO_SET_OUTPUTTYPE _IOW(HI_ID_GPIO, 0x5, GPIO_OUTPUT_TYPE_S) #define CMD_GPIO_GET_OUTPUTTYPE _IOWR(HI_ID_GPIO,0x6, GPIO_OUTPUT_TYPE_S) #define CMD_GPIO_SET_DIRECT _IOW(HI_ID_GPIO, 0x7, GPIO_DIRECT_S) #define CMD_GPIO_GET_DIRECT _IOWR(HI_ID_GPIO,0x8, GPIO_DIRECT_S) #define CMD_GPIO_SET_VALUE _IOW(HI_ID_GPIO, 0x9, GPIO_VALUE_S) #define CMD_GPIO_GET_VALUE _IOWR(HI_ID_GPIO,0xa, GPIO_VALUE_S) #endif /* End of #ifndef __HI_DRV_GPIO_H__*/
fa1f8f60e3e0cf5d63aecf9c639d1badd492fc13
df3843e4312de33f6e2960555cb1d1d4556c4299
/order.c
921a839876921b45bdc9a56ae94e2caf19fed965
[]
no_license
wsrf-wmq/Home
056ca10cfc40bc4edc9c3022432922f6e65b0766
93a94098050398270ccfb4e301beb560de4f5251
refs/heads/master
2022-07-10T05:29:14.928781
2020-05-20T14:13:59
2020-05-20T14:13:59
null
0
0
null
null
null
null
UTF-8
C
false
false
524
c
order.c
//指针运算中的优先级 // order.c // C programming // // Created by bhjml on 2020/4/22. // Copyright © 2020 bhjml. All rights reserved. // #include <stdio.h> int data[2]={100,200}; int moredata[2]={300,400}; int main() { int *p1, *p2, *p3; p1 = p2 = data; p3 = moredata; printf(" *p1 = %d, *p2 = %d, *p3 = %d\n",*p1 ,*p2, *p3); printf(" *p1++ = %d, *++p2 = %d, (*p3)++ = %d\n",*p1++,*++p2,(*p3)++); printf(" *p1 = %d, *p2 = %d, *p3 = %d\n",*p1 ,*p2, *p3); return 0; }
e686aa0c85d196e33562ea3bdaf171bbf40530d2
83951f7fd0bbaba9675bdf9ba6980504213bc1c6
/interface/Enums.h
f01a0c06eae5d052313b568f3477642a520bb73d
[]
no_license
DryRun/DijetSkimmer
6db71583b969ecc64841da26107f43c4c734ca43
ead65f8e2a5d11f99f3e1a60a1d2f9a163e68491
refs/heads/main
2021-07-22T19:41:09.096943
2021-07-14T13:01:00
2021-07-14T13:01:00
171,485,404
0
1
null
null
null
null
UTF-8
C
false
false
113
h
Enums.h
#ifndef Enums_h #define Enums_h enum Year_t { k2016, k2017, k2018 }; enum Source_t { kDATA, kMC }; #endif
13f4149bf235ca8d349d59b5ff74d43ebdc67a0d
028274ea477dd5aaf5a854c48d8d88dd52f768aa
/trunk/capturer/wifistub.c
86833b5242374245adf216725fd1e6a1fd839eac
[]
no_license
TrainingProject/FINS-Framework
c1a182cb1733248f762c4216dc81ac0416d92db8
475bdcfd7478c0c545bcf0c4b6cf023d884e47c1
refs/heads/master
2020-04-06T09:34:53.471498
2012-12-07T12:57:16
2012-12-07T12:57:16
null
0
0
null
null
null
null
UTF-8
C
false
false
9,738
c
wifistub.c
/* * wifistub.c * * Created on: Nov 22, 2010 * Author: Abdallah Abdallah */ #include "wifistub.h" #include <signal.h> /** ONLY FOR DEBUGGING * TO BE REMOVED REMOVED REMOVED * */ /** Globally defined counters * */ extern int inject_count; extern int capture_count; /** * print data in rows of 16 bytes: offset hex ascii * * 00000 sniff_udp 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a GET / HTTP/1.1.. */ void print_hex_ascii_line(const u_char *payload, int len, int offset) { int i; int gap; const u_char *ch; /* offset */ printf("%05d ", offset); /* hex */ ch = payload; for (i = 0; i < len; i++) { printf("%02x ", *ch); ch++; /* print extra space after 8th byte for visual aid */ if (i == 7) printf(" "); } /* print space to handle line less than 8 bytes */ if (len < 8) printf(" "); /* fill hex gap with spaces if not full line */ if (len < 16) { gap = 16 - len; for (i = 0; i < gap; i++) { printf(" "); } } printf(" "); /* ascii (if printable) */ ch = payload; for (i = 0; i < len; i++) { if (isprint(*ch)) printf("%c", *ch); else printf("."); ch++; } printf("\n"); return; } //end of print_hex_ascii_line() /** * print a captured frame */ void print_frame(const u_char *payload, int len) { PRINT_DEBUG("passed len = %d", len); int len_rem = len; int line_width = 16; /* number of bytes per line */ int line_len; int offset = 0; /* zero-based offset counter */ const u_char *ch = payload; if (len <= 0) return; /* data fits on one line */ if (len <= line_width) { PRINT_DEBUG("calling hex_ascii_line"); print_hex_ascii_line(ch, len, offset); return; } /* data spans multiple lines */ for (;;) { /* compute current line length */ line_len = line_width % len_rem; /* print line */ print_hex_ascii_line(ch, line_len, offset); /* compute total remaining */ len_rem = len_rem - line_len; /* shift pointer to remaining bytes to print */ ch = ch + line_len; /* add offset */ offset = offset + line_width; /* check if we have line width chars or less */ if (len_rem <= line_width) { /* print last line and get out */ print_hex_ascii_line(ch, len_rem, offset); break; } } return; } // end of print_frame /** ----------------------------------------------------------------------------------*/ /*int*/void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packetReceived) { //TODO: pcap_handlers must be of void type. This method of returning data will have to be amended static int count = 1; /* packet counter */ //u_char * packet; /* Packet Pointer */ //struct data_to_pass data; u_int numBytes; u_int dataLength; PRINT_DEBUG("Packet number %d: has been captured \n", count); if (header->caplen != header->len) { PRINT_DEBUG("Snaplen value is not enough to capture the whole packet as it is on wire \n"); exit(1); } //data.frameLength = header->caplen ; //data.frame = (u_char *) malloc(header->caplen); //memcpy(data.frame,packetReceived,data.frameLength); /** Write the length of the received frame to the pipe, then write the frame contents * This part is an atomic critical section. Need to be handled carefully */ dataLength = header->caplen; print_frame(packetReceived, dataLength); fflush(stdout); numBytes = write(income_pipe_fd, &dataLength, sizeof(u_int)); if (numBytes <= 0) { PRINT_DEBUG("numBytes written %d\n", numBytes); //return (0); return; } numBytes = write(income_pipe_fd, packetReceived, dataLength); if (numBytes <= 0) { PRINT_DEBUG("numBytes written %d\n", numBytes); //return (0); return; } PRINT_DEBUG("A frame of length %d has been captured \n", numBytes); capture_count++; //return (1); return; } // end of the function got_packet void capture_init(char *interface) { char device[20]; strcpy(device, interface); char errbuf[PCAP_ERRBUF_SIZE]; /* error buffer */ //unsigned char dev_macAddress[17]; char *filter_exp; unsigned char *dev; filter_exp = (char *) malloc(200); int check_monitor_mode; struct bpf_program fp; /* compiled filter program (expression) */ bpf_u_int32 mask; /* subnet mask */ bpf_u_int32 net; /* ip */ // int num_packets = 1000; /* number of packets to capture */ int num_packets = 0; /* INFINITY */ int data_linkValue; //print_app_banner(); dev = (unsigned char *) device; /* if (mkfifo(INCOME_PIPE, 0777) !=0 ) { PRINT_DEBUG("MKFIFO Failed \n"); exit(EXIT_FAILURE); } */ /* has to run without return check to work as blocking call */ /** It blocks until the other communication side opens the pipe */ income_pipe_fd = open(INCOME_PIPE, O_WRONLY); if (income_pipe_fd == -1) { PRINT_DEBUG("Income Pipe failure \n"); exit(EXIT_FAILURE); } //TODO recv MAC/ip address from Core? /* Build the filter expression based on the mac address of the passed * device name */ // strcat(filter_exp,"ether dst "); //char filter_exp[] = "ether src 00:1e:2a:52:ec:9c"; /* filter expression [3] */ // getDevice_MACAddress(dev_macAddress,dev); // strcat(filter_exp,dev_macAddress); //strcat(filter_exp, ""); //everything //strcat(filter_exp, "dst host 127.0.0.1"); //local loopback - for internal testing, can't use external net strcat(filter_exp, "(ether dst 080027445566) or (ether broadcast and (not ether src 080027445566))"); /* get network number and mask associated with capture device */ if (pcap_lookupnet((char *)dev, &net, &mask, errbuf) == -1) { fprintf(stderr, "Couldn't get netmask for device %s: %s\n", dev, errbuf); net = 0; mask = 0; } /* print capture info */ printf("Device: %s\n", dev); printf("Number of packets: %d\n", num_packets); printf("Filter expression: %s\n", filter_exp); /* open capture device */ capture_handle = pcap_open_live((char *)dev, SNAP_LEN, 1, 1000, errbuf); if (capture_handle == NULL) { fprintf(stderr, "Couldn't open device %s: %s\n", dev, errbuf); exit(EXIT_FAILURE); } /* make sure we're capturing on an Ethernet device [2] */ data_linkValue = pcap_datalink(capture_handle); if (data_linkValue != DLT_EN10MB) { fprintf(stderr, "%s is not an Ethernet\n", dev); exit(EXIT_FAILURE); } printf("Datalink layer Description: %s (%d) \n", pcap_datalink_val_to_description(data_linkValue), data_linkValue); /* compile the filter expression */ if (pcap_compile(capture_handle, &fp, filter_exp, 0, net) == -1) { fprintf(stderr, "Couldn't parse filter %s: %s\n", filter_exp, pcap_geterr(capture_handle)); exit(EXIT_FAILURE); } /* apply the compiled filter */ if (pcap_setfilter(capture_handle, &fp) == -1) { fprintf(stderr, "Couldn't install filter %s: %s\n", filter_exp, pcap_geterr(capture_handle)); exit(EXIT_FAILURE); } //CHANGED mrd015 !!!!! start pcap_can_set_rfmon(...) not in Bionic! #ifndef BUILD_FOR_ANDROID check_monitor_mode = pcap_can_set_rfmon(capture_handle); if (check_monitor_mode) { PRINT_DEBUG("\n Monitor mode can be set\n"); } else if (check_monitor_mode == 0) { PRINT_DEBUG("\n Monitor mode could not be set\n"); } else PRINT_DEBUG("\n check_monior_mode value is %d \n", check_monitor_mode); #endif //CHANGE END !!!!! /* now we can set our callback function */ pcap_loop(capture_handle, num_packets, got_packet, (u_char *) NULL); /* cleanup */ pcap_freecode(&fp); free(filter_exp); PRINT_DEBUG("END of capt init"); } // end of capture_init /** -----------------------------------------------------------------*/ void inject_init(char *interface) { /* if (mkfifo(INJECT_PIPE, 0777) !=0 ) { PRINT_DEBUG("MKFIFO of INJECT Failed \n"); exit(EXIT_FAILURE); } */ // static int count = 1; unsigned char device[20]; //unsigned char dev_macAddress[17]; strcpy((char *)device, interface); int framelen; //char *frame; int numBytes; unsigned char *dev; dev = (unsigned char *) device; char errbuf[PCAP_ERRBUF_SIZE]; /* error buffer */ char frame[SNAP_LEN]; //getDevice_MACAddress(dev_macAddress,dev); /** has to run without return check to work as blocking call * It blocks until the other communication side opens the pipe * */ // mkfifo(INJECT_PIPE, 0777); inject_pipe_fd = open(INJECT_PIPE, O_RDONLY); if (inject_pipe_fd == -1) { PRINT_DEBUG("Inject Pipe failure \n"); exit(EXIT_FAILURE); } /** Setup the Injection Interface */ if ((inject_handle = pcap_open_live((char *)dev, BUFSIZ, 1, -1, errbuf)) == NULL) { PRINT_DEBUG( "\nError: %s\n", errbuf); exit(1); } /** --------------------------------------------------------------------------*/ while (1) { numBytes = read(inject_pipe_fd, &framelen, sizeof(int)); if (numBytes <= 0) { PRINT_DEBUG("numBytes written %d\n", numBytes); break; } //frame = (char *) malloc (framelen); numBytes = read(inject_pipe_fd, frame, framelen); if (numBytes <= 0) { PRINT_DEBUG("numBytes written %d\n", numBytes); break; } PRINT_DEBUG("A frame of length %d will be injected-----", framelen); print_frame((u_char *)frame, framelen); /** * Inject the Ethernet Frame into the Device */ numBytes = pcap_inject(inject_handle, frame, framelen); if (numBytes == -1) { PRINT_DEBUG("Failed to inject the packet"); } else { PRINT_DEBUG("\n Message #%d has been injected whose size is %d ", inject_count, numBytes); inject_count++; } } // end of while loop } // inject_init() /** ------------------------------------------------------------------*/ void wifi_terminate() { pcap_close(inject_handle); pcap_close(capture_handle); } // end of wifi_terminate /** -------------------------------------------------------------*/ void close_pipes() { unlink(INCOME_PIPE); unlink(INJECT_PIPE); close(income_pipe_fd); close(inject_pipe_fd); }
a35842f57c6eee1248ae8bb7ea4508f931920b01
fa5ba506f7c7842af37e95270241cbb3b9cd92e3
/extmod/zvm/tas_account.c
794308d9b9b7a0517d2bbb4a7796f68aa761065f
[ "GPL-3.0-or-later", "MIT" ]
permissive
zvchain/zvm
d5a89b274fc7fb663a1cdfd659917ed66df76f8d
b44136b73b98222b43d907d58f536bcb80e20fc1
refs/heads/develop
2020-06-07T17:21:24.009943
2020-02-25T10:04:12
2020-02-25T10:04:12
193,063,101
1
1
MIT
2019-09-17T09:39:34
2019-06-21T08:41:33
C
UTF-8
C
false
false
2,853
c
tas_account.c
// Copyright (C) 2018 TASChain // // 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 <https://www.gnu.org/licenses/>. #include <stdio.h> #include "py/runtime.h" #include "py/obj.h" #include "py/objtuple.h" #include "py/objstr.h" #include "py/bc0.h" #include "py/objint.h" #include "py/lexer.h" #include "py/compile.h" #include "py/tvm.h" #include "py/gas.h" #include "py/obj.h" #include <stdlib.h> #include <string.h> STATIC mp_obj_t mod_account_get_balance(mp_obj_t address) { byte code = MP_BC_GET_BALANCE; if(!CheckGas(&code)) { return mp_const_none; } char* str = get_balance(mp_obj_str_get_str(address)); char* t_str = str; //TODO: not neg bool neg = false; if (str[0] == 45) { neg = true; t_str ++; } int len = strlen(t_str); const char* const_t_str = t_str; mp_obj_t o = mp_obj_new_int_from_str_len(&const_t_str, len, neg, 10); free(str); return o; }; STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_account_get_balance_obj , mod_account_get_balance); STATIC mp_obj_t mod_account_transfer(mp_obj_t address,mp_obj_t amount) { bool success=false; mp_obj_get_int(amount); char stack_buf[sizeof(mp_int_t) * 4]; char *buf = stack_buf; size_t buf_size = sizeof(stack_buf); size_t fmt_size; char *str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, amount, 10, NULL, '\0', '\0'); if (buf != stack_buf) { m_del(char, buf, buf_size); } byte code = MP_BC_TRANSFER; if(CheckGas(&code)) { success = transfer_fn(mp_obj_str_get_str(address), str); } return mp_obj_new_bool(success); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_account_transfer_obj, mod_account_transfer); STATIC const mp_rom_map_elem_t mp_module_account_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_account) }, { MP_ROM_QSTR(MP_QSTR_get_balance), MP_ROM_PTR(&mod_account_get_balance_obj) }, { MP_ROM_QSTR(MP_QSTR_transfer), MP_ROM_PTR(&mod_account_transfer_obj)}, }; STATIC MP_DEFINE_CONST_DICT(mp_module_account_globals, mp_module_account_globals_table); const mp_obj_module_t mp_module_account = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_account_globals, };
5e2e07ef46bb6357af4ddfb999b9a33308b2988c
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/fastsocket/kernel/sound/pci/au88x0/extr_au88x0_pcm.c_snd_vortex_spdif_get.c
47e16223afccc35b7cf2798beb935e3a3df41d61
[]
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,585
c
extr_au88x0_pcm.c_snd_vortex_spdif_get.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_7__ TYPE_3__ ; typedef struct TYPE_6__ TYPE_2__ ; typedef struct TYPE_5__ TYPE_1__ ; /* Type definitions */ struct TYPE_7__ {int spdif_sr; } ; typedef TYPE_3__ vortex_t ; struct snd_kcontrol {int dummy; } ; struct TYPE_5__ {int* status; } ; struct TYPE_6__ {TYPE_1__ iec958; } ; struct snd_ctl_elem_value {TYPE_2__ value; } ; /* Variables and functions */ int IEC958_AES1_CON_DIGDIGCONV_ID ; int IEC958_AES1_CON_ORIGINAL ; int IEC958_AES3_CON_FS_32000 ; int IEC958_AES3_CON_FS_44100 ; int IEC958_AES3_CON_FS_48000 ; TYPE_3__* snd_kcontrol_chip (struct snd_kcontrol*) ; __attribute__((used)) static int snd_vortex_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); ucontrol->value.iec958.status[0] = 0x00; ucontrol->value.iec958.status[1] = IEC958_AES1_CON_ORIGINAL|IEC958_AES1_CON_DIGDIGCONV_ID; ucontrol->value.iec958.status[2] = 0x00; switch (vortex->spdif_sr) { case 32000: ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS_32000; break; case 44100: ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS_44100; break; case 48000: ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS_48000; break; } return 0; }
8c55cdf0c6c20006a307b49da91895e9a9817d86
72e98dbc4e8a16dd4022ebe32f7d0a755443d05c
/main_node.c
025b6a2338c643bfc42741e9d40c611637cee750
[]
no_license
polarpolar/BLENode
62e0e50be914cefc7906a2fa33b40df0b419ee35
055d9e522991104ffb6ce37b57a848d649e915c3
refs/heads/master
2020-05-28T11:19:14.070280
2014-09-19T11:53:48
2014-09-19T11:53:48
null
0
0
null
null
null
null
UTF-8
C
false
false
1,276
c
main_node.c
#include <REG51.H> #include <stdio.h> #include "Delay.h" #include "LCD.h" #include "BDE0700.h" #include "KXTJ9.h" #include "ADS1000.h" #include "BlueUART.h" #include "tmp100.h" #include "UVMeter.h" #define ANum 1 int a_time=0; int a_count=0; int cnt=0; uint temperaqture; unsigned char payload[1+2+6*ANum+2]; void main() { //int acc_x,acc_y,acc_z; int tmp = 0xAAAA; unsigned char i; unsigned char ini_cnt; //Initialize Ht1621_Init(); Ht1621WrAllData(); LCD_show(0xFFFF);wait(1,1000); // tmp100 if(cnt){ tmpInit(); // Init, Res12/RanH/Mod0 tmpSetRes(3); // Set Resolution (0-9/1-10/2-11/3-12) tmpSetRange(1); // Set Range (0:L/1:H) tmpSetMode(0); // Set Mode (0:Continuous/1:ShutDown) } if(1){ // UV_Meter uvReset(); uvPre(); setForceMode(); setALSVISMode(); } LCD_show(0x7777);wait(3,1000); payload[0]=1; ini_cnt=0; i=1; while(1) { //initialization /*if(ini_cnt==50) { Ht1621_Init(); ini_cnt=1; }*/ //tmpGetTmpCont(&tmp); startForceMeas(); getALSVISData(&tmp); //circleData(&tmp); //uvPre(); cnt++; if(cnt==1) { LCD_show(tmp); BlueTooth_Send(payload, 1); wait(3,1000); } if(cnt==2){ LCD_show(payload[0]++); BlueTooth_Send(payload, 1); wait(2,1000); cnt=0; } } }
475beb152e7604dbce1187b8b76af829d6440df0
bb108c3ea7d235e6fee0575181b5988e6b6a64ef
/mame/src/emu/cpu/tms9900/99xxcore.h
f37adc5d1d2ae576a29014405fe445ec49ccf65d
[ "MIT" ]
permissive
clobber/MAME-OS-X
3c5e6058b2814754176f3c6dcf1b2963ca804fc3
ca11d0e946636bda042b6db55c82113e5722fc08
refs/heads/master
2021-01-20T05:31:15.086981
2013-04-17T18:42:40
2013-04-17T18:42:40
3,805,274
15
8
null
2013-04-17T18:42:41
2012-03-23T04:23:01
C
UTF-8
C
false
false
147,527
h
99xxcore.h
/* 99xxcore.h : generic tms99xx emulation The TMS99XX_MODEL switch tells which emulator we want to build. Set the switch, then include 99xxcore.h, and you will have an emulator for this processor. Only ti990/10, tms9900, tms9980a/9981, and tms9995 work OK for now. Note that tms9995 has not been tested extensively. tms9940 is WIP: it is probably still buggy (particularily the BCD support), as it has not been tested. tms9985 has been implemented as a 9940 with a data bus, which should be mostly correct. I think all software aspects of tms9985 and tms9989 are implemented. You just need to implement bus interfaces, provided you know them. (I don't...) tms99000 cannot be implemented fully yet, due to lack of documentation. ti990/12 is not supported at all, and it should probably be implemented as a separate processor core, anyway. Original tms9900 emulator by Edward Swartz Smoothed out by Raphael Nabet Originally converted for Mame by M.Coates Processor timing, support for tms9980 and tms9995, and many bug fixes by R Nabet */ /* The first member of the family was actually the ti990/10 minicomputer, released in 1975. tms9900 was released in 1976, and has the same instruction set as ti990/10: however, tms9900 is slower, it does not support privileges and memory mapping, and illegal instructions do not cause an error interrupt. The ti990 family later evoluted into the huge ti990/12 system, with support for 144 different instructions, and microcode programming in case some user found it was not enough. ti990/10 was eventually replaced by a cheaper ti990/10a board, built around a tms99000 microprocessor. The tms9980 processor is merely a tms9900 with a 8-bit data bus (instead of 16-bit on tms9900). tms9940 is a microcontroller, and is mostly similar to 9900/9980. The variant I know has 2kb of ROM, 128 bytes of RAM, a timer, 32 I/O line, some of which can be reconfigured as a CRU bus, but no external memory bus. It includes three additional opcodes, which are not supported by any other member of the family (with the probable exception of TMS9985). tms9985 is similar to tms9940, but it supports an external 8-bit-wide memory bus. At least one variant included 8kb of ROM, 256 bytes of RAM. It was ill-fated, as it was never released due to technical problems. tms9989 is mostly alien to me. I guess it is a close relative of tms9995, although I am not sure. I have read that the SBP68689 supports tms9995 opcodes, but that tms9989 does not. tms9995 belongs to another generation. It is quite faster than tms9900, and supports 4 extra opcodes. Its external bus is 8-bit-wide, and it has 256 bytes of internal 16-bit RAM. tms99000 is the successor to both ti9900 and ti990/10. It supports privileges, and has a coprocessor interface which enables the use of an external memory mapper. Additionnally, it can use a Macrostore ROM to emulate additional instructions. This feature allowed TI to expand the 99000 family with the tms99105 (which was said to support 84 instructions types), the tms99110 (which supported floating point instructions), and possibly another chip (tms99220???) which included parts of the UCSD P-system in Macrostore. References : * 9900 family systems design, chapter 6, 7, 8 * TMS 9980A/ TMS 9981 Product Data Book * TMS 9995 16-Bit Microcomputer Data Manual * Model 990/10A computer general description, section 4 (p/n 2302633-9701 A) * 990/99000 assembly language reference manual (p/n 2270509-9701 A) * Chapter 18 of unidentified book is the only reference on tms9940 I have found so far (Paperport format) <ftp://ftp.whtech.com//datasheets/Hardware manuals/tms9900 9901 9904 9940 9980 (by a osborne).max> Other references can be found on spies.com: <http://www.spies.com/arcade/simulation/processors/index.html> <http://www.spies.com/~aek/pdf/ti/> */ #include "tms9900.h" #if (TMS99XX_MODEL == TI990_10_ID) #define TMS99XX_PREFIX ti990_10 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( ti990_10 ) #define TMS99XX_device_get_name "TI990/10" #elif (TMS99XX_MODEL == TMS9900_ID) #define TMS99XX_PREFIX tms9900 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms9900 ) #define TMS99XX_device_get_name "TMS9900" #elif (TMS99XX_MODEL == TMS9940_ID) #define TMS99XX_PREFIX tms9940 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms9940 ) #define TMS99XX_device_get_name "TMS9940" #error "tms9940 is not yet supported" #elif (TMS99XX_MODEL == TMS9980_ID) #define TMS99XX_PREFIX tms9980a #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms9980a ) #define TMS99XX_device_get_name "TMS9980A/TMS9981" #elif (TMS99XX_MODEL == TMS9985_ID) #define TMS99XX_PREFIX tms9985 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms9985 ) #define TMS99XX_device_get_name "TMS9985" #error "tms9985 is not yet supported" #elif (TMS99XX_MODEL == TMS9989_ID) #define TMS99XX_PREFIX tms9989 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms9989 ) #define TMS99XX_device_get_name "TMS9989" #error "tms9989 is not yet supported" #elif (TMS99XX_MODEL == TMS9995_ID) #define TMS99XX_PREFIX tms9995 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms9995 ) #define TMS99XX_device_get_name "TMS9995" #elif (TMS99XX_MODEL == TMS99000_ID) #define TMS99XX_PREFIX tms99000 #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms99000 ) #define TMS99XX_device_get_name "TMS99000" #error "tms99000 is not yet supported" #elif (TMS99XX_MODEL == TMS99105A_ID) #define TMS99XX_PREFIX tms99105a #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms99105a ) #define TMS99XX_device_get_name "TMS99105A" #error "tms99105a is not yet supported" #elif (TMS99XX_MODEL == TMS99110A_ID) #define TMS99XX_PREFIX tms99110a #define TMS99XX_GET_INFO CPU_GET_INFO_NAME( tms99110a ) #define TMS99XX_device_get_name "TMS99110A" #error "tms99110a is not yet supported" #endif /* Now for some preprocessor wizardry. */ #define concat2(a,b) a##b #define GET_INFO(prefix) concat2(prefix,_get_info) #define RESET_PARAM(prefix) concat2(prefix,reset_param) #define TMS99XX_RESET_PARAM RESET_PARAM(TMS99XX_PREFIX) /* I include this macro because we may eventually support other 99000 variants such as tms99110, and this macro will remain true for every 99000 family member, even when we have (TMS99XX_MODEL != TMS99000_ID). */ #define IS_99000 (TMS99XX_MODEL == TMS99000_ID) /* On microprocessor implementations (other than TMS9940 and, probably, TMS9985), the CKOF, CKON, IDLE, LREX and RSET cause an external CRU write. CKOF, CKON and LREX do nothing apart of this, therefore they must be implemented with external hardware (CKON and CKOF are supposed to enable/disable a line clock interrupt, and LREX to trigger a LOAD interrupt). IDLE and RSET are functional, but, on the one hand, the design allowed to light a diagnostic LED when the processor is in IDLE state, and, on the other hand, the RSET instruction is supposed to reset external devices as well. On the TI990/10 and TI990/12 minicomputers, there is no such CRU write. The line clock interrupt latch is part of the CPU board, LREX is fully functional, the IDLE led is connected to the board, and the RSET line is part of the TILINE bus connector. On the TMS9940, CKOF, CKON, LREX and RSET are not supported. IDLE, on the other hand, is supported, and the CPU can be configured to output its IDLE state on the P16 I/O pin. */ #define EXTERNAL_INSTRUCTION_DECODING (TMS99XX_MODEL != TI990_10_ID) && (TMS99XX_MODEL != TI9940_ID) && (TMS99XX_MODEL != TI9985_ID) #define EXTERNAL_INSTRUCTION_CALLBACK (TMS99XX_MODEL == TI990_10_ID) /* ti990/10, ti990/12 and tms99000 support privileges privileged instructions: CKOF, CKON, IDLE, LIMI, LREX, RSET, LDD, LDS, LMF, (memory mapping instructions) DINT, EINT, EMD , LCS, LIM, SLSP. (990/12 instructions) instructions which are privileged when the effective CRU address is higher than 0xE00: LDCR, SBO, SBZ, STCR, TB. instructions whose behaviour is modified in user mode (only user flags in ST are affected): RTWP, LST. (ti990/12 and tms99000 instruction) */ #define HAS_PRIVILEGE ((TMS99XX_MODEL == TI990_10_ID) || IS_99000) /* opcode groups * 69 basic opcodes implemented on all family members * 3 memory mapping opcodes implemented on ti990/10 with mapping option, ti990/12, and the tim99610 mapper in conjunction with any tms99000 family member: LMF, LDS, LDD * 3 opcodes implemented on tms9940 (and probably tms9985) only: DCA, DCS, LIIM * 4 opcodes implemented on ti990/12, tms9989 and above: MPYS, DIVS, LST, LWP * 1 opcode implemented on ti990/12, and tms99000: BIND * 72 opcodes implemented on ti990/12 only (some of which are emulated by tms99105 & tms99110) */ #define HAS_MAPPING ((TMS99XX_MODEL == TI990_10_ID) /*|| IS_99000*/) #define HAS_9995_OPCODES ((TMS99XX_MODEL == TMS9989_ID) || (TMS99XX_MODEL == TMS9995_ID) || IS_99000) #define HAS_BIND_OPCODE IS_99000 #define HAS_OVERFLOW_INTERRUPT ((TMS99XX_MODEL == TMS9995_ID) || IS_99000) /* Under tms9900, opcodes >0200->03FF are incompletely decoded: bits 11 is ignored, and so are bits 12-15 for instructions which do not require a register. On the other hand, ti990/10 generates an illegal instruction error when bit 11 is set, but still ignores bits 12-15. Additionally, ti990/12 and tms9995 will generate an illegal error when bits 12-15 are non-zero. */ #define BETTER_0200_DECODING (TMS99XX_MODEL == TI990_10_ID) #define COMPLETE_0200_DECODING (TMS99XX_MODEL >= TMS9995_ID) /* TI990/10 and tms9900 force unused bits in the ST register to 0. TMS9995 does not. */ #define USE_ST_MASK (TMS99XX_MODEL <= TMS9985_ID) /* TI990/10, TMS9900 and TMS99000 have a 16-bit-wide memory bus, and use 16-bus accessors. TMS9940 use 16-bit accessors, too, as it has an internal 16-bit bus, and no external bus. */ #define USE_16_BIT_ACCESSORS ((TMS99XX_MODEL == TI990_10_ID) || (TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9940_ID) || (IS_99000)) typedef struct _tms99xx_state tms99xx_state; INLINE void execute(tms99xx_state *cpustate, UINT16 opcode); #if EXTERNAL_INSTRUCTION_DECODING static void external_instruction_notify(tms99xx_state *cpustate, int ext_op_ID); #endif static UINT16 decipheraddr(tms99xx_state *cpustate, UINT16 opcode); static UINT16 decipheraddrbyte(tms99xx_state *cpustate, UINT16 opcode); static void contextswitch(tms99xx_state *cpustate, UINT16 addr); #if HAS_MAPPING || HAS_PRIVILEGE static void contextswitchX(tms99xx_state *cpustate, UINT16 addr); #else #define contextswitchX(cs, addr) contextswitch(cs, addr) #endif static void field_interrupt(tms99xx_state *cpustate); /***************************/ /* Mame Interface Routines */ /***************************/ /* tms9900 ST register bits. */ /* These bits are set by every compare, move and arithmetic or logical operation : */ /* (Well, COC, CZC and TB only set the E bit, but these are kind of exceptions.) */ #define ST_LGT 0x8000 /* Logical Greater Than (strictly) */ #define ST_AGT 0x4000 /* Arithmetical Greater Than (strictly) */ #define ST_EQ 0x2000 /* Equal */ /* These bits are set by arithmetic operations, when it makes sense to update them. */ #define ST_C 0x1000 /* Carry */ #define ST_OV 0x0800 /* OVerflow (overflow with operations on signed integers, */ /* and when the result of a 32bits:16bits division cannot fit in a 16-bit word.) */ /* This bit is set by move and arithmetic operations WHEN THEY USE BYTE OPERANDS. */ #define ST_OP 0x0400 /* Odd Parity */ #if (TMS99XX_MODEL != TMS9940_ID) /* This bit is set by the XOP instruction. */ #define ST_X 0x0200 /* Xop */ #endif #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) /* This bit is set by arithmetic operations to support BCD */ #define ST_DC 0x0100 /* Digit Carry */ #endif #if HAS_PRIVILEGE /* This bit is set in user (i.e. non-supervisor) mode */ #define ST_PR 0x0100 /* PRivilege */ #endif #if HAS_MAPPING /* This tells which map is currently in use */ #define ST_MF 0x0080 /* Map File */ #endif #if (HAS_OVERFLOW_INTERRUPT) /* This bit is set in ti990/12, TMS9995 and later chips to generate a level-2 interrupt when the Overflow status bit is set */ #define ST_OVIE 0x0020 /* OVerflow Interrupt Enable */ #endif #if (IS_99000) /* This bit enables the macrostore feature on tms99000 */ /* (It is used on ti990/12 with a different meaning.) */ #define ST_EMR 0x0010 /* Enable Macrostore Rom */ #endif #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) #define ST_IM 0x0003 /* Interrupt Mask */ #else #define ST_IM 0x000F /* Interrupt Mask */ #endif /* On models before TMS9995 (TMS9989 ?), unused ST bits are always forced to 0, so we define a ST_MASK */ #if (USE_ST_MASK) #if (TMS99XX_MODEL == TI990_10_ID) #define ST_MASK 0xFF8F #elif (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) #define ST_MASK 0xFD03 #else #define ST_MASK 0xFE0F #endif #endif /* error interrupt register bits */ #if (TMS99XX_MODEL == TI990_10_ID) /* This bit is set in user (i.e. non-supervisor) mode */ #define EIR_MAPERR 0x0800 /* memory MAPping ERRor */ #define EIR_MER 0x1000 /* Memory parity ERRor */ #define EIR_ILLOP 0x2000 /* ILLegal OPcode */ #define EIR_PRIVOP 0x4000 /* PRiviledged OPeration */ #define EIR_TIMEOUT 0x8000 /* TILINE TIMEOUT */ #endif /* Offsets for registers. */ #define R0 0 #define R1 2 #define R2 4 #define R3 6 #define R4 8 #define R5 10 #define R6 12 #define R7 14 #define R8 16 #define R9 18 #define R10 20 #define R11 22 #define R12 24 #define R13 26 #define R14 28 #define R15 30 typedef struct map_file_t { UINT16 L[3], B[3]; /* actual registers */ UINT32 limit[3], bias[3]; /* equivalent in a more convenient form */ } map_file_t; struct _tms99xx_state { /* "actual" tms9900 registers : */ UINT16 WP; /* Workspace pointer */ UINT16 PC; /* Program counter */ UINT16 STATUS; /* STatus register */ /* Now, data used for emulation */ UINT8 lastparity; char lds_flag, ldd_flag; UINT16 IR; /* Instruction register, with the currently parsed opcode */ UINT8 interrupt_pending; /* true if an interrupt must be honored... */ #if ! ((TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID)) UINT8 load_state; /* nonzero if the LOAD* line is active (low) */ #endif #if (TMS99XX_MODEL == TI990_10_ID) || (TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID) /* On tms9900, we cache the state of INTREQ* and IC0-IC3 here */ /* On tms9980/9981, we translate the state of IC0-IC2 to the equivalent state for a tms9900, and store the result here */ UINT8 irq_level; /* when INTREQ* is active, interrupt level on IC0-IC3 ; else always 16 */ UINT8 irq_state; /* nonzero if the INTREQ* line is active (low) */ /* with TMS9940, bit 0 means INT1, bit 1 decrementer, bit 2 INT2 */ #elif (TMS99XX_MODEL == TMS9995_ID) /* tms9995 is quite different : it latches the interrupt inputs */ UINT8 irq_level; /* We store the level of the request with the highest level here */ UINT8 int_state; /* interrupt lines state */ UINT8 int_latch; /* interrupt latches state */ #endif /* interrupt callback */ /* note that this callback is used by tms9900_set_irq_line(cpustate) and tms9980a_set_irq_line(cpustate) to retreive the value on IC0-IC3 (non-standard behaviour) */ device_irq_callback irq_callback; legacy_cpu_device *device; address_space *program; address_space *io; int icount; UINT8 IDLE; /* nonzero if processor is IDLE - i.e waiting for interrupt while writing special data on CRU bus */ #if HAS_MAPPING UINT8 mapping_on; /* set by a CRU write */ map_file_t map_files[3]; /* internal mapper registers */ UINT8 cur_map; /* equivalent to ST_MF status bit */ UINT8 cur_src_map; /* set to 2 by LDS */ UINT8 cur_dst_map; /* set to 2 by LDD */ #if (TMS99XX_MODEL == TI990_10_ID) UINT8 reset_maperr; /* reset mapper error flag line (reset flags in 945417-9701 p. 3-90) */ UINT32 mapper_address_latch; /* used to load the map file and for diagnostic purpose */ UINT16 mapper_cru_read_register; /* read register select code for mapper cru interface */ UINT8 diaglat; /* set when diagnostic address latch is done */ UINT8 latch_control[3]; /* latch control */ #endif #endif #if (TMS99XX_MODEL == TI990_10_ID) UINT16 error_interrupt_register; /* one flag for each interrupt condition */ ti99xx_error_interrupt_func error_interrupt_callback; #endif #if (TMS99XX_MODEL == TMS9985_ID) || (TMS99XX_MODEL == TMS9995_ID) UINT8 RAM[256]; /* on-chip RAM (I know this is weird, but the internal bus is 16-bit-wide, whereas the external bus is 8-bit-wide) */ #endif #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) || (TMS99XX_MODEL == TMS9995_ID) /* on-chip event counter/timer*/ UINT8 decrementer_enabled; UINT16 decrementer_interval; UINT16 decrementer_count; /* used in event counter mode*/ emu_timer *timer; /* used in timer mode */ #endif #if (TMS99XX_MODEL == TMS9995_ID) /* additionnal registers */ UINT16 flag; /* flag register */ UINT8 MID_flag; /* MID flag register */ /* chip config, which can be set on reset */ UINT8 memory_wait_states_byte; UINT8 memory_wait_states_word; /* mask option (off on normal tms9995) */ UINT8 is_mp9537; #endif /* Some instructions (i.e. XOP, BLWP, and MID) disable interrupt recognition until another instruction is executed : so they set this flag */ UINT8 disable_interrupt_recognition; /* notify the driver of changes in IDLE state */ ti99xx_idle_func idle_callback; #if EXTERNAL_INSTRUCTION_CALLBACK ti99xx_rset_func rset_callback; ti99xx_lrex_func lrex_callback; ti99xx_ckon_ckof_func ckon_ckof_callback; #endif int write_inhibit; int extra_byte; /* buffer holding the unused byte in a word read */ }; INLINE tms99xx_state *get_safe_token(device_t *device) { assert(device != NULL); // assert(device->type() == TMS99XX_GET_INFO); return (tms99xx_state *)downcast<legacy_cpu_device *>(device)->token(); } #if (TMS99XX_MODEL == TMS9995_ID) static void reset_decrementer(tms99xx_state *cpustate); #endif #if (TMS99XX_MODEL == TI990_10_ID) /* accessor for the internal ROM */ READ16_HANDLER(ti990_10_internal_r) { //return cpustate->ROM[offset]; return space->read_word(0x1ffc00+offset); } #endif #if (TMS99XX_MODEL == TMS9995_ID) /* accessor for the first 252 bytes of internal RAM */ READ8_HANDLER(tms9995_internal1_r) { tms99xx_state *cpustate = get_safe_token(&space->device()); return cpustate->RAM[offset]; } WRITE8_HANDLER(tms9995_internal1_w) { tms99xx_state *cpustate = get_safe_token(&space->device()); cpustate->RAM[offset]=data; } /* accessor for the last 4 bytes of internal RAM */ READ8_HANDLER(tms9995_internal2_r) { tms99xx_state *cpustate = get_safe_token(&space->device()); return cpustate->RAM[offset+0xfc]; } WRITE8_HANDLER(tms9995_internal2_w) { tms99xx_state *cpustate = get_safe_token(&space->device()); cpustate->RAM[offset+0xfc]=data; } #endif #if (TMS99XX_MODEL == TI990_10_ID) /* on-board ROMs are not emulated (we use a hack) */ #define readword(cs, addr) readwordX((cs), (addr), (cs)->cur_map) static int readwordX(tms99xx_state *cpustate, int addr, int map_file) { if ((map_file == 0) && (addr >= 0xf800)) { /* intercept TPCS and CPU ROM */ if (addr < 0xfc00) /* TPCS */ return cpustate->program->read_word(0x1f0000+addr); else /* CPU ROM */ return cpustate->program->read_word(0x1f0000+addr); /* hack... */ } else if (! cpustate->mapping_on) { return cpustate->program->read_word(addr); } else { int map_index; if (addr <= cpustate->map_files[map_file].limit[0]) map_index = 0; else if (addr <= cpustate->map_files[map_file].limit[1]) map_index = 1; else if (addr <= cpustate->map_files[map_file].limit[2]) map_index = 2; else { /* mapping error */ if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = addr; if ((! cpustate->reset_maperr) && ! (cpustate->error_interrupt_register & EIR_MAPERR)) { cpustate->error_interrupt_register |= EIR_MAPERR; cpustate->write_inhibit = 1; } return cpustate->program->read_word(addr); } if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = cpustate->map_files[map_file].bias[map_index]+addr; if ((cpustate->latch_control[map_index]) && (! cpustate->reset_maperr)) cpustate->diaglat = 1; return cpustate->program->read_word(cpustate->map_files[map_file].bias[map_index]+addr); } } #define writeword(cs, addr, data) writewordX((cs), (addr), (data), (cs)->cur_map) static void writewordX(tms99xx_state *cpustate, int addr, int data, int map_file) { if ((map_file == 0) && (addr >= 0xf800)) { /* intercept TPCS and CPU ROM */ if (addr < 0xfc00) /* TPCS */ cpustate->program->write_word(0x1f0000+addr, data); else /* CPU ROM */ cpustate->program->write_word(0x1f0000+addr, data); /* hack... */ } else if (! cpustate->mapping_on) { cpustate->program->write_word(addr, data); } else { int map_index; if (addr <= cpustate->map_files[map_file].limit[0]) map_index = 0; else if (addr <= cpustate->map_files[map_file].limit[1]) map_index = 1; else if (addr <= cpustate->map_files[map_file].limit[2]) map_index = 2; else { /* mapping error */ if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = addr; if ((! cpustate->reset_maperr) && ! (cpustate->error_interrupt_register & EIR_MAPERR)) { cpustate->error_interrupt_register |= EIR_MAPERR; cpustate->write_inhibit = 1; } if (cpustate->write_inhibit) (void)cpustate->program->read_word(addr); else cpustate->program->write_word(addr, data); return; } if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = cpustate->map_files[map_file].bias[map_index]+addr; if ((cpustate->latch_control[map_index]) && (! cpustate->reset_maperr)) cpustate->diaglat = 1; cpustate->program->write_word(cpustate->map_files[map_file].bias[map_index]+addr, data); } } #define readbyte(cs, addr) readbyteX((cs), (addr), (cs)->cur_map) static int readbyteX(tms99xx_state *cpustate, int addr, int map_file) { if ((map_file == 0) && (addr >= 0xf800)) { /* intercept TPCS and CPU ROM */ if (addr < 0xfc00) /* TPCS */ return cpustate->program->read_byte(0x1f0000+addr); else /* CPU ROM */ return cpustate->program->read_byte(0x1f0000+addr); /* hack... */ } else if (! cpustate->mapping_on) { return cpustate->program->read_byte(addr); } else { int map_index; if (addr <= cpustate->map_files[map_file].limit[0]) map_index = 0; else if (addr <= cpustate->map_files[map_file].limit[1]) map_index = 1; else if (addr <= cpustate->map_files[map_file].limit[2]) map_index = 2; else { /* mapping error */ if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = addr; if ((! cpustate->reset_maperr) && ! (cpustate->error_interrupt_register & EIR_MAPERR)) { cpustate->error_interrupt_register |= EIR_MAPERR; cpustate->write_inhibit = 1; } return cpustate->program->read_byte(addr); } if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = cpustate->map_files[map_file].bias[map_index]+addr; if ((cpustate->latch_control[map_index]) && (! cpustate->reset_maperr)) cpustate->diaglat = 1; return cpustate->program->read_byte(cpustate->map_files[map_file].bias[map_index]+addr); } } #define writebyte(cs, addr, data) writebyteX((cs), (addr), (data), (cs)->cur_map) static void writebyteX(tms99xx_state *cpustate, int addr, int data, int map_file) { if ((map_file == 0) && (addr >= 0xf800)) { /* intercept TPCS and CPU ROM */ if (addr < 0xfc00) /* TPCS */ cpustate->program->write_byte(0x1f0000+addr, data); else /* CPU ROM */ cpustate->program->write_byte(0x1f0000+addr, data); /* hack... */ } else if (! cpustate->mapping_on) { cpustate->program->write_byte(addr, data); } else { int map_index; if (addr <= cpustate->map_files[map_file].limit[0]) map_index = 0; else if (addr <= cpustate->map_files[map_file].limit[1]) map_index = 1; else if (addr <= cpustate->map_files[map_file].limit[2]) map_index = 2; else { /* mapping error */ if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = addr; if ((! cpustate->reset_maperr) && ! (cpustate->error_interrupt_register & EIR_MAPERR)) { cpustate->error_interrupt_register |= EIR_MAPERR; cpustate->write_inhibit = 1; } if (cpustate->write_inhibit) (void)cpustate->program->read_byte(addr); else cpustate->program->write_byte(addr, data); return; } if ((! (cpustate->error_interrupt_register & EIR_MAPERR)) && ! (cpustate->diaglat)) cpustate->mapper_address_latch = cpustate->map_files[map_file].bias[map_index]+addr; if ((cpustate->latch_control[map_index]) && (! cpustate->reset_maperr)) cpustate->diaglat = 1; cpustate->program->write_byte(cpustate->map_files[map_file].bias[map_index]+addr, data); } } #elif (TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9940_ID) /*16-bit data bus, 16-bit address bus (internal bus in the case of TMS9940)*/ /*Note that tms9900 actually never accesses a single byte : when performing byte operations, it reads a 16-bit word, changes the revelant byte, then write a complete word. You should remember this when writing memory handlers.*/ /*This does not apply to tms9995 and tms99xxx, but does apply to tms9980 (see below).*/ #define readword(cs, addr) (cs)->program->read_word(addr) #define writeword(cs, addr,data) (cs)->program->write_word((addr), (data)) #define readbyte(cs, addr) (cs)->program->read_byte(addr) #define writebyte(cs, addr,data) (cs)->program->write_byte((addr),(data)) #elif (TMS99XX_MODEL == TMS9980_ID) /*8-bit data bus, 14-bit address*/ /*Note that tms9980 never accesses a single byte (however crazy it may seem). Although this makes memory access slower, I have emulated this feature, because if I did otherwise, there would be some implementation problems in some driver sooner or later.*/ INLINE int readword(tms99xx_state *cpustate, int addr) { int val; cpustate->icount -= 2; val = cpustate->program->read_byte(addr); return (val << 8) | cpustate->program->read_byte(addr+1); } #define writeword(cs, addr,data) { (cs)->icount -= 2; (cs)->program->write_byte((addr), (data) >> 8); cpustate->program->write_byte((addr) + 1, (data) & 0xff); } #if 0 #define readbyte(cs, addr) ((cs)->icount -= 2, (cs)->program->read_byte(addr)) #define writebyte(cs, addr,data) { (cs)->icount -= 2; (cs)->program->write_byte((addr),(data)); } #else /*This is how it really works*/ /*Note that every writebyte must match a readbyte (which is indeed the case)*/ static int readbyte(tms99xx_state *cpustate, int addr) { cpustate->icount -= 2; if (addr & 1) { cpustate->extra_byte = cpustate->program->read_byte(addr-1); return cpustate->program->read_byte(addr); } else { int val = cpustate->program->read_byte(addr); cpustate->extra_byte = cpustate->program->read_byte(addr+1); return val; } } static void writebyte (tms99xx_state *cpustate, int addr, int data) { cpustate->icount -= 2; if (addr & 1) { cpustate->program->write_byte(addr-1, cpustate->extra_byte); cpustate->program->write_byte(addr, data); } else { cpustate->program->write_byte(addr, data); cpustate->program->write_byte(addr+1, cpustate->extra_byte); } } #endif #elif (TMS99XX_MODEL == TMS9985_ID) /*Note that every writebyte must match a readbyte (which is indeed the case)*/ static int readword(tms99xx_state *cpustate, int addr) { if (addr < 0x2000) { } else if ((addr >= 0x8300) && (addr < 0x8400)) { } else { cpustate->icount -= 2; return (cpustate->program->read_byte(addr) << 8) + cpustate->program->read_byte(addr + 1); } } static void writeword(tms99xx_state *cpustate, int addr, int data) { if ((addr >= 0x8300) && (addr < 0x8400)) { } else if (!(addr < 0x2000)) { cpustate->icount -= 2; cpustate->program->write_byte(addr, data >> 8); cpustate->program->write_byte(addr + 1, data & 0xff); } } static int readbyte(tms99xx_state *cpustate, int addr) { if (addr < 0x2000) { } else if ((addr >= 0x8300) && (addr < 0x8400)) { } else { cpustate->icount -= 2; if (addr & 1) { cpustate->extra_byte = cpustate->program->read_byte(addr-1); return cpustate->program->read_byte(addr); } else { int val = cpustate->program->read_byte(addr); cpustate->extra_byte = cpustate->program->read_byte(addr+1); return val; } } } static void writebyte(tms99xx_state *cpustate, int addr, int data) { if ((addr >= 0x8300) && (addr < 0x8400)) { } else if (!(addr < 0x2000)) { cpustate->icount -= 2; if (addr & 1) { cpustate->program->write_byte(addr-1, cpustate->extra_byte); cpustate->program->write_byte(addr, data); } else { cpustate->program->write_byte(addr, data); cpustate->program->write_byte(addr+1, cpustate->extra_byte); } } } #elif (TMS99XX_MODEL == TMS9995_ID) /*8-bit external data bus, with on-chip 16-bit RAM, and 16-bit address bus*/ /*The code is complex, so we use functions rather than macros*/ static TIMER_CALLBACK( decrementer_callback ); static int readword(tms99xx_state *cpustate, int addr) { if ((addr < 0xf000) || (cpustate->is_mp9537)) { int reply; cpustate->icount -= cpustate->memory_wait_states_word; reply = cpustate->program->read_byte(addr); return (reply << 8) | cpustate->program->read_byte(addr + 1); } else if (addr < 0xf0fc) { return *(UINT16 *)(& cpustate->RAM[addr - 0xf000]); } else if (addr < 0xfffa) { int reply; cpustate->icount -= cpustate->memory_wait_states_word; reply = cpustate->program->read_byte(addr); return (reply << 8) | cpustate->program->read_byte(addr + 1); } else if (addr < 0xfffc) { /* read decrementer */ if (cpustate->decrementer_enabled && !(cpustate->flag & 1)) /* timer mode, timer enabled */ return cpustate->device->attotime_to_cycles(cpustate->timer->remaining() / 16); else /* event counter mode or timer mode, timer disabled */ return cpustate->decrementer_count; } else { return *(UINT16 *)(& cpustate->RAM[addr - 0xff00]); } } static void writeword (tms99xx_state *cpustate, int addr, int data) { if ((addr < 0xf000) || (cpustate->is_mp9537)) { cpustate->icount -= cpustate->memory_wait_states_word; cpustate->program->write_byte(addr, data >> 8); cpustate->program->write_byte(addr + 1, data & 0xff); } else if (addr < 0xf0fc) { *(UINT16 *)(& cpustate->RAM[addr - 0xf000]) = data; } else if (addr < 0xfffa) { cpustate->icount -= cpustate->memory_wait_states_word; cpustate->program->write_byte(addr, data >> 8); cpustate->program->write_byte(addr + 1, data & 0xff); } else if (addr < 0xfffc) { /* write decrementer */ cpustate->decrementer_interval = data; reset_decrementer(cpustate); } else { *(UINT16 *)(& cpustate->RAM[addr - 0xff00]) = data; } } static int readbyte(tms99xx_state *cpustate, int addr) { if ((addr < 0xf000) || (cpustate->is_mp9537)) { cpustate->icount -= cpustate->memory_wait_states_byte; return cpustate->program->read_byte(addr); } else if (addr < 0xf0fc) { return cpustate->RAM[BYTE_XOR_BE(addr - 0xf000)]; } else if (addr < 0xfffa) { cpustate->icount -= cpustate->memory_wait_states_byte; return cpustate->program->read_byte(addr); } else if (addr < 0xfffc) { /* read decrementer */ int value; if (cpustate->decrementer_enabled && !(cpustate->flag & 1)) /* timer mode, timer enabled */ value = cpustate->device->attotime_to_cycles(cpustate->timer->remaining() / 16); else /* event counter mode or timer mode, timer disabled */ value = cpustate->decrementer_count; if (addr & 1) return (value & 0xFF); else return (value >> 8); } else { return cpustate->RAM[BYTE_XOR_BE(addr - 0xff00)]; } } static void writebyte (tms99xx_state *cpustate, int addr, int data) { if ((addr < 0xf000) || (cpustate->is_mp9537)) { cpustate->icount -= cpustate->memory_wait_states_byte; cpustate->program->write_byte(addr, data); } else if (addr < 0xf0fc) { cpustate->RAM[BYTE_XOR_BE(addr - 0xf000)] = data; } else if (addr < 0xfffa) { cpustate->icount -= cpustate->memory_wait_states_byte; cpustate->program->write_byte(addr, data); } else if (addr < 0xfffc) { /* write decrementer */ /* Note that a byte write to tms9995 timer messes everything up. */ cpustate->decrementer_interval = (data << 8) | data; reset_decrementer(cpustate); } else { cpustate->RAM[BYTE_XOR_BE(addr - 0xff00)] = data; } } #else #error "memory access not implemented" #endif #if !HAS_MAPPING #define readwordX(cs, addr, map_file) readword(cs, addr) #define writewordX(cs, addr, data, map_file) writeword(cs, (addr), (data)) #define readbyteX(cs, addr, map_file) readbyte(cs, addr) #define writebyteX(cs, addr, data, map_file) writebyte(cs, (addr), (data)) #endif #define READREG(reg) readword(cpustate, (cpustate->WP+(reg)) & 0xffff) #define WRITEREG(reg, data) writeword(cpustate, (cpustate->WP+(reg)) & 0xffff, (data)) INLINE UINT16 READREG_DEBUG(tms99xx_state *cpustate, int reg) { int temp = cpustate->icount; UINT16 result = READREG(reg); cpustate->icount = temp; return result; } INLINE void WRITEREG_DEBUG(tms99xx_state *cpustate, int reg, UINT16 data) { int temp = cpustate->icount; WRITEREG(reg, data); cpustate->icount = temp; } #if (TMS99XX_MODEL == TI990_10_ID) READ8_HANDLER(ti990_10_mapper_cru_r) { tms99xx_state *cpustate = get_safe_token(&space->device()); int reply = 0; switch(cpustate->mapper_cru_read_register) { case 0xb000: reply = cpustate->map_files[cpustate->cur_map].B[0]; break; case 0xb001: reply = cpustate->map_files[cpustate->cur_map].B[1]; break; case 0xb010: reply = cpustate->map_files[cpustate->cur_map].B[2]; break; case 0xb011: reply = cpustate->map_files[cpustate->cur_map].L[0]; break; case 0xb100: reply = cpustate->map_files[cpustate->cur_map].L[1]; break; case 0xb101: reply = cpustate->map_files[cpustate->cur_map].L[2]; break; case 0xb110: reply = cpustate->mapper_address_latch; break; case 0xb111: reply = cpustate->mapper_address_latch >> 16; break; } if (offset) return (reply >> 8) & 0xff; else return reply & 0xff; } WRITE8_HANDLER(ti990_10_mapper_cru_w) { tms99xx_state *cpustate = get_safe_token(&space->device()); switch (offset) { case 0: case 1: case 2: /* read register select */ if (data) cpustate->mapper_cru_read_register |= (1 << offset); else cpustate->mapper_cru_read_register &= ~ (1 << offset); break; case 3: /* enable mapping */ cpustate->mapping_on = data; break; case 4: /* reset flags */ cpustate->reset_maperr = data; if (data) { cpustate->error_interrupt_register &= ~ EIR_MAPERR; cpustate->diaglat = 0; } break; case 5: case 6: case 7: /* latch control */ cpustate->latch_control[7-offset] = data; break; } } INLINE void handle_error_interrupt(tms99xx_state *cpustate) { if (cpustate->error_interrupt_callback) (*cpustate->error_interrupt_callback)(cpustate->device, cpustate->error_interrupt_register ? 1 : 0); } READ8_HANDLER(ti990_10_eir_cru_r) { tms99xx_state *cpustate = get_safe_token(&space->device()); return (offset == 1) ? (cpustate->error_interrupt_register & 0xff) : 0; } WRITE8_HANDLER(ti990_10_eir_cru_w) { tms99xx_state *cpustate = get_safe_token(&space->device()); if (offset < 4) /* does not work for EIR_MAPERR */ { cpustate->error_interrupt_register &= ~ (1 << offset); handle_error_interrupt(cpustate); } } #endif /* Interrupt mask */ #define IMASK (cpustate->STATUS & ST_IM) /* CYCLES macro : you provide timings for tms9900 and tms9995, and the macro chooses for you. BTW, I have no idea what the timings are for tms9989 and tms99xxx... */ #if TMS99XX_MODEL == TI990_10_ID /* Use TI990/10 timings*/ #define CYCLES(a,b,c) cpustate->icount -= a #elif TMS99XX_MODEL <= TMS9985_ID /* Use TMS9900/TMS9980 timings*/ #define CYCLES(a,b,c) cpustate->icount -= b #else /* Use TMS9995 timings*/ #define CYCLES(a,b,c) cpustate->icount -= c*4 #endif #if (TMS99XX_MODEL == TMS9995_ID) static void set_flag0(tms99xx_state *cpustate, int val); static void set_flag1(tms99xx_state *cpustate, int val); #endif /************************************************************************ * Status register functions ************************************************************************/ #include "99xxstat.h" /**************************************************************************/ static void register_for_save_state(device_t *device) { tms99xx_state *cpustate = get_safe_token(device); device->save_item(NAME(cpustate->WP)); device->save_item(NAME(cpustate->PC)); device->save_item(NAME(cpustate->STATUS)); device->save_item(NAME(cpustate->interrupt_pending)); #if ! ((TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID)) device->save_item(NAME(cpustate->load_state)); #endif #if (TMS99XX_MODEL == TI990_10_ID) || (TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID) device->save_item(NAME(cpustate->irq_level)); device->save_item(NAME(cpustate->irq_state)); #elif (TMS99XX_MODEL == TMS9995_ID) device->save_item(NAME(cpustate->irq_level)); device->save_item(NAME(cpustate->int_state)); device->save_item(NAME(cpustate->int_latch)); #endif device->save_item(NAME(cpustate->IDLE)); #if HAS_MAPPING device->save_item(NAME(cpustate->mapping_on)); device->save_item(NAME(cpustate->map_files[0].L)); device->save_item(NAME(cpustate->map_files[0].B)); device->save_item(NAME(cpustate->map_files[0].limit)); device->save_item(NAME(cpustate->map_files[0].bias)); device->save_item(NAME(cpustate->map_files[1].L)); device->save_item(NAME(cpustate->map_files[1].B)); device->save_item(NAME(cpustate->map_files[1].limit)); device->save_item(NAME(cpustate->map_files[1].bias)); device->save_item(NAME(cpustate->map_files[2].L)); device->save_item(NAME(cpustate->map_files[2].B)); device->save_item(NAME(cpustate->map_files[2].limit)); device->save_item(NAME(cpustate->map_files[2].bias)); device->save_item(NAME(cpustate->cur_map)); device->save_item(NAME(cpustate->cur_src_map)); device->save_item(NAME(cpustate->cur_dst_map)); #if (TMS99XX_MODEL == TI990_10_ID) device->save_item(NAME(cpustate->reset_maperr)); device->save_item(NAME(cpustate->mapper_address_latch)); device->save_item(NAME(cpustate->mapper_cru_read_register)); device->save_item(NAME(cpustate->diaglat)); device->save_item(NAME(cpustate->latch_control)); #endif #endif #if (TMS99XX_MODEL == TI990_10_ID) device->save_item(NAME(cpustate->error_interrupt_register)); #endif #if (TMS99XX_MODEL == TMS9985_ID) || (TMS99XX_MODEL == TMS9995_ID) device->save_item(NAME(cpustate->RAM)); #endif #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) || (TMS99XX_MODEL == TMS9995_ID) device->save_item(NAME(cpustate->decrementer_enabled)); device->save_item(NAME(cpustate->decrementer_interval)); device->save_item(NAME(cpustate->decrementer_count)); #endif #if (TMS99XX_MODEL == TMS9995_ID) device->save_item(NAME(cpustate->flag)); device->save_item(NAME(cpustate->MID_flag)); device->save_item(NAME(cpustate->memory_wait_states_byte)); device->save_item(NAME(cpustate->memory_wait_states_word)); device->save_item(NAME(cpustate->is_mp9537)); #endif device->save_item(NAME(cpustate->disable_interrupt_recognition)); } static CPU_INIT( tms99xx ) { const TMS99XX_RESET_PARAM *param = (const TMS99XX_RESET_PARAM *) device->static_config(); tms99xx_state *cpustate = get_safe_token(device); register_for_save_state(device); cpustate->irq_level = 16; cpustate->irq_callback = irqcallback; cpustate->device = device; cpustate->program = device->space(AS_PROGRAM); cpustate->io = device->space(AS_IO); #if (TMS99XX_MODEL == TMS9995_ID) cpustate->timer = device->machine().scheduler().timer_alloc(FUNC(decrementer_callback), cpustate); #endif cpustate->idle_callback = param ? param->idle_callback : NULL; #if (TMS99XX_MODEL == TI990_10_ID) cpustate->rset_callback = param ? param->rset_callback : NULL; cpustate->lrex_callback = param ? param->lrex_callback : NULL; cpustate->ckon_ckof_callback = param ? param->ckon_ckof_callback : NULL; cpustate->error_interrupt_callback = param ? param->error_interrupt_callback : NULL; #endif #if (TMS99XX_MODEL == TMS9995_ID) /* we can ask at reset time that the CPU always generates one wait state automatically */ if (param == NULL) { /* if no param, the default is currently "wait state added" */ cpustate->memory_wait_states_byte = 4; cpustate->memory_wait_states_word = 12; cpustate->is_mp9537 = 0; } else { cpustate->memory_wait_states_byte = (param->auto_wait_state) ? 4 : 0; cpustate->memory_wait_states_word = (param->auto_wait_state) ? 12 : 4; cpustate->is_mp9537 = param->is_mp9537; } #endif } /* TMS9900 hard reset */ static CPU_RESET( tms99xx ) { tms99xx_state *cpustate = get_safe_token(device); cpustate->STATUS = 0; /* TMS9980 and TMS9995 Data Books say so */ getstat(cpustate); #if HAS_MAPPING cpustate->mapping_on = 0; { int i,j; for (i=0; i<3; i++) for (j=0; j<3; j++) { cpustate->map_files[i].L[j] = 0; cpustate->map_files[i].limit[j] = 0xffff; cpustate->map_files[i].B[j] = 0; cpustate->map_files[i].bias[j] = 0; } } cpustate->cur_map = 0; /* equivalent to ST_MF status bit */ cpustate->cur_src_map = 0; /* set to 2 by LDS */ cpustate->cur_dst_map = 0; /* set to 2 by LDD */ cpustate->reset_maperr = 0; #endif if (cpustate->IDLE) { cpustate->IDLE = 0; /* clear IDLE condition */ if (cpustate->idle_callback) (*cpustate->idle_callback)(device, 0); } #if (TMS99XX_MODEL == TMS9995_ID) cpustate->MID_flag = 0; /* Clear flag bits 0 & 1 */ set_flag0(cpustate, 0); set_flag1(cpustate, 0); /* Clear internal interrupt latches */ cpustate->int_latch = 0; cpustate->flag &= 0xFFE3; #endif /* The ST register and interrupt latches changed, didn't they ? */ field_interrupt(cpustate); contextswitchX(cpustate, 0x0000); CYCLES(6, 26, 14); } static CPU_EXIT( tms99xx ) { /* nothing to do ? */ } /* fetch : read one word at * PC, and increment PC. */ INLINE UINT16 fetch(tms99xx_state *cpustate) { UINT16 value = readword(cpustate, cpustate->PC); cpustate->PC += 2; return value; } static CPU_EXECUTE( tms99xx ) { tms99xx_state *cpustate = get_safe_token(device); cpustate->lds_flag = 0; cpustate->ldd_flag = 0; do { /* all TMS9900 chips I know do not honor interrupts after XOP, BLWP or MID (after any interrupt-like instruction, actually), and they do not either after LDS and LDD (There are good reasons for this). */ if ((cpustate->interrupt_pending) && (! cpustate->disable_interrupt_recognition)) { int level; level = cpustate->irq_level; if (cpustate->load_state) { /* LOAD has the highest priority */ contextswitchX(cpustate, 0xFFFC); /* load vector, save PC, WP and ST */ cpustate->STATUS &= ~ST_IM; /* clear interrupt mask */ /* clear IDLE status if necessary */ if (cpustate->IDLE) { cpustate->IDLE = 0; /* clear IDLE condition */ if (cpustate->idle_callback) (*cpustate->idle_callback)(device, 0); } CYCLES(6/*to be confirmed*/, 22, 14); } else if (level <= IMASK) { /* a maskable interrupt is honored only if its level isn't greater than IMASK */ contextswitchX(cpustate, level*4); /* load vector, save PC, WP and ST */ /* change interrupt mask */ if (level) { cpustate->STATUS = (cpustate->STATUS & ~ST_IM) | (level -1); /* decrement mask */ cpustate->interrupt_pending = 0; /* as a consequence, the interrupt request will be subsequently ignored */ } else cpustate->STATUS &= ~ST_IM; /* clear mask (is this correct???) */ #if (TMS99XX_MODEL == TMS9995_ID) cpustate->STATUS &= 0xFE00; #endif /* clear IDLE status if necessary */ if (cpustate->IDLE) { cpustate->IDLE = 0; /* clear IDLE condition */ if (cpustate->idle_callback) (*cpustate->idle_callback)(device, 0); } #if (TMS99XX_MODEL == TMS9995_ID) /* Clear bit in latch */ /* I think tms9989 does this, too */ if (level != 2) { /* Only do this on level 1, 3, 4 interrupts */ int mask = 1 << level; int flag_mask = (level == 1) ? 4 : mask; cpustate->int_latch &= ~ mask; cpustate->flag &= ~ flag_mask; /* unlike tms9900, we can call the callback */ if (level == 1) (* cpustate->irq_callback)(cpustate->device, 0); else if (level == 4) (* cpustate->irq_callback)(cpustate->device, 1); } #endif CYCLES(6, 22, 14); } else { logerror("tms9900.c : the interrupt_pending flag was set incorrectly\n"); cpustate->interrupt_pending = 0; } } debugger_instruction_hook(device, cpustate->PC); if (cpustate->IDLE) { /* IDLE instruction has halted execution */ #if EXTERNAL_INSTRUCTION_DECODING external_instruction_notify(cpustate, 2); CYCLES(Moof!, 2, 2); /* 2 cycles per CRU write */ #else cpustate->icount = 0; /* much simpler... */ #endif } else { /* we execute an instruction */ cpustate->disable_interrupt_recognition = 0; /* default value */ cpustate->IR = fetch(cpustate); execute(cpustate, cpustate->IR); #if HAS_MAPPING if (cpustate->lds_flag) { cpustate->lds_flag = 0; cpustate->cur_src_map = 2 /*(cpustate->cur_src_map != 2) ? 2 : cpustate->cur_map*/; } else cpustate->cur_src_map = cpustate->cur_map; if (cpustate->ldd_flag) { cpustate->ldd_flag = 0; cpustate->cur_dst_map = 2 /*(cpustate->cur_src_map != 2) ? 2 : cpustate->cur_map*/; } else cpustate->cur_dst_map = cpustate->cur_map; #if (TMS99XX_MODEL == TI990_10_ID) cpustate->write_inhibit = 0; #endif #endif #if (HAS_OVERFLOW_INTERRUPT) #if (TMS99XX_MODEL == TMS9995_ID) /* Note that TI had some problem implementing this... I don't know if this feature works on a real-world TMS9995. */ if ((cpustate->STATUS & ST_OVIE) && (cpustate->STATUS & ST_OV) && (cpustate->irq_level > 2)) cpustate->irq_level = 2; /* interrupt request */ #else #warning "todo..." #endif #endif } } while (cpustate->icount > 0); } #if (TMS99XX_MODEL == TI990_10_ID) static void tms99xx_set_irq_line(tms99xx_state *cpustate, int irqline, int state) { if (irqline == INPUT_LINE_NMI) { cpustate->load_state = state; /* save new state */ field_interrupt(cpustate); /* interrupt status changed */ } else { /*if (cpustate->irq_state == state) return;*/ cpustate->irq_state = state; if (state == CLEAR_LINE) cpustate->irq_level = 16; /* trick : 16 will always be bigger than the IM (0-15), so there will never be interrupts */ else cpustate->irq_level = (* cpustate->irq_callback)(cpustate->device, 0); field_interrupt(cpustate); /* interrupt state is likely to have changed */ } } #elif (TMS99XX_MODEL == TMS9900_ID) /* void tms99xx_set_irq_line(cpustate, INPUT_LINE_NMI, int state) : change the state of the LOAD* line state == 0 -> LOAD* goes high (inactive) state != 0 -> LOAD* goes low (active) While LOAD* is low, we keep triggering LOAD interrupts... A problem : some peripherals lower the LOAD* line for a fixed time interval (causing the 1st instruction of the LOAD interrupt routine to be repeated while the line is low), and will be perfectly happy with the current scheme, but others might be more clever and wait for the IAQ (Instruction acquisition) line to go high, and this needs a callback function to emulate. */ /* void tms99xx_set_irq_line(cpustate, int irqline, int state) : sets the state of the interrupt line. irqline is ignored, and should always be 0. state == 0 -> INTREQ* goes high (inactive) state != 0 -> INTREQ* goes low (active) */ /* R Nabet 991020, revised 991218 : In short : interrupt code should call "cpu_set_irq_line(0, 0, ASSERT_LINE);" to set an interrupt request (level-triggered interrupts). Also, there MUST be a call to "cpu_set_irq_line(0, 0, CLEAR_LINE);" in the machine code, when the interrupt line is released by the hardware (generally in response to an action performed by the interrupt routines). On tms9995 (9989 ?), you can use PULSE_LINE, too, since the processor latches the line... **Note** : HOLD_LINE *NEVER* makes sense on the TMS9900 (or 9980, 9995...). The reason is the TMS9900 does NOT tell the world it acknoledges an interrupt, so no matter how much hardware you use, you cannot know when the CPU takes the interrupt, hence you cannot release the line when the CPU takes the interrupt. Generally, the interrupt condition is cleared by the interrupt routine (with some CRU or memory access). Note that cpu_generate_interrupt uses HOLD_LINE, so your driver interrupt code should always use the new style, i.e. return "ignore_interrupt(cpustate)" and call "cpu_set_irq_line(0, 0, ASSERT_LINE);" explicitely. Last, many TMS9900-based hardware use a TMS9901 interrupt-handling chip. If anybody wants to emulate some hardware which uses it, note that I am writing some emulation in the TI99/4(A) driver in MESS, so you should ask me. */ /* * HJB 990430: changed to use irq_callback(cpustate) to retrieve the vector * instead of using 16 irqlines. * * R Nabet 990830 : My mistake, I rewrote all these once again ; I think it is now correct. * A driver using the TMS9900 should do : * cpu_0_irq_line_vector_w(0, level); * cpu_set_irq_line(0,0,ASSERT_LINE); * * R Nabet 991108 : revised once again, with advice from Juergen Buchmueller, after a discussion * with Nicola... * We use the callback to retreive the interrupt level as soon as INTREQ* is asserted. * As a consequence, I do not support HOLD_LINE normally... However, we do not really have to * support HOLD_LINE, since no real world TMS9900-based system can support this. * FYI, there are two alternatives to retreiving the interrupt level with the callback : * a) using 16 pseudo-IRQ lines. Mostly OK, though it would require a few core changes. * However, this could cause some problems if someone tried to set two lines simulteanously... * And TMS9900 did NOT have 16 lines ! This is why Juergen and I did not retain this solution. * b) modifying the interrupt system in order to provide an extra int to every xxx_set_irq_line * function. I think this solution would be fine, but it would require quite a number of * changes in the MAME core. (And I did not feel the courage to check out 4000 drivers and 25 * cpu cores ;-) .) * * Note that this does not apply to tms9995. */ static void tms99xx_set_irq_line(tms99xx_state *cpustate, int irqline, int state) { if (irqline == INPUT_LINE_NMI) { cpustate->load_state = state; /* save new state */ field_interrupt(cpustate); /* interrupt status changed */ } else { /*if (cpustate->irq_state == state) return;*/ cpustate->irq_state = state; if (state == CLEAR_LINE) cpustate->irq_level = 16; /* trick : 16 will always be bigger than the IM (0-15), so there will never be interrupts */ else cpustate->irq_level = (* cpustate->irq_callback)(cpustate->device, 0); field_interrupt(cpustate); /* interrupt state is likely to have changed */ } } #elif (TMS99XX_MODEL == TMS9980_ID) /* interrupt system similar to tms9900, but only 3 interrupt pins (IC0-IC2) */ static void tms99xx_set_irq_line(tms99xx_state *cpustate, int irqline, int state) { if (state == CLEAR_LINE) { cpustate->load_state = 0; cpustate->irq_state = 0; cpustate->irq_level = 16; /* trick : 16 will always be bigger than the IM (0-15), so there will never be interrupts */ } else { int level; if (irqline == INPUT_LINE_NMI) level = 2; /* translate MAME's convention to CPU's representation */ else level = (* cpustate->irq_callback)(cpustate->device, 0); switch (level) { case 0: case 1: cpustate->load_state = 0; cpustate->irq_state = 0; cpustate->irq_level = 16; CPU_RESET_NAME(tms99xx)(cpustate->device); break; case 2: cpustate->load_state = 1; cpustate->irq_state = 0; cpustate->irq_level = 16; break; case 7: cpustate->load_state = 0; cpustate->irq_state = 0; cpustate->irq_level = 16; break; default: /* external levels 1, 2, 3, 4 */ cpustate->load_state = 0; cpustate->irq_state = 1; cpustate->irq_level = level - 2; break; } } field_interrupt(cpustate); /* interrupt state is likely to have changed */ } #elif (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) /* 2 interrupt pins (int1 and int2) */ static void tms99xx_set_irq_line(tms99xx_state *cpustate, int irqline, int state) { int mask; if (irqline == 0) /* INT1 */ mask = 1; else if (irqline == 1) /* INT2 */ mask = 4; else /* What on earth??? */ return; if (state) cpustate->irq_state |= mask; else cpustate->irq_state &= ~mask; field_interrupt(cpustate); /* interrupt state is likely to have changed */ } #elif (TMS99XX_MODEL == TMS9995_ID) /* this call-back is called by MESS timer system when the timer reaches 0. */ static TIMER_CALLBACK( decrementer_callback ) { tms99xx_state *cpustate = (tms99xx_state *)ptr; /* request decrementer interrupt */ cpustate->int_latch |= 0x8; cpustate->flag |= 0x8; field_interrupt(cpustate); } /* reset and load the timer/decrementer Note that I don't know whether toggling flag0/flag1 causes the decrementer to be reloaded or not */ static void reset_decrementer(tms99xx_state *cpustate) { cpustate->timer->adjust(attotime::never); /* reload count */ cpustate->decrementer_count = cpustate->decrementer_interval; /* decrementer / timer enabled ? */ cpustate->decrementer_enabled = ((cpustate->flag & 2) && (cpustate->decrementer_interval)); if (cpustate->decrementer_enabled && ! (cpustate->flag & 1)) { /* timer */ attotime period = cpustate->device->cycles_to_attotime(cpustate->decrementer_interval * 16L); cpustate->timer->adjust(period, 0, period); } } /* You have two interrupt line : one triggers level-1 interrupts, the other triggers level-4 interrupts (or decrements the decrementer register). According to the hardware, you may use PULSE_LINE (edge-triggered interrupts), or ASSERT_LINE (level-triggered interrupts). Edge-triggered interrupts are way simpler, but if multiple devices share the same line, they must use level-triggered interrupts. */ static void tms99xx_set_irq_line(tms99xx_state *cpustate, int irqline, int state) { if (irqline == INPUT_LINE_NMI) { cpustate->load_state = state; /* save new state */ field_interrupt(cpustate); /* interrupt status changed */ } else { int mask = (irqline == 0) ? 0x2 : 0x10; int flag_mask = (irqline == 0) ? 0x4 : 0x10; if (((cpustate->int_state & mask) != 0) ^ (state != 0)) { /* only if state changes */ if (state) { cpustate->int_state |= mask; if ((irqline == 1) && (cpustate->flag & 1)) { /* event counter mode : INT4* triggers no interrupt... */ if (cpustate->decrementer_enabled) { /* decrement, then interrupt if reach 0 */ if ((-- cpustate->decrementer_count) == 0) { decrementer_callback(cpustate->device->machine(), cpustate, 0); cpustate->decrementer_count = cpustate->decrementer_interval; /* reload */ } } } else { /* plain interrupt mode */ cpustate->int_latch |= mask; cpustate->flag |= flag_mask; } } else { cpustate->int_state &= ~ mask; } field_interrupt(cpustate); /* interrupt status changed */ } } } #else #error "interrupt system not implemented" #endif /* * field_interrupt * * Determines whether if an interrupt is pending, and sets the revelant flag. * * Called when an interrupt pin (LOAD*, INTREQ*, IC0-IC3) is changed, and when the interrupt mask * is modified. * * By using this flag, we save some compares in the execution loop. Subtle, isn't it ;-) ? * * R Nabet. */ #if (TMS99XX_MODEL == TI990_10_ID) || (TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID) static void field_interrupt(tms99xx_state *cpustate) { cpustate->interrupt_pending = ((cpustate->irq_level <= IMASK) || (cpustate->load_state)); } #elif (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) static void field_interrupt(tms99xx_state *cpustate) { if (cpustate->irq_state & 1) cpustate->irq_level = 1; else if (cpustate->irq_state & 2) cpustate->irq_level = 2; else if (cpustate->irq_state & 4) cpustate->irq_level = 3; else cpustate->irq_level = 4; /* trick : 4 will always be bigger than the IM (0-3), so there will never be interrupts */ cpustate->interrupt_pending = ((cpustate->irq_level <= IMASK) || (cpustate->load_state)); } #elif (TMS99XX_MODEL == TMS9995_ID) static void field_interrupt(tms99xx_state *cpustate) { if (cpustate->load_state) { cpustate->interrupt_pending = 1; } else { int current_int; int level; if (cpustate->flag & 1) /* event counter mode : ignore int4* line... */ current_int = (cpustate->int_state & ~0x10) | cpustate->int_latch; else /* normal behavior */ current_int = cpustate->int_state | cpustate->int_latch; if (current_int) /* find first bit to 1 */ /* possible values : 1, 3, 4 */ for (level=0; ! (current_int & 1); current_int >>= 1, level++) ; else level=16; cpustate->irq_level = level; cpustate->interrupt_pending = (level <= IMASK); } } #else #error "field_interrupt(cpustate) not written" #endif static CPU_DISASSEMBLE( tms99xx ) { return Dasm9900(buffer, pc, TMS99XX_MODEL, oprom, opram); } /*****************************************************************************/ /* CRU support code The CRU bus is a 1-bit-wide I/O bus. The CPU can read or write bits at random address. Special instructions are dedicated to reading and writing one or several consecutive bits. Note that TMS99000 additionally supports parallel CRU operations, although I don't know how this feature is implemented. */ enum { #if (TMS99XX_MODEL == TI990_10_ID) /* 3 MSBs do exist, although they are not connected (don't ask...) */ CRUAddrBit = 15 #elif (TMS99XX_MODEL == TMS9900_ID) /* 3 MSBs are always 0 to support external instructions */ CRUAddrBit = 12 #elif (TMS99XX_MODEL == TMS9980_ID) /* 2 bits unused, and 2 MSBs are always 0 to support external instructions */ CRUAddrBit = 11 #elif (TMS99XX_MODEL == TMS9940_ID) /* 9 internal address lines (8 external) */ CRUAddrBit = 9 #elif (TMS99XX_MODEL == TMS9995_ID) /* no such problem here : data bus lines D0-D2 provide the external instruction code */ CRUAddrBit = 15 #else #warning "I don't know how your processor handles CRU." CRUAddrBit = 15 #endif }; enum { rCRUAddrMask = (1 << (CRUAddrBit - 3)) - 1, wCRUAddrMask = (1 << CRUAddrBit) - 1 }; #if (TMS99XX_MODEL == TMS9995_ID) /* set decrementer mode flag */ static void set_flag0(tms99xx_state *cpustate, int val) { if (val) cpustate->flag |= 1; else cpustate->flag &= ~ 1; reset_decrementer(cpustate); } /* set decrementer enable flag */ static void set_flag1(tms99xx_state *cpustate, int val) { if (val) cpustate->flag |= 2; else cpustate->flag &= ~ 2; reset_decrementer(cpustate); } #endif typedef enum { CRU_OK = 0, CRU_PRIVILEGE_VIOLATION = -1 } cru_error_code; #define WRITEPORT(cs, port, data) (cs)->io->write_byte(port, data) #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) /* on tms9940, we have to handle internal CRU ports */ static void write_single_CRU(tms99xx_state *cpustate, int port, int data) { int mask; if (! (port & 0x100)) { /*if (cpustate->config & CB0)*/ /* External CRU */ WRITEPORT(cpustate, port, (data & 0x01)); } else { /* internal CRU */ switch ((port >> 4) & 0xf) { case 0x8: if (port == 0x181) { /* clear decrementer interrupt */ cpustate->irq_state &= ~2; } if (port >= 0x183) && (port <= 0x186) { /* write configuration register */ mask = 1 << (port - 0x183); /* ... */ } break; case 0x9: if (port <= 0x19D) { /* write decrementer latch */ mask = 1 << (port - 0x190); /* ... */ } else if (port == 0x19E) { /* set decrementer as timer (1) or event counter (0) */ /* ... */ } break; case 0xA: /* multiprocessor system interface */ mask = 1 << (port - 0x1A0); /* ... */ break; case 0xB: /* flags */ mask = 1 << (port - 0x1B0); /* ... */ break; case 0xC: case 0xD: /* direction for P0-P31 */ mask = 1 << (port - 0x1C0); /* ... */ break; case 0xE: case 0xF: /* data for P0-P31 */ mask = 1 << (port - 0x1E0); /* ... */ break; } } } #elif (TMS99XX_MODEL == TMS9995_ID) /* on tms9995, we have to handle internal CRU ports */ static void write_single_CRU(tms99xx_state *cpustate, int port, int data) { /* Internal CRU */ switch (port) { case 0xF70: set_flag0(cpustate, data & 0x01); break; case 0xF71: set_flag1(cpustate, data & 0x01); break; case 0xF72: case 0xF73: case 0xF74: break; /* ignored */ case 0xF75: case 0xF76: case 0xF77: case 0xF78: case 0xF79: case 0xF7A: case 0xF7B: case 0xF7C: case 0xF7D: case 0xF7E: case 0xF7F: { /* user defined flags */ int mask = 1 << (port - 0xF70); if (data & 0x01) cpustate->flag |= mask; else cpustate->flag &= ~ mask; } break; case 0x0FED: /* MID flag */ cpustate->MID_flag = data & 0x01; break; } /* External CRU */ /* Even though all the registers above are implemented internally, accesses are passed to the external bus, too, and an external device might respond to a write to these CRU address as well (particularly a write to the user flag registers). */ WRITEPORT(cpustate, port, (data & 0x01)); } #else #define write_single_CRU(cs, port, data) WRITEPORT(cs, port, data) #endif /* performs a normal write to CRU bus (used by SBZ, SBO, LDCR : address range 0 -> 0xFFF) */ static cru_error_code writeCRU(tms99xx_state *cpustate, int CRUAddr, int Number, UINT16 Value) { int count; /*logerror("PC %4.4x Write CRU %x for %x =%x\n",cpustate->PC,CRUAddr,Number,Value);*/ CRUAddr &= wCRUAddrMask; /* Write Number bits from CRUAddr */ for(count=0; count<Number; count++) { #if HAS_PRIVILEGE if ((cpustate->STATUS & ST_PR) && (CRUAddr >= 0xE00)) return CRU_PRIVILEGE_VIOLATION; #endif write_single_CRU(cpustate, CRUAddr, (Value & 0x01)); Value >>= 1; CRUAddr = (CRUAddr + 1) & wCRUAddrMask; } return CRU_OK; } #if EXTERNAL_INSTRUCTION_DECODING /* Some opcodes perform a dummy write to a special CRU address, so that an external function may be triggered. Only the first 3 MSBs of the address matter : other address bits and the written value itself are undefined. How should we support this ? With callback functions ? Actually, as long as we do not support hardware which makes use of this feature, it does not really matter :-) . */ static void external_instruction_notify(tms99xx_state *cpustate, int ext_op_ID) { #if 1 /* I guess we can support this like normal CRU operations */ #if (TMS99XX_MODEL == TMS9900_ID) WRITEPORT(cpustate, ext_op_ID << 12, 0); /* or is it 1 ??? */ #elif (TMS99XX_MODEL == TMS9980_ID) WRITEPORT(cpustate, (ext_op_ID & 3) << 11, (ext_op_ID & 4) ? 1 : 0); #elif (TMS99XX_MODEL == TMS9995_ID) WRITEPORT(cpustate, ext_op_ID << 15, 0); /* or is it 1 ??? */ #else #warning "I don't know how your processor handles external opcodes (maybe you don't need them, though)." #endif #else switch (ext_op_ID) { case 2: /* IDLE */ break; case 3: /* RSET */ break; case 5: /* CKON */ break; case 6: /* CKOF */ break; case 7: /* LREX */ break; case 0: /* normal CRU write !!! */ logerror("PC %4.4x : external_instruction_notify : wrong ext_op_ID",cpustate->PC); break; default: /* unknown address */ logerror("PC %4.4x : external_instruction_notify : unknown ext_op_ID",cpustate->PC); break; } #endif } #endif /* performs a normal read to CRU bus (used by TB, STCR : address range 0->0xFFF) Note that on some hardware, e.g. TI99/4(a), all normal memory operations cause unwanted CRU read at the same address. This seems to be impossible to emulate efficiently, so, if you need to emulate this, you're in trouble. */ #define READPORT(cs, port) (cs)->io->read_byte(port) #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) /* on tms9940, we have to handle internal CRU ports */ static int read_single_CRU(tms99xx_state *cpustate, int port) { int reply; int shift; if (! (port & 0x20)) { /*if (cpustate->config & CB0)*/ /* External CRU */ reply = READPORT(cpustate, port, (data & 0x01)); } else { /* internal CRU */ switch (port) { case 0x10: /* read interrupt state */ reply = cpustate->irq_state; break; case 0x12: /* read decrementer LSB */ /* ... */ break; case 0x13: /* read decrementer MSB */ /* ... */ break; case 0x14: /* read multiprocessor system interface LSB */ /* ... */ break; case 0x15: /* read multiprocessor system interface MSB */ /* ... */ break; case 0x16: /* read flags LSB */ /* ... */ break; case 0x17: /* read flags MSB */ /* ... */ break; case 0x18: case 0x19: case 0x1A: case 0x1B: /* direction for P0-P31 */ shift = (port - 0x18) << 3; /* ... */ break; case 0x1C: case 0x1D: case 0x1E: case 0x1F: /* data for P0-P31 */ shift = (port - 0x1C) << 3; /* ... */ break; default: reply = 0; break; } } return reply; } #elif (TMS99XX_MODEL == TMS9995_ID) /* on tms9995, we have to handle internal CRU ports */ static int read_single_CRU(tms99xx_state *cpustate, int port) { switch (port) { case 0x1EE: /* flag, bits 0-7 */ return cpustate->flag & 0xFF; case 0x1EF: /* flag, bits 8-15 */ return (cpustate->flag >> 8) & 0xFF; case 0x1FD: /* MID flag, and external devices */ if (cpustate->MID_flag) return READPORT(cpustate, port) | 0x10; else return READPORT(cpustate, port) & ~ 0x10; default: /* external devices */ return READPORT(cpustate, port); } } #else #define read_single_CRU(cs, port) READPORT(cs, port) #endif static int readCRU(tms99xx_state *cpustate, int CRUAddr, int Number) { static const int BitMask[] = { 0, /* filler - saves a subtract to find mask */ 0x0001,0x0003,0x0007,0x000F,0x001F,0x003F,0x007F,0x00FF, 0x01FF,0x03FF,0x07FF,0x0FFF,0x1FFF,0x3FFF,0x7FFF,0xFFFF }; int Offset,Location,Value; /*logerror("Read CRU %x for %x\n",CRUAddr,Number);*/ Location = (CRUAddr >> 3) & rCRUAddrMask; Offset = CRUAddr & 07; /* Read 8 bits */ #if HAS_PRIVILEGE if ((cpustate->STATUS & ST_PR) && (Location >= (0xE00 >> 3))) return CRU_PRIVILEGE_VIOLATION; #endif Value = read_single_CRU(cpustate, Location); if ((Offset+Number) > 8) { /* Read next 8 bits */ Location = (Location + 1) & rCRUAddrMask; #if HAS_PRIVILEGE if ((cpustate->STATUS & ST_PR) && (Location >= (0xE00 >> 3))) return CRU_PRIVILEGE_VIOLATION; #endif Value |= read_single_CRU(cpustate, Location) << 8; if ((Offset+Number) > 16) { /* Read next 8 bits */ Location = (Location + 1) & rCRUAddrMask; #if HAS_PRIVILEGE if ((cpustate->STATUS & ST_PR) && (Location >= (0xE00 >> 3))) return CRU_PRIVILEGE_VIOLATION; #endif Value |= read_single_CRU(cpustate, Location) << 16; } } /* Allow for Offset */ Value >>= Offset; /* Mask out what we want */ Value &= BitMask[Number]; /* And update */ return Value; } /*****************************************************************************/ #if HAS_MAPPING /* load a map file from memory */ static void load_map_file(tms99xx_state *cpustate, UINT16 src_addr, int src_map_file, int dst_file) { int i; /* load mapped address into the memory address register */ if ((src_map_file == 0) && (src_addr >= 0xf800)) { /* intercept TPCS and CPU ROM */ if (src_addr < 0xfc00) /* TPCS */ cpustate->mapper_address_latch = 0x1f0000+src_addr; else /* CPU ROM */ cpustate->mapper_address_latch = 0x1f0000+src_addr; /* hack... */ } else if (! cpustate->mapping_on) { cpustate->mapper_address_latch = src_addr; } else { int map_index; if (src_addr <= cpustate->map_files[src_map_file].limit[0]) map_index = 0; else if (src_addr <= cpustate->map_files[src_map_file].limit[1]) map_index = 1; else if (src_addr <= cpustate->map_files[src_map_file].limit[2]) map_index = 2; else { if ((! cpustate->reset_maperr) && ! (cpustate->error_interrupt_register & EIR_MAPERR)) { cpustate->error_interrupt_register |= EIR_MAPERR; cpustate->write_inhibit = 1; } cpustate->mapper_address_latch = src_addr; map_index = -1; } if (map_index != -1) cpustate->mapper_address_latch = cpustate->map_files[src_map_file].bias[map_index]+src_addr; } for (i=0; i<3; i++) { cpustate->map_files[dst_file].L[i] = cpustate->program->read_word(cpustate->mapper_address_latch) & 0xffe0; cpustate->map_files[dst_file].limit[i] = (cpustate->map_files[dst_file].L[i] ^ 0xffe0) | 0x001f; cpustate->mapper_address_latch = (cpustate->mapper_address_latch+2) & 0x1fffff; cpustate->map_files[dst_file].B[i] = cpustate->program->read_word(cpustate->mapper_address_latch); cpustate->map_files[dst_file].bias[i] = ((unsigned int) cpustate->map_files[dst_file].B[i]) << 5; cpustate->mapper_address_latch = (cpustate->mapper_address_latch+2) & 0x1fffff; } } #endif /* contextswitch : performs a BLWP, i.e. load PC, WP, and save old PC, old WP and ST... */ static void contextswitch(tms99xx_state *cpustate, UINT16 addr) { UINT16 oldWP, oldpc; /* save old state */ oldWP = cpustate->WP; oldpc = cpustate->PC; /* load vector */ cpustate->WP = readword(cpustate, addr) & ~1; cpustate->PC = readword(cpustate, addr+2) & ~1; /* write old state to regs */ WRITEREG(R13, oldWP); WRITEREG(R14, oldpc); setstat(cpustate); WRITEREG(R15, cpustate->STATUS); } #if HAS_MAPPING || HAS_PRIVILEGE /* priviledged context switch, that occurs after a reset, interrupt or XOP: we enter priviledged mode and select map file 0 before doing the context switch */ /* For CPU that have no priviledge support, contextswitchX would behave identically to contextswitch, so we can call contextswitch in all cases. */ static void contextswitchX(tms99xx_state *cpustate, UINT16 addr) { UINT16 oldWP, oldpc, oldST; /* save old state */ oldWP = cpustate->WP; oldpc = cpustate->PC; setstat(cpustate); oldST = cpustate->STATUS; /* enter priviledged mode and select map file 0 */ #if HAS_PRIVILEGE cpustate->STATUS &= ~ ST_PR; #endif #if HAS_MAPPING cpustate->STATUS &= ~ ST_MF; #endif getstat(cpustate); /* load vector */ cpustate->WP = readword(cpustate, addr) & ~1; cpustate->PC = readword(cpustate, addr+2) & ~1; /* write old state to regs */ WRITEREG(R13, oldWP); WRITEREG(R14, oldpc); WRITEREG(R15, oldST); } #endif /* * decipheraddr : compute and return the effective adress in word instructions. * * NOTA : the LSBit is always ignored in word adresses, * but we do not set it to 0 because of XOP... */ static UINT16 decipheraddr(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 ts = opcode & 0x30; register UINT16 reg = opcode & 0xF; reg += reg; if (ts == 0) /* Rx */ return(reg + cpustate->WP); else if (ts == 0x10) { /* *Rx */ CYCLES(0, 4, 1); return(readword(cpustate, reg + cpustate->WP)); } else if (ts == 0x20) { register UINT16 imm; imm = fetch(cpustate); if (reg) { /* @>xxxx(Rx) */ CYCLES(1, 8, 3); return(readword(cpustate, reg + cpustate->WP) + imm); } else { /* @>xxxx */ CYCLES(3, 8, 1); return(imm); } } else /*if (ts == 0x30)*/ { /* *Rx+ */ register UINT16 response; reg += cpustate->WP; /* reg now contains effective address */ CYCLES(1, 8, 3); response = readword(cpustate, reg); writeword(cpustate, reg, response+2); /* we increment register content */ return(response); } } /* decipheraddrbyte : compute and return the effective adress in byte instructions. */ static UINT16 decipheraddrbyte(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 ts = opcode & 0x30; register UINT16 reg = opcode & 0xF; reg += reg; if (ts == 0) /* Rx */ return(reg + cpustate->WP); else if (ts == 0x10) { /* *Rx */ CYCLES(0, 4, 1); return(readword(cpustate, reg + cpustate->WP)); } else if (ts == 0x20) { register UINT16 imm; imm = fetch(cpustate); if (reg) { /* @>xxxx(Rx) */ CYCLES(1, 8, 3); return(readword(cpustate, reg + cpustate->WP) + imm); } else { /* @>xxxx */ CYCLES(3, 8, 1); return(imm); } } else /*if (ts == 0x30)*/ { /* *Rx+ */ register UINT16 response; reg += cpustate->WP; /* reg now contains effective address */ CYCLES(1, 6, 3); response = readword(cpustate, reg); writeword(cpustate, reg, response+1); /* we increment register content */ return(response); } } /*************************************************************************/ #if (TMS99XX_MODEL == TI990_10_ID) /* TI990/10 generates an error interrupt */ /* timings are unknown */ #define HANDLE_ILLEGAL \ { \ cpustate->error_interrupt_register |= EIR_ILLOP; \ if (cpustate->error_interrupt_callback) \ (*cpustate->error_interrupt_callback)(cpustate->device, 1); \ } #elif TMS99XX_MODEL <= TMS9989_ID /* TMS9900/TMS9980 merely ignore the instruction */ #define HANDLE_ILLEGAL cpustate->icount -= 6 #elif TMS99XX_MODEL == TMS9995_ID /* TMS9995 generates a MID interrupt */ #define HANDLE_ILLEGAL \ { \ cpustate->MID_flag = 1; \ contextswitchX(cpustate, 0x0008); \ cpustate->STATUS = (cpustate->STATUS & 0xFE00) | 0x1; \ cpustate->disable_interrupt_recognition = 1; \ } #else #define HANDLE_ILLEGAL #warning "don't know" #endif #if HAS_PRIVILEGE #if (TMS99XX_MODEL == TI990_10_ID) /* TI990/10 generates an error interrupt */ /* timings are unknown */ #define HANDLE_PRIVILEGE_VIOLATION \ { \ cpustate->error_interrupt_register |= EIR_PRIVOP; \ if (cpustate->error_interrupt_callback) \ (*cpustate->error_interrupt_callback)(cpustate->device, 1); \ } #else #define HANDLE_PRIVILEGE_VIOLATION #warning "don't know" #endif #endif /*========================================================================== Illegal instructions >0000->01FF (not for 9989 and later) >0C00->0FFF (not for 990/12 and 99110) ============================================================================*/ static void illegal(tms99xx_state *cpustate, UINT16 opcode) { HANDLE_ILLEGAL; } #if 0 /* ti990/12 only */ /*========================================================================== Additionnal instructions, >0000->002F Additionnal single-register instruction, >0030->003F --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e | | o p c o d e | reg # | --------------------------------- ============================================================================*/ static void h0000(tms99xx_state *cpustate, UINT16 opcode) { if (opcode >= 0x30) { /* STPC STore Program Counter */ } else { switch (opcode /*& 0x3F*/) { case 0x1C: /* SRAM */ /* SRAM -- Shift Right Arithmetic Multiple precision */ case 0x1D: /* SLAM */ /* SLAM -- Shift Left Arithmetic Multiple precision */ case 0x1E: /* RTO --- Right Test for Ones */ case 0x1F: /* LTO --- Left Test for Ones */ case 0x20: /* CNTO -- CouNT Ones */ case 0x21: /* SLSL -- Search LiSt Logical address */ case 0x22: /* SLSP -- Search LiSt Physical address */ case 0x23: /* BDC --- Binary to Decimal ascii Conversion */ case 0x24: /* DBC --- Decimal to Binary ascii Conversion */ case 0x25: /* SWPM -- SWaP Multiple precision */ case 0x26: /* XORM -- eXclusive OR Multiple precision */ case 0x27: /* ORM --- OR Multiple precision */ case 0x28: /* ANDM -- AND Multiple precision */ case 0x29: /* SM */ /* SM ---- Subtract Multiple precision integer */ case 0x2A: /* AM */ /* AM ---- Add Multiple precision integer */ case 0x2B: /* MOVA -- MOVe Address */ case 0x2D: /* EMD --- Execute Micro-Diagnostics */ case 0x2E: /* EINT -- Enable INTerrupts */ case 0x2F: /* DINT -- Disable INTerrupts */ break; default: HANDLE_ILLEGAL; break; } } } #endif #if HAS_9995_OPCODES /*========================================================================== Additionnal single-register instructions, >0040->00FF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e | reg # | --------------------------------- tms9989 and later : LST, LWP ============================================================================*/ static void h0040(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 addr; addr = opcode & 0xF; addr = ((addr + addr) + cpustate->WP) & ~1; switch ((opcode & 0xF0) >> 4) { case 8: /* LST */ /* LST --- Load STatus register */ /* ST = *Reg */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) cpustate->STATUS = (cpustate->STATUS & 0x01DF) | (readword(cpustate, addr) & 0xFE20); else cpustate->STATUS = readword(cpustate, addr); #else cpustate->STATUS = readword(cpustate, addr); #endif getstat(cpustate); /* set last_parity */ break; case 9: /* LWP */ /* LWP --- Load Workspace Pointer */ /* WP = *Reg */ cpustate->WP = readword(cpustate, addr) & ~1; break; #if 0 /* 990/12 opcodes */ case 4: /* CS ---- Compare Strings */ case 5: /* SEQB -- Search string for EQual Byte */ case 6: /* MOVS -- MOVe String */ case 7: /* LIM --- Load Interrupt Mask */ case 10: /* LCS --- Load writable Control Store */ case 11: /* BLSK */ /* BLSK -- Branch immediate and push Link to StacK */ case 12: /* MVSR -- MoVe String Reverse */ case 13: /* MVSK -- MoVe string from StacK */ case 14: /* POPS -- POP String from stack */ case 15: /* PSHS -- PuSH String to stack */ break; #endif default: HANDLE_ILLEGAL; break; } } /*========================================================================== Additionnal single-operand instructions, >0100->01FF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e |TS | S | --------------------------------- tms9989 and later : DIVS, MPYS tms99xxx : BIND ============================================================================*/ static void h0100(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 src; #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; #endif src = decipheraddr(cpustate, opcode) & ~1; switch ((opcode & 0xC0) >> 6) { #if HAS_BIND_OPCODE case 1: /* BIND */ /* BIND -- Branch INDirect */ cpustate->PC = readwordX(cpustate, src, src_map) & ~1; CYCLES(Mooof!, Mooof!, 4 /*don't know*/); break; #endif case 2: /* DIVS */ /* DIVS -- DIVide Signed */ /* R0 = (R0:R1)/S R1 = (R0:R1)%S */ { INT16 d = readwordX(cpustate, src, src_map); INT32 divq = (READREG(R0) << 16) | READREG(R1); INT32 q = divq/d; if ((q < -32768L) || (q > 32767L)) { cpustate->STATUS |= ST_OV; CYCLES(Mooof!, Mooof!, 10); } else { cpustate->STATUS &= ~ST_OV; setst_lae(cpustate, q); WRITEREG(R0, q); WRITEREG(R1, divq%d); /* tms9995 : 33 is the worst case */ CYCLES(Mooof!, Mooof!, 33); } } break; case 3: /* MPYS */ /* MPYS -- MultiPlY Signed */ /* Results: R0:R1 = R0*S */ { INT32 prod = ((INT32) (INT16) readwordX(cpustate, src, src_map)); prod = prod*((INT32) (INT16) READREG(R0)); cpustate->STATUS &= ~ (ST_LGT | ST_AGT | ST_EQ); if (prod > 0) cpustate->STATUS |= (ST_LGT | ST_AGT); else if (prod < 0) cpustate->STATUS |= ST_LGT; else cpustate->STATUS |= ST_EQ; WRITEREG(R0, prod >> 16); WRITEREG(R1, prod); } CYCLES(Mooof!, Mooof!, 25); break; #if 0 /* Origin unknown */ case 0: /* EVAD */ /* EVAD -- EValuate ADdress instruction */ break; #endif default: HANDLE_ILLEGAL; break; } } #endif /*========================================================================== Immediate, Control instructions, >0200->03FF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e |0| reg # | --------------------------------- LI, AI, ANDI, ORI, CI, STWP, STST, LIMI, LWPI, IDLE, RSET, RTWP, CKON, CKOF, LREX systems with memory mapper: LMF ============================================================================*/ static void h0200(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 addr; register UINT16 value; /* used for anything */ addr = opcode & 0xF; addr = ((addr + addr) + cpustate->WP) & ~1; #if HAS_MAPPING if ((opcode >= 0x0320) && (opcode < 0x0340)) { /* LMF */ /* LMF --- Load memory Map File */ /* Used by the memory mapper on ti990/10 with mapping option, ti990/12, and the TIM99610 mapper chip to be associated with tms99000. Syntax: "LMF Rn,m" loads map file m (0 or 1) with six words of memory, starting at address specified in workspace register Rn (0 thru 15). */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION return; } #endif /* read address pointer */ addr = readword(cpustate, addr); load_map_file(cpustate, addr, cpustate->cur_map, (opcode & 0x10) ? 1 : 0); CYCLES(3, Mooof!, Mooof!); return; } #endif #if BETTER_0200_DECODING /* better instruction decoding on ti990/10 */ if (opcode & 0x10) { HANDLE_ILLEGAL; return; } #elif COMPLETE_0200_DECODING /* full instruction decoding on tms9995 */ if (((opcode < 0x2E0) && (opcode & 0x10)) || ((opcode >= 0x2E0) && (opcode & 0x1F))) { #if 0 /* tms99110 opcode (not supported by 990/12) */ if (opcode == 0x0301) { /* CR ---- Compare Reals */ } else /* tms99105+tms99110 opcode (not supported by 990/12) */ if (opcode == 0x0302) { /* MM ---- Multiply Multiple */ } else #endif #if 0 /* ti990/12 only */ if (opcode >= 0x03F0) { /* EP ---- Extended Precision */ } else #endif HANDLE_ILLEGAL; return; } #endif switch ((opcode & 0x1e0) >> 5) { case 0: /* LI */ /* LI ---- Load Immediate */ /* *Reg = *PC+ */ value = fetch(cpustate); writeword(cpustate, addr, value); setst_lae(cpustate, value); CYCLES(3, 12, 3); break; case 1: /* AI */ /* AI ---- Add Immediate */ /* *Reg += *PC+ */ value = fetch(cpustate); value = setst_add_laeco(cpustate, readword(cpustate, addr), value); writeword(cpustate, addr, value); CYCLES(4, 14, 4); break; case 2: /* ANDI */ /* ANDI -- AND Immediate */ /* *Reg &= *PC+ */ value = fetch(cpustate); value = readword(cpustate, addr) & value; writeword(cpustate, addr, value); setst_lae(cpustate, value); CYCLES(4, 14, 4); break; case 3: /* ORI */ /* ORI --- OR Immediate */ /* *Reg |= *PC+ */ value = fetch(cpustate); value = readword(cpustate, addr) | value; writeword(cpustate, addr, value); setst_lae(cpustate, value); CYCLES(4, 14, 4); break; case 4: /* CI */ /* CI ---- Compare Immediate */ /* status = (*Reg-*PC+) */ value = fetch(cpustate); setst_c_lae(cpustate, value, readword(cpustate, addr)); CYCLES(6, 14, 4); break; case 5: /* STWP */ /* STWP -- STore Workspace Pointer */ /* *Reg = WP */ writeword(cpustate, addr, cpustate->WP); CYCLES(2, 8, 3); break; case 6: /* STST */ /* STST -- STore STatus register */ /* *Reg = ST */ setstat(cpustate); writeword(cpustate, addr, cpustate->STATUS); CYCLES(2, 8, 3); break; case 7: /* LWPI */ /* LWPI -- Load Workspace Pointer Immediate */ /* WP = *PC+ */ cpustate->WP = fetch(cpustate) & ~1; CYCLES(3, 10, 4); break; case 8: /* LIMI */ /* LIMI -- Load Interrupt Mask Immediate */ /* ST&15 |= (*PC+)&15 */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif value = fetch(cpustate); cpustate->STATUS = (cpustate->STATUS & ~ST_IM) | (value & ST_IM); field_interrupt(cpustate); /*IM has been modified.*/ CYCLES(3, 16, 5); break; case 9: /* LMF is implemented elsewhere - when it is implemented */ HANDLE_ILLEGAL; break; case 10: /* IDLE */ /* IDLE -- IDLE until a reset, interrupt, load */ /* The TMS99000 locks until an interrupt happen (like with 68k STOP instruction), and continuously performs a special CRU write (code 2). */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif cpustate->IDLE = 1; #if EXTERNAL_INSTRUCTION_DECODING external_instruction_notify(cpustate, 2); #endif if (cpustate->idle_callback) (*cpustate->idle_callback)(cpustate->device, 1); CYCLES(4, 12, 7); /* we take care of further external_instruction_notify(cpustate, 2); in execute(cpustate) */ break; case 12: /* RTWP */ /* RTWP -- Return with Workspace Pointer */ /* WP = R13, PC = R14, ST = R15 */ addr = (cpustate->WP + R13) & ~1; cpustate->WP = readword(cpustate, addr) & ~1; addr += 2; cpustate->PC = readword(cpustate, addr) & ~1; addr += 2; #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) cpustate->STATUS = (cpustate->STATUS & 0x01DF) | (readword(cpustate, addr) & 0xFE20); else cpustate->STATUS = readword(cpustate, addr); #else cpustate->STATUS = readword(cpustate, addr); #endif getstat(cpustate); /* set last_parity */ field_interrupt(cpustate); /*IM has been modified.*/ CYCLES(3, 14, 6); break; #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) case 11: /* RSET */ case 13: /* CKON */ case 14: /* CKOF */ case 15: /* LREX */ HANDLE_ILLEGAL; /* These instruction "have been deleted" on the TMS9940 */ break; #else case 11: /* RSET */ /* RSET -- ReSET */ /* Reset the Interrupt Mask, and perform a special CRU write (code 3). */ /* The CRU write is supposed to reset external devices. */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif cpustate->STATUS &= 0xFFF0; /*clear IM.*/ field_interrupt(cpustate); /*IM has been modified.*/ #if (TMS99XX_MODEL == TMS9995_ID) /*cpustate->MID_flag = 0;*/ /* not sure about this */ #endif #if (TMS99XX_MODEL == TI990_10_ID) cpustate->error_interrupt_register = 0; cpustate->mapping_on = 0; cpustate->reset_maperr = 0; cpustate->mapper_cru_read_register = 0; cpustate->latch_control[0] = cpustate->latch_control[1] = cpustate->latch_control[2] = 0; cpustate->diaglat = 0; #endif #if EXTERNAL_INSTRUCTION_DECODING external_instruction_notify(cpustate, 3); #endif #if EXTERNAL_INSTRUCTION_CALLBACK if (cpustate->rset_callback) (*cpustate->rset_callback)(cpustate->device); #endif CYCLES(5, 12, 7); break; #if EXTERNAL_INSTRUCTION_DECODING case 13: /* CKON */ case 14: /* CKOF */ case 15: /* LREX */ /* CKON -- ClocK ON */ /* Perform a special CRU write (code 5). */ /* An external circuitery could, for instance, enable the line clock interrupt (100Hz or 120Hz, depending on the electrical alimentation frequency). */ /* CKOF -- ClocK OFf */ /* Perform a special CRU write (code 6). */ /* An external circuitery could, for instance, disable the line clock interrupt. */ /* LREX -- Load or REstart eXecution */ /* Perform a special CRU write (code 7). */ /* An external circuitery could, for instance, activate the LOAD* line, causing a non-maskable LOAD interrupt (vector -1). */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif external_instruction_notify(cpustate, (opcode & 0x00e0) >> 5); #if EXTERNAL_INSTRUCTION_CALLBACK #warning "todo..." #endif CYCLES(Mooof!, 12, 7); break; #elif EXTERNAL_INSTRUCTION_CALLBACK case 13: /* CKON */ case 14: /* CKOF */ /* CKON -- ClocK ON */ /* Enable the line clock interrupt (100Hz or 120Hz, depending on the electrical alimentation frequency). */ /* CKOF -- ClocK OFf */ /* Disable the line clock interrupt. */ /* We use a callback because the line clock is implemented in machine code, not in the CPU core. */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif if (cpustate->ckon_ckof_callback) (*cpustate->ckon_ckof_callback)(cpustate->device, (opcode & 0x0020) ? 1 : 0); CYCLES(5, Mooof!, Mooof!); break; case 15: /* LREX */ /* LREX -- Load or REstart eXecution */ /* Trigger a LOAD interrupt (vector -1). (We use a callback, and I have forgotten the reason why.) */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif if (cpustate->lrex_callback) (*cpustate->lrex_callback)(cpustate->device); CYCLES(6, Mooof!, Mooof!); break; #else #warning "Should not happen..." #endif #endif } } /*========================================================================== Single-operand instructions, >0400->07FF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e |TS | S | --------------------------------- BLWP, B, X, CLR, NEG, INV, INC, INCT, DEC, DECT, BL, SWPB, SETO, ABS systems with memory mapper: LDD, LDS ============================================================================*/ static void h0400(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 addr = decipheraddr(cpustate, opcode) & ~1; register UINT16 value; /* used for anything */ #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; #endif switch ((opcode & 0x3C0) >> 6) { case 0: /* BLWP */ /* BLWP -- Branch and Link with Workspace Pointer */ /* Result: WP = *S+, PC = *S */ /* New R13=old WP, New R14=Old PC, New R15=Old ST */ contextswitch(cpustate, addr); CYCLES(3, 26, 11); cpustate->disable_interrupt_recognition = 1; break; case 1: /* B */ /* B ----- Branch */ /* PC = S */ #if ((TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID)) (void) readwordX(cpustate, addr, src_map); #endif cpustate->PC = addr; CYCLES(2, 8, 3); break; case 2: /* X */ /* X ----- eXecute */ /* Executes instruction *S */ execute(cpustate, readwordX(cpustate, addr, src_map)); /* On tms9900, the X instruction actually takes 8 cycles, but we gain 2 cycles on the next instruction, as we don't need to fetch it. */ CYCLES(1, 6, 2); break; case 3: /* CLR */ /* CLR --- CLeaR */ /* *S = 0 */ #if ((TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID)) (void) readwordX(cpustate, addr, src_map); #endif writewordX(cpustate, addr, 0, src_map); CYCLES(2, 10, 3); break; case 4: /* NEG */ /* NEG --- NEGate */ /* *S = -*S */ value = - (INT16) readwordX(cpustate, addr, src_map); if (value) cpustate->STATUS &= ~ ST_C; else cpustate->STATUS |= ST_C; #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) if (value & 0x0FFF) cpustate->STATUS &= ~ ST_DC; else cpustate->STATUS |= ST_DC; #endif setst_laeo(cpustate, value); writewordX(cpustate, addr, value, src_map); CYCLES(3, 12, 3); break; case 5: /* INV */ /* INV --- INVert */ /* *S = ~*S */ value = ~ readwordX(cpustate, addr, src_map); writewordX(cpustate, addr, value, src_map); setst_lae(cpustate, value); CYCLES(2, 10, 3); break; case 6: /* INC */ /* INC --- INCrement */ /* (*S)++ */ value = setst_add_laeco(cpustate, readwordX(cpustate, addr, src_map), 1); writewordX(cpustate, addr, value, src_map); CYCLES(2, 10, 3); break; case 7: /* INCT */ /* INCT -- INCrement by Two */ /* (*S) +=2 */ value = setst_add_laeco(cpustate, readwordX(cpustate, addr, src_map), 2); writewordX(cpustate, addr, value, src_map); CYCLES(2, 10, 3); break; case 8: /* DEC */ /* DEC --- DECrement */ /* (*S)-- */ value = setst_sub_laeco(cpustate, readwordX(cpustate, addr, src_map), 1); writewordX(cpustate, addr, value, src_map); CYCLES(2, 10, 3); break; case 9: /* DECT */ /* DECT -- DECrement by Two */ /* (*S) -= 2 */ value = setst_sub_laeco(cpustate, readwordX(cpustate, addr, src_map), 2); writewordX(cpustate, addr, value, src_map); CYCLES(2, 10, 3); break; case 10: /* BL */ /* BL ---- Branch and Link */ /* IP=S, R11=old IP */ #if ((TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID)) (void) readwordX(cpustate, addr, src_map); #endif WRITEREG(R11, cpustate->PC); cpustate->PC = addr; CYCLES(3, 12, 5); break; case 11: /* SWPB */ /* SWPB -- SWaP Bytes */ /* *S = swab(*S) */ value = readwordX(cpustate, addr, src_map); value = logical_right_shift(value, 8) | (value << 8); writewordX(cpustate, addr, value, src_map); CYCLES(2, 10, 13); break; case 12: /* SETO */ /* SETO -- SET to Ones */ /* *S = #$FFFF */ #if ((TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9980_ID)) (void) readwordX(cpustate, addr, src_map); #endif writewordX(cpustate, addr, 0xFFFF, src_map); CYCLES(2, 10, 3); break; case 13: /* ABS */ /* ABS --- ABSolute value */ /* *S = |*S| */ /* clearing ST_C seems to be necessary, although ABS will never set it. */ #if (TMS99XX_MODEL <= TMS9985_ID) /* ti990/10 and tms9900/tms9980 only write the result if it has changed */ cpustate->STATUS &= ~ (ST_LGT | ST_AGT | ST_EQ | ST_C | ST_OV); #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) /* I guess ST_DC is cleared here, too*/ cpustate->STATUS &= ~ ST_DC; #endif value = readwordX(cpustate, addr, src_map); CYCLES(5, 12, Mooof!); if (((INT16) value) > 0) cpustate->STATUS |= ST_LGT | ST_AGT; else if (((INT16) value) < 0) { cpustate->STATUS |= ST_LGT; if (value == 0x8000) cpustate->STATUS |= ST_OV; #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) if (! (value & 0x0FFF)) cpustate->STATUS |= ST_DC; #endif writewordX(cpustate, addr, - ((INT16) value), src_map); CYCLES(0, 2, Mooof!); } else cpustate->STATUS |= ST_EQ; break; #else /* tms9995 always write the result */ cpustate->STATUS &= ~ (ST_LGT | ST_AGT | ST_EQ | ST_C | ST_OV); value = readwordX(cpustate, addr, src_map); CYCLES(Mooof!, Mooof!, 3); if (((INT16) value) > 0) cpustate->STATUS |= ST_LGT | ST_AGT; else if (((INT16) value) < 0) { cpustate->STATUS |= ST_LGT; if (value == 0x8000) cpustate->STATUS |= ST_OV; value = - ((INT16) value); } else cpustate->STATUS |= ST_EQ; writewordX(cpustate, addr, value, src_map); break; #endif #if HAS_MAPPING /* Used by the memory mapper on ti990/10 with mapping option, ti990/12, and the TIM99610 mapper chip to be associated with tms99000. */ /* These opcode allow access to another page without the need of switching a page someplace. */ /* Note that, if I read the 990/10 schematics correctly, two consecutive LDS or LDD would cause some trouble. */ case 14: /* LDS */ /* LDS --- Long Distance Source */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif load_map_file(cpustate, addr, src_map, 2); cpustate->lds_flag = 1; cpustate->disable_interrupt_recognition = 1; break; case 15: /* LDD */ /* LDD --- Long Distance Destination */ #if HAS_PRIVILEGE if (cpustate->STATUS & ST_PR) { HANDLE_PRIVILEGE_VIOLATION break; } #endif load_map_file(cpustate, addr, src_map, 2); cpustate->ldd_flag = 1; cpustate->disable_interrupt_recognition = 1; break; #else default: /* illegal instructions */ HANDLE_ILLEGAL; break; #endif } } /*========================================================================== Shift instructions, >0800->0BFF -------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e | C | W | --------------------------------- SRA, SRL, SLA, SRC ============================================================================*/ static void h0800(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 addr; register UINT16 cnt = (opcode & 0xF0) >> 4; register UINT16 value; addr = (opcode & 0xF); addr = ((addr+addr) + cpustate->WP) & ~1; CYCLES(3, 12, 5); if (cnt == 0) { CYCLES(2, 8, 2); cnt = READREG(R0) & 0xF; if (cnt == 0) cnt = 16; } CYCLES(cnt, cnt+cnt, cnt); switch ((opcode & 0x300) >> 8) { case 0: /* SRA */ /* SRA --- Shift Right Arithmetic */ /* *W >>= C (*W is filled on the left with a copy of the sign bit) */ value = setst_sra_laec(cpustate, readword(cpustate, addr), cnt); writeword(cpustate, addr, value); break; case 1: /* SRL */ /* SRL --- Shift Right Logical */ /* *W >>= C (*W is filled on the left with 0) */ value = setst_srl_laec(cpustate, readword(cpustate, addr), cnt); writeword(cpustate, addr, value); break; case 2: /* SLA */ /* SLA --- Shift Left Arithmetic */ /* *W <<= C */ value = setst_sla_laeco(cpustate, readword(cpustate, addr), cnt); writeword(cpustate, addr, value); break; case 3: /* SRC */ /* SRC --- Shift Right Circular */ /* *W = rightcircularshift(*W, C) */ value = setst_src_laec(cpustate, readword(cpustate, addr), cnt); writeword(cpustate, addr, value); break; } } #if 0 /* 990/12 opcodes */ /*========================================================================== Additionnal instructions, >0C00->0C0F Additionnal single-register instructions, >0C10->0C3F --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e | | o p c o d e | reg # | --------------------------------- ============================================================================*/ static void h0c00(tms99xx_state *cpustate, UINT16 opcode) { if (opcode & 0x30) { switch ((opcode & 0x30) >> 4) { case 1: /* INSF -- INSert Field */ break; case 2: /* XV ---- eXtract Value */ break; case 3: /* XF ---- eXtract Field */ break; } } else { switch (opcode & 0x0F) { /* floating point instructions */ case 0: /* CRI --- Convert Real to Integer */ break; case 2: /* NEGR -- NEGate Real */ break; case 4: /* CRE --- Convert Real to Extended integer */ break; case 6: /* CER --- Convert Extended integer to Real */ break; case 1: /* CDI --- Convert Double precision real to Integer */ break; case 3: /* NEGD -- NEGate Double precision real */ break; case 5: /* CDE --- Convert Double precision real to Extended integer */ break; case 7: /* CED --- Convert Extended integer to Double precision real */ break; case 8: /* NRM --- NoRMalize */ break; case 9: /* TMB --- Test Memory Bit */ break; case 10: /* TCMB -- Test and Clear Memory Bit */ break; case 11: /* TSMB -- Test and Set Memory Bit */ break; case 12: /* SRJ --- Subtract from Register and Jump */ case 13: /* ARJ --- Add to Register and Jump */ case 14: case 15: /* XIT --- eXIT from floating point interpreter */ /* Generated by some compilers, but equivalent to NOP on TI990/12. May have been used by some software floating-point emulators. */ break; default: HANDLE_ILLEGAL; break; } } } /*========================================================================== Additionnal single-operand instructions, >0C40->0DFF >0E40->0FFF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e |TS | S | --------------------------------- ============================================================================*/ static void h0c40(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 src; #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; #endif src = decipheraddr(cpustate, opcode) & ~1; switch ((opcode & 0x03C0) >> 6) { case 1: /* AR ---- Add Real */ break; case 2: /* CIR --- Convert Integer to Real */ break; case 3: /* SR ---- Subtract Real */ break; case 4: /* MR ---- Multiply Real */ break; case 5: /* DR ---- Divide Real */ break; case 6: /* LR ---- Load Real */ break; case 7: /* STR --- STore Real */ break; case 9: /* AD ---- Add Double */ break; case 10: /* CID --- Convert Integer to Double */ break; case 11: /* SD ---- Subtract Double */ break; case 12: /* MD ---- Multiply Double */ break; case 13: /* DD ---- Divide Double */ break; case 14: /* LD ---- Load Double */ break; case 15: /* SD ---- Store Double */ break; default: HANDLE_ILLEGAL; break; } } /*========================================================================== Additionnal single-register instructions, >0E00->0E3F --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e | reg # | --------------------------------- ============================================================================*/ static void h0e00(tms99xx_state *cpustate, UINT16 opcode) { switch ((opcode & 0x30) >> 4) { case 1: /* IOF --- Invert Order of Field */ break; case 1: /* SNEB -- Search string for Not Equal Byte */ break; case 2: /* CRC --- Cyclic Redundancy Code calculation */ break; case 3: /* TS ---- Translate String */ break; } } #endif /*========================================================================== Jump, CRU bit instructions, >1000->1FFF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | o p c o d e | signed offset | --------------------------------- JMP, JLT, JLE, JEQ, JHE, JGT, JNE, JNC, JOC, JNO, JL, JH, JOP SBO, SBZ, TB ============================================================================*/ static void h1000(tms99xx_state *cpustate, UINT16 opcode) { /* we convert 8 bit signed word offset to a 16 bit effective word offset. */ register INT16 offset = ((INT8) opcode); switch ((opcode & 0xF00) >> 8) { case 0: /* JMP */ /* JMP --- unconditional JuMP */ /* PC += offset */ cpustate->PC += (offset + offset); CYCLES(3, 10, 3); break; case 1: /* JLT */ /* JLT --- Jump if Less Than (arithmetic) */ /* if (A==0 && EQ==0), PC += offset */ if (! (cpustate->STATUS & (ST_AGT | ST_EQ))) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 2: /* JLE */ /* JLE --- Jump if Lower or Equal (logical) */ /* if (L==0 || EQ==1), PC += offset */ if ((! (cpustate->STATUS & ST_LGT)) || (cpustate->STATUS & ST_EQ)) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 3: /* JEQ */ /* JEQ --- Jump if EQual */ /* if (EQ==1), PC += offset */ if (cpustate->STATUS & ST_EQ) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 4: /* JHE */ /* JHE --- Jump if Higher or Equal (logical) */ /* if (L==1 || EQ==1), PC += offset */ if (cpustate->STATUS & (ST_LGT | ST_EQ)) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 5: /* JGT */ /* JGT --- Jump if Greater Than (arithmetic) */ /* if (A==1), PC += offset */ if (cpustate->STATUS & ST_AGT) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 6: /* JNE */ /* JNE --- Jump if Not Equal */ /* if (EQ==0), PC += offset */ if (! (cpustate->STATUS & ST_EQ)) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 7: /* JNC */ /* JNC --- Jump if No Carry */ /* if (C==0), PC += offset */ if (! (cpustate->STATUS & ST_C)) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 8: /* JOC */ /* JOC --- Jump On Carry */ /* if (C==1), PC += offset */ if (cpustate->STATUS & ST_C) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 9: /* JNO */ /* JNO --- Jump if No Overflow */ /* if (OV==0), PC += offset */ if (! (cpustate->STATUS & ST_OV)) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 10: /* JL */ /* JL ---- Jump if Lower (logical) */ /* if (L==0 && EQ==0), PC += offset */ if (! (cpustate->STATUS & (ST_LGT | ST_EQ))) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 11: /* JH */ /* JH ---- Jump if Higher (logical) */ /* if (L==1 && EQ==0), PC += offset */ if ((cpustate->STATUS & ST_LGT) && ! (cpustate->STATUS & ST_EQ)) { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); break; case 12: /* JOP */ /* JOP --- Jump On (odd) Parity */ /* if (P==1), PC += offset */ { /* Let's set ST_OP. */ int i; UINT8 a; a = cpustate->lastparity; i = 0; while (a != 0) { if (a & 1) /* If current bit is set, */ i++; /* increment bit count. */ a >>= 1U; /* Next bit. */ } /* Set ST_OP bit. */ /*if (i & 1) cpustate->STATUS |= ST_OP; else cpustate->STATUS &= ~ ST_OP;*/ /* Jump accordingly. */ if (i & 1) /*(cpustate->STATUS & ST_OP)*/ { cpustate->PC += (offset + offset); CYCLES(3, 10, 3); } else CYCLES(2, 8, 3); } break; case 13: /* SBO */ /* SBO --- Set Bit to One */ /* CRU Bit = 1 */ #if HAS_PRIVILEGE if (writeCRU(cpustate, (READREG(R12) >> 1) + offset, 1, 1) == CRU_PRIVILEGE_VIOLATION) HANDLE_PRIVILEGE_VIOLATION #else writeCRU(cpustate, (READREG(R12) >> 1) + offset, 1, 1); #endif CYCLES(4, 12, 8); break; case 14: /* SBZ */ /* SBZ --- Set Bit to Zero */ /* CRU Bit = 0 */ #if HAS_PRIVILEGE if (writeCRU(cpustate, (READREG(R12) >> 1) + offset, 1, 0) == CRU_PRIVILEGE_VIOLATION) HANDLE_PRIVILEGE_VIOLATION #else writeCRU(cpustate, (READREG(R12) >> 1) + offset, 1, 0); #endif CYCLES(4, 12, 8); break; case 15: /* TB */ /* TB ---- Test Bit */ /* EQ = (CRU Bit == 1) */ #if HAS_PRIVILEGE { int value; value = readCRU(cpustate, (READREG(R12)>> 1) + offset, 1); if (value == CRU_PRIVILEGE_VIOLATION) HANDLE_PRIVILEGE_VIOLATION else setst_e(cpustate, value & 1, 1); } #else setst_e(cpustate, readCRU(cpustate, (READREG(R12)>> 1) + offset, 1) & 1, 1); #endif CYCLES(5, 12, 8); break; } } /*========================================================================== General and One-Register instructions >2000->3FFF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F --------------------------------- | opcode | D |TS | S | --------------------------------- COC, CZC, XOR, LDCR, STCR, XOP, MPY, DIV tms9940 : DCA, DCS, LIIM ==========================================================================*/ /* xop, ldcr and stcr are handled elsewhere */ static void h2000(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 dest = (opcode & 0x3C0) >> 6; register UINT16 src; register UINT16 value; #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; #endif src = decipheraddr(cpustate, opcode) & ~1; dest = ((dest+dest) + cpustate->WP) & ~1; switch ((opcode & 0x1C00) >> 10) { case 0: /* COC */ /* COC --- Compare Ones Corresponding */ /* status E bit = (S&D == S) */ value = readwordX(cpustate, src, src_map); setst_e(cpustate, value & readword(cpustate, dest), value); CYCLES(5, 14, 4); break; case 1: /* CZC */ /* CZC --- Compare Zeroes Corresponding */ /* status E bit = (S&~D == S) */ value = readwordX(cpustate, src, src_map); setst_e(cpustate, value & (~ readword(cpustate, dest)), value); CYCLES(5, 14, 4); break; case 2: /* XOR */ /* XOR --- eXclusive OR */ /* D ^= S */ value = readwordX(cpustate, src, src_map); value ^= readword(cpustate, dest); setst_lae(cpustate, value); writeword(cpustate, dest,value); CYCLES(3, 14, 4); break; /*case 3:*/ /* XOP is implemented elsewhere */ /*case 4:*/ /* LDCR is implemented elsewhere */ /*case 5:*/ /* STCR is implemented elsewhere */ case 6: /* MPY */ /* MPY --- MultiPlY (unsigned) */ /* Results: D:D+1 = D*S */ /* Note that early TMS9995 reportedly performs an extra dummy read in PC space */ { unsigned long prod = ((unsigned long) readwordX(cpustate, src, src_map)); prod = prod * ((unsigned long) readword(cpustate, dest)); writeword(cpustate, dest, prod >> 16); writeword(cpustate, (dest+2)&0xffff, prod); } /* ti990/10 : from 19 to 35, possibly 19 + (number of bits to 1 in one operand) */ CYCLES(35, 52, 23); break; case 7: /* DIV */ /* DIV --- DIVide (unsigned) */ /* D = D/S D+1 = D%S */ { UINT16 d = readwordX(cpustate, src, src_map); UINT16 hi = readword(cpustate, dest); unsigned long divq = (((unsigned long) hi) << 16) | readword(cpustate, (dest+2)&0xffff); if (d <= hi) { cpustate->STATUS |= ST_OV; CYCLES(4, 16, 6); } else { cpustate->STATUS &= ~ST_OV; writeword(cpustate, dest, divq/d); writeword(cpustate, (dest+2)&0xffff, divq%d); /* tms9900 : from 92 to 124, possibly 92 + 2*(number of bits to 1 (or 0?) in quotient) */ /* tms9995 : 28 is the worst case */ /* ti990/10 : from 41 to 58, possibly 41 + (number of bits to 1 (or 0?) in quotient) */ CYCLES(41, 92, 28); } } break; } } static void xop(tms99xx_state *cpustate, UINT16 opcode) { /* XOP */ /* XOP --- eXtended OPeration */ /* WP = *(40h+D), PC = *(42h+D) */ /* New R13=old WP, New R14=Old IP, New R15=Old ST */ /* New R11=S */ /* Xop bit set */ register UINT16 immediate = (opcode & 0x3C0) >> 6; register UINT16 operand; #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) switch (immediate) { case 0: /* DCA */ /* DCA --- Decimal Correct Addition */ operand = decipheraddrbyte(cpustate, opcode); { int value = readbyte(cpustate, operand); int X = (value >> 4) & 0xf; int Y = value & 0xf; if (Y >= 10) { Y -= 10; cpustate->STATUS |= ST_DC; X++; } else if (cpustate->STATUS & ST_DC) { Y += 6; } if (X >= 10) { X -= 10; cpustate->STATUS |= ST_C; } else if (cpustate->STATUS & ST_C) { X += 6; } writebyte(cpustate, operand, (X << 4) | Y); } break; case 1: /* DCS */ /* DCS --- Decimal Correct Substraction */ operand = decipheraddrbyte(cpustate, opcode); { int value = readbyte(cpustate, operand); if (! (cpustate->STATUS & ST_DC)) { value += 10; } if (! (cpustate->STATUS & ST_C)) { value += 10 << 4; } cpustate->STATUS ^= ST_DC; writebyte(cpustate, operand, value); } break; case 2: /* LIIM */ case 3: /* LIIM */ /* LIIM - Load Immediate Interrupt Mask */ /* Does the same job as LIMI, with a different opcode format. */ /* Note that, unlike TMS9900, the interrupt mask is only 2-bit long. */ (void)decipheraddr(cpustate, opcode); /* dummy decode (personnal guess) */ cpustate->STATUS = (cpustate->STATUS & ~ST_IM) | (opcode & ST_IM); break; default: /* normal XOP */ #endif /* TODO : emulate 990/10 hardware XOP */ operand = decipheraddr(cpustate, opcode); #if ((TMS99XX_MODEL <= TMS9989_ID) && (TMS99XX_MODEL != TI990_10_ID)) (void)readword(cpustate, operand & ~1); /*dummy read (personnal guess)*/ #endif contextswitchX(cpustate, 0x40 + (immediate << 2)); #if ! ((TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID)) /* The bit is not set on tms9940 */ cpustate->STATUS |= ST_X; #endif WRITEREG(R11, operand); CYCLES(7, 36, 15); cpustate->disable_interrupt_recognition = 1; #if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) break; } #endif } /* LDCR and STCR */ static void ldcr_stcr(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 cnt = (opcode & 0x3C0) >> 6; register UINT16 addr; int value; #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; #endif if (cnt == 0) cnt = 16; if (cnt <= 8) addr = decipheraddrbyte(cpustate, opcode); else addr = decipheraddr(cpustate, opcode) & ~1; if (opcode < 0x3400) { /* LDCR */ /* LDCR -- LoaD into CRu */ /* CRU R12--CRU R12+D-1 set to S */ if (cnt <= 8) { #if (TMS99XX_MODEL != TMS9995_ID) value = readbyteX(cpustate, addr, src_map); #else /* just for once, tms9995 behaves like earlier 8-bit tms99xx chips */ /* this must be because instruction decoding is too complex */ value = readwordX(cpustate, addr & ~1, src_map); if (addr & 1) value &= 0xFF; else value = (value >> 8) & 0xFF; #endif (void)READREG(cnt+cnt); /*dummy read (reasonnable guess for TMS9995 & TMS9900, ti990/10)*/ setst_byte_laep(cpustate, value); } else { value = readwordX(cpustate, addr, src_map); (void)READREG(cnt+cnt); /*dummy read (reasonnable guess for TMS9995 & TMS9900, ti990/10)*/ setst_lae(cpustate, value); } #if HAS_PRIVILEGE if (writeCRU(cpustate, (READREG(R12) >> 1), cnt, value) == CRU_PRIVILEGE_VIOLATION) HANDLE_PRIVILEGE_VIOLATION #else writeCRU(cpustate, (READREG(R12) >> 1), cnt, value); #endif CYCLES(4+cnt, 20 + cnt+cnt, 9 + cnt+cnt); } else { /* STCR */ /* STCR -- STore from CRu */ /* S = CRU R12--CRU R12+D-1 */ if (cnt <= 8) { #if (TMS99XX_MODEL != TMS9995_ID) (void)readbyteX(cpustate, addr, src_map); /*dummy read*/ (void)READREG(cnt+cnt); /*dummy read (reasonnable guess for TMS9995 & TMS9900, ti990/10)*/ #if HAS_PRIVILEGE value = readCRU(cpustate, (READREG(R12) >> 1), cnt); if (value == CRU_PRIVILEGE_VIOLATION) HANDLE_PRIVILEGE_VIOLATION else { setst_byte_laep(cpustate, value); writebyteX(cpustate, addr, value, src_map); } #else value = readCRU(cpustate, (READREG(R12) >> 1), cnt); setst_byte_laep(cpustate, value); writebyteX(cpustate, addr, value, src_map); #endif CYCLES(18+cnt, (cnt != 8) ? 42 : 44, 19 + cnt); #else /* just for once, tms9995 behaves like earlier 8-bit tms99xx chips */ /* this must be because instruction decoding is too complex */ int value2 = readwordX(cpustate, addr & ~1, src_map); (void)READREG(cnt+cnt); /*dummy read (reasonnable guess for TMS9995 & TMS9900, ti990/10)*/ value = readCRU(cpustate, (READREG(R12) >> 1), cnt); setst_byte_laep(cpustate, value); if (addr & 1) writewordX(cpustate, addr & ~1, (value & 0x00FF) | (value2 & 0xFF00), src_map); else writewordX(cpustate, addr & ~1, (value2 & 0x00FF) | ((value << 8) & 0xFF00), src_map); CYCLES(Mooof!, Mooof!, 19 + cnt); #endif } else { (void)readwordX(cpustate, addr, src_map); /*dummy read*/ (void)READREG(cnt+cnt); /*dummy read (reasonnable guess for TMS9995 & TMS9900, ti990/10)*/ #if HAS_PRIVILEGE value = readCRU(cpustate, (READREG(R12) >> 1), cnt); if (value == CRU_PRIVILEGE_VIOLATION) HANDLE_PRIVILEGE_VIOLATION else { setst_lae(cpustate, value); writewordX(cpustate, addr, value, src_map); } #else value = readCRU(cpustate, (READREG(R12) >> 1), cnt); setst_lae(cpustate, value); writewordX(cpustate, addr, value, src_map); #endif CYCLES(24+cnt, (cnt != 16) ? 58 : 60, 27 + cnt); } } } /*========================================================================== Two-Operand instructions >4000->FFFF --------------------------------------------------------------------------- 0 1 2 3-4 5 6 7+8 9 A B-C D E F ---------------------------------- |opcode|B|TD | D |TS | S | ---------------------------------- SZC, SZCB, S, SB, C, CB, A, AB, MOV, MOVB, SOC, SOCB ============================================================================*/ /* word instructions */ static void h4000w(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 src; register UINT16 dest; register UINT16 value; #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; int dst_map = (opcode & 0x0c00) ? cpustate->cur_dst_map : cpustate->cur_map; #endif src = decipheraddr(cpustate, opcode) & ~1; dest = decipheraddr(cpustate, opcode >> 6) & ~1; value = readwordX(cpustate, src, src_map); switch ((opcode >> 13) & 0x0007) /* ((opcode & 0xE000) >> 13) */ { case 2: /* SZC */ /* SZC --- Set Zeros Corresponding */ /* D &= ~S */ value = readwordX(cpustate, dest, dst_map) & (~ value); setst_lae(cpustate, value); writewordX(cpustate, dest, value, dst_map); CYCLES(2, 14, 4); break; case 3: /* S */ /* S ----- Subtract */ /* D -= S */ value = setst_sub_laeco(cpustate, readwordX(cpustate, dest, dst_map), value); writewordX(cpustate, dest, value, dst_map); CYCLES(2, 14, 4); break; case 4: /* C */ /* C ----- Compare */ /* ST = (D - S) */ setst_c_lae(cpustate, readwordX(cpustate, dest, dst_map), value); CYCLES(5, 14, 4); break; case 5: /* A */ /* A ----- Add */ /* D += S */ value = setst_add_laeco(cpustate, readwordX(cpustate, dest, dst_map), value); writewordX(cpustate, dest, value, dst_map); CYCLES(2, 14, 4); break; case 6: /* MOV */ /* MOV --- MOVe */ /* D = S */ setst_lae(cpustate, value); #if ((TMS99XX_MODEL >= TMS9900_ID) && (TMS99XX_MODEL <= TMS9985_ID)) /* MOV performs a dummy read with tms9900/9980 (but neither ti990/10 nor tms9995) */ (void)readwordX(cpustate, dest, dst_map); #endif writewordX(cpustate, dest, value, dst_map); CYCLES(1, 14, 3); break; case 7: /* SOC */ /* SOC --- Set Ones Corresponding */ /* D |= S */ value = value | readwordX(cpustate, dest, dst_map); setst_lae(cpustate, value); writewordX(cpustate, dest, value, dst_map); CYCLES(2, 14, 4); break; } } /* byte instruction */ static void h4000b(tms99xx_state *cpustate, UINT16 opcode) { register UINT16 src; register UINT16 dest; register UINT16 value; #if HAS_MAPPING int src_map = (opcode & 0x0030) ? cpustate->cur_src_map : cpustate->cur_map; int dst_map = (opcode & 0x0c00) ? cpustate->cur_dst_map : cpustate->cur_map; #endif src = decipheraddrbyte(cpustate, opcode); dest = decipheraddrbyte(cpustate, opcode >> 6); value = readbyteX(cpustate, src, src_map); switch ((opcode >> 13) & 0x0007) /* ((opcode & 0xE000) >> 13) */ { case 2: /* SZCB */ /* SZCB -- Set Zeros Corresponding, Byte */ /* D &= ~S */ value = readbyteX(cpustate, dest, dst_map) & (~ value); setst_byte_laep(cpustate, value); writebyteX(cpustate, dest, value, dst_map); CYCLES(3, 14, 4); break; case 3: /* SB */ /* SB ---- Subtract, Byte */ /* D -= S */ value = setst_subbyte_laecop(cpustate, readbyteX(cpustate, dest, dst_map), value); writebyteX(cpustate, dest, value, dst_map); CYCLES(3, 14, 4); break; case 4: /* CB */ /* CB ---- Compare Bytes */ /* ST = (D - S) */ setst_c_lae(cpustate, readbyteX(cpustate, dest, dst_map)<<8, value<<8); cpustate->lastparity = value; CYCLES(5, 14, 4); break; case 5: /* AB */ /* AB ---- Add, Byte */ /* D += S */ value = setst_addbyte_laecop(cpustate, readbyteX(cpustate, dest, dst_map), value); writebyteX(cpustate, dest, value, dst_map); CYCLES(3, 14, 4); break; case 6: /* MOVB */ /* MOVB -- MOVe Bytes */ /* D = S */ setst_byte_laep(cpustate, value); #if (TMS99XX_MODEL <= TMS9985_ID) /* On ti990/10 and tms9900, MOVB needs to read destination, because it cannot actually read one single byte. It reads a word, replaces the revelant byte, then write the result. A tms9980 should not need to do so, but still does, because it is just a tms9900 with a 16 to 8 bit multiplexer (instead of a new chip design, like tms9995). */ (void)readbyteX(cpustate, dest, dst_map); #endif writebyteX(cpustate, dest, value, dst_map); CYCLES(3, 14, 3); break; case 7: /* SOCB */ /* SOCB -- Set Ones Corresponding, Byte */ /* D |= S */ value = value | readbyteX(cpustate, dest, dst_map); setst_byte_laep(cpustate, value); writebyteX(cpustate, dest, value, dst_map); CYCLES(3, 14, 4); break; } } INLINE void execute(tms99xx_state *cpustate, UINT16 opcode) { #if (! HAS_9995_OPCODES) /* tms9900-like instruction set*/ static void (*const jumptable_short[128])(tms99xx_state *,UINT16) = { &illegal,&h0200,&h0400,&h0400,&h0800,&h0800,&illegal,&illegal, &h1000,&h1000,&h1000,&h1000,&h1000,&h1000,&h1000,&h1000, &h2000,&h2000,&h2000,&h2000,&h2000,&h2000,&xop,&xop, &ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&h2000,&h2000,&h2000,&h2000, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b }; (* jumptable_short[opcode >> 9])(cpustate, opcode); #else /* tms9989 and tms9995 include 4 extra instructions, and one additionnal instruction type */ /* tms99000 includes yet another additional instruction */ static void (*const jumptable_long[256])(tms99xx_state *,UINT16) = { &h0040,&h0100,&h0200,&h0200,&h0400,&h0400,&h0400,&h0400, &h0800,&h0800,&h0800,&h0800,&illegal,&illegal,&illegal,&illegal, &h1000,&h1000,&h1000,&h1000,&h1000,&h1000,&h1000,&h1000, &h1000,&h1000,&h1000,&h1000,&h1000,&h1000,&h1000,&h1000, &h2000,&h2000,&h2000,&h2000,&h2000,&h2000,&h2000,&h2000, &h2000,&h2000,&h2000,&h2000,&xop,&xop,&xop,&xop, &ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&ldcr_stcr,&ldcr_stcr, &h2000,&h2000,&h2000,&h2000,&h2000,&h2000,&h2000,&h2000, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w,&h4000w, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b, &h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b,&h4000b }; (* jumptable_long[opcode >> 8])(cpustate, opcode); #endif } /************************************************************************** * Generic set_info **************************************************************************/ static CPU_SET_INFO( tms99xx ) { tms99xx_state *cpustate = get_safe_token(device); switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI: tms99xx_set_irq_line(cpustate, INPUT_LINE_NMI, info->i); break; case CPUINFO_INT_INPUT_STATE + 0: tms99xx_set_irq_line(cpustate, 0, info->i); break; case CPUINFO_INT_INPUT_STATE + 1: tms99xx_set_irq_line(cpustate, 1, info->i); break; case CPUINFO_INT_INPUT_STATE + 2: tms99xx_set_irq_line(cpustate, 2, info->i); break; #if (TMS99XX_MODEL == TI990_10_ID) case CPUINFO_INT_PC: { const unsigned top = (cpustate->cur_map == 0) ? 0xf800 : 0x10000; if ((cpustate->cur_map == 0) && (info->i >= 0x1ff800)) /* intercept TPCS and CPU ROM */ cpustate->PC = info->i - 0x1f0000; else if (! cpustate->mapping_on) cpustate->PC = (info->i < top) ? info->i : 0; else { if ((info->i >= cpustate->map_files[cpustate->cur_map].bias[0]) && (info->i <= (cpustate->map_files[cpustate->cur_map].bias[0]+cpustate->map_files[cpustate->cur_map].limit[0]))) cpustate->PC = info->i - cpustate->map_files[cpustate->cur_map].bias[0]; else if ((info->i > (cpustate->map_files[cpustate->cur_map].bias[1]+cpustate->map_files[cpustate->cur_map].limit[0])) && (info->i <= (cpustate->map_files[cpustate->cur_map].bias[1]+cpustate->map_files[cpustate->cur_map].limit[1]))) cpustate->PC = info->i - cpustate->map_files[cpustate->cur_map].bias[1]; else if ((info->i > (cpustate->map_files[cpustate->cur_map].bias[2]+cpustate->map_files[cpustate->cur_map].limit[0])) && (info->i > (cpustate->map_files[cpustate->cur_map].bias[2]+cpustate->map_files[cpustate->cur_map].limit[1])) && (info->i <= (cpustate->map_files[cpustate->cur_map].bias[2]+cpustate->map_files[cpustate->cur_map].limit[2]))) cpustate->PC = info->i - cpustate->map_files[cpustate->cur_map].bias[2]; else { /*if ((info->i < top) && (info->i > cpustate->map_files[cpustate->cur_map].limit[0]) && (info->i > cpustate->map_files[cpustate->cur_map].limit[1]) && (info->i > cpustate->map_files[cpustate->cur_map].limit[2])) cpustate->PC = info->i; else*/ cpustate->PC = 0; } /*if (info->i >= top) cpustate->PC = 0;*/ } cpustate->PC &= 0xfffe; } break; #else case CPUINFO_INT_PC: #endif case CPUINFO_INT_REGISTER + TMS9900_PC: cpustate->PC = info->i & 0xfffe; break; case CPUINFO_INT_REGISTER + TMS9900_IR: cpustate->IR = info->i; break; case CPUINFO_INT_SP: case CPUINFO_INT_REGISTER + TMS9900_WP: cpustate->WP = info->i & 0xfffe; break; case CPUINFO_INT_REGISTER + TMS9900_STATUS: cpustate->STATUS = info->i; getstat(cpustate); break; case CPUINFO_INT_REGISTER + TMS9900_R0: WRITEREG_DEBUG(cpustate, R0, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R1: WRITEREG_DEBUG(cpustate, R1, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R2: WRITEREG_DEBUG(cpustate, R2, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R3: WRITEREG_DEBUG(cpustate, R3, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R4: WRITEREG_DEBUG(cpustate, R4, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R5: WRITEREG_DEBUG(cpustate, R5, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R6: WRITEREG_DEBUG(cpustate, R6, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R7: WRITEREG_DEBUG(cpustate, R7, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R8: WRITEREG_DEBUG(cpustate, R8, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R9: WRITEREG_DEBUG(cpustate, R9, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R10: WRITEREG_DEBUG(cpustate, R10, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R11: WRITEREG_DEBUG(cpustate, R11, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R12: WRITEREG_DEBUG(cpustate, R12, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R13: WRITEREG_DEBUG(cpustate, R13, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R14: WRITEREG_DEBUG(cpustate, R14, info->i); break; case CPUINFO_INT_REGISTER + TMS9900_R15: WRITEREG_DEBUG(cpustate, R15, info->i); break; } } /************************************************************************** * Generic get_info **************************************************************************/ void TMS99XX_GET_INFO(legacy_cpu_device *device, UINT32 state, cpuinfo *info) { tms99xx_state *cpustate = (device != NULL && device->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(tms99xx_state); break; case CPUINFO_INT_INPUT_LINES: info->i = 3; break; case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; case DEVINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break; case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 2; break; case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 6;/*8 with 990/12, 99105, 99110*/break; case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; case CPUINFO_INT_MAX_CYCLES: info->i = 10;/*TODO: compute this value*/break; #if (USE_16_BIT_ACCESSORS) case DEVINFO_INT_DATABUS_WIDTH + AS_PROGRAM: info->i = 16; break; #else case DEVINFO_INT_DATABUS_WIDTH + AS_PROGRAM: info->i = 8; break; #endif case DEVINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM: #if (TMS99XX_MODEL == TI990_10_ID) /* this CPU has a mapper to expand the address space */ info->i = 21; #elif (TMS99XX_MODEL == TMS9900_ID) || (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID) || (TMS99XX_MODEL == TMS9995_ID) /* basic 16-bit address bus */ info->i = 16; #elif (TMS99XX_MODEL == TMS9980_ID) /* 2 address MSBits are unconnected */ info->i = 14; #else #warning "Please check how many address bits your CPU has." info->i = 16; #endif break; case DEVINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM: info->i = 0; break; case DEVINFO_INT_DATABUS_WIDTH + AS_DATA: info->i = 0; break; case DEVINFO_INT_ADDRBUS_WIDTH + AS_DATA: info->i = 0; break; case DEVINFO_INT_ADDRBUS_SHIFT + AS_DATA: info->i = 0; break; case DEVINFO_INT_DATABUS_WIDTH + AS_IO: info->i = 8; break; case DEVINFO_INT_ADDRBUS_WIDTH + AS_IO: #if (TMS99XX_MODEL == TI990_10_ID) /* 3 MSBs do exist, although they are not connected (don't ask...) */ info->i = 15; #elif (TMS99XX_MODEL == TMS9900_ID) /* 3 MSBs are external instruction code */ info->i = 12; #elif (TMS99XX_MODEL == TMS9980_ID) /* 2 bits unused, and 2 MSBs are external instruction code */ info->i = 13; #elif (TMS99XX_MODEL == TMS9940_ID) /* 9 internal address lines (8 external) */ info->i = 9; #elif (TMS99XX_MODEL == TMS9995_ID) /* 15-bit address and data bus lines D0-D2 provide the external instruction code */ info->i = 15+3; #else #warning "I don't know how your processor handles CRU." info->i = 15; #endif break; case DEVINFO_INT_ADDRBUS_SHIFT + AS_IO: info->i = 0; break; /* not implemented */ /* case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI: info->i = get_irq_line(INPUT_LINE_NMI); break; case CPUINFO_INT_INPUT_STATE + 0: info->i = get_irq_line(0); break; case CPUINFO_INT_INPUT_STATE + 1: info->i = get_irq_line(1); break; case CPUINFO_INT_INPUT_STATE + 2: info->i = get_irq_line(2); break;*/ case CPUINFO_INT_PREVIOUSPC: /* not implemented */ break; #if (TMS99XX_MODEL == TI990_10_ID) case CPUINFO_INT_PC: if ((cpustate->cur_map == 0) && (cpustate->PC >= 0xf800)) /* intercept TPCS and CPU ROM */ info->i = 0x1f0000+cpustate->PC; else if (! cpustate->mapping_on) info->i = cpustate->PC; else { int map_index; if (cpustate->PC <= cpustate->map_files[cpustate->cur_map].limit[0]) map_index = 0; else if (cpustate->PC <= cpustate->map_files[cpustate->cur_map].limit[1]) map_index = 1; else if (cpustate->PC <= cpustate->map_files[cpustate->cur_map].limit[2]) map_index = 2; else { info->i = cpustate->PC; break; } info->i = cpustate->map_files[cpustate->cur_map].bias[map_index]+cpustate->PC; } break; #else case CPUINFO_INT_PC: #endif case CPUINFO_INT_REGISTER + TMS9900_PC: info->i = cpustate->PC; break; case CPUINFO_INT_REGISTER + TMS9900_IR: info->i = cpustate->IR; break; case CPUINFO_INT_SP: case CPUINFO_INT_REGISTER + TMS9900_WP: info->i = cpustate->WP; break; case CPUINFO_INT_REGISTER + TMS9900_STATUS: setstat(cpustate); info->i = cpustate->STATUS; break; case CPUINFO_INT_REGISTER + TMS9900_R0: info->i = READREG_DEBUG(cpustate, R0); break; case CPUINFO_INT_REGISTER + TMS9900_R1: info->i = READREG_DEBUG(cpustate, R1); break; case CPUINFO_INT_REGISTER + TMS9900_R2: info->i = READREG_DEBUG(cpustate, R2); break; case CPUINFO_INT_REGISTER + TMS9900_R3: info->i = READREG_DEBUG(cpustate, R3); break; case CPUINFO_INT_REGISTER + TMS9900_R4: info->i = READREG_DEBUG(cpustate, R4); break; case CPUINFO_INT_REGISTER + TMS9900_R5: info->i = READREG_DEBUG(cpustate, R5); break; case CPUINFO_INT_REGISTER + TMS9900_R6: info->i = READREG_DEBUG(cpustate, R6); break; case CPUINFO_INT_REGISTER + TMS9900_R7: info->i = READREG_DEBUG(cpustate, R7); break; case CPUINFO_INT_REGISTER + TMS9900_R8: info->i = READREG_DEBUG(cpustate, R8); break; case CPUINFO_INT_REGISTER + TMS9900_R9: info->i = READREG_DEBUG(cpustate, R9); break; case CPUINFO_INT_REGISTER + TMS9900_R10: info->i = READREG_DEBUG(cpustate, R10); break; case CPUINFO_INT_REGISTER + TMS9900_R11: info->i = READREG_DEBUG(cpustate, R11); break; case CPUINFO_INT_REGISTER + TMS9900_R12: info->i = READREG_DEBUG(cpustate, R12); break; case CPUINFO_INT_REGISTER + TMS9900_R13: info->i = READREG_DEBUG(cpustate, R13); break; case CPUINFO_INT_REGISTER + TMS9900_R14: info->i = READREG_DEBUG(cpustate, R14); break; case CPUINFO_INT_REGISTER + TMS9900_R15: info->i = READREG_DEBUG(cpustate, R15); break; /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(tms99xx); break; case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(tms99xx); break; case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(tms99xx); break; case CPUINFO_FCT_EXIT: info->exit = CPU_EXIT_NAME(tms99xx); break; case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(tms99xx); break; case CPUINFO_FCT_BURN: info->burn = NULL; break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(tms99xx); break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, TMS99XX_device_get_name); break; case DEVINFO_STR_FAMILY: strcpy(info->s, "Texas Instruments 9900"); break; case DEVINFO_STR_VERSION: strcpy(info->s, "2.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "C TMS9900 emulator by Edward Swartz, initially converted for Mame by M.Coates, updated by R. Nabet"); break; case CPUINFO_STR_FLAGS: sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", cpustate->WP & 0x8000 ? 'L':'.', cpustate->WP & 0x4000 ? 'A':'.', cpustate->WP & 0x2000 ? 'E':'.', cpustate->WP & 0x1000 ? 'C':'.', cpustate->WP & 0x0800 ? 'V':'.', cpustate->WP & 0x0400 ? 'P':'.', cpustate->WP & 0x0200 ? 'X':'.', cpustate->WP & 0x0100 ? '?':'.', cpustate->WP & 0x0080 ? '?':'.', cpustate->WP & 0x0040 ? '?':'.', cpustate->WP & 0x0020 ? '?':'.', cpustate->WP & 0x0010 ? '?':'.', cpustate->WP & 0x0008 ? 'I':'.', cpustate->WP & 0x0004 ? 'I':'.', cpustate->WP & 0x0002 ? 'I':'.', cpustate->WP & 0x0001 ? 'I':'.'); break; case CPUINFO_STR_REGISTER + TMS9900_PC: sprintf(info->s, "PC :%04X", cpustate->PC); break; case CPUINFO_STR_REGISTER + TMS9900_IR: sprintf(info->s, "IR :%04X", cpustate->IR); break; case CPUINFO_STR_REGISTER + TMS9900_WP: sprintf(info->s, "WP :%04X", cpustate->WP); break; case CPUINFO_STR_REGISTER + TMS9900_STATUS: sprintf(info->s, "ST :%04X", cpustate->STATUS); break; case CPUINFO_STR_REGISTER + TMS9900_R0: sprintf(info->s, "R0 :%04X", READREG_DEBUG(cpustate, R0)); break; case CPUINFO_STR_REGISTER + TMS9900_R1: sprintf(info->s, "R1 :%04X", READREG_DEBUG(cpustate, R1)); break; case CPUINFO_STR_REGISTER + TMS9900_R2: sprintf(info->s, "R2 :%04X", READREG_DEBUG(cpustate, R2)); break; case CPUINFO_STR_REGISTER + TMS9900_R3: sprintf(info->s, "R3 :%04X", READREG_DEBUG(cpustate, R3)); break; case CPUINFO_STR_REGISTER + TMS9900_R4: sprintf(info->s, "R4 :%04X", READREG_DEBUG(cpustate, R4)); break; case CPUINFO_STR_REGISTER + TMS9900_R5: sprintf(info->s, "R5 :%04X", READREG_DEBUG(cpustate, R5)); break; case CPUINFO_STR_REGISTER + TMS9900_R6: sprintf(info->s, "R6 :%04X", READREG_DEBUG(cpustate, R6)); break; case CPUINFO_STR_REGISTER + TMS9900_R7: sprintf(info->s, "R7 :%04X", READREG_DEBUG(cpustate, R7)); break; case CPUINFO_STR_REGISTER + TMS9900_R8: sprintf(info->s, "R8 :%04X", READREG_DEBUG(cpustate, R8)); break; case CPUINFO_STR_REGISTER + TMS9900_R9: sprintf(info->s, "R9 :%04X", READREG_DEBUG(cpustate, R9)); break; case CPUINFO_STR_REGISTER + TMS9900_R10: sprintf(info->s, "R10:%04X", READREG_DEBUG(cpustate, R10)); break; case CPUINFO_STR_REGISTER + TMS9900_R11: sprintf(info->s, "R11:%04X", READREG_DEBUG(cpustate, R11)); break; case CPUINFO_STR_REGISTER + TMS9900_R12: sprintf(info->s, "R12:%04X", READREG_DEBUG(cpustate, R12)); break; case CPUINFO_STR_REGISTER + TMS9900_R13: sprintf(info->s, "R13:%04X", READREG_DEBUG(cpustate, R13)); break; case CPUINFO_STR_REGISTER + TMS9900_R14: sprintf(info->s, "R14:%04X", READREG_DEBUG(cpustate, R14)); break; case CPUINFO_STR_REGISTER + TMS9900_R15: sprintf(info->s, "R15:%04X", READREG_DEBUG(cpustate, R15)); break; } }
d28708d6f4d801b6c83132fcf9ab466e5ce9ce14
8dd900f8e37e61d4770c8b4d81e5c63d0aa95b41
/ch14/ex9.c
d880a50cdd913a50dd23055795f60f9d9ca0604f
[]
no_license
DataParisian/knkc
171534b48f251101fa637e8bfff9f51bf3f3da81
f6c133e386ea18bb8871005a90c200ea027ac85c
refs/heads/master
2021-03-12T20:36:32.320470
2015-08-19T18:32:53
2015-08-19T18:32:53
21,332,011
2
0
null
null
null
null
UTF-8
C
false
false
813
c
ex9.c
/* KNKC chapter 14 exercise 9 * Sundeep Kolli 31-may-2014 * Program: ex9.c * Purpose: Write the following parametrized macros. */ /* * a) CHECK(x, y, n) - Has the value 1 if both x and y fall between 0 and n-1 * inclusive. */ #define CHECK(x, y, n) \ if ((x) >= 0 && (y) >= 0 && (x) <= (n-1) && (y) <= (n-1)) \ 1 CHECK(1, 2, 5); /* * b) MEDIAN(x, y, z) - Finds the median of x, y and z. */ #define MEDIAN(x, y, z) \ (((x)-(y)) * ((z)-(y)) >= 0) ? (x) : \ (((((y)-(x)) * ((z)-(y))) >= 0) ? (y) : (z)) MEDIAN(3, 2, 5); /* * c) POLYNOMIAL(x) - Computes the polynomial 3x⁵ + 2x⁴ - 5x³ - x² + 7x - 6. */ #define POLYNOMIAL(x) ((3*(x)*(x)*(x)*(x)*(x)) + \ (2*(x)*(x)*(x)*(x)) - \ (5*(x)*(x)*(x)) - \ ((x)*(x)) + \ (7*(x)) - \ 6) POLYNOMIAL(2);
2e9051a6beaa0e0fa20f696d3b8b77643a304546
70480b32c6c26d8807e7d25f55992f84501a223c
/Examples/BASICInterpreter/BASICInterpreter/BASICGrammar.h
0bf24d5d330ebbde4c5585f2158718a8460ab69a
[ "Zlib" ]
permissive
nicklockwood/FXParser
2311b3e10bf653508a56f7ecbb3d9c9be88656c2
a783ca83aafff0e6542b69a439f57739a0e21152
refs/heads/master
2023-06-22T04:55:33.025232
2017-10-26T10:45:48
2017-10-26T10:45:48
7,783,503
6
0
null
null
null
null
UTF-8
C
false
false
10,805
h
BASICGrammar.h
unsigned char BASICGrammar_txt[] = { 0x23, 0x20, 0x42, 0x41, 0x53, 0x49, 0x43, 0x20, 0x67, 0x72, 0x61, 0x6d, 0x6d, 0x61, 0x72, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a, 0x23, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x6c, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x73, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2d, 0x3f, 0x30, 0x7c, 0x28, 0x5b, 0x31, 0x2d, 0x39, 0x5d, 0x5b, 0x30, 0x2d, 0x39, 0x5d, 0x2a, 0x29, 0x2f, 0x0a, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2d, 0x3f, 0x30, 0x7c, 0x28, 0x5b, 0x31, 0x2d, 0x39, 0x5d, 0x5b, 0x30, 0x2d, 0x39, 0x5d, 0x2a, 0x29, 0x28, 0x5c, 0x2e, 0x5b, 0x30, 0x2d, 0x39, 0x5d, 0x2b, 0x29, 0x3f, 0x2f, 0x0a, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x7c, 0x20, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x0a, 0x0a, 0x23, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x6c, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x73, 0x0a, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x22, 0x2f, 0x2f, 0x0a, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x5c, 0x5c, 0x22, 0x2f, 0x22, 0x2f, 0x0a, 0x6e, 0x65, 0x77, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x5c, 0x5c, 0x6e, 0x2f, 0x5c, 0x6e, 0x2f, 0x0a, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x20, 0x7c, 0x20, 0x6e, 0x65, 0x77, 0x6c, 0x69, 0x6e, 0x65, 0x0a, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x20, 0x28, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x7c, 0x20, 0x2f, 0x5b, 0x5e, 0x22, 0x5d, 0x2f, 0x29, 0x2a, 0x20, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x0a, 0x0a, 0x23, 0x72, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x0a, 0x6c, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x7c, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x2a, 0x2f, 0x0a, 0x73, 0x75, 0x62, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x28, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x29, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x0a, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x22, 0x2d, 0x22, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x29, 0x3f, 0x20, 0x6c, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x7c, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x20, 0x7c, 0x20, 0x73, 0x75, 0x62, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x28, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x2a, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x29, 0x2a, 0x0a, 0x64, 0x69, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x28, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x2f, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x29, 0x2a, 0x0a, 0x74, 0x65, 0x72, 0x6d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x7c, 0x20, 0x64, 0x69, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x20, 0x28, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x2b, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x29, 0x2a, 0x0a, 0x73, 0x75, 0x62, 0x74, 0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x20, 0x28, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x2d, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x29, 0x2a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x7c, 0x20, 0x73, 0x75, 0x62, 0x74, 0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x0a, 0x23, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x0a, 0x72, 0x75, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x72, 0x75, 0x6e, 0x2f, 0x2f, 0x0a, 0x6e, 0x65, 0x77, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x6e, 0x65, 0x77, 0x2f, 0x2f, 0x0a, 0x72, 0x65, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x72, 0x65, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x2f, 0x2f, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2f, 0x2f, 0x0a, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x3f, 0x20, 0x28, 0x72, 0x75, 0x6e, 0x20, 0x7c, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x7c, 0x20, 0x72, 0x65, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x7c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x7c, 0x20, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x29, 0x0a, 0x0a, 0x23, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0a, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x3d, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x0a, 0x67, 0x6f, 0x74, 0x6f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x67, 0x6f, 0x74, 0x6f, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x0a, 0x66, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x66, 0x6f, 0x72, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x3d, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2b, 0x74, 0x6f, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x2f, 0x2f, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2b, 0x2f, 0x2f, 0x3f, 0x20, 0x28, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x7c, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x7c, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x20, 0x7c, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7c, 0x20, 0x67, 0x6f, 0x74, 0x6f, 0x20, 0x7c, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x7c, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x29, 0x0a, 0x0a, 0x23, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x0a, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x2f, 0x2e, 0x2a, 0x2f, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x7c, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x7c, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x65, 0x29, 0x20, 0x73, 0x2f, 0x5c, 0x73, 0x2a, 0x5c, 0x6e, 0x2b, 0x5c, 0x73, 0x2a, 0x2f, 0x2f, 0x3f, 0x0a, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2a }; unsigned int BASICGrammar_txt_len = 1739;
e95c6cb98a592995cc2c6dfc8608af2ce1ed67ec
75dd85b5eccaf549c836d1faea0e4df805d79f76
/fillit.h
75183c129c7f429bfb2feca0ab42a08c1c1e3b7c
[]
no_license
mirexcool/fillit
c97d833e28994d1c0d290fffbe7f9b7883f89ea7
a99ff62240dbe89dcb3d62bd89f52c37159eff56
refs/heads/master
2021-01-20T12:37:37.339617
2017-05-05T14:41:37
2017-05-05T14:41:37
90,385,586
0
0
null
null
null
null
UTF-8
C
false
false
1,251
h
fillit.h
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fillit.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dburtnja <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:10:24 by dburtnja #+# #+# */ /* Updated: 2016/12/22 18:20:41 by dburtnja ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FILLIT_H # define FILLIT_H # include "libft.h" # include <fcntl.h> int ft_fillit(char *file, int i); int make_arrays(char **tet, int s, int i); char **ft_mkarray(int row, int col); int move_side(char **arr); int solve_tet(char ***arr, int s); int ft_strcat_array(char **from, char **into); int ft_check_tetr(char **tet, int n, int j); #endif
c80a059fcc09fc56d3455c73afb951d2a542fb54
737f9c62d56cfa46ececd105513d2705f6354584
/Exercies/Exercices tableau et pointeurs/04.1.exercices-tableaux-pointeurs.c
12fdf9de69500852b77e3812d17b67ac284b86ce
[]
no_license
NicolasBauerV/Programmer_en_C
f67e1ad257f352d1a99ad9e635d968afcea62593
f12cae1e787d15c727ca1b9c4fa048cedf344c57
refs/heads/master
2020-08-07T20:47:29.108689
2020-01-27T10:58:03
2020-01-27T10:58:03
213,582,782
0
0
null
null
null
null
UTF-8
C
false
false
727
c
04.1.exercices-tableaux-pointeurs.c
/* ENCONCE 1) Ecrire, de deux façons différentes, un programme quui lit 10 nombres entiers dans un tableau avant d'en rechercher le plus grand et le plus petit : * En utilisant le formalisme tableau * En utilisant le formalisme pointeur, chaque fois que cela est possible */ #include <stdio.h> #define NBMAX 10 //Version tableau int main(int argc, char const *argv[]) { int i, min, max; int tableau[NBMAX]; printf("Bonjour saisissez %d valeurs\n", NBMAX); for (i = 0; i < NBMAX; ++i) { scanf("%d", &t[i]); } min = t[0]; max = min; for (i = 1; i < NBMAX; ++i) { if (t[i] > max) max = t[i]; if (t[i] < min) min = t[i]; } printf("Valeur Max = %d et valeur Min = %d\n", max, min); return 0; }
242973973106efc001ce7c98b41d0b50fec0c54f
cc0250eab474d7c6cf9794d2d8a4a7ecf6bdaeba
/calificaciones.c
d5d8e36300f572830d3b57bd6e6ee2f28503dcb6
[]
no_license
ERick9483/Iniciando
946aa33640d62bcc7a1893d3780d61059e2899b9
1caa72392ed841390ec3d3f3b3f3880ba209c726
refs/heads/master
2020-12-24T05:59:37.946813
2016-11-23T23:13:26
2016-11-23T23:13:26
73,436,792
0
0
null
2016-11-11T18:00:06
2016-11-11T01:53:28
C
ISO-8859-10
C
false
false
1,788
c
calificaciones.c
/*Un profesor necesita un programa que permita guardar la calf. de 10 alumnos. Una vez capturados las calf. dar la operacion de buscar una calf. e indicar el numero de veces que se encuentra en la lista y en que numero de lista, de iguak manera indicar cuantos alumnos hay reprobados y cuantos reprobados Erick Orduņo*/ #include<stdio.h> #include<stdlib.h> int main(){ int cal[10],n,c,nv=0,aprobado=0,reprobado=0; printf("\n\t Programa calificaciones \n"); for(n=0;n<=9;n++){ //Comienza contador de calificaciones printf("\n\t Ingresa calif #%i \t",n+1); scanf("%i",&cal[n]); //guarda calf. en el arreglo while(cal[n]<0 || cal[n]>10){ //verifica calf. en el arreglo printf("\n\t ERROR! \n\t Ingrese de nuevo calf.#%i \t",n+1); scanf("%i",&cal[n]); } } do{ reprobado=0; aprobado=0; nv=0; printf("\n\t Busq. por calf. \n\t Ingrese calf. a buscar: "); scanf("%i",&c); for(n=0;n<10;n++){ //contador de cal para iniciar comparacion con calf. ingresada if(cal[n]>=6){ aprobado++; } else{ reprobado++; } } for(n=0;n<10;n++){ //contador para comparacio de valores de arreglo y calf. ingresada if(c==cal[n]){ nv++; printf("\n El alumno con #lista %i tiene: %i",n+1,c); } } printf("\n\n\t Se encontro la calf. %i veces",nv); printf("\n\t Los estudiantes reprobados son: %i",reprobado); printf("\n\t Los estudiantes aprobados son: %i",aprobado); printf("\n\n Desea buscar otra calf.? 1=Si \t"); scanf("%i",&n); } while(n==1); system("pause"); return 0; }
1bf05dde6f5c29559ffd49f69230c2cc8d59035e
07965d6344c1c68ebab98ca157d40280819d2f8f
/e19/e.h.h
55c143d832db3bd4654a996dc8d210b2f8dc41d3
[]
no_license
blakemcbride/Rand-E-Editor
bebb1360470b85646726823628713e293b6badf0
f8100b1da46f59311f0766f1e18ede550e4365c9
refs/heads/master
2021-07-23T04:15:00.422955
2021-02-13T01:12:28
2021-02-13T01:12:28
63,915,487
12
5
null
2021-02-13T01:12:29
2016-07-22T01:59:34
C
UTF-8
C
false
false
535
h
e.h.h
/* ** header file for help stuff. */ #define MXLATE(c) (*term.tt_xlate) (c) #define MHOME (*term.tt_home) () #define MCLEAR (*term.tt_clear) () #define MSSO (*term.tt_so) () #define MSSE (*term.tt_soe) () #define HELP_GS 14 /* ctrl-n */ #define HELP_GE 15 /* ctrl-o */ #define HELP_SS 16 /* ctrl-p */ #define HELP_SE 17 /* ctrl-q */ #define HELP_CH 'E' /* first graphics character */ #define HELP_CX 'O' /* last graphics character */
df92455b2c15cd9af71b0ccc1263147d556bcfc4
8bc2181125c3257439ff3056f27454b506e80a87
/MfgToolLib/stdafx.h
2b60dc8724cc8fb743c6755b8d920b9264002ed0
[]
permissive
Koltak/mfgtools
73ee205f432a290dcb52618d9fdc49b5d1d318bc
02d9e639ceeda38be0184f3b697a126c5d3f03e7
refs/heads/master
2021-04-15T19:03:39.672351
2018-04-19T09:42:36
2018-04-19T09:42:36
126,459,999
0
0
BSD-3-Clause
2018-03-23T11:28:03
2018-03-23T09:06:16
C++
UTF-8
C
false
false
4,539
h
stdafx.h
/* // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently #pragma once #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif #include "targetver.h" #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #ifndef _AFX_NO_OLE_SUPPORT #include <afxole.h> // MFC OLE classes #include <afxodlgs.h> // MFC OLE dialog classes #include <afxdisp.h> // MFC Automation classes #endif // _AFX_NO_OLE_SUPPORT #ifndef _AFX_NO_DB_SUPPORT #include <afxdb.h> // MFC ODBC database classes #endif // _AFX_NO_DB_SUPPORT #ifndef _AFX_NO_DAO_SUPPORT #include <afxdao.h> // MFC DAO database classes #endif // _AFX_NO_DAO_SUPPORT #ifndef _AFX_NO_OLE_SUPPORT #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #endif #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT */ // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently #pragma once #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif //#include "targetver.h" #ifndef __linux__ // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. #define WINVER 0x0502 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. #define _WIN32_WINNT 0x0502 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0502 // Change this to the appropriate value to target Windows Me or later. #endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. #define _WIN32_IE 0x0603 // Change this to the appropriate value to target IE 5.0 or later. #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS #endif #ifndef __linux__ #include "win_def.h" #else #include "lnx_def.h" #endif //#include <winioctl.h> //#include "resource.h" #ifndef __linux__ #ifdef _UNICODE #if defined _M_IX86 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_IA64 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_X64 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") #else #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #endif #endif #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) #define __WFILE__ WIDEN(__FILE__) #endif #ifdef UNICODE #define __TFILE__ __WFILE__ #else #define __TFILE__ __FILE__ #endif ///////////////////////////////////////////////////// my defines struct myevent { pthread_mutex_t *mutex; pthread_cond_t *cond; bool triggered; }; #ifdef INFINITE #undef INFINITE #endif #define INFINITE (time_t)UINT_MAX; //redefine infinite for time_t types int InitEvent(myevent **Ev); void SetEvent(myevent *Ev,sem_t*sem_att=NULL); void ClearEvent(myevent *Ev); void WaitOnEvent(myevent *Ev); bool CheckEvent(myevent *Ev); int DestroyEvent(myevent * Ev); int CheckArrayOfEvents(myevent* container[], int length);
619c51cfe697bdb21d0a9214693f175db92c3b18
523a433e44c116c9c09556cb3337d76ec7e7bb83
/C_program/作业/LinuxC/将满足条件的数存入数组.c
5a00e0cc0e57d968d3f1ca2e72e0d63f9dfaecb8
[]
no_license
kotzkotz/Program
7c9abf771a18e030fa556a868c4e22f5245fbe48
58a323764d88b9df29d280674f5406de0ea9e2fd
refs/heads/master
2020-06-17T17:04:11.118088
2016-06-28T23:58:28
2016-06-28T23:58:28
null
0
0
null
null
null
null
UTF-8
C
false
false
381
c
将满足条件的数存入数组.c
#include <stdio.h> int main(void) { int a[10] = {1010,2367,2132,3535,4748,6657,4563,2325,2346,6769}; int c[10]; int i,j,q,b,s,g,k=0; for (i=0; i<10; i++) { q = a[i]/1000; b = a[i]/100%10; s = a[i]/10%10; g = a[i]%10; if (q == s && b == g) { c[k] = a[i]; k++; } } for (j=0; j<k; j++) printf("%d ",c[j]); printf("\n"); return 0; }
cd5a6f6045d211f03c2a13d30dfc311844cbabe4
14cd062620ab533671e60f62a69fd07f84d4135f
/init/pro.c
df25ad1d1a9ed13d668b9c04a22fc3639747d81c
[]
no_license
yerson001/Semaphore
d8c76a5ae2b4c9c95303227b383425df4e2d1f91
7573b9f02279cf56f83fce6afac3eeebe5a5aff4
refs/heads/main
2023-01-13T19:37:25.218750
2020-11-14T12:30:59
2020-11-14T12:30:59
312,812,819
0
0
null
null
null
null
UTF-8
C
false
false
1,176
c
pro.c
#include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <time.h> void *Program2(void *arg); void *Program3(void *arg); int Number; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int main(int argc,char *argv[]) { int t; srand(time(NULL)); t = atoi(argv[1]); while(t--){ pthread_t thread_1,thread_2; //int number; Number = rand()%100; pthread_create(&thread_1,NULL,Program2,NULL);//&number pthread_create(&thread_2,NULL,Program3,NULL);//&number pthread_join(thread_1,NULL); pthread_join(thread_2,NULL); } return 0; } void *Program2(void *arg) { //int Number = *((int*)arg); printf("--------Even Nnumber Origin: %d\n",Number); if(Number%2==0) { pthread_mutex_lock(&mutex); Number+=2; pthread_mutex_unlock(&mutex); printf("Even Nnumber: %d\n",Number); } //printf("Thread_1 end\n"); } void *Program3(void *arg) { //int Number = *((int*)arg); printf("---------Odd Nnumber Origin: %d\n",Number); if(Number%2==1) { pthread_mutex_lock(&mutex); Number+=2; pthread_mutex_unlock(&mutex); printf("Odd Number: %i\n",Number); } //printf("Thread_2 end\n"); }
d3fe6601eaf5096f9ea32733f3079edebef5daff
f71a7f225f805c0f9d1df135276410566757cb2e
/1.libft/libft/ft_isascii.c
c2bbc01675f1218dfaca719c47d174df9af6715c
[]
no_license
Kovaleva-21/21School
edd82479438bb73b01c8bbbe9a559fb4b0d64bbf
5c8803fd1a03e1a96176bae25fb7343010998738
refs/heads/main
2023-07-18T11:02:11.841577
2021-08-21T18:06:11
2021-08-21T18:06:11
395,110,282
0
0
null
null
null
null
UTF-8
C
false
false
970
c
ft_isascii.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isascii.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ccorliss <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/27 02:49:59 by student #+# #+# */ /* Updated: 2020/05/27 02:55:07 by student ### ########.fr */ /* */ /* ************************************************************************** */ int ft_isascii(int c) { if (c >= 0 && c <= 127) return (1); return (0); }
1fc4facba104f883cd9fee214ec839a39c49bc2c
d1ce666dd38d62ef04f23077acfaae59a13535d0
/initial-utilities/wzip/wzip.c
1fea26f08b78db5b9169ccad8e29af7dfd36952b
[]
no_license
lizhijianrd/ostep-projects
e11ba356b37b43695740baec272b31ec0a683a07
ae59eaf327735fb26d9d0c0de06497ac8971befc
refs/heads/master
2023-01-02T08:19:28.172726
2020-10-20T03:08:47
2020-10-20T03:08:47
285,712,409
0
0
null
2020-08-07T01:55:40
2020-08-07T01:55:40
null
UTF-8
C
false
false
1,227
c
wzip.c
#include <string.h> #include <stdio.h> #include <stdlib.h> #define TRUE 1 #define FALSE 0 #define BUFF_SIZE 4096 int main(int argc, char **argv) { if (argc == 1) { printf("wzip: file1 [file2 ...]\n"); exit(1); } int n = -1, nread; char c; char buff[BUFF_SIZE]; for (int i = 1; i < argc; i++) { const char *filename = argv[i]; FILE *stream = fopen(filename, "r"); if (stream == NULL) { exit(1); } while (TRUE) { nread = fread(buff, sizeof(char), BUFF_SIZE, stream); if (nread > 0 && n == -1) { c = buff[0]; n = 0; } for (int i = 0; i < nread; i++) { if (buff[i] == c) { n++; } else { fwrite(&n, sizeof(int), 1, stdout); fwrite(&c, sizeof(char), 1, stdout); c = buff[i]; n = 1; } } if (nread < BUFF_SIZE) { break; } } fclose(stream); } fwrite(&n, sizeof(int), 1, stdout); fwrite(&c, sizeof(char), 1, stdout); return 0; }
9c79a27bb23090d09fc819cd836d50dc94d64cc2
26623f11bde46870f809934149739ebacaffa517
/ft_file2.c
b0169cc1da2badb31773e7050985fb88e0a985bc
[]
no_license
nhamidn/RTv1-42
5ba7fac3bfd02a2a711533266cac7e1c627bbed6
ecfadc5b6f7b8781b86ff9fab69115b3556b5854
refs/heads/master
2020-07-02T18:33:16.974038
2019-08-10T12:11:20
2019-08-10T12:11:20
201,623,310
2
0
null
null
null
null
UTF-8
C
false
false
2,525
c
ft_file2.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_file2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ymoukhli <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/11 20:03:43 by ymoukhli #+# #+# */ /* Updated: 2019/07/11 20:24:17 by ymoukhli ### ########.fr */ /* */ /* ************************************************************************** */ #include "rtv1.h" float ft_inter_cylinder(t_cam cam, t_obj obj, t_val *v) { t_vect x; t_var var; float t1; x = vec_sub(cam.pos, obj.pos); var.a = (vec_dot(cam.ray, cam.ray) - (vec_dot(cam.ray, obj.dir) * vec_dot(cam.ray, obj.dir))); var.b = 2 * (vec_dot(cam.ray, x) - (vec_dot(cam.ray, obj.dir) * vec_dot(x, obj.dir))); var.c = (vec_dot(x, x) - (vec_dot(x, obj.dir) * vec_dot(x, obj.dir)) - (obj.rad * obj.rad)); var.d = var.b * var.b - (4 * var.a * var.c); if (var.d < 0) return (INFINIT); var.t1 = (-var.b + sqrtf(var.d)) / (2 * var.a); var.t2 = (-var.b - sqrtf(var.d)) / (2 * var.a); if ((var.t1 < 0 && var.t2 < 0)) return (INFINIT); t1 = ft_min_posi(var.t1, var.t2); t1 -= 0.2; if (t1 < v->dis) v->m = vec_dot(cam.ray, obj.dir) * t1 + (vec_dot(x, obj.dir)); return (ft_min_posi(var.t1, var.t2)); } void ft_sphere(t_cam cam, t_obj obj, t_val *v, int i) { float distance; distance = ft_inter_sphere(cam, obj); if (v->dis > distance) { v->dis = distance; if (i == 1) v->obj = obj; } } void ft_plane(t_cam cam, t_obj obj, t_val *v, int i) { float distance; distance = ft_inter_plane(cam, obj); if (v->dis > distance) { v->dis = distance; if (i == 1) v->obj = obj; } } void ft_cone(t_cam cam, t_obj obj, t_val *v, int i) { float distance; distance = ft_inter_cone(cam, obj, v); if (v->dis > distance) { v->dis = distance; if (i == 1) v->obj = obj; } } void ft_cylinder(t_cam cam, t_obj obj, t_val *v, int i) { float distance; distance = ft_inter_cylinder(cam, obj, v); if (v->dis > distance) { v->dis = distance; if (i == 1) v->obj = obj; } }
4d449d14b40732ed9757cef5171fafa1d721347d
2e74f7aaed091c3dc33ce1a13ac99c5220b38efd
/lib/core/flgs.c
e0de5bf7a80b4bbb7f8b66eecad4e8f04a66cc5e
[]
no_license
BillotP/42sh
85b06a81909adc7b82aff518e2b41158cf01f462
feab6dfb9d2d7da9338b8870629a447443960b3e
refs/heads/master
2021-07-18T07:37:52.341957
2021-03-08T10:54:25
2021-03-08T10:54:25
89,345,251
1
0
null
null
null
null
UTF-8
C
false
false
771
c
flgs.c
/* ** flgs.c for PSU_2016_42sh in /home/bender/LASTP/psu_2016_42sh ** ** Made by Bender_Jr ** Login <@epitech.eu> ** ** Started on Mon Apr 10 09:33:52 2017 Bender_Jr ** Last update Mon Apr 10 09:33:54 2017 Bender_Jr */ # include "base.h" # include "printf.h" int flg_d(va_list list, int fd) { int nb; nb = va_arg(list, int); p_putnbr(nb, fd); return (nb); } int flg_i(va_list list, int fd) { int nb; nb = va_arg(list, int); p_putnbr(nb, fd); return (0); } int flg_c(va_list list, int fd) { int a; a = va_arg(list, int); if (write(fd, &a, 1) == -1) return (-1); return (0); } int flg_s(va_list list, int fd) { const char *s; s = va_arg(list, char *); if (s == NULL) pprint("(null)", fd); pprint(s, fd); return (0); }
a1d574332d895f0d60055941d03d4d0a77902705
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/stb/tests/extr_stb.c_bst_test.c
9b53154bbd83736f7816ecc16e75729f2559be36
[]
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
3,438
c
extr_stb.c_bst_test.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_23__ TYPE_1__ ; /* Type definitions */ typedef int /*<<< orphan*/ sorted ; typedef int /*<<< orphan*/ items ; struct TYPE_23__ {int v; } ; typedef TYPE_1__ Btest ; /* Variables and functions */ int /*<<< orphan*/ assert (int) ; int /*<<< orphan*/ btest__validate (TYPE_1__*,int) ; TYPE_1__* btest_find (TYPE_1__*,int) ; TYPE_1__* btest_first (TYPE_1__*) ; TYPE_1__* btest_insert (TYPE_1__*,TYPE_1__*) ; TYPE_1__* btest_last (TYPE_1__*) ; TYPE_1__* btest_next (TYPE_1__*,TYPE_1__*) ; TYPE_1__* btest_prev (TYPE_1__*,TYPE_1__*) ; TYPE_1__* btest_remove (TYPE_1__*,TYPE_1__*) ; int /*<<< orphan*/ c (int /*<<< orphan*/ ,char*) ; int /*<<< orphan*/ free (TYPE_1__*) ; TYPE_1__* malloc (int) ; int /*<<< orphan*/ memcpy (int*,int*,int) ; int /*<<< orphan*/ qsort (int*,int,int,int /*<<< orphan*/ ) ; int /*<<< orphan*/ stb_intcmp (int /*<<< orphan*/ ) ; int stb_rand () ; int /*<<< orphan*/ stb_reverse (int*,int,int) ; int /*<<< orphan*/ stb_shuffle (int*,int,int,int) ; void bst_test(void) { Btest *root = NULL, *t; int items[500], sorted[500]; int i,j,z; for (z=0; z < 10; ++z) { for (i=0; i < 500; ++i) items[i] = stb_rand() & 0xfffffff; // check for collisions, and retrry if so memcpy(sorted, items, sizeof(sorted)); qsort(sorted, 500, sizeof(sorted[0]), stb_intcmp(0)); for (i=1; i < 500; ++i) if (sorted[i-1] == sorted[i]) break; if (i != 500) { --z; break; } for (i=0; i < 500; ++i) { t = malloc(sizeof(*t)); t->v = items[i]; root = btest_insert(root, t); #ifdef STB_DEBUG btest__validate(root,1); #endif for (j=0; j <= i; ++j) c(btest_find(root, items[j]) != NULL, "stb_bst 1"); for ( ; j < 500; ++j) c(btest_find(root, items[j]) == NULL, "stb_bst 2"); } t = btest_first(root); for (i=0; i < 500; ++i) t = btest_next(root,t); c(t == NULL, "stb_bst 5"); t = btest_last(root); for (i=0; i < 500; ++i) t = btest_prev(root,t); c(t == NULL, "stb_bst 6"); memcpy(sorted, items, sizeof(sorted)); qsort(sorted, 500, sizeof(sorted[0]), stb_intcmp(0)); t = btest_first(root); for (i=0; i < 500; ++i) { assert(t->v == sorted[i]); t = btest_next(root, t); } assert(t == NULL); if (z==1) stb_reverse(items, 500, sizeof(items[0])); else if (z) stb_shuffle(items, 500, sizeof(items[0]), stb_rand()); for (i=0; i < 500; ++i) { t = btest_find(root, items[i]); assert(t != NULL); root = btest_remove(root, t); c(btest_find(root, items[i]) == NULL, "stb_bst 5"); #ifdef STB_DEBUG btest__validate(root, 1); #endif for (j=0; j <= i; ++j) c(btest_find(root, items[j]) == NULL, "stb_bst 3"); for ( ; j < 500; ++j) c(btest_find(root, items[j]) != NULL, "stb_bst 4"); free(t); } } }
bbddcdff98e5545fe58de609e236dc8ce95dc97b
6c20fe263a624e75da8e87efc129a59a128e3357
/source/core/ut/ut.c
7c879ed569a2136860205698fc1474f5fb895f38
[ "MIT" ]
permissive
in4lio/predict
df2e66639b26e2901459134df084b44e235c61ba
b7e1e4d753877da3bb2c2a0f0f770c6c2fc130bd
refs/heads/master
2021-01-17T02:00:52.228136
2017-11-27T11:48:18
2017-11-27T11:48:18
16,715,644
3
0
null
null
null
null
UTF-8
C
false
false
8,837
c
ut.c
/* ut.c was generated by yup.py (yupp) 1.0c2 out of ut.yu-c *//** * \file ut.c (ut.yu-c) * \brief Unit testing. * \author Vitaly Kravtsov (in4lio@gmail.com) * \copyright See the LICENSE file. */ #define LOGGING #define LINK_CONSOLE #define LINK_UT #define LINK_UT_UT #define LINK_UT_CORO #define LINK_UT_DATA #define UT_IMPLEMENT #include "include.h" /** * \addtogroup ut * \{ */ #define ________ "................................................................................" \ "................................................................................" #define __PASSED__ "P A S S E D" #define __FAILED__ "F A I L E D" static uint32_t __executed = 0; static uint32_t __failed = 0; static uint32_t __quiet = 0; static uint32_t __executed_before; static uint32_t __failed_before; static uint32_t ut_executed[ 3 ] = { 0 }; static uint32_t ut_failed[ 3 ] = { 0 }; static unsigned long ut_start, ut_stop; enum { ut_thread_IDLE, ut_thread_START, ut_thread_EXEC, }; static int ut_thread = ut_thread_IDLE; static char *ut_unit = NULL; static __inline uint32_t __get_time( void ) { return ( ut_get_time_callback ) ? ut_get_time_callback() : 0; } static __inline void __started_callback( int t ) { if ( ut_started_callback ) ut_started_callback( t ); } static __inline void __finished_callback( int t, bool result ) { if ( ut_finished_callback ) ut_finished_callback( t, result ); } static __inline void __lock( void ) { if ( ut_lock_callback ) ut_lock_callback(); } static __inline void __unlock( void ) { if ( ut_unlock_callback ) ut_unlock_callback(); } bool ut_assert_true( bool test, const char *path, const char *func, uint32_t line ) { if ( !test ) ut_fault( "should be true", path, func, line ); return ( !test ); } bool ut_assert_false( bool test, const char *path, const char *func, uint32_t line ) { if ( test ) ut_fault( "should be false", path, func, line ); return ( test ); } bool ut_assert_assigned( int data, const char *path, const char *func, uint32_t line ) { if ( data == 0 ) ut_fault( "should be assigned", path, func, line ); return ( data == 0 ); } bool ut_assert_int_equal( int expected, int actual, const char *path, const char *func, uint32_t line ) { bool test = ( expected == actual ); if ( !test ) { ut_fault_format( "expected " "%d" " but " "%d", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_u32_equal( uint32_t expected, uint32_t actual, const char *path, const char *func, uint32_t line ) { bool test = ( expected == actual ); if ( !test ) { ut_fault_format( "expected " "%" PRIu32 " but " "%" PRIu32, expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_float_equal( float expected, float actual, float delta, const char *path, const char *func, uint32_t line ) { float result = expected - actual; bool test; if ( result < 0.0 ) result = 0.0 - result; test = ( result <= delta ); if ( !test ) { ut_fault_format( "expected " "%f" " but " "%f", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_double_equal( double expected, double actual, double delta, const char *path, const char *func, uint32_t line ) { double result = expected - actual; bool test; if ( result < 0.0 ) result = 0.0 - result; test = ( result <= delta ); if ( !test ) { ut_fault_format( "expected " "%f" " but " "%f", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_string_equal( const char *expected, const char *actual, const char *path, const char *func, uint32_t line ) { bool test; if (( expected == NULL ) && ( actual == NULL )) { test = true; } else if ( expected == NULL ) { test = false; expected = "<NULL>"; } else if ( actual == NULL ) { test = false; actual = "<NULL>"; } else { test = ( strcmp( expected, actual ) == 0 ); } if ( !test ) { ut_fault_format( "expected %s but %s", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_string_ends_with( const char *expected, const char *actual, const char *path, const char *func, uint32_t line ) { bool test = ( strcmp( expected, actual + ( strlen( actual ) - strlen( expected ))) == 0 ); if ( !test ) { ut_fault_format( "expected %s to end with %s", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_string_starts_with( const char *expected, const char *actual, const char *path, const char *func, uint32_t line ) { bool test = ( strncmp( expected, actual, strlen( expected )) == 0 ); if ( !test ) { ut_fault_format( "expected %s to start with %s", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_string_contains( const char *expected, const char *actual, const char *path, const char *func, uint32_t line ) { bool test = ( strstr( actual, expected ) != 0 ); if ( !test ) { ut_fault_format( "expected %s to be in %s", expected, actual, path, func, line ); } return ( !test ); } bool ut_assert_string_doesnt_contain( const char *expected, const char *actual, const char *path, const char *func, uint32_t line ) { bool test = ( strstr( actual, expected ) == 0 ); if ( !test ) { ut_fault_format( "expected %s not to have %s in it", expected, actual, path, func, line ); } return ( !test ); } static char *__get_name( const char *path ) { char *name = strrchr( path, '\\' ); return ( name ) ? name + 1 : ( char *) path; } void __print_header( const char *s, int len, char ch ) { int l = strlen( s ); int d = ( len - ( l + 2 )) / 2; int i; printf( __CRLF__ ); for ( i = 0; i < d; i++ ) putchar( ch ); putchar( ' ' ); printf( s ); putchar( ' ' ); for ( i = d + l + 2; i < len; i++ ) putchar( ch ); } static void __print_result( bool result ) { printf( __CRLF__ ); printf( "%.*s", ( int ) console_col_count, ________ ); printf( __CRLF__ __CRLF__"%*s", ( int )( console_col_count + strlen( __PASSED__ )) / 2, ( result ) ? __PASSED__ : __FAILED__ ); printf( __CRLF__ __CRLF__" %d fault(s) in %d test(s)", __failed, __executed ); printf( " for %.1f sec"__CRLF__, ( float )( ut_stop - ut_start ) / 10 ); printf( "%.*s", ( int ) console_col_count, ________ ); flush(); } void ut_print_statistics( void ) { printf( __CRLF__" ut_stage_1() - %d fault(s) in %d test(s)", ut_failed[ 1 ], ut_executed[ 1 ]); printf( __CRLF__" ut_stage_2() - %d fault(s) in %d test(s)", ut_failed[ 2 ], ut_executed[ 2 ]); if ( ut_thread != ut_thread_IDLE ) printf( " ( running... )" ); printf( __CRLF__" assert() - %d fault(s) beyond test(s)", ut_failed[ 0 ] + __failed ); } void ut_fault( const char *error, const char *path, const char *func, uint32_t line ) { if ( __quiet ) { ++__quiet; return; } ++__failed; __lock(); if ( ut_unit == NULL ) __print_header( __get_name( path ), console_col_count, '.' ); printf( __CRLF__"%-22s %-4d %s", func, line, error ); __unlock(); } void ut_quiet( void ) { __quiet = 1; } void ut_loud( void ) { __quiet = 0; } uint32_t ut_get_quiet( void ) { return __quiet; } void ut_1_exec( void ( *test )( void )) { test(); ++__executed; } void ut_1_unit_begin( const char *path ) { ut_unit = __get_name( path ); __print_header( ut_unit, console_col_count, '.' ); __failed_before = __failed; __executed_before = __executed; } void ut_1_unit_end( void ) { printf( __CRLF__ __CRLF__" %d fault(s) in %d test(s)", __failed - __failed_before, __executed - __executed_before ); ut_unit = NULL; } bool ut_stage_1( void ( *test )( void )) { bool result; __started_callback( 1 ); ut_failed[ 0 ] += __failed; __failed = 0; ut_loud(); ut_start = __get_time(); test(); ut_stop = __get_time(); ut_assert_loud(); result = ( __failed == 0 ); __print_result( result ); __finished_callback( 1, result ); ut_executed[ 1 ] += __executed; __executed = 0; ut_failed[ 1 ] += __failed; __failed = 0; return ( result ); } void ut_2_unit_begin( const char *path ) { __print_header( __get_name( path ), console_col_count, '.' ); } void ut_stage_2_start( int count ) { __executed = count; ut_thread = ut_thread_START; __started_callback( 2 ); } bool ut_stage_2( int ( *test )( void )) { bool result; switch ( ut_thread ) { case ut_thread_START: ut_failed[ 0 ] += __failed; __failed = 0; ut_loud(); ut_unit = "thread"; ut_start = __get_time(); ut_thread = ut_thread_EXEC; test(); return ( true ); case ut_thread_EXEC: if ( test()) return ( true ); ut_stop = __get_time(); ut_thread = ut_thread_IDLE; ut_assert_loud(); result = ( __failed == 0 ); __print_result( result ); __finished_callback( 2, result ); ut_executed[ 2 ] += __executed; __executed = 0; ut_failed[ 2 ] += __failed; __failed = 0; ut_unit = NULL; /* fallthrough */ default: return ( false ); } } /** \} */
d4f1512d8f24e9b91b8c010115a31b23c148e5af
1e5d278b286b3ed8bee31a1b2586e5165b95b0ff
/turnin/ehsu027_lab7_part4.c
5ee167c67ca58b4adb6fa97cb534ef11be71ae8f
[]
no_license
EvanHsu21/Lab7_ADC
1371e8536481c2c918bb4cfdd0357dac96401490
0e1bb47d59f973f24a706f157b57e75cfc263a30
refs/heads/master
2023-05-21T09:56:47.393369
2021-05-03T00:27:09
2021-05-03T00:27:09
363,622,252
0
0
null
null
null
null
UTF-8
C
false
false
1,213
c
ehsu027_lab7_part4.c
/* Author: Evan Hsu * Partner(s) Name: * Lab Section: * Assignment: Lab 7 Exercise 4 * Exercise Description: [optional - include for your own benefit] * * Video Link: * * Confusion regarding part 2, 3, & 4: Part 4 complies with my * understanding in part 2, so I was planning on using the max * from part 2, but this would barely light the B7, so I decreased the max. * * I acknowledge all content contained herein, excluding template or * example code, is my own original work. */ #include <avr/io.h> #ifdef _SIMULATE_ #include "simAVRHeader.h" #endif void ADC_init() { ADCSRA |= (1 << ADEN) | (1 << ADSC) | (1 << ADATE) ; } int main(void) { /* Insert DDR and PORT initializations */ DDRA = 0x00; PORTA = 0xFF; DDRB = 0xFF; PORTB = 0x00; /* Insert your solution below */ ADC_init(); unsigned static short ADC_max = 0x020F; unsigned char dividedADC = ADC_max / 8; signed short tmpADC; unsigned char count = 0; unsigned char i; while (1) { PORTB = 0x00; count = 0; tmpADC = ADC; tmpADC -= dividedADC; while (tmpADC > 0) { tmpADC -= dividedADC; count++; } for (i = 0; i < count; ++i) { PORTB = PORTB << 1; PORTB++; } } return 1; }
cf97b9f5f7dae80cac67a1921d07cf6569a8948c
c9bae7c6d17e76d42d7ce8a4b26c221cabab73d4
/PART1/deleteSmallest/Prob2/IntegerLinkedList.h
4619c0f6bb0f1b563617ac3226b682fb5c3eb2fd
[]
no_license
balhayer/epp-preparation-practice
00d3266abc80fe07c7f10613f0dd4e78f759f842
6427c5e813363bf779f3fd277c9fa241cdf424e2
refs/heads/master
2022-01-06T02:31:02.836233
2019-06-05T07:30:55
2019-06-05T07:30:55
null
0
0
null
null
null
null
UTF-8
C
false
false
1,356
h
IntegerLinkedList.h
//IntegerLinkedList.cpp #include"IntegerLinkedList.h" IntegerLinkedList::IntegerLinkedList() { head = NULL; } void IntegerLinkedList::addFront(int val) { node *newNode,*next; if (head == NULL) { head = new node; head->value = val; head->next = NULL; } else { newNode = new node; newNode->value = val; newNode->next = NULL; //save next pointer next = head; head = newNode; head->next = next; } } void IntegerLinkedList::deleteSmallest() { node *cur = head, *prev = cur,*next=NULL; int min = cur->value; //first find smallest number in list and then delete while (cur != NULL) { if (min > cur->value) { min = cur->value; } cur = cur->next; } //now delete the min by searching the number //if smallest is at head if (head !=NULL && head->value == min) { prev = head; head = head->next; delete prev; } else { cur = head; /*if (cur != NULL) { while (cur->next != NULL && cur->next->value != min) { cur = cur->next; prev = cur; } cur->next = NULL; delete prev->next; }*/ while (cur != NULL && cur->value != min) { prev = cur; cur = cur->next; next = cur->next; } prev->next = next; delete cur; } } string IntegerLinkedList::print() { node *cur = head; string str; while (cur != NULL) { str += to_string(cur->value); str += ' '; cur = cur->next; } cout << str<<endl; return str; }
72065ed42cb0554516730ea22d302baff1b4aa69
d3d3a623793a1e98afdf3b89f19d4b99ccfb74ca
/Old Solutions/Extra_Spaces.c
80281e11bbd5a8f8c0046add4d4325c7af5da44f
[]
no_license
phsaurav/Solution
d95f353699189d34851e855326f6e583dbb9961b
17dcecfa9fdf69d3b01f5cc9280148d6ea82dfd1
refs/heads/master
2020-12-20T07:30:45.644087
2020-12-12T13:24:28
2020-12-12T13:24:28
236,003,225
1
0
null
null
null
null
UTF-8
C
false
false
783
c
Extra_Spaces.c
#include <stdio.h> #include <string.h> int main() { int T,n,i,j; char line[51][501]; scanf("%d",&T); for(int test = 0; test < T; test++) { scanf("%d",&n); getchar(); for(i = 0; i < n; i++) { gets(line[i]); } if(test!= 0) printf("\n"); printf("Case %d:\n",test+1); for(i = 0; i < n; i++) { for(j = 0; line[i][j] != '\0'; j++) { if(line[i][j] == ' ' && line[i][j+1] == ' ') { continue; } else { printf("%c",line[i][j]); } } printf("\n"); } } return 0; }
0548c99982031c9d2ea680c881c7f236308de3fa
5c4135880188af8b0561fa63cd9e7ce08e160c7c
/lib/libft/src/ft_lstadd_front_bonus.c
04f1a7fc1c6e8a405647425458de783bc932f2de
[]
no_license
dalba-de/minishell
08d182ccfdfee7c83df3821c5758d2a0ea012928
3e86dff3b5a1e3fa7f7f55093845e89c23a62ac3
refs/heads/master
2023-03-09T21:42:09.345078
2021-02-23T21:52:10
2021-02-23T21:52:10
289,314,105
0
0
null
null
null
null
UTF-8
C
false
false
999
c
ft_lstadd_front_bonus.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstadd_front_bonus.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dalba-de <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/12 13:11:54 by dalba-de #+# #+# */ /* Updated: 2019/11/18 11:51:36 by dalba-de ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_lstadd_front(t_list **alst, t_list *new) { new->next = *alst; *alst = new; }
548302c9e2ad185f251643858acc0293d8e06e02
516b594509bf8a7d79c3a5af2bd1b4385665e642
/w8/stack.h
eed18fa689913b71a47d36a67c432fcf15e0f21b
[]
no_license
Sherly1001/cadvance
42b1349dd9531c0b93e2775e29d57f1e116aac12
1fff3ffde1cc046c800c90a580f74c2d66e21575
refs/heads/master
2022-12-29T12:49:14.433880
2020-10-13T16:20:33
2020-10-13T16:20:33
null
0
0
null
null
null
null
UTF-8
C
false
false
221
h
stack.h
typedef struct { int data; struct STACK *next; } STACK; int isEmpty(STACK *myStack); void push(STACK **myStack, int data); int getTop(STACK *myStack);// tra ve gia tri o dinh, ko lay ra int pop(STACK **myStack);
fd6b45578f9a5e62b7a5bb1f9327ed6df3cb2145
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/freebsd/sys/dev/liquidio/extr_lio_main.c_lio_get_counter.c
913bb281211eac0bb772c40fd844c7f0cfec168e
[]
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
4,024
c
extr_lio_main.c_lio_get_counter.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_24__ TYPE_9__ ; typedef struct TYPE_23__ TYPE_8__ ; typedef struct TYPE_22__ TYPE_7__ ; typedef struct TYPE_21__ TYPE_6__ ; typedef struct TYPE_20__ TYPE_5__ ; typedef struct TYPE_19__ TYPE_4__ ; typedef struct TYPE_18__ TYPE_3__ ; typedef struct TYPE_17__ TYPE_2__ ; typedef struct TYPE_16__ TYPE_1__ ; typedef struct TYPE_15__ TYPE_12__ ; typedef struct TYPE_14__ TYPE_11__ ; typedef struct TYPE_13__ TYPE_10__ ; /* Type definitions */ typedef scalar_t__ uint64_t ; struct TYPE_14__ {scalar_t__ frame_err; scalar_t__ l2_err; scalar_t__ fcs_err; scalar_t__ total_mcst; } ; struct TYPE_13__ {scalar_t__ total_collisions; scalar_t__ mcast_pkts_sent; } ; struct TYPE_15__ {TYPE_11__ fromwire; TYPE_10__ fromhost; } ; struct octeon_device {int num_oqs; int num_iqs; TYPE_12__ link_stats; TYPE_9__** instr_queue; TYPE_4__** droq; } ; struct TYPE_22__ {TYPE_6__* txpciq; TYPE_2__* rxpciq; } ; struct lio {TYPE_7__ linfo; struct octeon_device* oct_dev; } ; typedef int ift_counter ; typedef int /*<<< orphan*/ if_t ; struct TYPE_23__ {scalar_t__ tx_dropped; scalar_t__ tx_tot_bytes; scalar_t__ tx_done; } ; struct TYPE_24__ {TYPE_8__ stats; } ; struct TYPE_20__ {int q_no; } ; struct TYPE_21__ {TYPE_5__ s; } ; struct TYPE_18__ {scalar_t__ rx_dropped; scalar_t__ rx_bytes_received; scalar_t__ rx_pkts_received; } ; struct TYPE_19__ {TYPE_3__ stats; } ; struct TYPE_16__ {int q_no; } ; struct TYPE_17__ {TYPE_1__ s; } ; /* Variables and functions */ #define IFCOUNTER_COLLISIONS 137 #define IFCOUNTER_IBYTES 136 #define IFCOUNTER_IERRORS 135 #define IFCOUNTER_IMCASTS 134 #define IFCOUNTER_IPACKETS 133 #define IFCOUNTER_IQDROPS 132 #define IFCOUNTER_OBYTES 131 #define IFCOUNTER_OMCASTS 130 #define IFCOUNTER_OPACKETS 129 #define IFCOUNTER_OQDROPS 128 scalar_t__ if_get_counter_default (int /*<<< orphan*/ ,int) ; struct lio* if_getsoftc (int /*<<< orphan*/ ) ; __attribute__((used)) static uint64_t lio_get_counter(if_t ifp, ift_counter cnt) { struct lio *lio = if_getsoftc(ifp); struct octeon_device *oct = lio->oct_dev; uint64_t counter = 0; int i, q_no; switch (cnt) { case IFCOUNTER_IPACKETS: for (i = 0; i < oct->num_oqs; i++) { q_no = lio->linfo.rxpciq[i].s.q_no; counter += oct->droq[q_no]->stats.rx_pkts_received; } break; case IFCOUNTER_OPACKETS: for (i = 0; i < oct->num_iqs; i++) { q_no = lio->linfo.txpciq[i].s.q_no; counter += oct->instr_queue[q_no]->stats.tx_done; } break; case IFCOUNTER_IBYTES: for (i = 0; i < oct->num_oqs; i++) { q_no = lio->linfo.rxpciq[i].s.q_no; counter += oct->droq[q_no]->stats.rx_bytes_received; } break; case IFCOUNTER_OBYTES: for (i = 0; i < oct->num_iqs; i++) { q_no = lio->linfo.txpciq[i].s.q_no; counter += oct->instr_queue[q_no]->stats.tx_tot_bytes; } break; case IFCOUNTER_IQDROPS: for (i = 0; i < oct->num_oqs; i++) { q_no = lio->linfo.rxpciq[i].s.q_no; counter += oct->droq[q_no]->stats.rx_dropped; } break; case IFCOUNTER_OQDROPS: for (i = 0; i < oct->num_iqs; i++) { q_no = lio->linfo.txpciq[i].s.q_no; counter += oct->instr_queue[q_no]->stats.tx_dropped; } break; case IFCOUNTER_IMCASTS: counter = oct->link_stats.fromwire.total_mcst; break; case IFCOUNTER_OMCASTS: counter = oct->link_stats.fromhost.mcast_pkts_sent; break; case IFCOUNTER_COLLISIONS: counter = oct->link_stats.fromhost.total_collisions; break; case IFCOUNTER_IERRORS: counter = oct->link_stats.fromwire.fcs_err + oct->link_stats.fromwire.l2_err + oct->link_stats.fromwire.frame_err; break; default: return (if_get_counter_default(ifp, cnt)); } return (counter); }
62220954e5164670a9fbc025b1629e593a50f0b3
2f8079558c54f0d6dca5e58f45291ddb525194e4
/docs/.vuepress/public/full_demo.c
784b935139abc4ee03025751411b5c2de10048fb
[ "MIT", "BSD-3-Clause" ]
permissive
xwl3190217171/LiteOS_Documents
c3a86a7fb2ffa72d8eec59d7844dd6538e0a3148
e169950d43eefc2a2680e52d4fc35b6d28ac868e
refs/heads/master
2020-04-09T07:35:14.870216
2018-10-29T11:34:33
2018-10-29T11:34:33
160,162,307
1
0
MIT
2018-12-03T09:05:39
2018-12-03T09:05:39
null
UTF-8
C
false
false
23,084
c
full_demo.c
/*---------------------------------------------------------------------------- * Copyright (c) <2016-2018>, <Huawei Technologies 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. *---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- * Notice of Export Control Law * =============================================== * Huawei LiteOS may be subject to applicable export control laws and regulations, which might * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such * applicable export control laws and regulations. *---------------------------------------------------------------------------*/ #include "los_swtmr.h" #include "los_queue.h" #include "los_task.h" #include "los_memory.h" #include "los_list.h" #include "los_mux.h" #include "los_sem.h" #include "los_hwi.h" /**********************************README**************************************************** 1, this demo will use 7 task,1 queue,2 mux,1 sem,3 softtimer,make sure these are configured correctly 2, task_cmd intend to receive command from the cloud host, and send corresponding event to task_event 3, task_alarm intend to monitor the alarm sensor, and send event to the task_event 4, task_event handle all the event do the corresponding actions(print instead) 5, task_sample(more than one) sample the data periodicly(triggered by the soft timer) and send to the sample queue 6, task_rcv read the sample data from the sample queue and cache them in a list,when enough message get, we will pack all the message and do report 7, report here we only use print instead that is all! ********************************************************************************************/ /**************************************FILE DEFINES*********************************************/ #define LOC_DEVICEID 0x0001 //for the imitate,may be you should use globle vars for change #define INVALID_TASKID (0xFFFFFFFF) //all the handle if failed we will set it to invalid as this #define INVALID_TIMERID (0xFFFF) //this is defines for the rcv task #define Q_MAX_MSGNUM 30 //UNIT:message item #define Q_CACHE_TIMEOUT 5000 //UNIT:TICK #define RCV_LOOPCYCLE 10 //UNIT:TICK //defines for general task stacksize and prior #define DEFAULT_TASK_PRIOR 8 //task prior if not specified #define DEFAULT_TASK_STACKSIZE 0x1000//task stacksize if not specified //defines the event used for the alarm task,cmdtask,eventtask #define EVENT_IO_OPEN (1<<0) #define EVENT_IO_CLOSE (1<<1) #define EVENT_ALARM (1<<2) //defines for the cmd buf #define CLOUD_CMD_LENGTH 256 #define CMD_WAIT_TIMEOUT 2000 //UNIT:TICKS #define NOT_USED(arg) (arg = arg;) /**************************************FILE DATA STRUCTURE**********************************/ //the data receive task use this structure to cache the message typedef struct _sample_msg_item { LOS_DL_LIST list; UINT8 *buf; }tSampleMsgItem; //all the sample demo use the same logic, so we define it format here,you may change it yourself as you wish typedef struct _sample_params { CHAR *name; UINT16 prior; UINT32 stacksize; TSK_ENTRY_FUNC entry; UINT32 cycle; UINT32 taskId; UINT16 timerId; }tSampleParams; typedef struct sample_data { UINT16 device_id; UINT16 data_type; UINT32 loop_times; UINT64 tick_now; }tSampleData; #define SAMPLE_DATA_LEN (sizeof(tSampleData)) static VOID *Task_Sample(UINT32 args); /**************************************FILE VARS*********************************************/ UINT32 g_SampleQueueId; //queue, used to cache the message UINT32 g_RecvTaskId; UINT32 g_EventTaskId; static UINT32 g_CloudCmdSemId; //this sync is used for the cmdtask, which will wait the sem static UINT32 g_DebugPrintMuxId; //debug mux lock static UINT32 g_DataReportMuxId; //the report function will use this mux for multi task reasons static EVENT_CB_S g_SampleEvent; //the event,ipc between tasks without parameters static UINT8 g_CmdBuffer[CLOUD_CMD_LENGTH]; //the cmd buffer,write by the isr of the hardware and read by cmd task static UINT32 g_CmdBufferLength; //how many data in cmd buffer //define the sample process static tSampleParams g_SampleParams[] = { { "CSQ_SAMPLE", DEFAULT_TASK_PRIOR + 1, DEFAULT_TASK_STACKSIZE, Task_Sample, 10000, INVALID_TASKID, INVALID_TIMERID }, { "PWR_SAMPLE", DEFAULT_TASK_PRIOR + 1, DEFAULT_TASK_STACKSIZE, Task_Sample, 5000, INVALID_TASKID, INVALID_TIMERID }, { "DHT_SAMPLE", DEFAULT_TASK_PRIOR, DEFAULT_TASK_STACKSIZE, Task_Sample, 1000, INVALID_TASKID, INVALID_TIMERID }, }; #define SAMPLE_TASKNUM (sizeof(g_SampleParams)/sizeof(tSampleParams)) /************************FUNCTION IMPLEMENT*********************************************/ /*************************************************************************************************** function :do printf for multi task parameters :same as printf instruction :here we deal the print,because we use multi task, they may has the same prior to avoid print conflict, we use a mutex here to do multi task sync ***************************************************************************************************/ static void Debug_Print(const CHAR *fmt,...) { UINT32 ulRet = LOS_OK; CHAR s[64] = {0}; //maybe enough here,if you need more, change it,take care of the task stack size! va_list arg_lst = {0}; ulRet = LOS_MuxPend(g_DebugPrintMuxId, LOS_WAIT_FOREVER); if (LOS_OK == ulRet) { va_start(arg_lst, fmt); vsprintf(s,fmt,arg_lst); va_end(arg_lst); puts(s); LOS_MuxPost(g_DebugPrintMuxId); } return; } /*************************************************************************************************** function :report data to the cloud parameters :buf, the address of the message to report len, the message length instruction :here we use print instead for we has no access to the cloud,you could implement yourself ***************************************************************************************************/ static VOID Data_Report(UINT8 *buf, UINT32 len) { UINT32 ulRet; //take care of the multi task called, if your method support multi task, you could remove the mux here ulRet = LOS_MuxPend(g_DataReportMuxId, LOS_WAIT_FOREVER); if (LOS_OK == ulRet) { Debug_Print("REPORT MESSAGELEN:%d\r\n",len); //we use the print to do the imitate LOS_MuxPost(g_DataReportMuxId); } return; } /*************************************************************************************************** function :alarm monitor task parameters :args,not used yet instruction :we has no alarm monitor sensor, so we will write a event at about 5000 ticks instead ***************************************************************************************************/ static VOID *Task_SmokyAlarm(UINT32 ulArg) { UINT32 ulRet = LOS_OK; UINT32 ulEvent = EVENT_ALARM; while (1) { LOS_TaskDelay(5000); //5000 ticks ulRet = LOS_EventWrite(&g_SampleEvent, ulEvent); if (LOS_OK != ulRet) { Debug_Print("TASK_ALARM:WRITE ALARM EVENT:%x ERROR\r\n",ulEvent); } else { Debug_Print("TASK_ALARM:WRITE ALARM EVENT:%x OK\r\n",ulEvent); } } } /*************************************************************************************************** function :cmd monitor task parameters :args,not used yet instruction :actually we will monitor the cloud host if any messages, here we use the data toggle here and the data simulated here using intlock between the task and isr ***************************************************************************************************/ static VOID *Task_CloudCmd(UINT32 args) { UINT32 ulRet = LOS_OK; UINT32 ulEvent = EVENT_IO_OPEN; UINT8 cmd_data[CLOUD_CMD_LENGTH]; while (1) { ulRet = LOS_SemPend(g_CloudCmdSemId, CMD_WAIT_TIMEOUT); //this will be trigglerd by the hardware isr LOS_IntLock(); //this sync with the isr if (g_CmdBufferLength > 0) { memcpy(cmd_data, g_CmdBuffer,g_CmdBufferLength); g_CmdBufferLength = 0; //clear it ulRet = LOS_OK; } else { g_CmdBufferLength = CLOUD_CMD_LENGTH; } LOS_IntUnLock(); //do the data analyze here, we just toggle the ulEvent instead ulEvent = (ulEvent == EVENT_IO_OPEN) ? EVENT_IO_CLOSE : EVENT_IO_OPEN; ulRet = LOS_EventWrite(&g_SampleEvent, ulEvent); if (LOS_OK != ulRet) { Debug_Print("TASK_CMD:WRITE CMD EVENT:%x ERROR\r\n",ulEvent); } else { Debug_Print("TASK_CMD:WRITE CMD EVENT:%x OK\r\n",ulEvent); } } } /*************************************************************************************************** function :event process task parameters :args,not used yet instruction :we read event,check its type and do corresponding,we use print here instead ***************************************************************************************************/ static VOID *Task_Sample(UINT32 ulTaskNo) { UINT32 ulRet = LOS_OK; UINT32 ulTaskId = INVALID_TASKID; tSampleData *pData = NULL; UINT32 ulLoopTimes = NULL; ulTaskId = g_SampleParams[ulTaskNo].taskId; while(1) { ulLoopTimes++; LOS_TaskSuspend(ulTaskId); //wait until the soft timer active it pData = (tSampleData*)LOS_MemAlloc(m_aucSysMem0, SAMPLE_DATA_LEN); if (NULL != pData) { pData->device_id = LOC_DEVICEID; pData->data_type = ulTaskNo; pData->loop_times = ulLoopTimes; pData->tick_now = LOS_TickCountGet(); ulRet= LOS_QueueWrite(g_SampleQueueId, pData, SAMPLE_DATA_LEN, LOS_WAIT_FOREVER); if (LOS_OK != ulRet) { Debug_Print("TASK %d WRITE DATA ERROR:%x\r\n", ulTaskId, ulRet); LOS_MemFree(m_aucSysMem0, pData); } else { Debug_Print("TASK %d WRITE DATA:%d Bytes\r\n",ulTaskId, SAMPLE_DATA_LEN); } } } } /*************************************************************************************************** function :task receive entry parameters :args,not used yet instruction :we will read message from the queue, and make it to a list added to the cache queue, if cached length is over or time is up,we will pack all the message received and send it to the cloud ***************************************************************************************************/ static VOID *Task_RecvQ(UINT32 args) { UINT32 ulRet = LOS_OK; UINT8 *pMsgBuffer = NULL; //usedto pack all the message UINT32 *pData = NULL; //storage the pointer read from the queue UINT32 ulDataNum = NULL; UINT32 ulMsgNo = NULL; UINT64 last_reporttick = NULL; LOS_DL_LIST msg_lst_head; //message cached list head LOS_DL_LIST *item,*next; //used for the interate the message list tSampleMsgItem *itemcache; //initialize the message cached list LOS_ListInit(&msg_lst_head); while (1) { //we read data from the queue, and we will block here when no messages in queue pData = NULL; ulRet = LOS_QueueRead(g_SampleQueueId, &pData, sizeof(pData), RCV_LOOPCYCLE); if (ulRet == LOS_OK && NULL != pData){ //we get a message here, so pack it with list and cached it itemcache = LOS_MemAlloc(m_aucSysMem0,sizeof(tSampleMsgItem)); if (NULL != itemcache) { memset(itemcache,0,sizeof(tSampleMsgItem)); itemcache->buf = (UINT8 *)pData; LOS_ListAdd(&msg_lst_head, &itemcache->list); ulDataNum++; } } if (((LOS_TickCountGet() - last_reporttick) > Q_CACHE_TIMEOUT) || (ulDataNum > Q_MAX_MSGNUM)) { //pack all the data and send here if (ulDataNum == 0){ continue; //no message get here, do another loop } pMsgBuffer = LOS_MemAlloc(m_aucSysMem0, SAMPLE_DATA_LEN * ulDataNum); if (NULL != pMsgBuffer) { ulMsgNo = 0; LOS_DL_LIST_FOR_EACH_SAFE(item, next, &msg_lst_head) { itemcache = (tSampleMsgItem*)item; memcpy(pMsgBuffer + (ulMsgNo * SAMPLE_DATA_LEN), itemcache->buf, SAMPLE_DATA_LEN); //remove the item and free the memory(INCLUDE THE LIST AND BUF IN THE LIST) LOS_ListDelete(&itemcache->list); LOS_MemFree(m_aucSysMem0, itemcache->buf); LOS_MemFree(m_aucSysMem0, itemcache); } Data_Report(pMsgBuffer, ulDataNum * SAMPLE_DATA_LEN); LOS_MemFree(m_aucSysMem0, pMsgBuffer); ulDataNum = 0; last_reporttick = LOS_TickCountGet(); } else { Debug_Print("NO MEMORY HERE,CHECK THE HEAP\r\n\r"); } } } } /*************************************************************************************************** function :event process task parameters :args,not used yet instruction :we read event,check its type and do corresponding,we use print here instead ***************************************************************************************************/ static VOID *Task_EventsHandle(UINT32 args){ UINT32 ulEvent; const CHAR *alarm_msg = "HELLO, ALARM"; while (1) { ulEvent = LOS_EventRead( &g_SampleEvent, EVENT_IO_OPEN|EVENT_IO_CLOSE|EVENT_ALARM, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER ); if (ulEvent & EVENT_ALARM) { Data_Report((UINT8 *)alarm_msg, strlen(alarm_msg)); } if (ulEvent & EVENT_IO_OPEN) { Debug_Print("IO EVENT:OPEN\r\n"); //we use print imitating the hardware } if (ulEvent & EVENT_IO_CLOSE) { Debug_Print("IO EVENT:CLOSE\r\n");//we use print imitationg the hardware } } } /*************************************************************************************************** function :timer call back entry parameters :args,pass the id_task which will be resumed instruction :all the trigger timer use the same entry,specify them by the args ***************************************************************************************************/ static VOID Timer_Callback(UINT32 ulTaskId) { UINT32 ulRet = LOS_OK; ulRet = LOS_TaskResume(ulTaskId); if (ulRet != LOS_OK) { Debug_Print("RESUME TASK:%d ERROR:%x\r\n", ulTaskId, ulRet); } return; } /*************************************************************************************************** function :this is the demo entry parameters : instruction :we will create one task(task_rcv),one queue(queue_demo), and one soft timer the soft timer send data to queue each 2000 ticks (tick default 1ms) the receive task receive data from the queue,if no messsage it will block here ***************************************************************************************************/ UINT32 Full_Demo(VOID) { UINT32 ulRet; TSK_INIT_PARAM_S stTaskParam = {0}; UINT32 ulTaskId = INVALID_TASKID; UINT16 ulSwTmrId = INVALID_TIMERID; UINT32 ulTaskNo = NULL; ulRet = LOS_EventInit(&g_SampleEvent); if (LOS_OK != ulRet) { Debug_Print("create Event error.:%x\r\n", ulRet); return LOS_NOK; } ulRet = LOS_MuxCreate(&g_DebugPrintMuxId); if (LOS_OK != ulRet) { Debug_Print("create Mutex error.:%x\r\n", ulRet); return LOS_NOK; } ulRet = LOS_MuxCreate(&g_DataReportMuxId); if (LOS_OK != ulRet) { Debug_Print("create Mutex error.:%x\r\n", ulRet); return LOS_NOK; } //create the cmd task trigger semphore ulRet = LOS_SemCreate(0, &g_CloudCmdSemId); //initialize it not active,it is actived by the irq or something else if (LOS_OK != ulRet) { Debug_Print("create Semaphore error.:%x\r\n", ulRet); return LOS_NOK; } //then we will create a queue here,depth is 8, and max message length is four bytes(storage the pointer) ulRet = LOS_QueueCreate("queue_demo", 8, &g_SampleQueueId, 0, sizeof(UINT32)); if (LOS_OK != ulRet) { Debug_Print("create queue error:%x\r\n",ulRet); return LOS_NOK; } //then we create receive task here:task size is DEFAULT_TASK_STACKSIZE, //task prior is DEFAULT_TASK_PRIOR,and task entry is task_rcv stTaskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task_RecvQ; stTaskParam.uwStackSize = DEFAULT_TASK_STACKSIZE; stTaskParam.pcName = "Task_RecvQ"; stTaskParam.usTaskPrio = DEFAULT_TASK_PRIOR; ulRet = LOS_TaskCreate(&g_RecvTaskId, &stTaskParam); if (LOS_OK != ulRet) { Debug_Print("create Task_RecvQ error:%x\r\n",ulRet); return LOS_NOK; } stTaskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task_SmokyAlarm; stTaskParam.uwStackSize = DEFAULT_TASK_STACKSIZE; stTaskParam.pcName = "Task_SmokyAlarm"; stTaskParam.usTaskPrio = DEFAULT_TASK_PRIOR; ulRet = LOS_TaskCreate(&g_EventTaskId, &stTaskParam); if (LOS_OK != ulRet) { Debug_Print("create Task_SmokyAlarm error:%x\r\n",ulRet); return LOS_NOK; } stTaskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task_CloudCmd; stTaskParam.uwStackSize = DEFAULT_TASK_STACKSIZE; stTaskParam.pcName = "Task_CloudCmd"; stTaskParam.usTaskPrio = DEFAULT_TASK_PRIOR; ulRet = LOS_TaskCreate(&ulTaskId, &stTaskParam); if (LOS_OK != ulRet) { Debug_Print("create Task_CloudCmd error:%x\r\n",ulRet); return LOS_NOK; } stTaskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task_EventsHandle; stTaskParam.uwStackSize = DEFAULT_TASK_STACKSIZE; stTaskParam.pcName = "Task_EventsHandle"; stTaskParam.usTaskPrio = DEFAULT_TASK_PRIOR; ulRet = LOS_TaskCreate(&ulTaskId, &stTaskParam); if (LOS_OK != ulRet) { Debug_Print("create Task_EventsHandle error:%x\r\n",ulRet); return LOS_NOK; } for (ulTaskNo = 0; ulTaskNo < SAMPLE_TASKNUM; ulTaskNo++) { (VOID)memset((VOID *)(&stTaskParam), 0, sizeof(TSK_INIT_PARAM_S)); stTaskParam.pfnTaskEntry = g_SampleParams[ulTaskNo].entry; stTaskParam.uwStackSize = g_SampleParams[ulTaskNo].stacksize; stTaskParam.pcName = g_SampleParams[ulTaskNo].name; stTaskParam.usTaskPrio = g_SampleParams[ulTaskNo].prior; stTaskParam.uwArg = ulTaskNo; ulRet = LOS_TaskCreate(&ulTaskId, &stTaskParam); if (LOS_OK != ulRet) { Debug_Print("create %s error:%x\r\n", stTaskParam.pcName, ulRet); return LOS_NOK; } g_SampleParams[ulTaskNo].taskId = ulTaskId; //now create a soft timer here,args use the id_task ulRet = LOS_SwtmrCreate( LOS_MS2Tick(g_SampleParams[ulTaskNo].cycle), LOS_SWTMR_MODE_PERIOD, Timer_Callback, &ulSwTmrId, ulTaskId #if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES) , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_SENSITIVE #endif ); if (LOS_OK != ulRet) { Debug_Print("create Swtmr error:%x\r\n", ulRet); return LOS_NOK; } g_SampleParams[ulTaskNo].timerId = ulSwTmrId; ulRet = LOS_SwtmrStart(ulSwTmrId); //you should start the timer(means enable) if (LOS_OK == ulRet) { Debug_Print("TaskId:%d TaskName:%-16s TimerId:%d\r\n", g_SampleParams[ulTaskNo].taskId, g_SampleParams[ulTaskNo].name, g_SampleParams[ulTaskNo].timerId); } } return LOS_OK; }
d3080b29b1700d45cd6045b942e25fa499d931c0
1ae06dc85014fbb658aba733053763165950d318
/vendor/github.com/spdk/spdk/dpdk/drivers/net/ark/ark_logs.h
b90e9f0ac9ad622940c070ed6d67e54bcecfdd1c
[ "GPL-2.0-only", "BSD-3-Clause", "Apache-2.0" ]
permissive
intel/oim
4bc003da0a6b75d1fe50c848aa9bb68145fc69c0
ee179563970db92487d76b373cc3b25dc2c99ca5
refs/heads/master
2023-09-03T01:15:52.079309
2022-08-04T22:47:56
2022-08-04T22:47:56
168,253,801
18
9
Apache-2.0
2019-03-04T15:20:47
2019-01-30T00:48:36
Go
UTF-8
C
false
false
2,623
h
ark_logs.h
/* SPDX-License-Identifier: BSD-3-Clause * Copyright (c) 2015-2018 Atomic Rules LLC */ #ifndef _ARK_DEBUG_H_ #define _ARK_DEBUG_H_ #include <inttypes.h> #include <rte_log.h> /* Configuration option to pad TX packets to 60 bytes */ #ifdef RTE_LIBRTE_ARK_PAD_TX #define ARK_TX_PAD_TO_60 1 #else #define ARK_TX_PAD_TO_60 0 #endif /* system camel case definition changed to upper case */ #define PRIU32 PRIu32 #define PRIU64 PRIu64 /* Format specifiers for string data pairs */ #define ARK_SU32 "\n\t%-20s %'20" PRIU32 #define ARK_SU64 "\n\t%-20s %'20" PRIU64 #define ARK_SU64X "\n\t%-20s %#20" PRIx64 #define ARK_SPTR "\n\t%-20s %20p" #define PMD_DRV_LOG(level, fmt, args...) \ RTE_LOG(level, PMD, fmt, ## args) /* Conditional trace definitions */ #define ARK_TRACE_ON(level, fmt, ...) \ RTE_LOG(level, PMD, fmt, ##__VA_ARGS__) /* This pattern allows compiler check arguments even if disabled */ #define ARK_TRACE_OFF(level, fmt, ...) \ do {if (0) RTE_LOG(level, PMD, fmt, ##__VA_ARGS__); } \ while (0) /* tracing including the function name */ #define ARK_FUNC_ON(level, fmt, args...) \ RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args) /* tracing including the function name */ #define ARK_FUNC_OFF(level, fmt, args...) \ do { if (0) RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args); } \ while (0) /* Debug macro for tracing full behavior, function tracing and messages*/ #ifdef RTE_LIBRTE_ARK_DEBUG_TRACE #define PMD_FUNC_LOG(level, fmt, ...) ARK_FUNC_ON(level, fmt, ##__VA_ARGS__) #define PMD_DEBUG_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__) #else #define PMD_FUNC_LOG(level, fmt, ...) ARK_FUNC_OFF(level, fmt, ##__VA_ARGS__) #define PMD_DEBUG_LOG(level, fmt, ...) ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__) #endif /* Debug macro for reporting FPGA statistics */ #ifdef RTE_LIBRTE_ARK_DEBUG_STATS #define PMD_STATS_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__) #else #define PMD_STATS_LOG(level, fmt, ...) ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__) #endif /* Debug macro for RX path */ #ifdef RTE_LIBRTE_ARK_DEBUG_RX #define ARK_RX_DEBUG 1 #define PMD_RX_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__) #else #define ARK_RX_DEBUG 0 #define PMD_RX_LOG(level, fmt, ...) ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__) #endif /* Debug macro for TX path */ #ifdef RTE_LIBRTE_ARK_DEBUG_TX #define ARK_TX_DEBUG 1 #define PMD_TX_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__) #else #define ARK_TX_DEBUG 0 #define PMD_TX_LOG(level, fmt, ...) ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__) #endif #endif
4cd5d8c27aa4cc624506235bb75bd317664c3514
a116cb320ec41ac31faaed9e81d238fedb796e66
/src/utils.c
ca3bbf4568808a8e6e442079b540d5b53c8b7506
[ "Apache-2.0" ]
permissive
za-ek/intersectdb
659d80654fb985ad4ca2483a6dafc1ced1480041
ea0b9cf7b07b1793e8a66760585df6b1c429aca1
refs/heads/master
2021-06-25T14:32:28.142726
2020-11-28T20:22:27
2020-11-28T20:22:27
148,192,052
0
0
Apache-2.0
2018-09-11T15:06:19
2018-09-10T17:20:16
C
UTF-8
C
false
false
1,040
c
utils.c
#include <stdio.h> #include <string.h> #include <ctype.h> #include <dirent.h> #include <errno.h> #include <sys/stat.h> #include <sys/types.h> #include "utils.h" /** * https://stackoverflow.com/questions/122616/how-do-i-trim-leading-trailing-whitespace-in-a-standard-way * * @brief z_trim * @param str * @return */ char *z_trim(char *str) { char *end; // Trim leading space while(isspace((unsigned char)*str)) str++; if(*str == 0) // All spaces? return str; // Trim trailing space end = str + strlen(str) - 1; while(end > str && isspace((unsigned char)*end)) end--; // Write new null terminator character end[1] = '\0'; return str; } void z_err (char*err) { printf("%s", err); printf("\n"); } /** * @brief z_dirExist * @param path * @return 1 - exist, 2 - no, 3 - failed to check */ int z_dirExist(char*path) { DIR* dir = opendir(path); if (dir) { closedir(dir); return 1; } else if (ENOENT == errno) { return 2; } else { return 3; } }
b389a5e3d471d2260f96233d4c2346f71de2fdef
45932ccaca48ec80cbca57ba3983522f9137d293
/my_project/mdcproject/decompression.c
72f0c114ac4124dd419ce2de2d45d8dda972fd04
[]
no_license
writetonewhorizon/device_driver_devlopment
dc00ab9e91518e2f56fcfcaf67c686bfd5a5b06b
a6429f69336b4bdd7867fddfe575e7f118d02d18
refs/heads/master
2021-01-21T07:25:40.229313
2016-08-30T11:43:50
2016-08-30T11:43:50
null
0
0
null
null
null
null
UTF-8
C
false
false
1,397
c
decompression.c
#include<stdio.h> #include<unistd.h> #include<fcntl.h> int main() { int fde,fe,fo,d,k,m,n; unsigned char h,c_count = 0,e_count = 0,r,x,y,z,tem; fde = open("compressed_code.c",O_RDONLY); fe = open("encryptionkey.c",O_RDONLY); fo = open("decomp_data.c",O_WRONLY); read(fde,&h,1); while(h != '\0') { c_count++; read(fde,&h,1); } unsigned char code[c_count]; read(fe,&h,1); while(h != '\0') { e_count++; read(fe,&h,1); } // printf("c_count is %d\t e_count is %d\n",c_count,e_count); char ekey[e_count]; lseek(fde,SEEK_SET,0); read(fde,&code,c_count); lseek(fe,SEEK_SET,0); read(fe,&ekey,e_count); // printf("%d\n",code[13]); // for(i = 0;i < 20;i++) // printf("%c %c\n",code[i],ekey[i]); for(d = 0;d < c_count;d++) { // printf("%d\n",code[d]); x = code[d]; z = code[d]; // if(x >= 128) // { // y = x >> 4; // y = y & 0x0f; // printf(">128 y is %d\t",y); // z = z & 15; // printf("z is %d\n",z); // } // if(x < 128) // { y = x >> 4; // printf("y is %d\t",y); // tem = z << 4; // z = tem >> 4; z = z & 15; // printf("z is %d\n",z); // } m = n = 0; if(m == 0) { for(k = 0;k < e_count;k++) { if(y == k ) { r = ekey[k]; write(fo,&r,1); n = 1; break; } } } if(n == 1); { for(k = 0;k < e_count;k++) { if(z == k ) { r = ekey[k]; write(fo,&r,1); break; } } } } return 0; }
93a33b2ec2862d41f207997c951e4b4b3be09f13
a8922cbe29448486112feb639893b199c6f65f1f
/chopstick.h
6be075a1f5823e48820576ed9d9f6ab58beb420f
[]
no_license
iwanght/philosopher_issue
6aa35d8416c1da81aabe2a8ed6f6fcc969db4848
a4e7d7e9f5e16f0c96d610e313c3bf076d20fc87
refs/heads/master
2022-07-26T23:54:56.803910
2020-05-17T04:58:05
2020-05-17T05:05:23
264,410,238
0
0
null
null
null
null
UTF-8
C
false
false
181
h
chopstick.h
#include <stdbool.h> bool create_chopsticks(int count); void destroy_chopsticks(); int pick_up_chopstick(int no); int try_pick_up_chopstick(int no); int put_down_chopstick(int no);
7a45c5c9afc59b41badc32842733228cc78a3b84
88354dea596f93aa7a05f1945e66e166427704a7
/libft/ft_printf/Handlers/type_handlers_cper.c
f81afa5beaaafd8787ad85d360f5364d9c345a66
[]
no_license
ppanchen/corewar
a4f77ef5eb6621726af5a87530812b3a09224594
898bf0387e3f8f83c6d9a3995595039fc7d7a277
refs/heads/master
2021-01-20T01:10:51.790256
2017-05-22T12:27:04
2017-05-22T12:27:04
89,229,318
0
0
null
null
null
null
UTF-8
C
false
false
2,151
c
type_handlers_cper.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* type_handlers(cC).c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ppanchen <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/19 18:01:34 by ppanchen #+# #+# */ /* Updated: 2017/02/06 17:10:51 by ppanchen ### ########.fr */ /* */ /* ************************************************************************** */ #include "../ft_printf.h" char *c_handler(t_format f, va_list *ap) { char *str; (void)f; str = ft_strnew(2); str[0] = (char)va_arg(*ap, int); if (str[0] == 0) str[0] = '\302'; return (str); } char *per_handler(t_format f, va_list *ap) { (void)ap; (void)f; return (ft_strdup("%")); } char *precision_handler2(char **str, t_format f) { char *ret; if ((f.spec == 'i' || f.spec == 'd' || f.spec == 'd') && ft_atoi(*str) < 0) ret = retstr_fill(f.after_dot - ft_strlen(*str) + 1, str, '0', 1); else if (f.spec != 'c') ret = retstr_fill(f.after_dot - ft_strlen(*str), str, '0', 0); else ret = ft_strdup(*str); return (ret); } char *precision_handler(char **str, t_format f) { char *ret; if (f.after_dot == -1 || f.spec == '%') ret = ft_strdup(*str); else if (f.after_dot == 0 && (ft_strcmp(*str, "0") == 0)) ret = ft_strdup(""); else if (f.spec == 's') { if ((int)ft_strlen(*str) > f.after_dot) ret = ft_strsub(*str, 0, f.after_dot); else ret = ft_strdup(*str); } else if ((int)ft_strlen(*str) < f.after_dot) ret = precision_handler2(str, f); else if (ft_strcmp(*str, "0x0") == 0 && f.after_dot == 0 && f.spec == 'p') ret = ft_strdup("0x"); else ret = ft_strdup(*str); ft_strdel(str); return (ret); }
8b83c567f72baddc970e3c3d8f8ba723f02a1b2e
83214753e9183327e98af0e6768e9be5385e5282
/kungfu/skill/aikido.c
0e89bc9775df815cf68a410f4c421dd22f920867
[]
no_license
MudRen/hymud
f5b3bb0e0232f23a48cb5f1db2e34f08be99614e
b9433df6cf48e936b07252b15b60806ff55bb2f3
refs/heads/main
2023-04-04T22:44:23.880558
2021-04-07T15:45:16
2021-04-07T15:45:16
318,484,633
1
5
null
null
null
null
GB18030
C
false
false
6,360
c
aikido.c
// Copyright (C) 1995, by Tie Yu and Daniel Yu. All rights reserved. // This software can not be used, copied, or modified in any form without // the written permission from authors. #include <ansi.h> inherit SKILL; object offensive_target(object me) { int sz; object *enemy; enemy = me->query_enemy(); if( !enemy || !arrayp(enemy) ) return 0; sz = sizeof(enemy); if( sz > 4 ) sz = 4; if( sz > 0 ) return enemy[random(sz)]; else return 0; } string* buwei = ({ "右手肘部", "手腕", "左手关节", "颈部", "肩部关节", "背心要穴", "膝关节", "命门" }); mapping *action = ({ ([ "action": "$N左腿在前,右腿在后,双掌用力向$n的$l挥来", "dodge": 30, "parry": 10, "force": 90, "damage": 190, "damage_type": "瘀伤" ]), ([ "action": "$N左脚点地,身体向后旋转,右腿向疾风扫落叶般扫向$n的$l", "dodge": 10, "parry": 30, "force": 90, "damage": 90, "damage_type": "瘀伤" ]), ([ "action": "$N右手虚晃,左肘从我意想不到的角度撞向我$n的$l", "dodge": 30, "parry": 10, "force": 90, "damage": 120, "damage_type": "瘀伤" ]), ([ "action": "$N右脚凌空,晃出一片腿影,霎那间向$n的$l一连踢出三脚", "dodge": 10, "parry": 30, "force": 90, "damage": 130, "damage_type": "瘀伤" ]), ([ "action": "$N凌空跃起,身体向后急转,双脚从下往上一前一后地撩向$n的$l", "dodge": 20, "parry": 30, "force": 90, "damage": 140, "damage_type": "瘀伤" ]), }); int valid_learn(object me) { if ((int)me->query_skill("shayi-xinfa", 1) < 30) return notify_fail("你的杀意心法火候不够。\n"); if( me->query_temp("weapon") || me->query_temp("secondary_weapon") ) return notify_fail("练合气道必须空手。\n"); return 1; } int valid_enable(string usage) { return usage=="unarmed" || usage=="parry"; } mapping query_action(object me, object weapon) { int i, level; object victim; string bw; if( !victim && me->is_fighting() ) victim = offensive_target(me); level = (int) me->query_skill("aikido",1); bw = buwei[random(sizeof(buwei))]; if (me && victim) { if ((int) me->query_skill("aikido",1) > random(50) && me->query("neili") > 300 && random(me->query("combat_exp")) > victim->query("combat_exp")/2 && random(4)==0 && me->query_skill_mapped("unarmed") == "aikido" && me->query_skill_mapped("parry") == "aikido" && !me->is_busy() && victim->query("qi") > 100 && !victim->is_busy() && !me->query_temp("weapon")) { me->add("neili", -50); message_vision(HIY"$N用合气道擒拿法斗然间抓住了$n的"+bw+"!\n"NOR,me,victim); message_vision(CYN"$N退避不及被$n抓住了"+bw+",然后被抛出!\n"NOR,victim,me); if (userp(victim)) victim->add("qi",-victim->query("qi")/20); else victim->add("qi",-level); victim->start_busy(2 + random(level/50)); } } for(i = sizeof(action); i > 0; i--) if(level > action[i-1]["lvl"]) return action[NewRandom(i, 20, level/5)]; } int practice_skill(object me) { if ((int)me->query_skill("shayi-xinfa", 1) < 10) return notify_fail("你的杀意心法火候不够。\n"); if( (int)me->query("qi") < 80 ) return notify_fail("你的体力不够了,休息一下再练吧。\n"); if( (int)me->query("neili") < 50 ) return notify_fail("你的内力不够了,休息一下再练吧。\n"); me->receive_damage("qi", 40); me->add("neili", -30); return 1; } int effective_level() { return 10;} string *parry_msg = ({ "$n就势一滚,双手一撑地,全身弹出$N的$w的攻击范围。\n", }); string *unarmed_parry_msg = ({ "$n就势一滚,双手一撑地,全身弹出$N的攻击范围。\n", }); string query_parry_msg(object weapon) { if( weapon ) return parry_msg[random(sizeof(parry_msg))]; else return unarmed_parry_msg[random(sizeof(unarmed_parry_msg))]; } int learn_bonus() { return 10; } int practice_bonus() { return 5; } int black_white_ness() { return -10; } string perform_action_file(string action) { return __DIR__"aikido/" + action; } mixed hit_ob(object me, object victim, int damage_bonus, int factor) { int lvl; int flvl; string msg; lvl = me->query_skill("shayi-xinfa", 1); flvl = me->query("jiali"); if (me->query_skill_mapped("force") == "shayi-xinfa" && lvl > 300 && random(8)==0) { flvl=random(lvl)*2+150; msg = HIR"「二重劲!」$N以极快速的连击,在第一击后,$n没产生抵抗力时给予第二击! \n"NOR; if (random(3)==0) msg = HIR"「隔空击物!」。$N将二重劲的威力传至远方攻击的$n,用以弥补远距离攻击的不足 。\n"NOR; if (random(3)==1) msg = HIR"「喷射火焰!」。$N胃装油袋,用火石制的假牙点火喷出火焰,$n被极大的火焰打中!! \n"NOR; if (random(3)==2) msg = HIR"「仙鹤飞腿!」。$N使出丑鬼直接传授的拳法之一踢向$n! 这踢法已独创一格!!\n"NOR; if (victim->query("qi") > flvl) { victim->start_busy(2); victim->add("qi",-flvl); victim->add("eff_qi",-flvl); } return msg; } }
ed9caed275bdcb2f5dafd6b175be105645cfad1d
5ec456057c4c9d936c92a7dcddf42c7a098d4211
/DummyEngine/Test Files/testMain.c
1493e3b886ab2588ee0fe0d03e2f0523d68f5c9c
[]
no_license
trusanen/TiRa
a9cf4240ccdb1a4b84c47e9a4d66fe3205b3e1f2
2f94decef2e26b31ee30978df18158e53b7a2abd
refs/heads/master
2020-05-04T10:27:25.717887
2013-06-16T17:03:54
2013-06-16T17:03:54
null
0
0
null
null
null
null
UTF-8
C
false
false
345
c
testMain.c
void runTests() { // Tämä funktio ajaa kaikki testit. matrixTest(); mathematicsTest(); normalTest(); //polygonTest(); //sdlTest(); sceneTest(); meshTest(); backfaceCullingTest(); solidDrawTest(); bspTest(); //md2ImportTest(); }
12f978479be6aad35899256d7125464a167651e6
f6070c9b79e9a3ce457a7cacee0e9f51c4b235f7
/linux_linked_list/simple.c
68bf7d1279164f05c4d91d9e1dfa60733c7420ea
[ "MIT" ]
permissive
AusCoder/linux-tinkering
c0daf8d63ae636cfd79790d5b9aa9f222ba1bc52
9f6c4b2043add07ef86ff82e6e752c97506e5355
refs/heads/master
2020-03-30T10:16:14.869065
2016-09-02T11:35:36
2016-09-02T11:35:36
54,236,001
0
0
null
null
null
null
UTF-8
C
false
false
3,275
c
simple.c
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/slab.h> /* this is the birthday struct */ struct birthday { int day; int month; int year; struct list_head list; }; /* initialise the birthday list */ static LIST_HEAD(birthday_list); /* This function is called when the module is loaded. */ int simple_init(void) { struct birthday *seb; struct birthday *bill; struct birthday *lui; struct birthday *ptr; printk(KERN_INFO "Loading Module\n"); /* define some birthdays and add them to the list */ seb = kmalloc(sizeof(*seb), GFP_KERNEL); seb->day = 6; seb->month = 8; seb->year = 1991; INIT_LIST_HEAD(&seb->list); /* the raw pointer manipulation */ ((&birthday_list)->prev)->next = &seb->list; (&seb->list)->next = &birthday_list; (&seb->list)->prev = (&birthday_list)->prev; (&birthday_list)->prev = &seb->list; //list_add_tail(&seb->list, &birthday_list); /* * struct list_head * has next and prev attributes * next/prev have type struct list_head * */ bill = kmalloc(sizeof(*bill), GFP_KERNEL); bill->day = 2; bill->month = 5; bill->year = 1980; INIT_LIST_HEAD(&bill->list); /* raw pointer manipulation */ ((&birthday_list)->prev)->next = &bill->list; (&bill->list)->next = &birthday_list; (&bill->list)->prev = (&birthday_list)->prev; (&birthday_list)->prev = &bill->list; //list_add_tail(&bill->list, &birthday_list); lui = kmalloc(sizeof(*lui), GFP_KERNEL); lui->day = 25; lui->month = 9; lui->year = 1900; INIT_LIST_HEAD(&lui->list); /* raw pointer manipulation */ ((&birthday_list)->prev)->next = &lui->list; (&lui->list)->next = &birthday_list; (&lui->list)->prev = (&birthday_list)->prev; (&birthday_list)->prev = &lui->list; //list_add_tail(&lui->list, &birthday_list); /* iterate through the list of birthdays */ for (ptr->list = *(birthday_list.next); \ &ptr->list != &birthday_list; \ ptr->list = *((ptr->list).next) ) { printk(KERN_INFO "birth year: %d", ptr->year); } /* list_for_each_entry(ptr, &birthday_list, list) { printk(KERN_INFO "birth year: %d", ptr->year); } */ return 0; } /* This function is called when the module is removed. */ void simple_exit(void) { struct birthday *ptr, *next; printk(KERN_INFO "Removing Module\n"); /* delete the list */ list_for_each_entry_safe(ptr, next, &birthday_list, list) { list_del(&ptr->list); kfree(ptr); } } /* Macros for registering module entry and exit points. */ module_init( simple_init ); module_exit( simple_exit ); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Simple Module"); MODULE_AUTHOR("SGG");
aa63bf888f4520b143c697fad8e50c14b3279501
88e5d83332234c10f984f92de8954c9d05557e46
/roboFinist2018/playTest.c
19a3b4da8bcc4e2164d057991d04d8e8645fd947
[]
no_license
drAlexAK/Lego
09646a27a210414aefbe7397f8186f6d50d626ac
cf5ba42805416f2c7f517218031c957fc1864d85
refs/heads/master
2021-01-12T10:14:17.397139
2018-09-08T22:07:18
2018-09-08T22:07:18
76,393,350
1
2
null
null
null
null
UTF-8
C
false
false
2,008
c
playTest.c
#pragma config(Motor, motorB, mLeft, tmotorNXT, openLoop) #pragma config(Motor, motorC, mRight, tmotorNXT, openLoop) #define MAX_BUFFER 500 typedef struct power{ byte left; byte right; byte sl; }power; string fileName = ""; power p[MAX_BUFFER]; int Iter = 120; // 1phase - 120, 2phase - void getRec(power *p); void getFileName(); task main() { getFileName(); displayBigTextLine(4, " START"); sleep(1000); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } break; } sleep (10); } sleep(1000); getRec(p); sleep(1000); for(int i = 0; i < Iter; i ++){ motor[mLeft] = p[i].left; motor[mRight] = p[i].right; sleep(p[i].sl); //sleep(25); } motor[mLeft] = 0; motor[mRight] = 0; } void getFileName(){ int i =0; displayBigTextLine(4, " FILE NAME"); while(true) { if (nNxtButtonPressed == 3) { while (nNxtButtonPressed == 3) { sleep (10); } string tmp = ""; sprintf(tmp, "rec%d.bin", i); fileName = tmp; return; } if (nNxtButtonPressed == 1) { while (nNxtButtonPressed == 1) { sleep (10); } i++; } if (nNxtButtonPressed == 2) { while (nNxtButtonPressed == 2) { sleep (10); } i--; } if(i < 0) i = 0; displayBigTextLine(4, " %d", i); sleep (10); } } void getRec(power *p){ TFileHandle hFile; TFileIOResult ioResult; short fileSize = 1; byte rByte; OpenRead(hFile, ioResult, fileName, fileSize); //ReadByte(hFile, ioResult, Iter); // get iteration Close(hFile, ioResult); //Iter = 480; fileSize = Iter * sizeof(power) + 1; OpenRead(hFile, ioResult, fileName, fileSize); // ReadByte(hFile, ioResult, rByte); ReadByte(hFile, ioResult, rByte); for(int i = 0; i < Iter; i++){ ReadByte(hFile, ioResult, rByte); p[i].left = rByte; ReadByte(hFile, ioResult, rByte); p[i].right= rByte; ReadByte(hFile, ioResult, rByte); p[i].sl = rByte; } Close(hFile, ioResult); }
a4208dcfa6919719bebbb82d6afd37bc119e68ea
7d33f88295b42560e54e1ee2220a70bbc1d42055
/c++/vector.C
b19da4a68b84e8612a46f66a108a97b274e12565
[]
no_license
wxie2013/code_example
d4d98ff0c21b7ab0a6b996876512346fd3dfdc90
87cb1643a989764c73271c475ec79f370507b01d
refs/heads/master
2023-09-02T21:11:54.069373
2023-09-02T00:29:14
2023-09-02T00:29:14
202,216,936
0
1
null
null
null
null
UTF-8
C
false
false
1,643
c
vector.C
#include <iostream> #include <algorithm> #include <vector> using namespace std; struct Synapse { float pre_ID; float weight; int delay; // in time_step bool operator< ( const Synapse &s ) const { return pre_ID > s.pre_ID; } //..used for equal_range and sort }; vector<Synapse> f() { vector<Synapse> tmp; Synapse t; for(int i = 0; i<10; i++) { t.pre_ID = i; t.weight = i; t.delay = i; tmp.push_back(t); } for(int i = 0; i<10; i++) { t.pre_ID = i+0.7; t.weight = i+0.7; t.delay = i+0.7; tmp.push_back(t); } for(int i = 0; i<10; i++) { t.pre_ID = i; t.weight = i; t.delay = i; tmp.push_back(t); } return tmp; }; bool compare_two_synapses(Synapse &s1, Synapse &s2) { return s1.pre_ID <= s2.pre_ID; } bool identical_two_synapses(Synapse &s1, Synapse &s2) { return s1.pre_ID == s2.pre_ID; } //__ int main() { vector<Synapse> a = f(); cout<<" ---- before sort ----"<<endl; for(int i = 0; i<30; i++) cout<<"i: "<<a[i].pre_ID<<endl; //.. now sort cout<<" ---- after sort ----"<<endl; //sort(a.begin(), a.end(), compare_two_synapses); //.. this is also OK. sort(a.begin(), a.end()); for(int i = 0; i<30; i++) cout<<"i: "<<a[i].pre_ID<<endl; cout<<" --- after remove duplicate ----"<<endl; vector<Synapse>::iterator ip = unique(a.begin(), a.end(), identical_two_synapses); a.resize(distance(a.begin(), ip)); cout<<" new size: "<<a.size()<<endl; for(int i = 0; i<a.size(); i++) cout<<"i: "<<a[i].pre_ID<<endl; }
ccb9c37d7c7098e85b9ec151ed2edadcfaf8a25c
982c6b06d72d646c809d5a12866359f720305067
/subprojects/templates/xcode-custom-file-reference/main.h
702fc28b7585c929e4bc1f16c01fbf0ada672392
[ "Apache-2.0" ]
permissive
nokeedev/gradle-native
e46709a904e20183ca09ff64b92d222d3c888df2
6e6ee42cefa69d81fd026b2cfcb7e710dd62d569
refs/heads/master
2023-05-30T02:27:59.371101
2023-05-18T15:36:49
2023-05-23T14:43:18
243,841,556
52
9
Apache-2.0
2023-05-23T14:58:33
2020-02-28T19:42:28
Java
UTF-8
C
false
false
155
h
main.h
// // main.h // CustomFileRef // // Created by Daniel Lacasse on 2022-08-12. // #ifndef main_h #define main_h #include <stdio.h> #endif /* main_h */
9b482f0c3285ef16b803a1c987419eeead55b0c7
c366ae71934541467841dc0657b74b8a9653db82
/coldfire/Project_Headers/ledbtn_irq.h
686fe34ef647c61bba93e9afaaf4401ad6499c32
[ "MIT" ]
permissive
initdb/mnp
9d0f26c8a3616a813cbe0dc057c8e6a7eb5223bc
c80c015add20c5ba8e1ca954f04098e5390ebc18
refs/heads/master
2020-04-01T18:27:21.679681
2019-01-10T15:08:04
2019-01-10T15:08:04
153,493,426
1
0
MIT
2018-10-24T18:10:28
2018-10-17T17:01:40
C
UTF-8
C
false
false
155
h
ledbtn_irq.h
/* * ledbtn_irq.h * * Created on: Dec 18, 2018 * Author: Benedict */ #ifndef LEDBTN_IRQ_H_ #define LEDBTN_IRQ_H_ #endif /* LEDBTN_IRQ_H_ */
1a2bb42d2d5707c2c16ea6c5566c293c2cee69d3
51635684d03e47ebad12b8872ff469b83f36aa52
/external/gcc-12.1.0/gcc/testsuite/gcc.target/aarch64/sve2/acle/asm/abdlt_s16.c
482d5ed873ffd3f3f6ff61d63d433f99d97429dc
[ "LGPL-2.1-only", "FSFAP", "LGPL-3.0-only", "GPL-3.0-only", "GPL-2.0-only", "GCC-exception-3.1", "LGPL-2.0-or-later", "Zlib", "LicenseRef-scancode-public-domain" ]
permissive
zhmu/ananas
8fb48ddfe3582f85ff39184fc7a3c58725fe731a
30850c1639f03bccbfb2f2b03361792cc8fae52e
refs/heads/master
2022-06-25T10:44:46.256604
2022-06-12T17:04:40
2022-06-12T17:04:40
30,108,381
59
8
Zlib
2021-09-26T17:30:30
2015-01-31T09:44:33
C
UTF-8
C
false
false
1,585
c
abdlt_s16.c
/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" } } */ #include "test_sve_acle.h" /* ** abdlt_s16_tied1: ** sabdlt z0\.h, z0\.b, z1\.b ** ret */ TEST_TYPE_CHANGE_Z (abdlt_s16_tied1, svint16_t, svint8_t, z0_res = svabdlt_s16 (z0, z1), z0_res = svabdlt (z0, z1)) /* ** abdlt_s16_tied2: ** sabdlt z0\.h, z1\.b, z0\.b ** ret */ TEST_TYPE_CHANGE_Z (abdlt_s16_tied2, svint16_t, svint8_t, z0_res = svabdlt_s16 (z1, z0), z0_res = svabdlt (z1, z0)) /* ** abdlt_s16_untied: ** sabdlt z0\.h, z1\.b, z2\.b ** ret */ TEST_TYPE_CHANGE_Z (abdlt_s16_untied, svint16_t, svint8_t, z0_res = svabdlt_s16 (z1, z2), z0_res = svabdlt (z1, z2)) /* ** abdlt_w0_s16_tied1: ** mov (z[0-9]+\.b), w0 ** sabdlt z0\.h, z0\.b, \1 ** ret */ TEST_TYPE_CHANGE_ZX (abdlt_w0_s16_tied1, svint16_t, svint8_t, int8_t, z0_res = svabdlt_n_s16 (z0, x0), z0_res = svabdlt (z0, x0)) /* ** abdlt_w0_s16_untied: ** mov (z[0-9]+\.b), w0 ** sabdlt z0\.h, z1\.b, \1 ** ret */ TEST_TYPE_CHANGE_ZX (abdlt_w0_s16_untied, svint16_t, svint8_t, int8_t, z0_res = svabdlt_n_s16 (z1, x0), z0_res = svabdlt (z1, x0)) /* ** abdlt_11_s16_tied1: ** mov (z[0-9]+\.b), #11 ** sabdlt z0\.h, z0\.b, \1 ** ret */ TEST_TYPE_CHANGE_Z (abdlt_11_s16_tied1, svint16_t, svint8_t, z0_res = svabdlt_n_s16 (z0, 11), z0_res = svabdlt (z0, 11)) /* ** abdlt_11_s16_untied: ** mov (z[0-9]+\.b), #11 ** sabdlt z0\.h, z1\.b, \1 ** ret */ TEST_TYPE_CHANGE_Z (abdlt_11_s16_untied, svint16_t, svint8_t, z0_res = svabdlt_n_s16 (z1, 11), z0_res = svabdlt (z1, 11))
de9e9164922ba9aced2a775aed12dfa709b46b56
44c12d66c36c767741799f82bec1d145e956a989
/RGR.c
b3af16c6224ad9d9e08181727e43e736f10b0a6e
[]
no_license
TheLester/spo
ea13df7c0bd62bea879b66ff1aa91d65bdcd1be0
80ae4f9d4850272c758f4d2b4f6d4645acf3bf11
refs/heads/master
2020-12-30T10:23:19.509620
2014-06-09T14:58:10
2014-06-09T14:58:10
20,650,415
2
0
null
null
null
null
UTF-8
C
false
false
3,361
c
RGR.c
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <sys/ipc.h> #include <sys/sem.h> #include <signal.h> #define SEMKEY 65 void process1(); void process2(); void process3(); void process4(); int num_of_digits(int num); int p1(int signum); int p4(int signum); int semid; int A, B, C; int received_A, received_B, received_C; int pid1, pid2, pid3, pid4; int msgid; key_t key; struct pid_msgbuf { long mtype; int pid; }; struct sembuf sop; FILE *file = NULL; void v(int sid) { sop.sem_op = 1; semop(sid, &sop, 1); } void p(int sid) { sop.sem_op = -1; semop(sid, &sop, 1); } int p1(int signum) { printf("P1 got a signal\n"); return 0; } int p4(int signum) { printf("P4 got a signal\n"); return 0; } void main(void) { key = ftok("/home/lester/soft/test", 'S'); msgid = msgget(key, 0666 | IPC_CREAT); short arg[1]; arg[0] = 0; semid = semget(SEMKEY, 1, 0777 | IPC_CREAT); semctl(semid, 0, SETALL, arg); sop.sem_num = 0; sop.sem_flg = 0; file = fopen("res.txt", "w+"); pid1 = getpid(); printf("Process p1, pid = %d:\n", pid1); pid2 = fork(); if (pid2 == 0) { printf("Process p2, pid = %d:\n", getpid()); pid3 = fork(); if (pid3 == 0) { printf("Process p3, pid = %d:\n", getpid()); process3(); } else if (pid3 > 0) { // в pid2 process2(); } } else if (pid2 > 0) { // в pid1 pid4 = fork(); if (pid4 == 0) { // в pid4 struct pid_msgbuf pmb = { 1, getpid() }; msgsnd(msgid, &pmb, sizeof(struct pid_msgbuf) - sizeof(long), 1);//отправка ид 4 процесса signal(SIGUSR2, p4); printf("Process p4, pid = %d:\n", getpid()); process4(); } else if (pid4 > 0) { signal(SIGUSR1, p1); process1(); } } wait(NULL); msgctl(msgid, IPC_RMID, NULL); semctl(semid, IPC_RMID, NULL); exit(0); } void process4() { pause(); FILE *fp4 = fopen("4.txt", "r"); fscanf(fp4, "%d", &C); fprintf(file, "%d", C); fseek(file, -num_of_digits(C), SEEK_CUR);//сдвиг курсора на количество цифр числа printf("P4 Sent C-%d\n", C); v(semid); exit(0); } void process2() { sleep(1); FILE *fp2 = fopen("2.txt", "r"); fscanf(fp2, "%d", &A); fprintf(file, "%d", A); printf("P2 Sent A-%d\n", A); fseek(file, -num_of_digits(A), SEEK_CUR); //отправка ид 4 процесса v(semid); wait(NULL); exit(0); } void process3() { struct pid_msgbuf pmb_recv; p(semid); fscanf(file, "%d", &received_A); fseek(file, 0, SEEK_END); //сдвиг курсора на конец записи printf("P3 Got A:%d\n", received_A); kill(pid1, SIGUSR1); p(semid); fscanf(file, "%d", &received_B); fseek(file, 0, SEEK_END); printf("P3 Got B:%d\n", received_B); msgrcv(msgid, &pmb_recv, sizeof(struct pid_msgbuf) - sizeof(long), 1, 0);//прием ид 4 процесса kill(pmb_recv.pid, SIGUSR2); p(semid); fscanf(file, "%d", &received_C); fseek(file, 0, SEEK_END); printf("P3 Got C:%d\n", received_C); printf("Result of (A+B)*C=%d\n", (received_A + received_B) * received_C);//вывод результата на консоль exit(0); } void process1() { pause(); printf("Type B:\n"); scanf("%d", &B); fprintf(file, "%d", B); printf("P1 Sent B- %d", B); fseek(file, -num_of_digits(B), SEEK_CUR); v(semid); } int num_of_digits(int num) { int count = 0; while (num != 0) { num /= 10; ++count; } return count; }
f7b6677d2c36471223baed8d48f7273fe0ad9a99
af12199b055823474ee4658299e76d864814f597
/LED/LED_guanglifang.h
b9cfcdf7ec9be0f6f9dd065305e985da5eef6a50
[]
no_license
coldspace/3DSnake
3030a2c0a22c77d50a078c8190ce2da6d1c8377e
0cf6c0cfa6d462bf35c2f1c1f82b0ce2a49b5c50
refs/heads/master
2020-12-24T18:13:53.591377
2016-05-04T04:43:50
2016-05-04T04:43:50
58,023,284
0
0
null
null
null
null
WINDOWS-1252
C
false
false
361
h
LED_guanglifang.h
# ifndef _LED_GUANGLIFANG_H_ # define _LED_GUANGLIFANG_H_ # include <STC12C5A60S2.H> #include <intrins.h> #define uchar unsigned char #define uint unsigned int extern void clr(uchar x,uchar y,uchar z); extern void set(uchar x,uchar y,uchar z); extern void delay5us(void); //Îó²î -0.026765046296us STC 1T 22.1184Mhz extern void delay(uint i); # endif
b6ad609a0f421666abc28302fdea928e36528d4f
c5d25ae9aba75961c99eb388bfd979d48326cb24
/philo_one/includes/philo.h
e3b16a7208d86d49cc9cc29c17cc99d545ce5ac6
[]
no_license
fredrikalindh/philosophers
7157bf8b238b6e28aa3694fab75d36e36706256e
09311bdeff346fb978ade3e812ddc3459e6ceb15
refs/heads/master
2023-01-05T16:33:42.622291
2020-11-04T10:51:25
2020-11-04T10:51:25
245,888,716
0
0
null
null
null
null
UTF-8
C
false
false
2,013
h
philo.h
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* philo.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fredrika <fredrika@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/03/08 16:39:25 by fredrika #+# #+# */ /* Updated: 2020/10/27 12:11:57 by fredrikalindh ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef PHILO_H # define PHILO_H # include <unistd.h> # include <stdlib.h> # include <stdio.h> # include <sys/time.h> # include <pthread.h> # define FORK "has taken a fork\n" # define EAT "is eating\n" # define SLEEP "is sleeping\n" # define THINK "is thinking\n" # define DEAD "died\n" typedef struct s_info { int someone_is_dead:1; pthread_mutex_t write; pthread_mutex_t *forks; int num_phil; int phils_whos_eaten_enough; int time_to_die; int time_to_eat; int time_to_sleep; int max_eat; int start:1; } t_info; typedef struct s_phil { int name; unsigned long long last_eat; int times_eaten; pthread_mutex_t is_eating; pthread_mutex_t *f1; pthread_mutex_t *f2; t_info *info; pthread_t thread; } t_phil; typedef struct s_list { void *data; struct s_list *next; } t_list; int ft_atoi(char *str); void eat(t_phil *phil); t_phil **start_program(t_info *info); u_int64_t get_time(void); void real_sleep(u_int64_t n); int errormess(char *mess); int message(t_phil *phil, char *message); #endif
1c3babea8cae3c89856a9f326b7388fac866f665
b81bc7ce02646a754254c820f807c6469141cb54
/process.h
b4c6116e897ec6cc6d73882c55a7465960442f24
[]
no_license
Hariprasath1998/OS_Scheduling_Algorithms
e6b7024c6304a54be899df224693c29fa72f5c11
12b30482d9a1be36bd048790cde03ee6da043bae
refs/heads/main
2023-03-16T11:45:03.737161
2021-03-05T08:37:17
2021-03-05T08:37:17
344,717,026
0
0
null
null
null
null
UTF-8
C
false
false
673
h
process.h
typedef struct Process{ char id; unsigned int burstTime; int pendingProc; unsigned int waitTime; unsigned int turnAroundTime; }Process; typedef struct priorityProcess { Process *p; int priority; }priorityProcess; Process * newProcess(char I, int BT){ Process *temp=malloc(sizeof(Process)); temp->id=I; temp->burstTime=BT; temp->pendingProc=BT; temp->waitTime=0; temp->turnAroundTime=0; return temp; } priorityProcess * newPriorityProcess(char I,int BT, int priority){ priorityProcess *temp=malloc(sizeof(struct priorityProcess)); temp->p=newProcess(I,BT); temp->priority=priority; return temp; }
3768a62a4d65efab30700093a39ca0e2ad2ebb26
9b93e8bc1b03c8df71c4603108721cdada3cc7d0
/listas de exercicios resolvidos/lista matrizes/matriz3.c
936cc26274b4c586770f212ffa2f801006453c5f
[]
no_license
RaquelBelmiro/exercicios-c
19d9082512ab2d977d36745c0e20f213ce1a7fad
1372965ae2927cac4a42d4b4020dea66bbc90347
refs/heads/master
2023-08-15T06:27:32.600848
2021-09-21T21:30:05
2021-09-21T21:30:05
408,978,517
0
0
null
null
null
null
UTF-8
C
false
false
1,058
c
matriz3.c
#include <stdio.h> #define TAM 5 void lerMatriz(int matriz[TAM][TAM]); int verificaMatriz(int matriz[TAM][TAM], int x); int main() { int matriz[TAM][TAM], x; lerMatriz(matriz); printf("\nEntre com o numero que deseja pesquisar na matriz: "); scanf("%d", &x); if (verificaMatriz(matriz, x)) printf("\nO numero %d pertence a matriz.\n\n", x); else printf("\nO numero %d NAO pertence a matriz.\n\n", x); return 0; } void lerMatriz(int matriz[TAM][TAM]) { int i, j; printf("\nEntre com os valores da matriz:\n\n"); for (i = 0; i < TAM; i++) { for (j = 0; j < TAM; j++) { printf("A%d%d: ", i + 1, j + 1); scanf("%d", &matriz[i][j]); } } printf("\n"); //imprimindo os valores for (i = 0; i < TAM; i++) { for (j = 0; j < TAM; j++) { printf("%d\t", matriz[i][j]); } printf("\n"); } } int verificaMatriz(int matriz[TAM][TAM], int x) { int i, j; for (i = 0; i < TAM; i++) for (j = 0; j < TAM; j++) if (matriz[i][j] == x) return 1; return 0; }
5ae5d1fce6e6e5a37597c47bf70e35caa561af71
be39206892f53feadd34056c3e00cf07ac1f2721
/Atividades em C/Switch Case/Exercício 4.c
d7badf697bb4808b051a96f0f02f9ff23716e2b8
[ "MIT" ]
permissive
RodrigoPasini/Programas_C
c26c376c9f0be7c8efcc5ca1b4d4ce79c8541186
0e7a64b6e250ac5eed295f647733038953a1d8f7
refs/heads/main
2023-01-23T04:49:10.230297
2020-12-02T18:56:05
2020-12-02T18:56:05
317,953,030
0
0
null
null
null
null
ISO-8859-1
C
false
false
950
c
Exercício 4.c
#include<stdio.h> #include<stdlib.h> #include<locale.h> int main (void) { setlocale(LC_ALL, ""); int jogo; printf ("#####BEM-VINDOS À MELHOR OPÇÃO DE JOGOS ANTIGOS DO MUNDO#####\n"); printf("1 - ATARI\n"); printf("2 - PHANTON\n"); printf("3 - MEGA DRIVE\n"); printf("4 - MASTER SYSTEM\n"); printf("5 - SUPER NINTENDO\n"); printf("Informe qual é o seu jogo antigo preferido:\n"); scanf ("%i", &jogo); switch (jogo) { case 1: printf ("ATARI\n"); break; case 2: printf ("PHANTON\n"); break; case 3: printf ("MEGA-DRIVE\n"); break; case 4: printf ("MASTER-SYSTEM\n"); break; case 5: printf ("SUPER NINTENDO\n"); break; default: printf("Opção inválida.\n"); printf ("Volte na tela anterior e escolha as opções de 1 a 5.\n"); } return (0); }
e72274bfd523ad06847991f8b3aef3b86a0919ab
fe5563438637ed990c43b18937efacc099bb7ca9
/src/array_functions.c
535d196220068d3bb8212cb8cb9e1d6d1582988a
[]
no_license
mguerrea/21sh
a3e1c1c135e2d4e25ed43a9116f488b9c276677f
40e9f3bdd9d8efe4329099ad0f95c5bf47c2eb69
refs/heads/master
2020-04-17T14:28:52.290180
2019-10-04T14:34:29
2019-10-04T14:34:29
166,658,745
1
1
null
null
null
null
UTF-8
C
false
false
2,189
c
array_functions.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* array_functions.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gmichaud <gmichaud@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/01/03 17:58:37 by mguerrea #+# #+# */ /* Updated: 2019/09/12 14:58:31 by gmichaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" char **ft_tabdup(char **dest, char **src) { int i; i = 0; while (src[i]) i++; if (!(dest = (char **)malloc(sizeof(char *) * (i + 1)))) return (NULL); i = 0; while (src[i]) { if (!(dest[i] = ft_strdup(src[i]))) return (NULL); i++; } dest[i] = NULL; return (dest); } char **ft_addentry(char **array, int size, char *str) { char **newarray; int i; i = 0; if (!(newarray = (char **)malloc(sizeof(char *) * (size + 2)))) return (NULL); while (array[i]) { if (!(newarray[i] = ft_strdup(array[i]))) return (NULL); i++; } if (!(newarray[i] = ft_strdup(str))) return (NULL); newarray[i + 1] = NULL; if (array) free_tab(array); return (newarray); } void ft_delentry(char ***array, int pos) { ft_strdel(&((*array)[pos])); while ((*array)[pos + 1]) { (*array)[pos] = ft_strdup((*array)[pos + 1]); ft_strdel(&((*array)[pos + 1])); pos++; } if ((*array)[pos]) ft_strdel(&((*array)[pos])); } char *ft_strjointab(char **array, char c) { int i; int len; char *str; i = 0; len = 0; while (array[i]) len += ft_strlen(array[i++]); if (!(str = ft_strnew(len + i - 1))) return (NULL); i = 0; while (array[i]) { ft_strcat(str, array[i]); if (array[i + 1]) str[ft_strlen(str)] = c; i++; } return (str); }
8a071679806a4e58695663bd49d44e6312cffa59
b65a7535f7f5363396eadc56e50a8cd029ad63b0
/LUGE2/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Collections_ObjectModel_Collection_1_gen_3MethodDeclarations.h
71cd9080bb9b01c8d6221f0b29f54a58d72187e3
[]
no_license
Folofl/L-U-G-E_final
8916b3f5a7a9cfc39bad39163b602fc27213933a
d4a6c3f18d9b13e75beb60e6e2274638546d7ae0
refs/heads/master
2021-01-18T01:23:48.069619
2015-12-15T16:22:46
2015-12-15T16:22:46
48,052,044
0
0
null
2015-12-15T15:35:49
2015-12-15T15:35:48
null
UTF-8
C
false
false
18,359
h
mscorlib_System_Collections_ObjectModel_Collection_1_gen_3MethodDeclarations.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.Collections.ObjectModel.Collection`1<UnityEngine.Vector4> struct Collection_1_t1_1173; // System.Array struct Array_t; // System.Collections.IEnumerator struct IEnumerator_t1_129; // System.Object struct Object_t; // UnityEngine.Vector4[] struct Vector4U5BU5D_t5_288; // System.Collections.Generic.IEnumerator`1<UnityEngine.Vector4> struct IEnumerator_1_t1_1481; // System.Collections.Generic.IList`1<UnityEngine.Vector4> struct IList_1_t1_1172; #include "codegen/il2cpp-codegen.h" #include "UnityEngine_UnityEngine_Vector4.h" // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::.ctor() extern "C" void Collection_1__ctor_m1_7739_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1__ctor_m1_7739(__this, method) (( void (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1__ctor_m1_7739_gshared)(__this, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.Generic.ICollection<T>.get_IsReadOnly() extern "C" bool Collection_1_System_Collections_Generic_ICollectionU3CTU3E_get_IsReadOnly_m1_7740_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_System_Collections_Generic_ICollectionU3CTU3E_get_IsReadOnly_m1_7740(__this, method) (( bool (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_System_Collections_Generic_ICollectionU3CTU3E_get_IsReadOnly_m1_7740_gshared)(__this, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.ICollection.CopyTo(System.Array,System.Int32) extern "C" void Collection_1_System_Collections_ICollection_CopyTo_m1_7741_gshared (Collection_1_t1_1173 * __this, Array_t * ___array, int32_t ___index, const MethodInfo* method); #define Collection_1_System_Collections_ICollection_CopyTo_m1_7741(__this, ___array, ___index, method) (( void (*) (Collection_1_t1_1173 *, Array_t *, int32_t, const MethodInfo*))Collection_1_System_Collections_ICollection_CopyTo_m1_7741_gshared)(__this, ___array, ___index, method) // System.Collections.IEnumerator System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IEnumerable.GetEnumerator() extern "C" Object_t * Collection_1_System_Collections_IEnumerable_GetEnumerator_m1_7742_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_System_Collections_IEnumerable_GetEnumerator_m1_7742(__this, method) (( Object_t * (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_System_Collections_IEnumerable_GetEnumerator_m1_7742_gshared)(__this, method) // System.Int32 System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.Add(System.Object) extern "C" int32_t Collection_1_System_Collections_IList_Add_m1_7743_gshared (Collection_1_t1_1173 * __this, Object_t * ___value, const MethodInfo* method); #define Collection_1_System_Collections_IList_Add_m1_7743(__this, ___value, method) (( int32_t (*) (Collection_1_t1_1173 *, Object_t *, const MethodInfo*))Collection_1_System_Collections_IList_Add_m1_7743_gshared)(__this, ___value, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.Contains(System.Object) extern "C" bool Collection_1_System_Collections_IList_Contains_m1_7744_gshared (Collection_1_t1_1173 * __this, Object_t * ___value, const MethodInfo* method); #define Collection_1_System_Collections_IList_Contains_m1_7744(__this, ___value, method) (( bool (*) (Collection_1_t1_1173 *, Object_t *, const MethodInfo*))Collection_1_System_Collections_IList_Contains_m1_7744_gshared)(__this, ___value, method) // System.Int32 System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.IndexOf(System.Object) extern "C" int32_t Collection_1_System_Collections_IList_IndexOf_m1_7745_gshared (Collection_1_t1_1173 * __this, Object_t * ___value, const MethodInfo* method); #define Collection_1_System_Collections_IList_IndexOf_m1_7745(__this, ___value, method) (( int32_t (*) (Collection_1_t1_1173 *, Object_t *, const MethodInfo*))Collection_1_System_Collections_IList_IndexOf_m1_7745_gshared)(__this, ___value, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.Insert(System.Int32,System.Object) extern "C" void Collection_1_System_Collections_IList_Insert_m1_7746_gshared (Collection_1_t1_1173 * __this, int32_t ___index, Object_t * ___value, const MethodInfo* method); #define Collection_1_System_Collections_IList_Insert_m1_7746(__this, ___index, ___value, method) (( void (*) (Collection_1_t1_1173 *, int32_t, Object_t *, const MethodInfo*))Collection_1_System_Collections_IList_Insert_m1_7746_gshared)(__this, ___index, ___value, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.Remove(System.Object) extern "C" void Collection_1_System_Collections_IList_Remove_m1_7747_gshared (Collection_1_t1_1173 * __this, Object_t * ___value, const MethodInfo* method); #define Collection_1_System_Collections_IList_Remove_m1_7747(__this, ___value, method) (( void (*) (Collection_1_t1_1173 *, Object_t *, const MethodInfo*))Collection_1_System_Collections_IList_Remove_m1_7747_gshared)(__this, ___value, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.ICollection.get_IsSynchronized() extern "C" bool Collection_1_System_Collections_ICollection_get_IsSynchronized_m1_7748_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_System_Collections_ICollection_get_IsSynchronized_m1_7748(__this, method) (( bool (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_System_Collections_ICollection_get_IsSynchronized_m1_7748_gshared)(__this, method) // System.Object System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.ICollection.get_SyncRoot() extern "C" Object_t * Collection_1_System_Collections_ICollection_get_SyncRoot_m1_7749_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_System_Collections_ICollection_get_SyncRoot_m1_7749(__this, method) (( Object_t * (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_System_Collections_ICollection_get_SyncRoot_m1_7749_gshared)(__this, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.get_IsFixedSize() extern "C" bool Collection_1_System_Collections_IList_get_IsFixedSize_m1_7750_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_System_Collections_IList_get_IsFixedSize_m1_7750(__this, method) (( bool (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_System_Collections_IList_get_IsFixedSize_m1_7750_gshared)(__this, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.get_IsReadOnly() extern "C" bool Collection_1_System_Collections_IList_get_IsReadOnly_m1_7751_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_System_Collections_IList_get_IsReadOnly_m1_7751(__this, method) (( bool (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_System_Collections_IList_get_IsReadOnly_m1_7751_gshared)(__this, method) // System.Object System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.get_Item(System.Int32) extern "C" Object_t * Collection_1_System_Collections_IList_get_Item_m1_7752_gshared (Collection_1_t1_1173 * __this, int32_t ___index, const MethodInfo* method); #define Collection_1_System_Collections_IList_get_Item_m1_7752(__this, ___index, method) (( Object_t * (*) (Collection_1_t1_1173 *, int32_t, const MethodInfo*))Collection_1_System_Collections_IList_get_Item_m1_7752_gshared)(__this, ___index, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::System.Collections.IList.set_Item(System.Int32,System.Object) extern "C" void Collection_1_System_Collections_IList_set_Item_m1_7753_gshared (Collection_1_t1_1173 * __this, int32_t ___index, Object_t * ___value, const MethodInfo* method); #define Collection_1_System_Collections_IList_set_Item_m1_7753(__this, ___index, ___value, method) (( void (*) (Collection_1_t1_1173 *, int32_t, Object_t *, const MethodInfo*))Collection_1_System_Collections_IList_set_Item_m1_7753_gshared)(__this, ___index, ___value, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::Add(T) extern "C" void Collection_1_Add_m1_7754_gshared (Collection_1_t1_1173 * __this, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_Add_m1_7754(__this, ___item, method) (( void (*) (Collection_1_t1_1173 *, Vector4_t5_51 , const MethodInfo*))Collection_1_Add_m1_7754_gshared)(__this, ___item, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::Clear() extern "C" void Collection_1_Clear_m1_7755_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_Clear_m1_7755(__this, method) (( void (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_Clear_m1_7755_gshared)(__this, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::ClearItems() extern "C" void Collection_1_ClearItems_m1_7756_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_ClearItems_m1_7756(__this, method) (( void (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_ClearItems_m1_7756_gshared)(__this, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::Contains(T) extern "C" bool Collection_1_Contains_m1_7757_gshared (Collection_1_t1_1173 * __this, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_Contains_m1_7757(__this, ___item, method) (( bool (*) (Collection_1_t1_1173 *, Vector4_t5_51 , const MethodInfo*))Collection_1_Contains_m1_7757_gshared)(__this, ___item, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::CopyTo(T[],System.Int32) extern "C" void Collection_1_CopyTo_m1_7758_gshared (Collection_1_t1_1173 * __this, Vector4U5BU5D_t5_288* ___array, int32_t ___index, const MethodInfo* method); #define Collection_1_CopyTo_m1_7758(__this, ___array, ___index, method) (( void (*) (Collection_1_t1_1173 *, Vector4U5BU5D_t5_288*, int32_t, const MethodInfo*))Collection_1_CopyTo_m1_7758_gshared)(__this, ___array, ___index, method) // System.Collections.Generic.IEnumerator`1<T> System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::GetEnumerator() extern "C" Object_t* Collection_1_GetEnumerator_m1_7759_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_GetEnumerator_m1_7759(__this, method) (( Object_t* (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_GetEnumerator_m1_7759_gshared)(__this, method) // System.Int32 System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::IndexOf(T) extern "C" int32_t Collection_1_IndexOf_m1_7760_gshared (Collection_1_t1_1173 * __this, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_IndexOf_m1_7760(__this, ___item, method) (( int32_t (*) (Collection_1_t1_1173 *, Vector4_t5_51 , const MethodInfo*))Collection_1_IndexOf_m1_7760_gshared)(__this, ___item, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::Insert(System.Int32,T) extern "C" void Collection_1_Insert_m1_7761_gshared (Collection_1_t1_1173 * __this, int32_t ___index, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_Insert_m1_7761(__this, ___index, ___item, method) (( void (*) (Collection_1_t1_1173 *, int32_t, Vector4_t5_51 , const MethodInfo*))Collection_1_Insert_m1_7761_gshared)(__this, ___index, ___item, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::InsertItem(System.Int32,T) extern "C" void Collection_1_InsertItem_m1_7762_gshared (Collection_1_t1_1173 * __this, int32_t ___index, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_InsertItem_m1_7762(__this, ___index, ___item, method) (( void (*) (Collection_1_t1_1173 *, int32_t, Vector4_t5_51 , const MethodInfo*))Collection_1_InsertItem_m1_7762_gshared)(__this, ___index, ___item, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::Remove(T) extern "C" bool Collection_1_Remove_m1_7763_gshared (Collection_1_t1_1173 * __this, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_Remove_m1_7763(__this, ___item, method) (( bool (*) (Collection_1_t1_1173 *, Vector4_t5_51 , const MethodInfo*))Collection_1_Remove_m1_7763_gshared)(__this, ___item, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::RemoveAt(System.Int32) extern "C" void Collection_1_RemoveAt_m1_7764_gshared (Collection_1_t1_1173 * __this, int32_t ___index, const MethodInfo* method); #define Collection_1_RemoveAt_m1_7764(__this, ___index, method) (( void (*) (Collection_1_t1_1173 *, int32_t, const MethodInfo*))Collection_1_RemoveAt_m1_7764_gshared)(__this, ___index, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::RemoveItem(System.Int32) extern "C" void Collection_1_RemoveItem_m1_7765_gshared (Collection_1_t1_1173 * __this, int32_t ___index, const MethodInfo* method); #define Collection_1_RemoveItem_m1_7765(__this, ___index, method) (( void (*) (Collection_1_t1_1173 *, int32_t, const MethodInfo*))Collection_1_RemoveItem_m1_7765_gshared)(__this, ___index, method) // System.Int32 System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::get_Count() extern "C" int32_t Collection_1_get_Count_m1_7766_gshared (Collection_1_t1_1173 * __this, const MethodInfo* method); #define Collection_1_get_Count_m1_7766(__this, method) (( int32_t (*) (Collection_1_t1_1173 *, const MethodInfo*))Collection_1_get_Count_m1_7766_gshared)(__this, method) // T System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::get_Item(System.Int32) extern "C" Vector4_t5_51 Collection_1_get_Item_m1_7767_gshared (Collection_1_t1_1173 * __this, int32_t ___index, const MethodInfo* method); #define Collection_1_get_Item_m1_7767(__this, ___index, method) (( Vector4_t5_51 (*) (Collection_1_t1_1173 *, int32_t, const MethodInfo*))Collection_1_get_Item_m1_7767_gshared)(__this, ___index, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::set_Item(System.Int32,T) extern "C" void Collection_1_set_Item_m1_7768_gshared (Collection_1_t1_1173 * __this, int32_t ___index, Vector4_t5_51 ___value, const MethodInfo* method); #define Collection_1_set_Item_m1_7768(__this, ___index, ___value, method) (( void (*) (Collection_1_t1_1173 *, int32_t, Vector4_t5_51 , const MethodInfo*))Collection_1_set_Item_m1_7768_gshared)(__this, ___index, ___value, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::SetItem(System.Int32,T) extern "C" void Collection_1_SetItem_m1_7769_gshared (Collection_1_t1_1173 * __this, int32_t ___index, Vector4_t5_51 ___item, const MethodInfo* method); #define Collection_1_SetItem_m1_7769(__this, ___index, ___item, method) (( void (*) (Collection_1_t1_1173 *, int32_t, Vector4_t5_51 , const MethodInfo*))Collection_1_SetItem_m1_7769_gshared)(__this, ___index, ___item, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::IsValidItem(System.Object) extern "C" bool Collection_1_IsValidItem_m1_7770_gshared (Object_t * __this /* static, unused */, Object_t * ___item, const MethodInfo* method); #define Collection_1_IsValidItem_m1_7770(__this /* static, unused */, ___item, method) (( bool (*) (Object_t * /* static, unused */, Object_t *, const MethodInfo*))Collection_1_IsValidItem_m1_7770_gshared)(__this /* static, unused */, ___item, method) // T System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::ConvertItem(System.Object) extern "C" Vector4_t5_51 Collection_1_ConvertItem_m1_7771_gshared (Object_t * __this /* static, unused */, Object_t * ___item, const MethodInfo* method); #define Collection_1_ConvertItem_m1_7771(__this /* static, unused */, ___item, method) (( Vector4_t5_51 (*) (Object_t * /* static, unused */, Object_t *, const MethodInfo*))Collection_1_ConvertItem_m1_7771_gshared)(__this /* static, unused */, ___item, method) // System.Void System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::CheckWritable(System.Collections.Generic.IList`1<T>) extern "C" void Collection_1_CheckWritable_m1_7772_gshared (Object_t * __this /* static, unused */, Object_t* ___list, const MethodInfo* method); #define Collection_1_CheckWritable_m1_7772(__this /* static, unused */, ___list, method) (( void (*) (Object_t * /* static, unused */, Object_t*, const MethodInfo*))Collection_1_CheckWritable_m1_7772_gshared)(__this /* static, unused */, ___list, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::IsSynchronized(System.Collections.Generic.IList`1<T>) extern "C" bool Collection_1_IsSynchronized_m1_7773_gshared (Object_t * __this /* static, unused */, Object_t* ___list, const MethodInfo* method); #define Collection_1_IsSynchronized_m1_7773(__this /* static, unused */, ___list, method) (( bool (*) (Object_t * /* static, unused */, Object_t*, const MethodInfo*))Collection_1_IsSynchronized_m1_7773_gshared)(__this /* static, unused */, ___list, method) // System.Boolean System.Collections.ObjectModel.Collection`1<UnityEngine.Vector4>::IsFixedSize(System.Collections.Generic.IList`1<T>) extern "C" bool Collection_1_IsFixedSize_m1_7774_gshared (Object_t * __this /* static, unused */, Object_t* ___list, const MethodInfo* method); #define Collection_1_IsFixedSize_m1_7774(__this /* static, unused */, ___list, method) (( bool (*) (Object_t * /* static, unused */, Object_t*, const MethodInfo*))Collection_1_IsFixedSize_m1_7774_gshared)(__this /* static, unused */, ___list, method)
8d9066b4400000a5130f81daa4e0a9eb7347c3dc
135f8170db5b37e3aa93161b62aeaface6722532
/Annealing/main.c
ca9478bae67e207b4c1d014be78d25ff9022c257
[]
no_license
imbturtle/MDsimulation
e6f247dd111400b3fdd79455b5387b849e431ce0
5b8dddc0b38d15c3163c15d66d653fd65a8fa7af
refs/heads/main
2023-06-30T09:11:22.454392
2021-08-06T11:24:16
2021-08-06T11:24:16
393,329,328
0
0
null
null
null
null
UTF-8
C
false
false
2,041
c
main.c
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> #include"Annealing.h" void main(int argc,char* argv[]){ int i,t,x,CTimes,steps=120000,Nparticles=3000,Balance_steps=100; char Ifile[20]="Init_inform.txt"; double Rcut =2.5,Dt=0.01,Alpha=0.5,T_bath; double **ArrR,**ArrV,**ArrA,**ArrAP,**ArrAPP,KE,Potent,AveKE,halfL; FILE *frR,*frV,*fwR,*fwV,*fwE,*fwI; clock_t start,end; if(argc!=8) exit(1) ; frR=fopen(argv[1],"r"); frV=fopen(argv[2],"r"); fwR=fopen(argv[3],"w"); fwV=fopen(argv[4],"w"); fwE=fopen(argv[5],"w"); halfL=atof(argv[6]); T_bath=atof(argv[7]); fwI=fopen(Ifile,"a"); /////////////// ArrR = Array2nd(Nparticles,3); ArrV = Array2nd(Nparticles,3); for(i=0;i<Nparticles;i++){ fscanf(frR,"%lf %lf %lf",&*(*(ArrR+i)+0),&*(*(ArrR+i)+1),&*(*(ArrR+i)+2)); fscanf(frV,"%lf %lf %lf",&*(*(ArrV+i)+0),&*(*(ArrV+i)+1),&*(*(ArrV+i)+2)); } fclose(frR); fclose(frV); ArrA = Array2nd(Nparticles,3); ArrAP = Array2nd(Nparticles,3); ArrAPP = Array2nd(Nparticles,3); Potent=Acc(Nparticles,ArrR,ArrA,halfL,Rcut); KE=Center_V(Nparticles,ArrV); /////////// start=clock(); for(t=1;t<=steps;t++){ if(t<=steps/2 && t%Balance_steps==0) Quench(Nparticles,ArrV,KE,T_bath,Alpha); New_R(Nparticles,ArrR,ArrV,ArrA,ArrAP,ArrAPP,halfL,Dt); Potent=Acc(Nparticles,ArrR,ArrA,halfL,Rcut); New_V(Nparticles,ArrV,ArrA,ArrAP,ArrAPP,Dt); KE=Center_V(Nparticles,ArrV); if(t%(steps/10)==0){ end=clock(); printf("T_bath %lf,Temp %lf,Tpotent %lf cost_time:%ldsec\n",T_bath,2.*KE/3./Nparticles,Potent,(end-start)/CLOCKS_PER_SEC); start=clock(); } fprintf(fwE,"%d\t%lf\t%lf\t%lf\n",t,KE,Potent,Potent+KE); if((steps-t)<3000)for(i=0;i<Nparticles;i++){ fprintf(fwR,"%lf %lf %lf\n",*(*(ArrR+i)+0),*(*(ArrR+i)+1),*(*(ArrR+i)+2)); fprintf(fwV,"%lf %lf %lf\n",*(*(ArrV+i)+0),*(*(ArrV+i)+1),*(*(ArrV+i)+2)); AveKE += KE; } } if(((2.*AveKE/3./Nparticles/3000)-T_bath)>0.02*T_bath) printf("inbalance"); fprintf(fwI,"T_bath=%lf\tRecor 3000",T_bath); }
b0297824e303b0e9942fdc2eb69534cbdc76815d
8d9c437148d6b0b2f6175bb38ed673dbc1d65e4e
/tabela_hash_lista_encadeada_indice_string.c
a2d2cc56208a05d388b09704ec230b9079a0bcca
[]
no_license
fernando-albsilva/tabelas_hash_em_C
049bb01dc53dde5d9a24bed6d2dc009f026772c8
f2723e68a32a76dc83b51e3fc159b4e150fd2b99
refs/heads/master
2020-09-03T20:28:40.217600
2019-11-04T17:49:46
2019-11-04T17:49:46
219,561,606
0
0
null
null
null
null
UTF-8
C
false
false
6,675
c
tabela_hash_lista_encadeada_indice_string.c
/* A chave para o indice na tabela hash é o primeiro nome do aluno, nao foi considerado que haverá matricula em duplicidade. */ #include <stdio.h> #include <stdlib.h> #include <string.h> struct aluno { char nome[82]; int mat; struct aluno *prox; }; typedef struct aluno Aluno; #define N 10 void inicializa_hash(Aluno **); void imprime_hash_endereco(Aluno **); int calcula_indice(char *); void incluir_na_tabela(Aluno **); void imprime_conteudo(Aluno **); void busca_elemento(Aluno **); void excluir_elemento(Aluno *,Aluno *,Aluno *); void colisao(Aluno **); int main(void) { Aluno *hash[N]; inicializa_hash(&hash[0]); imprime_hash_endereco(&hash[0]); for(;;){ incluir_na_tabela(&hash[0]); imprime_conteudo(&hash[0]); colisao(&hash[0]); busca_elemento(&hash[0]); imprime_conteudo(&hash[0]); } return 0; } /* Percorre a tabela hash iniciando todos elementos , fazendo com que apontem para NULL */ void inicializa_hash(Aluno **ptrhash) { int i = 0; for (; i < N; i++) { *ptrhash = NULL; ptrhash++; } } /* imprime os elementos da tabela hash para verificar para onde estão apontando */ void imprime_hash_endereco(Aluno **ptrhash) { int i = 0; for (; i < N; i++) { printf("\n hash[%d] = %p ", i, *ptrhash); ptrhash++; } } /* Recebe o primeiro elemento que aparece na string por referencia, percorre a string somando cada char e retorna como indice o total % N, onde N siginifica o tamanho da tabela hash */ int calcula_indice(char *ptrChar) { int total = 0; while (*ptrChar != '\0') { total += (int)*ptrChar; ptrChar++; } return total % N; } /* Recebe o endereço do primeiro ponteiro para lista ta tabela hash */ void incluir_na_tabela(Aluno **ptrHash) { int mat, teste = 0, indice = 0; char nome[82]; Aluno *pai, *aux; do { printf("\n -----------------------------------------------------------------------\n"); printf("\nInclusão de aluno.\n"); printf("\nDigite o nome do aluno: "); scanf("%s", nome); printf("\nDigite a matricula do aluno: "); scanf("%d", &mat); indice = calcula_indice(&nome[0]); /* Se a posicao da tabela hash estiver vazia ele cria uma lista */ if (ptrHash[indice] == NULL) { aux = (Aluno *)malloc(sizeof(Aluno)); if (aux == NULL) { printf("\n Nao ha memoria suficiente"); free(aux); exit(1); } else { aux->mat = mat; strcpy(aux->nome, nome); aux->prox = NULL; ptrHash[indice] = aux; } } else { aux = ptrHash[indice]; while (aux != NULL) { pai = aux; aux = aux->prox; } aux = (Aluno *)malloc(sizeof(Aluno)); if (aux == NULL) { printf("\n Nao ha memoria suficiente"); free(aux); exit(1); } else { aux->mat = mat; strcpy(aux->nome, nome); aux->prox = NULL; pai->prox = aux; } } printf("\n Digite 1 para incluir novamente ou qualquer outro número para sair: "); scanf("%d", &teste); } while (teste == 1); } /*imprime o conteudo das listas encadeadas se houver elemento nas mesmas*/ void imprime_conteudo(Aluno **ptrhash) { int i = 0; Aluno *aux; for (; i < N; i++) { if (*ptrhash != NULL) { printf("\n----------------------------------\n"); aux = *ptrhash; while (aux != NULL) { printf("\n hash[%d]: \n", i); printf("\nNome: %s", aux->nome); printf("\nMatricula: %d\n", aux->mat); aux = aux->prox; } } else { printf("\n----------------------------------\n"); printf("\n hash[%d] = %p ", i, *ptrhash); } ptrhash++; } } void busca_elemento(Aluno **ptrHash) { char busca_nome[82]; int busca_mat, indice; Aluno *aux, *pai, *neto; printf("\nDigite o nome do aluno que deseja buscar."); scanf("%s", busca_nome); printf("Digite a matricula do aluno para que a exclusao seja feita:"); scanf("%d", &busca_mat); indice = calcula_indice(busca_nome); /* verifica se o nome do aluno existe na tabela */ if (ptrHash[indice] == NULL) { printf("\n Não existe esse aluno na tabela.\n"); } else { aux = ptrHash[indice]; /* Se for o primeiro elemento da lista o programa exclui e linka com o proximo elemento idependente dele ser NULL */ if (aux->mat == busca_mat) { ptrHash[indice]=aux->prox; free(aux); } /*Se nao for o primeiro elemento da lista ele percorre ate achar a matricula correta */ else { while (aux->mat != busca_mat && aux != NULL) { pai = aux; aux =aux->prox; neto = aux->prox; } /* Se aux for NULL ele percorreu a lista toda e nao encontrou a matricula */ if(aux==NULL) { printf("\n Matricula nao encontrada.\n"); return ; }else { excluir_elemento(aux,pai,neto); } } } } /* exclui o aluno e faz a ligação da lista */ void excluir_elemento(Aluno* aux, Aluno *pai, Aluno * neto) { if (aux->prox==NULL) { free(aux); pai->prox=NULL; }else{ pai->prox=neto; free(aux); } } /* Conta quantas Alunos colidiram em determinado indice */ void colisao(Aluno ** ptrHash) { int i = 0,cont=0; Aluno *aux; for (; i < N; i++) { if (*ptrHash != NULL) { printf("\n----------------------------------\n"); aux = *ptrHash; while (aux != NULL) { cont++; aux = aux->prox; } printf("\n hash[%d]: %d colisoes.\n", i ,cont); cont=0; } else { printf("\n----------------------------------\n"); printf("\n hash[%d] = %d colisoes.\n ", i, cont); } ptrHash++; } }
16bc4862dfa10c605aa73fb4f7c50ea2ebdb82fe
a0f55e31c92c31832fbe074038f07b8f8726425b
/课件/程序设计/c课件/Ch06/Code/Ex6.10/PaxHeader/Ex6.10.c
fe0a677696c67134b5d77c05e19b568580003d85
[ "MIT" ]
permissive
jjc521/E-book-Collection
7533717250395a8b81163564eef821e66bae5202
b18bf6630bf99b7bf19b4cc4450b67887f618d31
refs/heads/master
2023-03-15T23:48:49.018347
2019-08-30T07:26:01
2019-08-30T07:26:01
206,090,622
2
2
null
null
null
null
UTF-8
C
false
false
68
c
Ex6.10.c
41 path=课件/Ch06/Code/Ex6.10/Ex6.10.c 27 atime=1478790832.781714
653f6d690e861169a62a8e378a13d5b259d6801e
04c8d8da9cebc13513c1b9c7658707ecadfa0ed3
/Roll a Ball/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Comparison_1_gen_3MethodDeclarations.h
e5cd7a9960527df772aaecf5bab31fb5f2a476ec
[]
no_license
fkieyhzen/RollABall
ed9ef9e93f3cfaecd2be10013797e97e9c1e479e
f083b660966094939ed2b5d2028e31bb4e86a67e
refs/heads/master
2023-03-19T18:19:11.437779
2015-06-08T15:27:45
2015-06-08T15:27:45
null
0
0
null
null
null
null
UTF-8
C
false
false
1,408
h
mscorlib_System_Comparison_1_gen_3MethodDeclarations.h
#pragma once // System.Comparison`1<GlobalScoreboard/ScoreEntry> struct Comparison_1_t4175; // System.Object struct Object_t; // System.IAsyncResult struct IAsyncResult_t63; // System.AsyncCallback struct AsyncCallback_t64; // System.IntPtr #include "mscorlib_System_IntPtr.h" // GlobalScoreboard/ScoreEntry #include "AssemblyU2DCSharp_GlobalScoreboard_ScoreEntry.h" // System.Void System.Comparison`1<GlobalScoreboard/ScoreEntry>::.ctor(System.Object,System.IntPtr) void Comparison_1__ctor_m13882 (Comparison_1_t4175 * __this, Object_t * ___object, IntPtr_t34 ___method, MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Comparison`1<GlobalScoreboard/ScoreEntry>::Invoke(T,T) int32_t Comparison_1_Invoke_m13883 (Comparison_1_t4175 * __this, ScoreEntry_t7 ___x, ScoreEntry_t7 ___y, MethodInfo* method) IL2CPP_METHOD_ATTR; // System.IAsyncResult System.Comparison`1<GlobalScoreboard/ScoreEntry>::BeginInvoke(T,T,System.AsyncCallback,System.Object) Object_t * Comparison_1_BeginInvoke_m13884 (Comparison_1_t4175 * __this, ScoreEntry_t7 ___x, ScoreEntry_t7 ___y, AsyncCallback_t64 * ___callback, Object_t * ___object, MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 System.Comparison`1<GlobalScoreboard/ScoreEntry>::EndInvoke(System.IAsyncResult) int32_t Comparison_1_EndInvoke_m13885 (Comparison_1_t4175 * __this, Object_t * ___result, MethodInfo* method) IL2CPP_METHOD_ATTR;
085dd2f08e205a6af9c53d93f9449b0e25648b6e
af79492c6999077f88b820185ecd4eb82c355c9a
/eta_id_pictures_sim_2aOnly_FeD_Fe/rspic/hM2_21.C
24145feed9bbf29760ce0d96f5996d29ca672a05
[]
no_license
orsosa/Eg2_ana
f8d20c0a4c3c0a2e725a24fa84518b552dde31e3
f49ee1384f54365c0b293656386635b111c54ae0
refs/heads/master
2020-07-01T09:30:30.162135
2018-11-05T15:08:42
2018-11-05T15:08:42
74,095,684
0
0
null
null
null
null
UTF-8
C
false
false
7,319
c
hM2_21.C
{ //=========Macro generated from canvas: c/The canvas //========= (Tue Dec 20 13:45:39 2016) by ROOT version5.34/19 TCanvas *c = new TCanvas("c", "The canvas",1,1,800,576); gStyle->SetOptFit(1); c->SetHighLightColor(2); c->Range(0.425,-1.727549,0.675,15.54794); c->SetBorderSize(2); c->SetFrameFillColor(0); TH1F *hM = new TH1F("hM","Mass bin (pt2,nu,z) = (4,0,1)",75,0.45,0.65); hM->SetBinContent(0,2215); hM->SetBinContent(1,3); hM->SetBinContent(2,4); hM->SetBinContent(3,3); hM->SetBinContent(4,3); hM->SetBinContent(5,4); hM->SetBinContent(6,4); hM->SetBinContent(7,3); hM->SetBinContent(9,6); hM->SetBinContent(10,3); hM->SetBinContent(11,5); hM->SetBinContent(12,4); hM->SetBinContent(13,4); hM->SetBinContent(14,4); hM->SetBinContent(15,6); hM->SetBinContent(16,5); hM->SetBinContent(17,6); hM->SetBinContent(18,7); hM->SetBinContent(19,3); hM->SetBinContent(20,4); hM->SetBinContent(21,5); hM->SetBinContent(22,4); hM->SetBinContent(23,6); hM->SetBinContent(24,4); hM->SetBinContent(25,2); hM->SetBinContent(26,1); hM->SetBinContent(27,10); hM->SetBinContent(28,8); hM->SetBinContent(29,6); hM->SetBinContent(30,2); hM->SetBinContent(31,7); hM->SetBinContent(32,9); hM->SetBinContent(33,5); hM->SetBinContent(34,5); hM->SetBinContent(35,5); hM->SetBinContent(36,3); hM->SetBinContent(37,7); hM->SetBinContent(38,6); hM->SetBinContent(39,3); hM->SetBinContent(40,4); hM->SetBinContent(41,4); hM->SetBinContent(42,2); hM->SetBinContent(43,3); hM->SetBinContent(44,5); hM->SetBinContent(45,7); hM->SetBinContent(46,3); hM->SetBinContent(47,4); hM->SetBinContent(48,4); hM->SetBinContent(49,1); hM->SetBinContent(51,1); hM->SetBinContent(52,4); hM->SetBinContent(53,3); hM->SetBinContent(54,1); hM->SetBinContent(55,1); hM->SetBinContent(56,1); hM->SetBinContent(57,2); hM->SetBinContent(58,2); hM->SetBinContent(59,3); hM->SetBinContent(60,1); hM->SetBinContent(61,1); hM->SetBinContent(62,6); hM->SetBinContent(64,1); hM->SetBinContent(65,2); hM->SetBinContent(66,4); hM->SetBinContent(67,1); hM->SetBinContent(68,3); hM->SetBinContent(69,4); hM->SetBinContent(70,1); hM->SetBinContent(71,4); hM->SetBinContent(72,1); hM->SetBinContent(73,1); hM->SetBinContent(74,2); hM->SetBinContent(76,60); hM->SetEntries(2541); TPaveStats *ptstats = new TPaveStats(0.62,0.515,0.98,0.995,"brNDC"); ptstats->SetName("stats"); ptstats->SetBorderSize(2); ptstats->SetTextAlign(12); TText *text = ptstats->AddText("hM"); text->SetTextSize(0.04014545); text = ptstats->AddText("Entries = 2541 "); text = ptstats->AddText("Mean = 0.5355"); text = ptstats->AddText("RMS = 0.05043"); text = ptstats->AddText("#chi^{2} / ndf = 57.58 / 65"); text = ptstats->AddText("p0 = -89.78 #pm 21.72 "); text = ptstats->AddText("p1 = 375.8 #pm 83.7 "); text = ptstats->AddText("p2 = -376 #pm 81.8 "); text = ptstats->AddText("p3 = 9.911 #pm 5.912 "); text = ptstats->AddText("p4 = 0.6975 #pm 0.0387 "); text = ptstats->AddText("p5 = 0.04812 #pm 0.01782 "); ptstats->SetOptStat(1111); ptstats->SetOptFit(111); ptstats->Draw(); hM->GetListOfFunctions()->Add(ptstats); ptstats->SetParent(hM); TF1 *fsig = new TF1("fsig","fmb+fpeak",0.45,0.65); fsig->SetFillColor(19); fsig->SetFillStyle(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#ff0000"); fsig->SetLineColor(ci); fsig->SetLineWidth(3); fsig->SetChisquare(57.57949); fsig->SetNDF(65); fsig->GetXaxis()->SetLabelFont(42); fsig->GetXaxis()->SetLabelSize(0.035); fsig->GetXaxis()->SetTitleSize(0.035); fsig->GetXaxis()->SetTitleFont(42); fsig->GetYaxis()->SetLabelFont(42); fsig->GetYaxis()->SetLabelSize(0.035); fsig->GetYaxis()->SetTitleSize(0.035); fsig->GetYaxis()->SetTitleFont(42); fsig->SetParameter(0,-89.77798); fsig->SetParError(0,21.72409); fsig->SetParLimits(0,0,0); fsig->SetParameter(1,375.7889); fsig->SetParError(1,83.74079); fsig->SetParLimits(1,0,0); fsig->SetParameter(2,-375.9914); fsig->SetParError(2,81.77824); fsig->SetParLimits(2,-10000,0); fsig->SetParameter(3,9.910717); fsig->SetParError(3,5.911925); fsig->SetParLimits(3,0,0); fsig->SetParameter(4,0.6975048); fsig->SetParError(4,0.03866659); fsig->SetParLimits(4,0,0); fsig->SetParameter(5,0.04811778); fsig->SetParError(5,0.0178202); fsig->SetParLimits(5,0.04788336,0.07182504); hM->GetListOfFunctions()->Add(fsig); ci = TColor::GetColor("#0000ff"); hM->SetMarkerColor(ci); hM->SetMarkerStyle(24); hM->GetXaxis()->SetTitle("M_{#gamma#gamma} (GeV)"); hM->GetXaxis()->SetLabelFont(42); hM->GetXaxis()->SetLabelSize(0.035); hM->GetXaxis()->SetTitleSize(0.035); hM->GetXaxis()->SetTitleFont(42); hM->GetYaxis()->SetTitle("dN/dM (GeV)"); hM->GetYaxis()->SetLabelFont(42); hM->GetYaxis()->SetLabelSize(0.035); hM->GetYaxis()->SetTitleSize(0.035); hM->GetYaxis()->SetTitleFont(42); hM->GetZaxis()->SetLabelFont(42); hM->GetZaxis()->SetLabelSize(0.035); hM->GetZaxis()->SetTitleSize(0.035); hM->GetZaxis()->SetTitleFont(42); hM->Draw("e"); TF1 *fmb = new TF1("fmb","pol2",0.45,0.65); fmb->SetFillColor(19); fmb->SetFillStyle(0); ci = TColor::GetColor("#00ff00"); fmb->SetLineColor(ci); fmb->SetLineWidth(3); fmb->SetLineStyle(2); fmb->GetXaxis()->SetLabelFont(42); fmb->GetXaxis()->SetLabelSize(0.035); fmb->GetXaxis()->SetTitleSize(0.035); fmb->GetXaxis()->SetTitleFont(42); fmb->GetYaxis()->SetLabelFont(42); fmb->GetYaxis()->SetLabelSize(0.035); fmb->GetYaxis()->SetTitleSize(0.035); fmb->GetYaxis()->SetTitleFont(42); fmb->SetParameter(0,-89.77798); fmb->SetParError(0,0); fmb->SetParLimits(0,0,0); fmb->SetParameter(1,375.7889); fmb->SetParError(1,0); fmb->SetParLimits(1,0,0); fmb->SetParameter(2,-375.9914); fmb->SetParError(2,0); fmb->SetParLimits(2,0,0); fmb->Draw("same"); TF1 *fpeak = new TF1("fpeak","gaus",0.45,0.65); fpeak->SetFillColor(19); fpeak->SetFillStyle(0); fpeak->SetLineWidth(3); fpeak->SetLineStyle(2); fpeak->GetXaxis()->SetLabelFont(42); fpeak->GetXaxis()->SetLabelSize(0.035); fpeak->GetXaxis()->SetTitleSize(0.035); fpeak->GetXaxis()->SetTitleFont(42); fpeak->GetYaxis()->SetLabelFont(42); fpeak->GetYaxis()->SetLabelSize(0.035); fpeak->GetYaxis()->SetTitleSize(0.035); fpeak->GetYaxis()->SetTitleFont(42); fpeak->SetParameter(0,9.910717); fpeak->SetParError(0,0); fpeak->SetParLimits(0,0,0); fpeak->SetParameter(1,0.6975048); fpeak->SetParError(1,0); fpeak->SetParLimits(1,0,0); fpeak->SetParameter(2,0.04811778); fpeak->SetParError(2,0); fpeak->SetParLimits(2,0,0); fpeak->Draw("same"); TPaveText *pt = new TPaveText(0.01,0.9404546,0.4709548,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(2); text = pt->AddText("Mass bin (pt2,nu,z) = (4,0,1)"); pt->Draw(); c->Modified(); c->cd(); c->SetSelected(c); }
09ecbf5a7172cbcd6046967148cc73caab6cbfe2
f141ab39b7dfa21003239f77d9934a482fb3c599
/crecon/crecon.h
3d82ba857cb0b904273d73f27529f5769ea8229f
[ "MIT" ]
permissive
harmanpa/crecon
7614152e6118ecc8afcc7ba0fb1d4968c8f71287
db8979709382323aa6180781f663caa82331e4a9
refs/heads/master
2021-01-21T13:14:26.275762
2017-10-24T18:15:17
2017-10-24T18:15:17
14,306,051
1
1
null
2017-10-24T18:15:18
2013-11-11T16:18:11
C
UTF-8
C
false
false
13,274
h
crecon.h
/* * The MIT License * * Copyright 2014 CyDesign Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef CRECON_H #define CRECON_H #include <stdio.h> #include "msgpack.h" #define RECON_OK 0 #define RECON_ALREADY_DEFINED -1 #define RECON_NAME_NOT_UNIQUE -2 #define RECON_INVALID_NUMBER_SIGNALS -3 #define RECON_NOT_FOUND -4 #define RECON_WRITE_ERROR -5 #define RECON_READ_ERROR -6 #define RECON_WRONG_FILE_TYPE -7 #define RECON_DESERIALIZATION_ERROR -8 #define RECON_SERIALIZATION_ERROR -9 #define RECON_NOT_FULLY_DEFINED -10 #define RECON_UNDEFINED -11 #define RECON_INCOMPLETE_ROW -12 #define RECON_INCOMPLETE_FIELD -13 #define RECON_OBJECT_DEFINITION_ERROR -14 #define RECON_BUFFER_RESIZE_ERROR -15 #define RECON_SCALAR_FIELD_VALUE -16 #define RECON_FIELD_DESERIALIZATION_ERROR -17 #ifdef __cplusplus extern "C" { #endif typedef unsigned char recon_booleantype; #define RECON_FALSE 0; #define RECON_TRUE 1; typedef int recon_status; typedef void* recon_wall; typedef void* recon_wall_table; typedef void* recon_wall_object; typedef void* recon_wall_signal_pointer; typedef void* recon_wall_object_field; typedef void* recon_wall_object_mobj; typedef void* recon_wall_object_field_element; /** * Open an existing Wall file * @param File pointer * @param Pointer to Wall object * @return Status */ recon_status recon_wall_open(const char*, recon_wall*); /** * Create a new Wall file * @param File pointer * @param Number of tables * @param Number of objects * @param Pointer to Wall object * @return Status */ recon_status recon_wall_create(char*, int, int, recon_wall*); /** * Close a Wall file * @param The Wall object * @return Status */ recon_status recon_wall_close(recon_wall); /** * Finalize a Wall file (write header) * @param The Wall object * @return Status */ recon_status recon_wall_finalize(recon_wall); /** * Flush data to file, finalizing first if necessary * @param The Wall object * @return Status */ recon_status recon_wall_flush(recon_wall); // META DATA recon_status recon_wall_add_meta_double(recon_wall, const char*, double); recon_status recon_wall_add_meta_int(recon_wall, const char*, int); recon_status recon_wall_add_meta_string(recon_wall, const char*, const char*); // TABLE FUNCTIONS /** * Add a new table to the Wall file * @param The Wall object * @param Name * @param Number of signals * @param Number of aliases * @param Pointer to returned table object * @return Status */ recon_status recon_wall_add_table(recon_wall, const char*, int, int, recon_wall_table*); /** * Get the number of tables in the Wall file * @param The Wall object * @param Pointer to number of tables * @return Status */ recon_status recon_wall_n_tables(recon_wall, int*); /** * Fetch a table by index * @param The Wall object * @param Table index * @param Pointer to returned table * @return Status */ recon_status recon_wall_get_table(recon_wall, int, recon_wall_table*); /** * Find a table by name * @param The Wall object * @param Table name * @param Pointer to returned table * @return Status */ recon_status recon_wall_find_table(recon_wall, const char*, recon_wall_table*); /** * Find the first table containing the named signal * @param The Wall object * @param Signal name * @param Pointer to returned table * @return Status */ recon_status recon_wall_find_table_for_signal(recon_wall, const char*, recon_wall_table*); /** * Add a signal to the table * @param The Table object * @param Signal name * @return Status */ recon_status recon_wall_table_add_signal(recon_wall_table, const char*); /** * An an aliased signal * @param The Table object * @param Signal name * @param Original signal name * @param The transform, see recon_transform_xxx functions * @return Status */ recon_status recon_wall_table_add_alias(recon_wall_table, const char*, const char*, char*); /** * Find a signal by name * @param The Table object * @param Signal name * @param Index of the signal * @return Status */ recon_status recon_wall_table_find_signal(recon_wall_table, const char*, int*); /** * Get an alias by index * @param * @param * @param * @return */ recon_status recon_wall_table_get_alias(recon_wall_table, int, char**); /** * * @param * @param * @param * @return */ recon_status recon_wall_table_get_signal(recon_wall_table, int, char**); /** * * @param * @param * @param * @return */ recon_status recon_wall_table_n_signals(recon_wall_table, int*, int*); /** * * @param * @param * @return */ recon_status recon_wall_table_count_rows(recon_wall_table, int*); recon_status recon_wall_table_get_signal_double(recon_wall_table, char*, double*); recon_status recon_wall_table_get_signal_int(recon_wall_table, char*, int*); recon_status recon_wall_table_get_signal_boolean(recon_wall_table, char*, recon_booleantype*); recon_status recon_wall_table_get_signal_object(recon_wall_table, char*, msgpack_object*); // ROW FUNCTIONS /** * Start writing a new row * @param The table to be written to */ recon_status recon_wall_table_start_row(recon_wall_table); /** * Append a double to the current row * @param The table to be written to * @param The value to be written */ recon_status recon_wall_table_row_add_double(recon_wall_table, double); /** * Append an int to the current row * @param The table to be written to * @param The value to be written */ recon_status recon_wall_table_row_add_int(recon_wall_table, int); /** * Append a string to the current row * @param The table to be written to * @param The value to be written */ recon_status recon_wall_table_row_add_string(recon_wall_table, char*); /** * Append a double array to the current row * @param The table to be written to * @param The value to be written * @param The number of values in the array */ recon_status recon_wall_table_row_add_double_array(recon_wall_table, double*, int); /** * Append an int array to the current row * @param The table to be written to * @param The value to be written * @param The number of values in the array */ recon_status recon_wall_table_row_add_int_array(recon_wall_table, int*, int); /** * Append a string array to the current row * @param The table to be written to * @param The value to be written * @param The number of values in the array */ recon_status recon_wall_table_row_add_string_array(recon_wall_table, char**, int); /** * Close the current row * @param The table to be written to */ recon_status recon_wall_table_end_row(recon_wall_table); // OBJECT FUNCTIONS /** * * @param * @param * @param * @return */ recon_status recon_wall_add_object(recon_wall, const char*, recon_wall_object*); /** * * @param * @param * @return */ recon_status recon_wall_n_objects(recon_wall, int*); recon_status recon_wall_get_object(recon_wall, int, recon_wall_object*); recon_status recon_wall_find_object(recon_wall, const char*, recon_wall_object*); recon_status recon_wall_start_field_entry(recon_wall_object obj); recon_status recon_wall_object_add_field_string(recon_wall_object, const char*, const char*); recon_status recon_wall_object_add_field_double(recon_wall_object, const char*, double); recon_status recon_wall_object_add_field_int(recon_wall_object, const char*, int); recon_status recon_wall_object_add_field_object(recon_wall_object, const char*, void*); recon_status recon_wall_end_field_entry(recon_wall_object obj); recon_status recon_wall_table_find_row_index(recon_wall_table tab, int tableIndex, int *bufferIndex); recon_status recon_wall_table_get_row_double(recon_wall_table tab, int n, double *out); recon_status recon_wall_table_get_row_integer(recon_wall_table tab, int n, int *out); recon_status recon_wall_table_get_row_boolean(recon_wall_table tab, int n, recon_booleantype *out); recon_status recon_wall_table_get_row_object(recon_wall_table tab, int n, msgpack_object* out); /* Helper methods for generation of object field entries in msgpack object form. Used * in conjunction with direct calls to msgpack_pack functions. * Example form (for existing recon_wall_objet obj): * * recon_wall_object_mobj *m_obj; * msgpack_packer *packer; * msgpack_sbuffer *buffer; * recon_wall_object_new_mobj(&m_obj); * recon_wall_object_get_mobj_packer(m_obj, &packer); * recon_wall_object_get_mobj_buffer(m_obj, &buffer); * msgpack_pack_raw(packer, ...); * .... * msgpack_pack_map(packer,...); * ... * recon_wall_object_finish_mobj(m_obj); * recon_wall_object_add_field_object(obj, "name", m_obj); * */ recon_status recon_wall_object_new_mobj(recon_wall_object_mobj *mobj); recon_status recon_wall_object_finish_mobj(recon_wall_object_mobj mobj); recon_status recon_wall_object_free_mobj(recon_wall_object_mobj mobj); recon_status recon_wall_object_new_mobj_from_file(recon_wall_object_mobj *mobj, msgpack_object *obj_in); recon_status recon_wall_object_get_mobj_packer(recon_wall_object_mobj mobj, msgpack_packer **pack); recon_status recon_wall_object_get_mobj_buffer(recon_wall_object_mobj mobj, msgpack_sbuffer **buff); recon_status recon_wall_object_get_mobj_data(recon_wall_object_mobj mobj, msgpack_object **data); recon_status recon_wall_object_print_mobj(recon_wall_object_mobj mobj); /* Methods for processing individual object fields and their elements*/ recon_status recon_wall_object_get_fields(recon_wall_object obj); recon_status recon_wall_object_add_field(recon_wall_object obj, const char* name, void* value, recon_booleantype ischar); recon_status recon_wall_object_find_field(recon_wall_object obj, const char* name, int* out); recon_status recon_wall_object_get_field(recon_wall_object obj, int index, recon_wall_object_field *out); recon_status recon_wall_object_get_n_fields(recon_wall_object obj, int *n); recon_status recon_wall_object_get_field_name(recon_wall_object_field field, char **name); recon_status recon_wall_object_extract_field_value_element(recon_wall_object_field_element elem, char **name, char ***values, int *no_values); recon_status recon_wall_object_get_field_value_n_elements(recon_wall_object_field field, int *n); recon_status recon_wall_object_get_field_value_element(recon_wall_object_field field, int i, recon_wall_object_field_element *elem); recon_status recon_wall_object_find_field_value_element(recon_wall_object_field field, const char *name, recon_wall_object_field_element *elem); recon_status recon_wall_object_parse_field_value_elements(recon_wall_object_field field); recon_status recon_wall_object_get_field_value(recon_wall_object_field field, void **value); recon_status recon_wall_object_get_field_ischar(recon_wall_object_field field, recon_booleantype *ischar); // TRANSFORMATIONS recon_status recon_transform_create_none(char**); recon_status recon_transform_create_inverse(char**); recon_status recon_transform_create_affine(char**, double, double); recon_status recon_transform_apply_double(char*, double, double*); recon_status recon_transform_apply_int(char*, int, int*); recon_status recon_transform_apply_boolean(char*, recon_booleantype, recon_booleantype*); #ifdef __cplusplus } #endif #endif /* CRECON_H */
85293b78b07e869f02604520c7359e2b82bbbe76
c42df3922eb587c88201f8a7941183a8b2582b66
/Projects/STM32F030R8-Nucleo/Examples/MY_LIB/pwm3_4.c
4e26b83d16f75d0af422143d195f636710e06744
[]
no_license
Rayling35/STM32Cube_FW_F0_V1.9.0
9e2226c56f70f16f444ab1894e3e0a4accdfc662
ab5919af62c96129bd4c155fcf99dad65b96d0df
refs/heads/master
2020-03-20T07:47:33.851019
2019-05-20T13:16:23
2019-05-20T13:16:23
137,237,819
0
0
null
null
null
null
UTF-8
C
false
false
1,893
c
pwm3_4.c
/* Copyright (C) 2018 Rayling <https://github.com/Rayling35> * SPDX-License-Identifier: MIT */ #include "stm32f0xx_hal.h" #include "pwm3_4.h" #include "api_define.h" TIM_HandleTypeDef TimHandle3_4; static void _PWM3_4_MspInit(void) { GPIO_InitTypeDef GPIO_InitStruct; TIM3_CHANNEL4_CLK_ENABLE(); GPIO_InitStruct.Pin = TIM3_CHANNEL4_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = TIM3_CHANNEL4_AF; HAL_GPIO_Init(TIM3_CHANNEL4_PORT, &GPIO_InitStruct); TIM3_CLK_ENABLE(); } static void pwm3_4_init(void) { _PWM3_4_MspInit(); printf("PWM3_4 HAL init\r\n"); } static int pwm3_4_pin_set(uint32_t period_cycles, uint32_t pulse_cycles, uint32_t prescaler) { TIM_OC_InitTypeDef sConfig; TimHandle3_4.Instance = TIM3; TimHandle3_4.Init.Prescaler = prescaler; TimHandle3_4.Init.CounterMode = TIM_COUNTERMODE_UP; TimHandle3_4.Init.Period = period_cycles; TimHandle3_4.Init.ClockDivision = 0; TimHandle3_4.Init.RepetitionCounter = 0; TimHandle3_4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; HAL_TIM_PWM_Init(&TimHandle3_4); sConfig.OCMode = TIM_OCMODE_PWM1; sConfig.Pulse = pulse_cycles; sConfig.OCPolarity = TIM_OCPOLARITY_HIGH; sConfig.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfig.OCFastMode = TIM_OCFAST_DISABLE; sConfig.OCIdleState = TIM_OCIDLESTATE_RESET; sConfig.OCNIdleState = TIM_OCNIDLESTATE_RESET; HAL_TIM_PWM_ConfigChannel(&TimHandle3_4, &sConfig, TIM3_CHANNEL4); return HAL_TIM_PWM_Start(&TimHandle3_4, TIM3_CHANNEL4); } static struct pwm_api Pwm3_4_api = { .init = pwm3_4_init, .pin_set = pwm3_4_pin_set, }; struct pwm_api* pwm3_4_binding(void) { return &Pwm3_4_api; }
9db4cea7c03054bdc98e1a24701a038ae57a351c
b8e5d350059ed8826c67639ba88e6b3aaff21eeb
/vm/src/fill_map.c
9b44ea040eb625b4c69bf32dee7db0d36cf56011
[]
no_license
Daykz/Corewar
82ce30cc90702c7117e92572b3c32637d8c11fd0
40eac77d8b93564fe7f9f5bb06e541455b9e5349
refs/heads/master
2020-06-16T16:53:07.884220
2017-03-02T14:38:15
2017-03-02T14:38:15
75,082,200
0
0
null
null
null
null
UTF-8
C
false
false
1,315
c
fill_map.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fill_map.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: amaitre <amaitre@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/08 19:30:07 by dmathe #+# #+# */ /* Updated: 2017/02/01 16:00:46 by amaitre ### ########.fr */ /* */ /* ************************************************************************** */ #include <corewar.h> void write_map(t_cwdata *data, t_process *proc, int dest, int src) { int size; int octet; int value; int start_write; size = sizeof(proc->reg[src]) - 1; value = proc->reg[src]; start_write = dest % MEM_SIZE; while (size >= 0) { octet = value & 0xFF; value >>= 8; data->mem[(dest + size) % MEM_SIZE] = octet; size--; } if (data->show_vm) vm_print(data, proc, start_write); }
3d7f2b19e232660c7965657718ced4b0e9f181d9
6b22c22b2de14d5c5069cc8530a746dea9f1b9b7
/Section 1.7/Exercise172/Exercise172/Length.c
bf865f38a40ef8590304b7fb377ada1aacd5d5bc
[ "MIT" ]
permissive
scottsidoli/CPP-Applications-for-Financial-Engineering-Pre-MFE
68be095c15d85868c66e18b6b79588edf8afcce1
79c2fb297a85c914d5f0b8671bb17636801e3ce7
refs/heads/master
2020-06-08T19:49:38.332228
2019-06-23T17:27:42
2019-06-23T17:27:42
193,296,240
1
0
null
null
null
null
UTF-8
C
false
false
1,637
c
Length.c
// Exercise 1.7.2 - Arrays and the Length Function // // by Scott Sidoli // // 4-10-19 // // The goal of this exercise is to create a function that counts the length of a string which // contains at most 30 characters. Our length function takes an array as an argument. Much of // the code is supplied in the statement of the exercise. We merely define the function. /* Calculate the length of a string */ #include <stdio.h> #define MAXLINE 30 // String length declaration int Length(char str[]); int main() { char string[MAXLINE + 1]; // Line of maxium 30 chars + \0 int c; // The input character int i=0; // The counter // Print intro text printf("Type up to %d chars. Exit with Enter followed by ^Z\n", MAXLINE); // To make this work, we had to // prompt the user to hit enter // Get the characters // before ^Z. while ((c=getchar())!=EOF && i<MAXLINE) { // Append entered character to string string[i++]=(char)c; } string[i]='\0'; // String must be closed with \0 printf("String length is %d\n", Length(string)); return 0; } int Length(char str[]) // Length function implementation. { int n; // The variable n counts the entries of the string. for (n = 0; *str != '\0'; str++) // If an address contains '\0', then the loop exits. { // If not, then we increase the count and move to the n++; // next entry in the array. The functions returns the count. } // It should be noted that spaces, new lines, and tabs return n; // increase the count. }
d1a1d4977ec8b282520ed91390fb7d6b18db6d21
8863c2c3d6dab3b6b72f028ab5f141391e7f0861
/CheckMate/Config.h
d4ee401fc411fbf24b1335e87fcccfeaf6930395
[]
no_license
rwithur/CheckMate
c1c932424f305f182e7a810adb2d66d3ec40ded0
ceaa8b82461d7078a7fdc057771f3cf497cca30f
refs/heads/master
2021-01-10T03:55:01.281553
2015-11-14T04:52:26
2015-11-14T04:52:26
46,112,189
0
0
null
2015-11-14T04:15:19
2015-11-13T09:19:54
Objective-C
UTF-8
C
false
false
1,046
h
Config.h
// // Config.h // CheckMate // // Created by Rwithu Menon on 10/11/15. // Copyright © 2015 Rwithu Menon. All rights reserved. // #ifndef Config_h #define Config_h #define SINCH_APPLICATION_KEY @"0d43a89c-2247-4842-a50d-250a4c125a20" #define SINCH_APPLICATION_SECRET @"6eU9anL3h0Ko60sSwdsJQg==" #define SINCH_ENVIRONMENT_HOST @"sandbox.sinch.com" #define PARSE_APPLICATION_ID @"XFhZww2w6u8F25XYqxmR9kNNJ1E12xhA6nQAdlUb" #define PARSE_CLIENT_KEY @"7JnCGflBds32nAr7VUhAf4SkATlKJ6CGAX5o4vJk" #define SINCH_MESSAGE_RECIEVED @"SINCH_MESSAGE_RECIEVED" #define SINCH_MESSAGE_SENT @"SINCH_MESSAGE_SENT" #define SINCH_MESSAGE_DELIVERED @"SINCH_MESSAGE_DELIVERED" #define SINCH_MESSAGE_FAILED @"SINCH_MESSAGE_DELIVERED" #define CHECKMATE_THEME_COLOUR [UIColor colorWithRed:0.416f green:0.800f blue:0.796f alpha:1.00f] #define CHECKMATE_TITLE_COLOUR [UIColor colorWithRed:0.125f green:0.373f blue:0.353f alpha:1.00f] #define CHECKMATE_DESCRIPTION_COLOUR [UIColor colorWithRed:0.541f green:0.541f blue:0.541f alpha:1.00f] #endif /* Config_h */
c2297f1b107404c577f40ecbdc36a4b7fbf13127
dc03d00b73c4723be66edd3f4b380d7531483a2c
/sort_a_and_b.c
3fc7e42e4fa8934e9d003ace3b265abd26dc3a87
[ "MIT" ]
permissive
sandriches/push_swap
c3eadecb5497719ffafc2ba52a6df46a5a8ccfb0
8f80e428b0bf28dfd7316ef1b1b75605c8d8f768
refs/heads/master
2020-05-20T12:46:16.938763
2020-01-24T10:45:08
2020-01-24T10:45:08
185,578,937
0
0
null
null
null
null
UTF-8
C
false
false
2,772
c
sort_a_and_b.c
/* ************************************************************************** */ /* */ /* :::::::: */ /* sort_a_and_b.c :+: :+: */ /* +:+ */ /* By: rcorke <rcorke@student.codam.nl> +#+ */ /* +#+ */ /* Created: 2019/08/19 12:57:04 by rcorke #+# #+# */ /* Updated: 2019/08/22 16:45:36 by rcorke ######## odam.nl */ /* */ /* ************************************************************************** */ #include "push_swap.h" static void init_int_variables(int *a, int *b, int *c) { *a = 0; *b = 0; *c = 0; } static void finish_sort_b_function(t_ps *ps, int pushed, int rotated, int inoff) { int median; ps->a_value = pushed; ps->a_done = 0; median = rotated; while (median > 0 && inoff == 1) { reverse_b(ps); median--; } if (pushed < 4) sort_3_a(ps); } void sort_b_by_half(t_ps *ps, t_blist *list, int len, int inoffensive) { int median; int x; int pushed; int rotated; median = find_median_sorted_array(ps->b, len); init_int_variables(&x, &pushed, &rotated); while (x < len) { if (check_amount_left_to_push_b(ps, len, x, median) == 0) { change_end_list_value(list, rotated + (len - x)); return (smart_sort_finish_b(ps, len, rotated, pushed)); } if (ps->b[0] > median) pushed += push_a(ps); else rotated += rotate_b(ps); x++; } change_end_list_value(list, rotated); finish_sort_b_function(ps, pushed, rotated, inoffensive); if (len < 7) sort_3_b(ps); } static void finish_sort_a_function(t_ps *ps, int pushed, int rotated) { int median; median = rotated; while (median > 0) { reverse_a(ps); median--; } ps->a_value = rotated; ps->a_done = 0; if (pushed < 4) sort_3_b(ps); } void sort_a_by_half(t_ps *ps, t_blist *list, int len) { int median; int x; int pushed; int rotated; median = find_median_sorted_array(ps->a, len); init_int_variables(&x, &pushed, &rotated); while (x < len) { if (check_amount_left_to_push_a(ps, len, x, median) == 0) { add_to_list_end(list, pushed); ps->a_value = rotated + (len - x); return (smart_sort_finish_a_inoff(ps, len, rotated, pushed)); } if (ps->a[0] <= median) pushed += push_b(ps); else rotated += rotate_a(ps); x++; } add_to_list_end(list, pushed); finish_sort_a_function(ps, pushed, rotated); if (len <= 7) sort_3_a(ps); }
9a24fa7d689cf15aa2d871f709e816739c713a50
c45ba3c578c7d3ba11847792ce336ad787b3add1
/Practica 6/primerprograma.c
b75ac4db7ad6d48dad6e42efce89a0f6cab172a5
[]
no_license
rmezadia/SO
101a07f83c1e47847ebd76c5f10f09803173de57
d714b53c830fec41d776266a02768a06daa5b5cf
refs/heads/master
2022-03-10T22:57:59.773573
2019-11-21T19:45:49
2019-11-21T19:45:49
null
0
0
null
null
null
null
UTF-8
C
false
false
390
c
primerprograma.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> #include <signal.h> int var int main(int argc, char*argv[]){ int p; p=fork(); printf("Hola"); printf("Hola proceso %d\n",getpid()); if(p==0){ printf("Nuevo = %d",getpid()); printf("p=%d\n",p); exit(0); } else{ printf("Viejo=%d",getpid()); exit(0); } exit(0); }
19f3314c8e6e35035b331940c3055fa5ea9ce6fe
61c86dc1ab3daf236de934291ff0c8e0d5190271
/include/json/editor/extract/object.h
76b23aaa73f6d57505fac70a7604e7ceeaf6ccf5
[]
no_license
Krapaince/c_json_tools
c7f3262a3c5af91650a912c9fec27e5596f789e0
3b6663fed1c8521d2b25033b6bacd27a112bfb0b
refs/heads/master
2023-03-08T16:58:38.963736
2021-02-26T20:51:53
2021-02-26T20:51:53
259,383,168
0
0
null
null
null
null
UTF-8
C
false
false
212
h
object.h
#ifndef JSON_EDITOR_EXTRACT_OBJECT_H_ #define JSON_EDITOR_EXTRACT_OBJECT_H_ #include <json/editor/extract/index/object.h> #include <json/editor/extract/key/object.h> #endif /* !JSON_EDITOR_EXTRACT_OBJECT_H_ */
79803db08c513677eaf377d3d5a071bc42232533
84f88ea5546429710fd93c7a187286da7e83e52e
/code/component modeling/无刷电机建模/HARDWARE/PWMIN/pwmin.h
266907c67872d6a9ef557800e99dd97f9565ab2f
[]
no_license
shizhuozhang/2018_quad-tilt-rotor-YkZ
5a14f465c772ed8fe1af4c64c9510cf7f3ed8888
8df78b96aa55f42e4bfc5e404b72ecde19a925b7
refs/heads/master
2023-09-03T10:20:30.771862
2021-10-23T04:20:52
2021-10-23T04:20:52
416,241,962
2
1
null
null
null
null
UTF-8
C
false
false
447
h
pwmin.h
#ifndef __PWMIN_H #define __PWMIN_H #include "sys.h" #if __TIM1_PWMIN void TIM1_PWMIN_Init(u16 arr,u16 psc); #endif #if __TIM2_PWMIN void TIM2_PWMIN_Init(u16 arr,u16 psc); #endif #if __TIM3_PWMIN void TIM3_PWMIN_Init(u16 arr,u16 psc); #endif #if __TIM4_PWMIN void TIM4_PWMIN_Init(u16 arr,u16 psc); #endif #if __TIM5_PWMIN void TIM5_PWMIN_Init(u16 arr,u16 psc); #endif #if __TIM8_PWMIN void TIM8_PWMIN_Init(u16 arr,u16 psc); #endif #endif
79d6b212fec2c0b841b43081690dc2d751dbe367
aaa88b2f7af4d53b793fe4fd302593d2f0975dfc
/unreliableDatagramNetworking/multilevel_queue.c
9a31659d2c30028cd4f503c67b633e1aa755b499
[]
no_license
santoshKalyan/OS-Practicum-Projects
d0490e4f0a2b093801634faaa0bed41005051d20
0d6f9517ed0751691c27692630382cf9a4c0e4e8
refs/heads/master
2021-09-09T12:37:55.335818
2018-03-16T05:59:07
2018-03-16T05:59:07
125,468,028
0
0
null
null
null
null
UTF-8
C
false
false
2,819
c
multilevel_queue.c
/* * Multilevel queue manipulation functions */ #include "multilevel_queue.h" #include <stdlib.h> #include <stdio.h> //extern multilevel_queue_TESTING = 1; struct multilevel_queue{ int levels; queue_t *queues; }; /* * Returns an empty multilevel queue with number_of_levels levels. On error should return NULL. */ multilevel_queue_t multilevel_queue_new(int number_of_levels) { multilevel_queue_t mqueue; int i; if(number_of_levels <=0) return NULL; mqueue = (multilevel_queue_t)malloc(sizeof(multilevel_queue_s)); if(mqueue != NULL) { mqueue->levels = number_of_levels; mqueue->queues = (queue_t)malloc(number_of_levels * sizeof(queue_t)); if(mqueue->queues != NULL) { for(i=0;i<number_of_levels;i++) { mqueue->queues[i] = queue_new(); if(multilevel_queue_TESTING) { printf("\nmqueue:%d level queue -- ",i); if(mqueue->queues[i] != NULL) printf("Created."); else printf(" Problem with creating the queue."); } } } } return mqueue; } /* * Appends an void* to the multilevel queue at the specified level. Return 0 (success) or -1 (failure). */ int multilevel_queue_enqueue(multilevel_queue_t mqueue, int level, void* item) { if(mqueue->levels <= level || level < 0) return -1; if(multilevel_queue_TESTING) printf("\nmqueue:Appending %d element to %d level queue",*(int *)item,level); return queue_append(mqueue->queues[level],item); } /* * Dequeue and return the first void* from the multilevel queue starting at the specified level. * Levels wrap around so as long as there is something in the multilevel queue an item should be returned. * Return the level that the item was located on and that item if the multilevel queue is nonempty, * or -1 (failure) and NULL if queue is empty. */ int multilevel_queue_dequeue(multilevel_queue_t mqueue, int level, void** item) { int i,temp,count; if(mqueue->levels <= level || level < 0) return -1; i=level; for(count=0;count<mqueue->levels;count++) { temp = queue_dequeue(mqueue->queues[i],item); if(temp == 0) { if(multilevel_queue_TESTING) { printf("\nmqueue:Dequeued %d element from %d level queue",**(int **)item,i); } return i; } i = (i+1)%(mqueue->levels); //i = i-1; if(i<0) i=mqueue->levels-1; } *item = NULL; return -1; } /* * Free the queue and return 0 (success) or -1 (failure). Do not free the queue nodes; this is * the responsibility of the programmer. */ int multilevel_queue_free(multilevel_queue_t mqueue) { int i=0; for(i=0;i<mqueue->levels;i++) { if(multilevel_queue_TESTING) { printf("\nmqueue:Freeing %d level queue",i); } free(mqueue->queues[i]); } if(multilevel_queue_TESTING) { printf("\nmqueue:Freeing multi-level queue structure"); } free(mqueue); return 0; }
cc900b3d695b9a8d5ae61f0581ba5c61bb566e2f
271eb49a6030908362825bd40e61bc667ee8924d
/fillit/getedges.c
18c7572e1bd0b9bcbcaad13ef1e6d652de01039e
[]
no_license
svend92/projets
acdabb0d9c4c5f481c2f38cd7417a5f665cde82a
d860b097fd1bca6fd8a35394af3cde0d17242c34
refs/heads/master
2022-12-19T18:15:54.247419
2020-09-21T08:01:53
2020-09-21T08:01:53
292,355,250
0
0
null
null
null
null
UTF-8
C
false
false
1,765
c
getedges.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* getedges.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: stherkil <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/23 14:40:48 by stherkil #+# #+# */ /* Updated: 2019/05/25 19:08:09 by stherkil ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" static int upper(char s[4][4]) { int i; int j; i = -1; while (++i < 4) { j = -1; while (++j < 4) if (s[i][j] != '.') return (i); } return (0); } int lower(char s[4][4]) { int i; int j; i = 4; while (--i != 0) { j = -1; while (++j < 4) if (s[i][j] != '.') return (i); } return (0); } static int lefter(char s[4][4]) { int i; int j; j = -1; while (++j < 4) { i = -1; while (++i < 4) if (s[i][j] != '.') return (j); } return (0); } int righter(char s[4][4]) { int i; int j; j = 4; while (--j < 4) { i = -1; while (++i < 4) if (s[i][j] != '.') return (j); } return (0); } int *getedges(char s[4][4]) { int *out; if (!(out = malloc(sizeof(int) * 4))) return (NULL); out[0] = upper(s); out[1] = lower(s); out[2] = lefter(s); out[3] = righter(s); return (out); }
14b73a6093bb6ff48cc842aa9130f509e5030063
fea6fef2c79574d997bb66863d4b2aec97cc251f
/ex1.c
e1c05e1c2ec099c57b39e2b83ddcb49f278209d8
[]
no_license
zuhairabbas14/OperatingSystem-Assignment3
20de3d45dec6c14ada54898eb3d135ea6ea983c1
9f1ed5c1cb6033b56641a6d953d84f151f889a13
refs/heads/master
2020-04-04T08:03:51.179863
2018-11-01T21:03:24
2018-11-01T21:03:24
null
0
0
null
null
null
null
UTF-8
C
false
false
792
c
ex1.c
#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> int main(void) { char *print_str = "This is a nice day"; char *path = "./ex1.txt"; int myFile = open(path, O_RDWR); size_t strSize = strlen(print_str); if (myFile < 0) { perror("Error: Can't open"); exit(EXIT_FAILURE); } if (ftruncate(myFile, strSize)) { perror("Error: Truncate"); exit(EXIT_FAILURE); } void *mapping = mmap(NULL, strSize, PROT_READ | PROT_WRITE, MAP_SHARED, myFile, 0); if (mapping == MAP_FAILED) { perror("Error: Mapping"); exit(EXIT_FAILURE); } memcpy(mapping, print_str, strSize); }
28de82303c7aff405540b67f6a4d924b2941895f
51635684d03e47ebad12b8872ff469b83f36aa52
/external/gcc-12.1.0/gcc/testsuite/g++.dg/warn/Waddress-7.C
efdafa50cd19b1be2ae86e23a0c386569f42d5a9
[ "LGPL-2.1-only", "GPL-3.0-only", "GCC-exception-3.1", "GPL-2.0-only", "LGPL-3.0-only", "LGPL-2.0-or-later", "FSFAP", "Zlib", "LicenseRef-scancode-public-domain" ]
permissive
zhmu/ananas
8fb48ddfe3582f85ff39184fc7a3c58725fe731a
30850c1639f03bccbfb2f2b03361792cc8fae52e
refs/heads/master
2022-06-25T10:44:46.256604
2022-06-12T17:04:40
2022-06-12T17:04:40
30,108,381
59
8
Zlib
2021-09-26T17:30:30
2015-01-31T09:44:33
C
UTF-8
C
false
false
1,854
c
Waddress-7.C
/* PR c/33925 - missing -Waddress with the address of an inline function { dg-do compile } { dg-options "-Wall" } */ struct A { int mf (); int mf_def () { return 0; } static int smf (); static int smf_def () { return 0; } int mi; static int smi; static int smi_def; __attribute__ ((weak)) static int wsmi; __attribute__ ((weak)) static int wsmi_def; int mia[]; static int smia[]; static int smia_def[]; __attribute__ ((weak)) static int wsmia[]; __attribute__ ((weak)) static int wsmia_def[]; void test_waddress (bool*); }; /* __attribute__ ((weak)) static */ int A::smi_def = 0; /* __attribute__ ((weak)) static */ int A::smia_def[] = { 0 }; /* __attribute__ ((weak)) static */ int A::wsmi_def = 0; /* __attribute__ ((weak)) static */ int A::wsmia_def[] = { 0 }; void A::test_waddress (bool *p) { if (mf) // { dg-error "cannot convert" } p++; if (mf_def) // { dg-error "cannot convert" } p++; if (smf) // { dg-warning "-Waddress" } p++; if (smf_def) // { dg-warning "-Waddress" } p++; if (&mi) // { dg-warning "-Waddress" } p++; if (&smi) // { dg-warning "-Waddress" } p++; if (&smi_def) // { dg-warning "-Waddress" } p++; if (&wsmi) p++; if (&wsmi_def) // { dg-warning "-Waddress" } p++; if (mia) // { dg-warning "-Waddress" } p++; if (smia) // { dg-warning "-Waddress" } p++; if (smia_def) // { dg-warning "-Waddress" } p++; if (wsmia) p++; if (wsmia_def) // { dg-warning "-Waddress" } p++; }
c051ed1e58779db4a64bc7b32b9169644f1e1418
9fe2a1fa04218bfda41f04e88771b7edfea5c62e
/challenges_c/093_capitalize_words/capitalize_words.c
9618e665a7adc0e7813108597eb0c1fbc8c710d4
[]
no_license
albertoide/code_eval
258cd28c01f63db8772e18175ac7aabfe1b8d29a
dc216e3454b585117b72b3c1232b2662334c8eb1
refs/heads/master
2021-06-06T08:47:02.526514
2016-08-29T17:54:02
2016-08-29T17:54:02
null
0
0
null
null
null
null
UTF-8
C
false
false
720
c
capitalize_words.c
#include <stdio.h> #include <string.h> #include <ctype.h> #define MAXLINE 100 int main(int argc, char *argv[]) { char line[MAXLINE]; FILE *fp = fopen(argv[1], "r"); while (fgets(line, sizeof(line), fp)) { enum { WORD_INSIDE, WORD_OUTSIDE } state; int i = 0; int word_beginning = 0; state = WORD_OUTSIDE; while (line[i]!='\0') { if ((line[i]==' '|| line[i]=='\n' )&& state==WORD_INSIDE) { line[word_beginning] = toupper(line[word_beginning]); state = WORD_OUTSIDE; } else if ((line[i]!=' '|| line[i]=='\n') && state==WORD_OUTSIDE) { word_beginning = i; state = WORD_INSIDE; } i++; } printf("%s", line); } return 0; }
6b896ce8de18bbb1fbeed8f11faf3b49655ec71b
ab7d780436b51ac974a0ba7e78d8e1f428dbc09f
/CarryPilot_For_LaunchPad_4.0.1_20210525_Released/WP_Ctrl/control_land.c
9c9a792536dad7dc949530097de2121bcb9aa74a
[]
no_license
fish-hub/ED
5c8ed4f3c5f2bcfa17750bd0256423cd5d7e762b
96826b07170f4887c0286d162966ddb8e31cfec5
refs/heads/master
2023-04-26T03:20:36.619215
2021-05-27T15:44:43
2021-05-27T15:44:43
371,415,648
0
0
null
null
null
null
GB18030
C
false
false
15,660
c
control_land.c
/* Copyright (c) 2018-2025 Wuhan Nameless Innovation Technology Co.,Ltd. All rights reserved.*/ /*----------------------------------------------------------------------------------------------------------------------/ 开源并不等于免费,先驱者的历史已经证明,在国内这个环境下,毫无收益的开源,单靠坊间个人爱好者,自发地参与项 目完善的方式行不通,好的开源项目需要请专职人员做好售后服务、手把手教学、统计用户反馈需求、在实践中完成对产 品的一次次完善与迭代升级。经过综合考虑,无名飞控开源代码中,程序仅保留公司正版激活功能代码,版本激活无实际 功能,属于公司产品常规出厂操作,不影响客户学习,其余代码全部开放给客户学习,客户移植和二次开发代码请保留代 码版权。 -----------------------------------------------------------------------------------------------------------------------/ * 本程序只供购买者学习使用,版权著作权属于无名科创团队,无名科创团队将飞控程序源码提供给购买者, * 购买者要为无名科创团队提供保护,未经作者许可,不得将源代码提供给他人,不得将源代码放到网上供他人免费下载, * 更不能以此销售牟利,如发现上述行为,无名科创团队将诉之以法律解决!!! ----------------------------------------------------------------------------------------------------------------------- * 为什么选择无名创新? * 感动人心价格厚道,最靠谱的开源飞控; * 国内业界良心之作,最精致的售后服务; * 追求极致用户体验,高效进阶学习之路; * 萌新不再孤单求索,合理把握开源尺度; * 响应国家扶贫号召,促进教育体制公平; * 新时代奋斗最出彩,建人类命运共同体。 ----------------------------------------------------------------------------------------------------------------------- * 生命不息、奋斗不止;前人栽树,后人乘凉!!! * 开源不易,且学且珍惜,祝早日逆袭、进阶成功!!! * 学习优秀者,简历可推荐到DJI、ZEROTECH、XAG、AEE、GDU、AUTEL、EWATT、HIGH GREAT等公司就业 * 求职简历请发送:15671678205@163.com,需备注求职意向单位、岗位、待遇等 * 无名科创开源飞控QQ群:2号群465082224、1号群540707961(人员已满) * CSDN博客:http://blog.csdn.net/u011992534 * 优酷ID:NamelessCotrun无名小哥 * B站教学视频:https://space.bilibili.com/67803559/#/video * 客户使用心得、改进意见征集贴:http://www.openedv.com/forum.php?mod=viewthread&tid=234214&extra=page=1 * 淘宝店铺:https://shop348646912.taobao.com/?spm=2013.1.1000126.2.5ce78a88ht1sO2 * 百度贴吧:无名科创开源飞控 * 公司官网:www.nameless.tech * 无名创新国内首款TI开源飞控设计初衷、知乎专栏:https://zhuanlan.zhihu.com/p/54471146 * 修改日期:2021/04/30 * 版本:筑梦者PLUS——GankerPilot_V3.0 * 版权所有,盗版必究。 * Copyright(C) 2019-2025 武汉无名创新科技有限公司 * All rights reserved ----------------------------------------------------------------------------------------------------------------------- * 重要提示: * 正常淘宝咸鱼转手的飞控、赠送朋友、传给学弟的都可以进售后群学习交流, * 不得直接在网上销售无名创新资料,无名创新代码有声明版权,他人不得将 * 资料代码传网上供他人下载,不得以谋利为目的销售资料代码,发现有此操 * 作者,公司会提前告知,请1天内及时处理,否则你的学校、单位、姓名、电 * 话、地址信息会被贴出在公司官网、官方微信公众平台、官方技术博客、知乎 * 专栏以及淘宝店铺首页予以公示公告,此种所作所为,会成为个人污点,影响 * 升学、找工作、社会声誉、很快就很在无人机界出名,后果很严重。 * 因此行为给公司造成重大损失者,会以法律途径解决,感谢您的合作,谢谢!!! ----------------------------------------------------------------------------------------------------------------------*/ #include "Headfile.h" #include "control_config.h" #include "control_land.h" Vector2_Nav land_pos_target,land_pos_now,land_home_pos; float target_yaw_rate=0,target_yaw_alt=0; bool land_althold(float taret_climb_rate,float target_climb_alt) { static uint8_t move_flag=0; bool handmove_flag=FALSE; float step_mapping=0,scale_mapping=0; Thr_Scale_Set(&RC_Data.cal[2]); High_Hold_Throttle=Thr_Hover_Default; /*高度控制器第1步*/ /******** ** ** ** ** ** ********/ /*******************************高度控制器开始****************************************/ /****************定高:高度位置环+速度环+加速度环,控制周期分别为8ms、4ms、4ms*******************/ if(target_climb_alt==0) { Total_Controller.High_Position_Control.Expect=NamelessQuad.Position[_YAW];//一直更新高度期望 } else { Total_Controller.High_Position_Control.Expect=target_climb_alt;//更新高度期望 } if(TRPY[0]>=Deadzone_Min &&TRPY[0]<=Deadzone_Max) { //高度位置环输出给定速度期望 Total_Controller.High_Position_Control.FeedBack=NamelessQuad.Position[_YAW];//反馈 PID_Control(&Total_Controller.High_Position_Control);//海拔高度位置控制器 //内环速度期望 if(target_climb_alt==0) Yaw_Vel_Target=taret_climb_rate;//本次速度期望来源于外部直接给定 else Yaw_Vel_Target=Total_Controller.High_Position_Control.Control_OutPut;//本次速度期望来源于位置控制器输出 #ifdef ALT_VEL_FEEDFORWARD_ENABLE //速度前馈控制器 ALT_VEL_FEEDFORWARD_ENABLE_Delta=(Yaw_Vel_Target-Last_Yaw_Vel_Target)/(1*Delta);//速度期望变化率 ALT_VEL_FEEDFORWARD_ENABLE_Output=ALT_VEL_FEEDFORWARD_ENABLE_Rate*ALT_VEL_FEEDFORWARD_ENABLE_Delta; Last_Yaw_Vel_Target=Yaw_Vel_Target;//上次速度期望 #endif Total_Controller.High_Speed_Control.Expect=Yaw_Vel_Target; handmove_flag=FALSE; move_flag=0; } else if(TRPY[0]>Deadzone_Max)//给定上升速度期望 { //油门杆上推、给定速度期望 step_mapping=(float)(TRPY[0]-Deadzone_Max)/(Thr_Top-Deadzone_Max);//范围0~1 scale_mapping=constrain_float(step_mapping*step_mapping,0,1); Total_Controller.High_Speed_Control.Expect=Max_Upvel*scale_mapping;//最大上升速度50cm/s handmove_flag=TRUE; move_flag=1; } else if(TRPY[0]<Deadzone_Min)//给定下降速度期望 { //油门杆下推、给定速度期望 step_mapping=(float)(TRPY[0]-Deadzone_Min)/(Deadzone_Min-Thr_Buttom);//范围0~-1 scale_mapping=constrain_float(step_mapping*step_mapping,0,1); Total_Controller.High_Speed_Control.Expect=-Max_Downvel*scale_mapping;//最大下降速度40cm/s handmove_flag=TRUE; move_flag=2; } /*高度控制器第2步*/ /******** * * * * * * * * ********/ /*******************************竖直速度控制器开始*******************************************************************/ Total_Controller.High_Speed_Control.FeedBack=NamelessQuad.Speed[_YAW];//惯导速度估计给速度反馈 Alt_Accel_Control(&Total_Controller.High_Speed_Control);//海拔高度速度控制 //ADRC_TD_Control(&ADRC_Alt_Vel_Controller,Total_Controller.High_Speed_Control.Expect,Total_Controller.High_Speed_Control.FeedBack); //Total_Controller.High_Speed_Control.Control_OutPut=ADRC_Alt_Vel_Controller.u; /*******************************上升下降过程中期望加速度限幅单独处理*******************************************************************/ if(move_flag==0) { Total_Controller.High_Speed_Control.Control_OutPut=constrain_float(Total_Controller.High_Speed_Control.Control_OutPut, -SDK_Mild_Acceleration_Max,SDK_Mild_Acceleration_Max); } else if(move_flag==1)//在上下推杆时对速度控制器输出,对期望上升、下降加速度进行分别限幅,确保快速下降时姿态平稳 { Total_Controller.High_Speed_Control.Control_OutPut=constrain_float(Total_Controller.High_Speed_Control.Control_OutPut, -Climb_Up_Acceleration_Max,Climb_Up_Acceleration_Max); } else if(move_flag==2) { Total_Controller.High_Speed_Control.Control_OutPut=constrain_float(Total_Controller.High_Speed_Control.Control_OutPut, -Climb_Down_Acceleration_Max,Climb_Down_Acceleration_Max); } /*******************************竖直速度控制器结束******************************************************************/ /*高度控制器第3步*/ /******** ** ** ** ** ** ********/ /*******************************竖直加速度控制器开始******************************************************************/ Total_Controller.High_Acce_Control.Expect=Total_Controller.High_Speed_Control.Control_OutPut;//加速度期望 #ifdef ALT_VEL_FEEDFORWARD_ENABLE //速度前馈控制器 Total_Controller.High_Acce_Control.Expect+=ALT_VEL_FEEDFORWARD_ENABLE_Output;//加上前馈控制器输出 #endif Total_Controller.High_Acce_Control.FeedBack=Acceleration_Feedback[_YAW];//加速度反馈 Alt_Accel_Control(&Total_Controller.High_Acce_Control);//海拔高度加速度控制 /************************************** 加速度环前馈补偿,引用时请注明出处 悬停油门 = 加速度环积分值 + 基准悬停油门 此时输出力 F = mg 当需要输出a的加速度时,输出力 F1=m(g+a) F1/F = 1 + a/g 因此此时应输出:悬停油门*(1 + a/g) **************************************/ Total_Controller.High_Acce_Control.Control_OutPut+=(High_Hold_Throttle+Total_Controller.High_Acce_Control.Integrate-Thr_Start)* (Total_Controller.High_Acce_Control.Expect/980); /*******************************竖直加速度控制器结束******************************************************************/ if(YAW_Pos_Control_Accel_Disable==0) { Throttle=Int_Sort(High_Hold_Throttle+Total_Controller.High_Acce_Control.Control_OutPut);//油门来源于高度加速度控制器输出 Alt_Hold_Output_LPF; } else { Throttle=Int_Sort(High_Hold_Throttle+Total_Controller.High_Speed_Control.Control_OutPut);//油门来源于高度速度控制器输出 Alt_Hold_Output_LPF; } /*****************************************高度控制器结束,给定油门控制量***********************************************************/ return handmove_flag; } #define Minimal_Thrust_Threshold 1150//着陆检测油门最小值 uint16_t Landon_Earth_Cnt=0; uint8_t Last_Landon_Earth_Flag=0,Landon_Earth_Flag=0; uint8_t Landon_Earth_Flag_Set=0; void landon_earth_check(void)//自检触地进入怠速模式 { Last_Landon_Earth_Flag=Landon_Earth_Flag; //油门控制处于较低行程://1、姿态模式下,油门杆处于低位 //2、定高模式下,期望速度向下,单加速度环反馈为角小值, //加速度控制输出由于长时间积分,到负的较大值,使得油门控制较低 if(Throttle_Output<=Minimal_Thrust_Threshold &&Gyro_Length<=30.0f//触地后无旋转,合角速度小于30deg/s &&ABS(NamelessQuad.Speed[_YAW])<=40.0f//惯导竖直轴速度+-40cm/s &&Unwanted_Lock_Flag==0) Landon_Earth_Cnt++; else Landon_Earth_Cnt/=2; if(Landon_Earth_Cnt>=1500) Landon_Earth_Cnt=1500;//防止溢出 if(Landon_Earth_Cnt>=200*2.0)//持续2.0S { Landon_Earth_Flag=1;//着陆标志位 //Landon_Earth_Cnt=0; } else { Landon_Earth_Flag=0;//着陆标志位 } /* if(ABS(Throttle_Rate)>=1.0E-5f)//只要油门变化率不为0,即清空着陆标志位 { Landon_Earth_Flag=0; Landon_Earth_Cnt=0; } */ } // land_nogps_run - runs the land controller // pilot controls roll and pitch angles // should be called at 100hz or more void land_nogps_run() { if(Landon_Earth_Flag==0)//未触地,有姿态控制参与 { Controller.roll_outer_control_output =RC_Data.rc_rpyt[RC_ROLL]; Controller.pitch_outer_control_output=RC_Data.rc_rpyt[RC_PITCH]; if(NamelessQuad.Position[_YAW]<=Safe_Height)//相对初始高度10M以内,暂时忽略漂移 target_yaw_rate=Nav_Decline_Rate;//以Nav_Decline_rate速度下降 else target_yaw_rate=Nav_Rapid_Decline_Rate;//以Nav_Rapid_Decline_rate速度下降 target_yaw_alt=0; // land_althold(target_yaw_rate,target_yaw_alt); Flight_Alt_Hold_Control(ALTHOLD_AUTO_VEL_CTRL,target_yaw_alt,target_yaw_rate);//高度控制 } else { Controller.roll_outer_control_output =0; Controller.pitch_outer_control_output=0; Take_Off_Reset();//清空积分控制器 target_yaw_rate=2*Nav_Rapid_Decline_Rate;//以2*Nav_Rapid_Decline_rate速度下降,使得油门量迅速满足怠速条件 target_yaw_alt=0; // land_althold(target_yaw_rate,target_yaw_alt); Flight_Alt_Hold_Control(ALTHOLD_AUTO_VEL_CTRL,target_yaw_alt,target_yaw_rate);//高度控制 } } uint8_t last_handmove_change_mode=1,handmove_change_mode=1; uint16 nav_transition_cnt=0; uint16 nav_transition_flag=0; uint16 nav_climb_rate_cnt=0; int16 nav_decline_rate_cnt=0; uint16 first_switch_flag=1; uint8_t distance_land_mode=0,last_distance_land_mode=0; uint8_t climb_safe_alt_flag=0,home_fixed_flag=0; bool check_pos_handmove=FALSE; bool check_alt_handmove=FALSE; void land_reset()//着陆过程中存在各种标志位,在一次飞行过程中,可能会频繁切换,需要清空上次未进行完毕的标志位,在切换时会全部清空 { //复位过程中的所有标志位,对于应对较为复杂的逻辑过程的必备编程技巧,一定要掌握好 last_handmove_change_mode=0; nav_transition_cnt=0; nav_transition_flag=0; nav_climb_rate_cnt=0; distance_land_mode=0; last_distance_land_mode=0;//将自动降落模式标志位置0,下一次循环会重新判断 climb_safe_alt_flag=0; first_switch_flag=1; home_fixed_flag=0; handmove_change_mode=2;//水平位置手动模式 first_switch_flag=1;//准备好下次回中时刻的切换 } bool GPS_ok()// returns true if the GPS is ok and home position is set { return FALSE; } // land_run - runs the land controller // should be called at 100hz or more void land_run() { land_nogps_run();//GPS无效时,执行一键着陆操作 } /* Copyright (c) 2018-2025 Wuhan Nameless Innovation Technology Co.,Ltd. All rights reserved.*/
39e07d5473af281139631dc7bd43c130bc8bdcec
c6e84cc0eeda373a4b9eee6dada3e6868bd38364
/Drivers_core_lib/DriverGPIO.h
af5a26ed45773dd03e2e1dfbf6d50a7a1845ea5d
[]
no_license
komakow/texas_driver
10b9ab82d6ee07c323dd6960656f7f402a5197ea
404810ede9125f2e2df8ec27f6aacfcdacef8b22
refs/heads/master
2020-03-26T06:48:06.895877
2018-08-30T20:07:26
2018-08-30T20:07:26
144,622,276
0
0
null
null
null
null
UTF-8
C
false
false
6,665
h
DriverGPIO.h
/** * @DriverGPIO.h * * @Created on: 31 lip 2018 * @Author: KamilM * * @brief Header file for abstract GPIO driver. * Header file include only for 'uint_32' and other numeric types. */ #ifndef DRIVERGPIO_H_ #define DRIVERGPIO_H_ #include <stdint.h> typedef int err; /** * @brief Numeric representation of error. TODO: multiple if necessary */ #define E_GPIO_OK 0 //Operation successful #define E_GPIO_NOT_INITIALIZE -1 //GPIO not initialized #define E_GPIO_INVALID_PARAM -2 //Invalid input parameters /** * @brief Numeric representation state of pin */ typedef enum { GPIO_SET, //set state of specific pin GPIO_RESET //reset state of specific pin } GPIOSet_Type; /** * brief Input qualification type: */ typedef enum { QSEL_MIN = 0, //Not related to GPIO, for debug purpose QSEL_SYNC, //Synchronization QSEL_3Samples, //Qualification (3 samples) QSEL_6Samples, //Qualification (6 samples) QSEL_Async, //Async (no Sync or Qualification) QSEL_MAX //Not related to GPIO, for debug purpose } GPIOQsel_Type; /** * @brief Numeric representation of other function which can be selected */ typedef enum { MUX_MIN = 0, //Not related to GPIO, for debug purpose MUX_0, //zero mux MUX_1, //first mux MUX_2, //etc MUX_3, MUX_4, MUX_5, MUX_6, MUX_7, MUX_8, MUX_9, MUX_10, MUX_11, MUX_12, MUX_13, MUX_14, MUX_15, MUX_MAX //Not related to GPIO, for debug purpose } GPIOMux_Type; /** * @brief Direction Register */ typedef enum { DIR_MIN = 0, //Not related to GPIO, for debug purpose DIR_Input, //GPIO as a input DIR_Output, //GPIO as a output DIR_MAX //Not related to GPIO, for debug purpose } GPIODir_Type; /** * @brief Disables or enables the Pull-Up on GPIO. */ typedef enum { PUD_MIN = 0, //Not related to GPIO, for debug purpose PUD_Enable, //Enables the Pull-up resistors PUD_Disable, //Disables the Pull-up resistors PUD_MAX //Not related to GPIO, for debug purpose } GPIOPud_Type; /** * @brief Input Polarity Invert Registers. Selects between non-inverted and inverted GPIO input to the device */ typedef enum { INV_MIN = 0, //Not related to GPIO, for debug purpose INV_InvertDisable, //Non invert GPIO input INV_InvertEnable, //Invert GPIO input INV_MAX //Not related to GPIO, for debug purpose } GPIOInv_Type; /** * @briefOpen Drain Output Register. Selects between normal and open-drain output for the GPIO pin */ typedef enum { ODR_MIN = 0, //Not related to GPIO, for debug purpose ODR_NormalOutput, //Normal output of GPIO ODR_OpenDrainOutput, //Open Drain output of GPIO ODR_MAX //Not related to GPIO, for debug purpose } GPIOOdr_Type; /** * @brief Core Select Register. Selects which master's GPIODAT/SET/CLEAR/TOGGLE registers control this GPIO pin */ typedef enum { CORE_MIN = 0, //Not related to GPIO, for debug purpose CORE_CPU1, //CPU1 selected as master CORE_CLA, //CLA selected as master CORE_MAX //Not related to GPIO, for debug purpose } GPIOCore_Type; /** * @brief Lock Configuration Register. GPyMUX1, GPyMUX2, GPyDIR, GPyINV, GPyODR, GPyAMSEL, GPyGMUX1, GPyGMUX2 and GPyCSELx * can't be changed */ typedef enum { LOCK_MIN = 0, //Not related to GPIO, for debug purpose LOCK_Disable, //Lock not enabled LOCK_Enable, //Lock enabled LOCK_MAX //Not related to GPIO, for debug purpose } GPIOLock_Type; typedef struct { /* * 1 - pin_1 * 2 - pin_2 * etc */ int32_t pin; /* * Qualification Sampling Period Control * 0 - QUALPRDx = PLLSYSCLK * 1 - QUALPRDx = PLLSYSCLK/2 * 2 - QUALPRDx = PLLSYSCLK/4 * i.e */ int32_t samplingPeriod; /* *MUX_1, //first mux *MUX_2, //i.e */ GPIOMux_Type pinFunction; /* * QSEL_SYNC, //Synchronization * QSEL_3Samples, //Qualification (3 samples) * QSEL_6Samples, //Qualification (6 samples) * QSEL_Async, //Async (no Sync or Qualification) */ GPIOQsel_Type samplingQualification; /* * DIR_Input - GPIO as a input * DIR_Output - GPIO as a output */ GPIODir_Type direction; /* * PUD_Enable - Enables the Pull-up resistors * PUD_Disable - Disables the Pull-up resistors */ GPIOPud_Type pull; /* * INV_InvertDisable - Non invert GPIO input * INV_InvertEnable - Invert GPIO input */ GPIOInv_Type invert; /* * ODR_NormalOutput - Normal output of GPIO * ODR_OpenDrainOutput - Open Drain output of GPIO */ GPIOOdr_Type type; /* * CORE_CPU1 - CPU1 selected as master * CORE_CLA - CLA selected as master */ GPIOCore_Type core; } GPIOCfg_Type; /** * @brief Function used to config specific pin by settings from structure * * @param GPIOCfg_Type* gpio - pointer to config structure * * @return Status of operation */ err pinGPIOCfg(GPIOCfg_Type* gpio); /** * @brief Function used to change state specific pin. * * @param Uint32 pin - numeric representation on specific pin * @param GPIOSet_Type status - state which specific pin should be changed * * @return Status of operation */ err pinGPIOSet(uint32_t pin, GPIOSet_Type state); /** * @brief Function used to enable or disable lock at specific pin * * @param Uint32 pin - numeric representation on specific pin * @param GPIOLock_Type lock - state which specific pin should be changed */ err pinLOCKset(uint32_t pin, GPIOLock_Type lock); /** * @brief Function used to read state of input pin * * @param uint32_t pin - number of specific pin which state should be read * * @return State of pin */ uint32_t pinGPIORead(uint32_t pin); /** * @brief Function used to toogle pin by Data register * * @param uint32_t pin - number of specific pin which state should be toogle * * return State of operation */ err pinGPIOToogle(uint32_t pin); #endif /* DRIVERGPIO_H_ */
1701181ddedf85b0602e071542b44789aa2963ab
9709f4dad26439a80b54f108a207cb9d4dac3f30
/XiAnalysis/Examples/fitHist.C
822f5c874ab184da8ef6e9ed60ac0ab9e6c6a627
[]
no_license
BenjaminTran/Macros
5397c8ff947d87a1a7b6dc8f4def9545b2d9c71b
42e6dec1908c5d9c3b4d99ebde2881b9462f9a48
refs/heads/master
2021-01-21T11:03:45.336907
2018-06-29T07:18:12
2018-06-29T07:18:12
83,518,921
0
0
null
null
null
null
UTF-8
C
false
false
1,076
c
fitHist.C
#include <TLatex.h> void fitTut() { TH1F *background; gStyle->SetOptStat(0); //To get rid of stat box gStyle->SetOptFit(0); //gStyle->setOptFit(1111); //For chi-squared and probability TCanvas *c1 = new TCanvas("c1","Lifetime of a Muon",10,10,700,500); c1->SetFillColor(33); c1->SetFrameFillColor(41); c1->SetGrid(); Double_t fitfunc(Double_t *x, Double_t *par) { Double_t xx = x[0]; Double_t br = -par[2]; //background Double_t sr = par[0]*TMath::Exp(par[1]*xx); //signal return sr + br; } TFile *f = new TFile("muonDecayDataSameBinW.root"); TH1F *result = (TH1F*)f->Get("muonSpectra"); TF1 *ftot = new TF1("ftot",fitfunc,5,10.4,3); ftot->SetNpx(30); ftot->SetParameters(4,-0.4,2); ftot->SetParNames("Normalization","decay","background"); result->Fit("ftot","","",1.4,10.4); result->GetXaxis()->SetTitle("Time (#mus)"); result->GetYaxis()->SetTitle("Decay Count"); } /* Fitting with a user defined exponential https://root.cern.ch/phpBB3/viewtopic.php?t=12210 */
3e92e88aa5f3c795ec613965f87507535f7b5f8b
aeb8302deb7f2240ef150d833515f26e82f4d692
/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Collections_Generic_EqualityComparer_1_gen_9.h
d34d146b07500fea176849ed77b3297fba7da5d6
[]
no_license
AlvianPrasetya/TwistedMaze
4f8ad5dbf10590d90bc4bda4f88607d6bc562bb8
ddf046f1d9acb4ba8335efcd5acde787e66a6434
refs/heads/master
2021-01-13T00:50:20.752597
2015-12-15T09:12:32
2015-12-15T09:12:32
47,547,689
1
0
null
null
null
null
UTF-8
C
false
false
547
h
mscorlib_System_Collections_Generic_EqualityComparer_1_gen_9.h
#pragma once #include <stdint.h> // System.Collections.Generic.EqualityComparer`1<System.DateTimeOffset> struct EqualityComparer_1_t2323; // System.Object #include "mscorlib_System_Object.h" // System.Collections.Generic.EqualityComparer`1<System.DateTimeOffset> struct EqualityComparer_1_t2323 : public Object_t { }; struct EqualityComparer_1_t2323_StaticFields{ // System.Collections.Generic.EqualityComparer`1<T> System.Collections.Generic.EqualityComparer`1<System.DateTimeOffset>::_default EqualityComparer_1_t2323 * ____default_0; };
4c9ccc985ef6a872cc4bb5ad69c3efc95dd0dfd3
f266f15d30e8d0cd2b522fa6a0e7b9f49d59eb39
/ConsoleApplication1/communication_struct_ABLE.h
d703c616a0b2d5ff3d9a0e6d10f1d046e69a020a
[]
no_license
Verdel469/ABLE_Control_Public
7b250295b11fa752de4d55239b246f1c61afa9fa
74bdc62f2e79657b432c09fe3e73f3249b0c8032
refs/heads/main
2023-08-11T23:14:25.904811
2021-10-14T11:07:01
2021-10-14T11:07:01
417,091,841
0
0
null
null
null
null
UTF-8
C
false
false
1,171
h
communication_struct_ABLE.h
/*********************************************************************************************************************** * communication_struct_ABLE.h - * * Author : Dorian Verdel * Creation date : 03/2021 * * Description : * Manages the declaration of the ThreadInformations struct ***********************************************************************************************************************/ #pragma once #ifndef COMMUNICATION_STRUCT_ABLE_H #define COMMUNICATION_STRUCT_ABLE_H // Project includes extern "C" { #include "carte_variateur\carte_variateur_V3.h" } #include "control_struct.h" // ------------------------------------------------- GLOBAL CONTROL STRUCT --------------------------------------------- struct ThreadInformations { ServoComEth* eth_ABLE; AbleControlStruct* ctrl_ABLE; FILE* err_file; FILE* out_file; FILE* identification_file; FILE* currents_file; FILE* artpos_file; FILE* speeds_file; FILE* xs_slider_file; FILE* fz_Arm_file; FILE* ft_Arm_sensor_file; FILE* fz_Wrist_file; FILE* ft_Wrist_sensor_file; FILE* times_file; FILE* times; }; #endif // !COMMUNICATION_STRUCT_ABLE_H
129f80be519cefe1a0443b5e29322ba7a854c8c3
8be3518a8d56abf83bf6dee28c87ad6055a3e726
/0x06-pointers_arrays_strings/100-print_number.c
3f500a13da96da3e1271b82f41fc470a475d88be
[]
no_license
marcowchan/holbertonschool-low_level_programming
212522469783d13674a5398f5d9c6ab79dbfe39b
6783e3249b0945a8806735aa60f2797851b4af8d
refs/heads/master
2022-01-04T14:39:02.417569
2020-01-14T22:31:11
2020-01-14T22:31:11
192,700,417
1
3
null
null
null
null
UTF-8
C
false
false
296
c
100-print_number.c
#include "holberton.h" /** * print_number - print an integer * @n: integer to print */ void print_number(int n) { if (n < 0) { _putchar('-'); if (n < -9) print_number(n / -10); _putchar('0' - n % 10); } else { if (n > 9) print_number(n / 10); _putchar(n % 10 + '0'); } }
c88373d7b5cb1132ece54564d885e84ccbe0e8f1
57091f6b809027a73ab49ecf4931153c93701d6a
/linux/ee41ab509c8c9712af5749cd659acf57c216079e.c
ec412f87bc43a3cd521f4866f3c12dd6987254cd
[ "Apache-2.0" ]
permissive
dvyukov/syzkaller-repros
660997cfa055d79a552bb9ebeda90b48e1599df3
026c8891a19e672bba71481be250080e1a302ed8
refs/heads/master
2022-06-01T18:03:25.480964
2022-05-16T07:36:42
2022-05-16T07:39:01
213,603,012
39
11
Apache-2.0
2022-05-16T07:39:02
2019-10-08T09:36:27
C
UTF-8
C
false
false
1,620
c
ee41ab509c8c9712af5749cd659acf57c216079e.c
// KASAN: slab-out-of-bounds Read in strcmp // https://syzkaller.appspot.com/bug?id=ee41ab509c8c9712af5749cd659acf57c216079e // status:fixed // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <sys/syscall.h> #include <unistd.h> #include <stdint.h> #include <string.h> static uintptr_t syz_open_procfs(uintptr_t a0, uintptr_t a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == (uintptr_t)-1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } long r[9]; void loop() { memset(r, -1, sizeof(r)); r[0] = syscall(__NR_mmap, 0x20000000ul, 0xe000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); r[1] = syscall(__NR_ioctl, 0xffffffffffffff9cul, 0x540ful, 0x20009ffcul); if (r[1] != -1) r[2] = *(uint32_t*)0x20009ffc; memcpy((void*)0x20003000, "\x61\x74\x74\x72\x2f\x73\x6f\x63\x6b\x63" "\x72\x65\x61\x74\x65\x00", 16); r[4] = syz_open_procfs(r[2], 0x20003000ul); memcpy((void*)0x20002fff, "\x54", 1); r[6] = syscall(__NR_write, r[4], 0x20002ffful, 0x1ul); *(uint64_t*)0x20004ff8 = (uint64_t)0x0; r[8] = syscall(__NR_sendfile, r[4], r[4], 0x20004ff8ul, 0x1ul); } int main() { loop(); return 0; }
666d2a15de8ff5e10be62fcd3952d92543fa951a
f938c04963c969dda357f36cbf810a6001cd9e47
/include/magic_cube_change.h
ffe465abaaecfd0fabbdf48cc2d56f0eb007da60
[]
no_license
NTK3H/MC_Lock
68afbb6c71b3c8a3366f748e094a04d93f1a84bb
1bfdd78abed04923ae1717b65540581981f7f7dd
refs/heads/master
2020-03-19T20:34:50.097447
2018-06-11T10:08:57
2018-06-11T10:08:57
133,798,051
2
0
null
null
null
null
UTF-8
C
false
false
6,931
h
magic_cube_change.h
#include <stdio.h> #include <string.h> #include <assert.h> /* 这个文件用于构建魔方模型并进行基础的旋转 * 其接口为两个函数,分别是EdgeChange和MidChange * 它们分别用做表面旋转和中间旋转 * 此文件内其它的函数不可单独使用,否则将无法达到效果 * * ***!此文件内所有函数均正确且有效,不应再修改任何东西!*** * * 修改日志: * 1.增加swap,anticlockwise和clockwise函数并定义结构体mc * 2.增加UpOrDown和LeftOrRight函数 * 3.增加ContraryArr函数和MCRound函数 * 4.修复UpOrDown和LeftOrRight函数的BUG * 5.修复MCRound的BUG并添加了特殊旋转功能 * 6.添加EdgeChange函数 * 7.添加MidChange函数 * 8.删除LeftOrRight函数 * * 近期修改时间: 2018/15/17 12:32 */ typedef struct Magic_Cube{ int order; char *box[6]; }mc; static void swap(char *x, char *y); static void anticlockwise(char *cArr,int n); static void clockwise(char *cArr, int n); static void UpOrDown(int mode,int pos,mc *m); static void ContraryArr(char *cArr, int len); static void MCRound(int mode, int pos, mc *m); void EdgeChange(int index, int mode, mc *m); void MidChange(int index, int dirmode, int mode, int pos, mc *m); /* This funcation can exchange x and y */ static void swap(char *x, char *y) { char z = *x; *x = *y; *y = z; } //逆时针 static void anticlockwise(char *cArr,int n) { for(int i=0; i<n; ++i) for(int j=0; j<n-i; ++j) swap(&cArr[n*i+j], &cArr[n*(n-1-j)+(n-1-i)]); for(int i=0; i<n/2; ++i) for(int j=0; j<n; ++j) swap(&cArr[n*i+j], &cArr[n*(n-1-i)+j]); } //顺时针 static void clockwise(char *cArr, int n) { for(int i=0; i<n; ++i) for(int j=i+1; j<n; ++j) swap(&cArr[n*i+j], &cArr[n*j+i]); for(int i=0; i<n/2; ++i) for(int j=0; j<n; ++j) swap(&cArr[n*i+j], &cArr[n*(n-1-i)+j]); } //控制上下 //mode = 0 : 下转 //mode = 1 : 上转 static void UpOrDown(int mode,int pos,mc *m) { assert(NULL != m); char *strTrv[4] = {NULL}; int BoxMap[4] = {0,2,4,5}; if(0 == mode) { int j=0; for(int i=0;i<=3;i++) { j = i==3?0:j+1; strTrv[i] = (char*)malloc(m->order+1); for(int k=0;k<m->order;k++) strTrv[i][k] = m->box[BoxMap[j]][m->order*k+pos]; } for(int i=0;i<=3;i++) for(int j=0;j<m->order;j++) m->box[BoxMap[i]][m->order*j+pos] = strTrv[i][j]; } if(1 == mode) for(int i=0; i<3; i++) UpOrDown(0,pos,m); } //控制左右 //mode = 0 : 左转 //mode = 1 : 右转 /* 这个函数因用不到而被删除 void LeftOrRight(int mode, int pos, mc *m) { assert(NULL != m); char *strTrv[3] = {NULL}; if(0 == mode) { int j=1; for(int i=0;i<3;i++) { j = i==2?1:j+1; strTrv[i] = (char*)malloc(m->order+1); for(int k=0;k<m->order;k++) strTrv[i][k] = m->box[j][m->order*pos+k]; } for(int i=1;i<=3;i++) for(int j=0;j<m->order;j++) { int k = i-1; m->box[i][m->order*pos+j] = strTrv[k][j]; } } if(1 == mode) for(int i=0; i<3; i++) UpOrDown(0,pos,m); } */ //倒置数组 static void ContraryArr(char *cArr, int len) { for(int i=0;i<len/2;i++) { char z = cArr[i]; cArr[i] = cArr[len-i-1]; cArr[len-i-1] = z; } } //控制旁边 static void MCRound(int mode, int pos, mc *m) { assert(NULL != m); char RBox[m->order+2][m->order+2]; memset(RBox,0,sizeof RBox); /* 这是一个特殊情况,R盒旋转需要使用块位移 */ if(3 == mode || 4 == mode) { //读取 for(int i=0;i<m->order;i++) { for(int j=0;j<3;j++) RBox[j][i] = m->box[j+1][m->order*(m->order-pos)+i]; RBox[3][i] = m->box[5][m->order*(pos-1)+i]; } char cRBox[m->order][m->order]; memset(cRBox,0,sizeof cRBox); //位移 for(int n=0;n<3;n++) { for(int i=0;i<3;i++) for(int j=0;j<m->order;j++) cRBox[i][j] = RBox[i+1][j]; for(int j=0;j<m->order;j++) cRBox[3][j] = RBox[0][j]; ContraryArr(cRBox[3],m->order); ContraryArr(cRBox[2],m->order); if(3 == mode)break; //如果mode是3那么无需更新R盒可以直接退出循环 //更新R盒 for(int i=0;i<4;i++) for(int j=0;j<m->order;j++) RBox[i][j] = cRBox[i][j]; } //写入 for(int i=0;i<m->order;i++) { for(int j=0;j<3;j++) m->box[j+1][m->order*(m->order-pos)+i] = cRBox[j][i]; m->box[5][m->order*(pos-1)+i] = cRBox[3][i]; } return; //特殊情况结束 } /* 以下是一般情况,R盒旋转可以直接套用顺逆时 */ void (*round)(char*, int); if(0 == mode)round = clockwise; if(1 == mode)round = anticlockwise; //读取 for(int i=0;i<m->order;i++) { RBox[0][i+1] = m->box[0][m->order*(m->order-pos)+i]; //上 RBox[m->order+1][i+1] = m->box[4][(m->order)*(pos-1)+i]; //下 RBox[i+1][0] = m->box[1][i*m->order+m->order-pos]; //左 RBox[i+1][m->order+1] = m->box[3][i*m->order+pos-1]; //右 } //旋转 round((char*)RBox,m->order+2); //写入 for(int i=0;i<m->order;i++) { m->box[0][m->order*(m->order-pos)+i] = RBox[0][i+1]; //上 m->box[4][(m->order)*(pos-1)+i] = RBox[m->order+1][i+1]; //下 m->box[1][i*m->order+m->order-pos] = RBox[i+1][0]; //左 m->box[3][i*m->order+pos-1] = RBox[i+1][m->order+1]; //右 } } //mode = 0: Left //mode = 1: Right // //index = 1-6 void EdgeChange(int index, int mode, mc *m) { if(0 == mode) anticlockwise(m->box[index-1],m->order); else if(1 == mode) clockwise(m->box[index-1],m->order); switch(index) { case 1: MCRound(3+mode,m->order,m); break; case 2: UpOrDown(1-mode,0,m); break; case 3: MCRound(1-mode,1,m); break; case 4: UpOrDown(mode,m->order,m); break; case 5: MCRound(4-mode,1,m); break; case 6: MCRound(mode,m->order,m); break; } } //index 表示选中的面 // //dirmode = 0: 表示横向旋转 //dirmode = 1: 表示竖向旋转 // //mode = 0: 表示向上或向右旋转 //mode = 1: 表示向下或向左旋转 // //pos 表示从左上角开始向左或右数的数 // //m 表示准备更改的结构体 // //取值范围: //index: 1-6 //dirmode: 0-1 //mode: 0-1 //pos: 2-(m->order-1) void MidChange(int index, int dirmode, int mode, int pos, mc *m) { assert(NULL != m && pos>1 && pos<m->order && m->order>2); switch(index) { case 1: case 5: //面1和面5执行起来效果一致 if(0 == dirmode) MCRound(1-mode, pos, m); if(1 == dirmode) UpOrDown(mode, pos-1, m); break; case 2: case 4: //面2和面4执行起来效果一致 if(0 == dirmode) MCRound(4-mode, pos, m); if(1 == dirmode) MCRound(1-mode, pos, m); break; case 3: case 6: //面3和面6执行起来效果一致 if(0 == dirmode) MCRound(4-mode, pos, m); if(1 == dirmode) UpOrDown(mode, pos-1, m); break; } }
06aad40b0e105729a58d765c9add4203f09bd3c7
016707a0e7d8eb9838b07b1d0d2f5f4fed2d4197
/BuoyFinderDataKit/BuoyFinderDataKit.h
b34414da367053302ae5b52b0bec10e7f2626f4b
[]
no_license
aeternas/BuoyFinder-iOS
b686f3accafee7c363db1284f3f4d7a6ba3c4568
c9fb49b33174fb204b1f58498208e6921271e333
refs/heads/master
2021-01-23T03:35:09.599833
2017-03-29T13:49:31
2017-03-29T13:49:31
86,102,962
0
0
null
2017-03-24T19:16:41
2017-03-24T19:16:41
null
UTF-8
C
false
false
245
h
BuoyFinderDataKit.h
// // BuoyFinderDataKit.h // BuoyFinder // // Created by Matthew Iannucci on 11/28/16. // Copyright © 2016 Matthew Iannucci. All rights reserved. // #ifndef BuoyFinderDataKit_h #define BuoyFinderDataKit_h #endif /* BuoyFinderDataKit_h */
3f05009a1e518397e9b5708191c1bf9c5d57f79b
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/linux/drivers/infiniband/ulp/isert/extr_ib_isert.c_isert_create_qp.c
1b8dea805a0f735de465539941d143cdc41d26dd
[]
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
2,798
c
extr_ib_isert.c_isert_create_qp.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_6__ TYPE_3__ ; typedef struct TYPE_5__ TYPE_2__ ; typedef struct TYPE_4__ TYPE_1__ ; /* Type definitions */ struct rdma_cm_id {struct ib_qp* qp; } ; struct isert_device {int /*<<< orphan*/ pd; scalar_t__ pi_capable; TYPE_2__* ib_device; } ; struct isert_conn {struct isert_device* device; } ; struct isert_comp {int /*<<< orphan*/ cq; } ; struct TYPE_6__ {int max_recv_sge; int /*<<< orphan*/ max_send_sge; int /*<<< orphan*/ max_rdma_ctxs; scalar_t__ max_recv_wr; scalar_t__ max_send_wr; } ; struct ib_qp_init_attr {int /*<<< orphan*/ create_flags; int /*<<< orphan*/ qp_type; int /*<<< orphan*/ sq_sig_type; TYPE_3__ cap; int /*<<< orphan*/ recv_cq; int /*<<< orphan*/ send_cq; struct isert_conn* qp_context; int /*<<< orphan*/ event_handler; } ; struct ib_qp {int dummy; } ; struct TYPE_4__ {int /*<<< orphan*/ max_send_sge; } ; struct TYPE_5__ {TYPE_1__ attrs; } ; /* Variables and functions */ struct ib_qp* ERR_PTR (int) ; int /*<<< orphan*/ IB_QPT_RC ; int /*<<< orphan*/ IB_QP_CREATE_INTEGRITY_EN ; int /*<<< orphan*/ IB_SIGNAL_REQ_WR ; int /*<<< orphan*/ ISCSI_DEF_XMIT_CMDS_MAX ; scalar_t__ ISERT_QP_MAX_RECV_DTOS ; scalar_t__ ISERT_QP_MAX_REQ_DTOS ; int /*<<< orphan*/ isert_err (char*,int) ; int /*<<< orphan*/ isert_qp_event_callback ; int /*<<< orphan*/ memset (struct ib_qp_init_attr*,int /*<<< orphan*/ ,int) ; int rdma_create_qp (struct rdma_cm_id*,int /*<<< orphan*/ ,struct ib_qp_init_attr*) ; __attribute__((used)) static struct ib_qp * isert_create_qp(struct isert_conn *isert_conn, struct isert_comp *comp, struct rdma_cm_id *cma_id) { struct isert_device *device = isert_conn->device; struct ib_qp_init_attr attr; int ret; memset(&attr, 0, sizeof(struct ib_qp_init_attr)); attr.event_handler = isert_qp_event_callback; attr.qp_context = isert_conn; attr.send_cq = comp->cq; attr.recv_cq = comp->cq; attr.cap.max_send_wr = ISERT_QP_MAX_REQ_DTOS + 1; attr.cap.max_recv_wr = ISERT_QP_MAX_RECV_DTOS + 1; attr.cap.max_rdma_ctxs = ISCSI_DEF_XMIT_CMDS_MAX; attr.cap.max_send_sge = device->ib_device->attrs.max_send_sge; attr.cap.max_recv_sge = 1; attr.sq_sig_type = IB_SIGNAL_REQ_WR; attr.qp_type = IB_QPT_RC; if (device->pi_capable) attr.create_flags |= IB_QP_CREATE_INTEGRITY_EN; ret = rdma_create_qp(cma_id, device->pd, &attr); if (ret) { isert_err("rdma_create_qp failed for cma_id %d\n", ret); return ERR_PTR(ret); } return cma_id->qp; }
bccaf970e58520444aad3402d0dbd58b8a7eb252
6d06441b5700a213e1ae09b04625436cf10cc9af
/HiSIF_V1.00/src/c/addDirEnd.c
22400328558f6d4a9e5083769c7960c576c4eb90
[ "MIT" ]
permissive
yufanzhouonline/HiSIF
ee3c5f7f0ae445b249d9da492237300cab447399
4dc04b85abfb305529e6d0acef034308f8c2d3fa
refs/heads/master
2021-10-23T09:34:56.030406
2021-10-20T16:25:24
2021-10-20T16:25:24
256,616,824
1
0
null
2021-03-17T21:55:39
2020-04-17T21:49:04
C++
UTF-8
C
false
false
632
c
addDirEnd.c
/******************************************************************** * Purpose: * Check for '/' and add to the end of the string. * Used when concatenating directories and filenames. * * Parameters: * char *dirpath directory string * * * Note: * Assumes that there is space to add the '/' ********************************************************************/ #if defined (__cplusplus) extern "C"{ #endif #include <string.h> void addDirEnd(char *dirpath){ int length = strlen(dirpath); if (dirpath[length-1] != '/'){ dirpath[length] = '/'; dirpath[length+1] = '\0'; } } #if defined (__cplusplus) } #endif
84c16584e328bf5d5e2621c5cdde9de8b2f8eaef
cb97177aa3ad45d5f51d35e6c996564be7c45479
/Primer Parcial/Ej2/funciones.c
2737ecfa0d38f90121e90704faf242116286dca3
[]
no_license
storres93/Informatica1r1022
3586781cd5290f3d161bf786454706358b6f1546
82c5ea7f794cf110256e31851a5fa5175cbd40d7
refs/heads/master
2021-01-18T23:56:05.459879
2018-01-23T19:34:38
2018-01-23T19:34:38
87,135,391
0
0
null
null
null
null
UTF-8
C
false
false
1,241
c
funciones.c
#include "../strings.h" #include "header.h" #include <stdio.h> int binHex(char *binario, char *hexa) { int i, j, k; int sum_aux; if(string_length(binario) != 32) { return -1; } if(!validBinary(binario)) { return -2; } for(i = 0, k = 0; i < STRING_MAX_LENGTH - 1; i += 4, k++) { sum_aux = 0; for(j = 0; j < 4; j++) { if(binario[i + j] == '1') { sum_aux += _pow(2, 3 - j); } } if(sum_aux > 9) { hexa[k] = 'A' + (sum_aux - 10); } else { hexa[k] = '0' + sum_aux; } } hexa[k] = STRING_NULL; return 0; } int string_length(char *string) { int i = 0; while(string[i] != STRING_NULL) { i++; } return i; } int validBinary(char *binary) { int i = 0; int valid = 1; while(binary[i] != STRING_NULL) { if(binary[i] != '1' && binary[i] != '0') { valid = 0; break; } i++; } return valid; } int _pow(int base, int power) { if(power == 0) { return 1; } else { return base * _pow(base, power - 1); } }
a0ddb77fd3a81ce0bfb75e92de9bb4f10b4e5073
3a56b1155d39c8e4dfaff52f0ec2e43b64304c28
/frames/01137.h
27f8ab4e944e8e5fcb3f22337c680f83e8eca94a
[]
no_license
RippedOrigami/GBA-Rick
6a610bde18e8dda978730b2d754565e9cdcbfe1d
0953de71ad0a392f5d3a0bcedc54d55e478925b7
refs/heads/master
2021-05-28T17:10:33.260039
2014-11-28T17:14:04
2014-11-28T17:14:04
null
0
0
null
null
null
null
UTF-8
C
false
false
660
h
01137.h
//{{BLOCK(_1137) //====================================================================== // // _1137, 40x40@8, // + palette 256 entries, not compressed // + 25 tiles lz77 compressed // Total size: 512 + 1532 = 2044 // // Time-stamp: 2014-11-28, 05:19:43 // Exported by Cearn's GBA Image Transmogrifier, v0.8.12 // ( http://www.coranac.com/projects/#grit ) // //====================================================================== #ifndef GRIT__1137_H #define GRIT__1137_H #define _1137TilesLen 1532 extern const unsigned int _1137Tiles[383]; #define _1137PalLen 512 extern const unsigned short _1137Pal[256]; #endif // GRIT__1137_H //}}BLOCK(_1137)
38f56cce76ad3870d467cd70e75ef9da61e8fd0b
d47aff0f67bac01af0cbd2a059b80b95a9b97b1b
/5.14/5.14.c
8971cac14e06c651f1add93eb2dc94404e84f146
[]
no_license
LinuxKernelDevelopment/ALC
e6fb23b7e289f3299fd1411b45fdd15654b0c5cc
bebffc2e3a64a3f6a288facac93047f8dccb78f3
refs/heads/master
2020-04-28T23:35:21.407296
2013-09-28T05:13:42
2013-09-28T05:13:42
null
0
0
null
null
null
null
UTF-8
C
false
false
3,171
c
5.14.c
#include <stdio.h> #include <math.h> #include <stdlib.h> typedef struct node* link; typedef struct node {char value; link l, r;}; int deep = 1; /*void delete(link t, int val) { if(t->l->value != val && t->r->value !=val) { delete(t->l, val); delete(t->r, val); } if(t->l->value == val) t->l = t->l->l; if(t->r->value == val) t->r = t->r->r; if(t->l == NULL && t->r == NULL) return; }*/ void visit(link t) { printf("the value of the node is %c\n", t->value);} void traverse(link h, void (*visit)(link)) { if (h == NULL) return; (*visit)(h); //printf("%c", h->value); traverse(h->l, visit); traverse(h->r, visit); } /*link CreateBiTree(link t) { link tem = t; tem = (link)malloc(sizeof(struct node)); tem->l = tem->r =NULL; int flag; char ch; if(deep == 1){ printf("please input the value of root:"); scanf("%c", &t->value);} else {printf("please input the value of the node:"); scanf("%c",&tem->value);} printf("please input the number of node:"); scanf("%c", &ch); printf("please choose the way the tree head(0-left, 1-right, 2-return high level):"); scanf("%d", &flag); if(flag == 0) { printf("left\n"); deep++; tem->value = ch; tem -> l = CreateBiTree(tem->l); printf("deep:%d\n", deep); printf("please choose the way the tree head(0-left, 1-right, 2-return high level:"); scanf("%d", &flag); } if(flag == 1) { printf("right\n"); deep++; tem->value = ch; tem -> r = CreateBiTree(tem->r); printf("deep:%d\n", deep); printf("please choose the way the tree head(0-left, 1-right, 2-return high level:"); scanf("%d", &flag); } if(flag == 2) {printf("return high level\n"); deep--; return tem;} if(deep == 1) {return t;} return tem; }*/ link CreateBiTree(link t) { char ch; rewind(stdin); t = (link)malloc(sizeof(struct node)); printf("please input the char of the data:"); if(deep != 1) ch = getchar(); ch = getchar(); t->value = ch; int flag; printf("please choose the way it grows(0-left, 1-right, 2-return high level):"); scanf("%d", &flag); if(flag == 0) { deep++; t->l = CreateBiTree(t->l); printf("choose:"); scanf("%d",&flag); } if(flag == 1) { deep++; t->r = CreateBiTree(t->r); printf("choose:"); scanf("%d",&flag); } printf("deep is %d\n", --deep); return t; } int main(void) { link t; //t = (link) malloc(sizeof(struct node)); //t->value = 0; t = CreateBiTree(t); printf("E's value is %c\n", t->value); printf("E's left child is %c\n", t->l->value); printf("E's right child is %c\n", t->r->value); printf("D's left child is %c\n", t->l->l->value); printf("B's left child is %c\n", t->l->l->l->value); printf("B's right child is %c\n", t->l->l->r->value); printf("H's left child is %c\n", t->r->l->value); printf("F's right child is %c\n", t->r->l->r->value); traverse(t, visit); return 0; }
b1d5eb1d887f1333b69ebda8061c86b6c474d33c
c1f846b0f13c7df4f0e9f2b43d641c06e84baf8a
/platform/hal/best1200/hal_cmu_best1200.h
62fe05a9059d209c9ddd3468cd3a0d2db87098a1
[]
no_license
hongshui3000/cc_bes2200_main
acb51ed6a2f4ebed5ec1dda14c33396aaba6e813
89dd8aaaad75c629f99f11737273f86005e0b001
refs/heads/master
2020-05-07T22:08:35.800388
2019-03-18T06:45:32
2019-03-18T06:45:32
180,933,261
1
0
null
2019-04-12T04:58:40
2019-04-12T04:58:40
null
UTF-8
C
false
false
111
h
hal_cmu_best1200.h
#ifndef __HAL_CMU_BEST1200_H__ #define __HAL_CMU_BEST1200_H__ #include "best1000/hal_cmu_best1000.h" #endif
852c949fc3dea9fcc311fe07b394aa4e21e345cb
6f37f529bae8bbcc99244468477f14e9f96ff95c
/wxWidgets-2.8.12/include/wx/mac/dc.h
f1215079e0826ac6316c0f5f617625cd6d1708be
[]
no_license
darknebuli/darknebuli-RM-graph
13326ddbc9a210605926f7ad4b70672a48b1b2f2
bf169c01f787fdd144e19fae6732a5b58fdbdafd
refs/heads/master
2020-05-16T23:40:56.853727
2012-04-30T22:14:24
2012-04-30T22:14:24
null
0
0
null
null
null
null
UTF-8
C
false
false
175
h
dc.h
U2FsdGVkX19fTms3OENxUnYu9yS8Tx8bhB5JQ4Up/ZHRnwhWO6j0ILy+shWXM4y2 Zc2Qsa/9/KKvmFZQ2zHcyaBHCQFJ0mMXVBHANvOWbYYw5zox6Sf+I8+Ha7YwkGEN WLlZeEMGC6PeAuZlunp8UfdwVTGPlNyA4G9IPTMmScU=
49e59bd0f7d650c51062b51b1580e239126e1e94
5fb6e52313b352ecf0734a6976fa32c47e5fa0de
/arp_handler/main.c
ebc6e4a7c4c48cb1e126cf0c228ded56cab2e0b8
[ "MIT" ]
permissive
XYlearn/mach-ipc
a3c9192cad229cecbc727ecba264ea490adb08c2
2727683cc788079a0a61d5d0fc346177d93c311f
refs/heads/master
2021-12-14T16:52:37.299000
2017-05-15T14:50:14
2017-05-15T14:50:14
null
0
0
null
null
null
null
UTF-8
C
false
false
2,850
c
main.c
#define _GNU_SOURCE 1 #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <hurd.h> #include <hurd/io.h> #include <mach.h> #include <device/device.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include <error.h> #include "proto.h" #include "ports.h" void make_request(mach_port_t port, char* ip) { arp_query_t* query; char buffer[256]; typeinfo_t tpinfo; query = (arp_query_t*)buffer; query->type = 0x0800; memcpy(query->addr, ip, 4); tpinfo.id = arp_query; tpinfo.size = 6; send_data(port, &tpinfo, buffer); } int main(int argc, char* argv[]) { file_t file; typeinfo_t tpinfo; mach_port_t arp, tmp; kern_return_t ret; char buffer[2048]; arp_register_t* reg; char myip[4] = {0x00, 0x00, 0x00, 0x00}; char ips[][4] = { {129, 199, 129, 30}, /* TROENE */ {129, 199, 129, 22}, /* TAGETTE */ {129, 199, 129, 33}, /* TAMARIN */ }; if(argc < 1) exit(1); file = file_name_lookup(argv[1], O_READ | O_WRITE, 0); if(file == MACH_PORT_NULL) { printf("file_name_lookup\n"); return 1; } ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &arp); if(ret != KERN_SUCCESS) { printf("mach_port_allocate\n"); return 1; } reg = (arp_register_t*)buffer; reg->port_type.msgt_name = MACH_MSG_TYPE_MAKE_SEND; reg->port_type.msgt_size = sizeof(mach_port_t) * 8; reg->port_type.msgt_number = 1; reg->port_type.msgt_inline = TRUE; reg->port_type.msgt_longform = FALSE; reg->port_type.msgt_deallocate = FALSE; reg->port_type.msgt_unused = 0; reg->port = arp; reg->content_type.msgt_name = MACH_MSG_TYPE_UNSTRUCTURED; reg->content_type.msgt_size = 8; reg->content_type.msgt_number = 8; reg->content_type.msgt_inline = TRUE; reg->content_type.msgt_longform = FALSE; reg->content_type.msgt_deallocate = FALSE; reg->content_type.msgt_unused = 0; reg->type = 0x0800; reg->len = 4; memcpy(reg->data, myip, 4); send_data_low(file, sizeof(arp_register_t) + 8, buffer, arp_register); make_request(file, ips[0]); make_request(file, ips[1]); make_request(file, ips[2]); while(1) { tmp = arp; if(!receive_data(&tmp, &tpinfo, buffer, 2048)) continue; if(tpinfo.id != arp_answer) { printf("Invalid ARP answer received\n"); continue; } printf("%hhu.%hhu.%hhu.%hhu -> %02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8], buffer[9]); } }
b95e4487c0ac3825c2d6380ce3afc9879e912d39
10e64f8dca0b596b339169f80c8706edb51eed9f
/linux-devkit/sysroots/armv7ahf-neon-linux-gnueabi/usr/share/ti/ti-ipc-tree/packages/ti/sdo/ipc/family/ti81xx/NotifyDriverMbx.h
66b438c421a3206d6d374564c3ae85941a585f3a
[]
no_license
wangy2000/LeezBoard_TI5708
264cea03d04402cf14714e35f1ca9efd4a1ef7cb
1c0e92c5b61de16f8d8aeb86852c9d53ed99ac58
refs/heads/master
2020-06-16T22:01:26.340391
2019-04-23T13:21:54
2019-04-23T13:21:54
null
0
0
null
null
null
null
UTF-8
C
false
false
45,877
h
NotifyDriverMbx.h
/* * Do not modify this file; it is automatically * generated and any modifications will be overwritten. * * @(#) xdc-D20 */ /* * ======== GENERATED SECTIONS ======== * * PROLOGUE * INCLUDES * * INTERNAL DEFINITIONS * MODULE-WIDE CONFIGS * PER-INSTANCE TYPES * VIRTUAL FUNCTIONS * FUNCTION DECLARATIONS * CONVERTORS * SYSTEM FUNCTIONS * * EPILOGUE * STATE STRUCTURES * PREFIX ALIASES */ /* * ======== PROLOGUE ======== */ #ifndef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__include #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__include #ifndef __nested__ #define __nested__ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__top__ #endif #ifdef __cplusplus #define __extern extern "C" #else #define __extern extern #endif #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx___VERS 200 /* * ======== INCLUDES ======== */ #include <xdc/std.h> #include <xdc/runtime/xdc.h> #include <xdc/runtime/Types.h> #include <xdc/runtime/IInstance.h> #include <ti/sdo/ipc/family/ti81xx/package/package.defs.h> #include <ti/sdo/utils/MultiProc.h> #include <ti/sdo/ipc/interfaces/INotifyDriver.h> #include <ti/sdo/ipc/Notify.h> #include <ti/sysbios/hal/Hwi.h> #include <xdc/runtime/Assert.h> /* * ======== AUXILIARY DEFINITIONS ======== */ /* * ======== INTERNAL DEFINITIONS ======== */ /* Module_State */ typedef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __T1_ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__drvHandles; typedef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __ARRAY1_ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__drvHandles[4]; typedef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __CARRAY1_ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__drvHandles[4]; typedef __ARRAY1_ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__drvHandles __TA_ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__drvHandles; /* * ======== MODULE-WIDE CONFIGS ======== */ /* Module__diagsEnabled */ typedef xdc_Bits32 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsEnabled__C) #endif /* Module__diagsIncluded */ typedef xdc_Bits32 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsIncluded__C) #endif /* Module__diagsMask */ typedef xdc_Bits16 *CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C) #endif /* Module__gateObj */ typedef xdc_Ptr CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gateObj__C) #endif /* Module__gatePrms */ typedef xdc_Ptr CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__gatePrms__C) #endif /* Module__id */ typedef xdc_runtime_Types_ModuleId CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id__C) #endif /* Module__loggerDefined */ typedef xdc_Bool CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerDefined__C) #endif /* Module__loggerObj */ typedef xdc_Ptr CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerObj__C) #endif /* Module__loggerFxn0 */ typedef xdc_runtime_Types_LoggerFxn0 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0 (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn0__C) #endif /* Module__loggerFxn1 */ typedef xdc_runtime_Types_LoggerFxn1 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1 (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn1__C) #endif /* Module__loggerFxn2 */ typedef xdc_runtime_Types_LoggerFxn2 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2 (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn2__C) #endif /* Module__loggerFxn4 */ typedef xdc_runtime_Types_LoggerFxn4 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4 (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn4__C) #endif /* Module__loggerFxn8 */ typedef xdc_runtime_Types_LoggerFxn8 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8 (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__loggerFxn8__C) #endif /* Object__count */ typedef xdc_Int CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count__C) #endif /* Object__heap */ typedef xdc_runtime_IHeap_Handle CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__C) #endif /* Object__sizeof */ typedef xdc_SizeT CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof__C) #endif /* Object__table */ typedef xdc_Ptr CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table__C (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__table__C) #endif /* A_notSupported */ typedef xdc_runtime_Assert_Id CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported__C_offset))) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported__C) #endif /* mailboxBaseAddr */ typedef xdc_UInt32 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr__C_offset))) #else #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr__D #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr__D) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr__C) #endif #endif /* intVectorId */ typedef xdc_UInt CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId__C_offset))) #else #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId__D #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId__D) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId__C) #endif #endif /* dspProcId */ typedef xdc_UInt16 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId__C_offset))) #else #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId__D #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId__D) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId__C) #endif #endif /* hostProcId */ typedef xdc_UInt16 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId__C_offset))) #else #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId__D #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId__D) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId__C) #endif #endif /* videoProcId */ typedef xdc_UInt16 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId__C_offset))) #else #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId__D #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId__D) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId__C) #endif #endif /* vpssProcId */ typedef xdc_UInt16 CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId; __extern __FAR__ const CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId__C; #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId__CR #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId (*((CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId*)(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId__C_offset))) #else #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId__D #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId__D) #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId__C) #endif #endif /* * ======== PER-INSTANCE TYPES ======== */ /* Params */ struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params { size_t __size; const void *__self; void *__fxns; xdc_runtime_IInstance_Params *instance; xdc_UInt16 remoteProcId; xdc_runtime_IInstance_Params __iprms; }; /* Struct */ struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct { const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Fxns__ *__fxns; xdc_Bits32 __f0; ti_sdo_ipc_Notify_Handle __f1; xdc_UInt16 __f2; xdc_runtime_Types_CordAddr __name; }; /* * ======== VIRTUAL FUNCTIONS ======== */ /* Fxns__ */ struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Fxns__ { const xdc_runtime_Types_Base* __base; const xdc_runtime_Types_SysFxns2* __sysp; xdc_Void (*registerEvent)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId); xdc_Void (*unregisterEvent)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId); xdc_Int (*sendEvent)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId, xdc_UInt32 payload, xdc_Bool waitClear); xdc_Void (*disable)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst); xdc_Void (*enable)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst); xdc_Void (*disableEvent)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId); xdc_Void (*enableEvent)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId); xdc_Void (*setNotifyHandle)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_Ptr driverHandle); xdc_runtime_Types_SysFxns2 __sfxns; }; #ifndef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__FXNS__CR /* Module__FXNS__C */ __extern const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Fxns__ ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__FXNS__C; #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__FXNS__C (*(xdcRomConstPtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__FXNS__C_offset)) #endif /* * ======== FUNCTION DECLARATIONS ======== */ /* Module_startup */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup") __extern xdc_Int ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup__E( xdc_Int state ); xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup__F, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup") __extern xdc_Int ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup__F( xdc_Int state ); /* Instance_init__E */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_init__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_init") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_init__E(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object *__obj, const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *__prms); /* Instance_finalize__E */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_finalize__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_finalize") __extern void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_finalize__E(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object *__obj); /* create */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_create, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_create") __extern ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_create( const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *__prms, xdc_runtime_Error_Block *__eb ); /* construct */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_construct, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_construct") __extern void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_construct( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct *__obj, const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *__prms ); /* delete */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_delete, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_delete") __extern void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_delete(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle *instp); /* destruct */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_destruct, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_destruct") __extern void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_destruct(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct *obj); /* Handle__label__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle__label__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle__label__S") __extern xdc_runtime_Types_Label *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle__label__S( xdc_Ptr obj, xdc_runtime_Types_Label *lab ); /* Module__startupDone__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__startupDone__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__startupDone__S") __extern xdc_Bool ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__startupDone__S( void ); /* Object__create__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__create__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__create__S") __extern xdc_Ptr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__create__S( xdc_CPtr __aa, const xdc_UChar *__pa, xdc_SizeT __psz, xdc_runtime_Error_Block *__eb ); /* Object__delete__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__delete__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__delete__S") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__delete__S( xdc_Ptr instp ); /* Object__get__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__get__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__get__S") __extern xdc_Ptr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__get__S( xdc_Ptr oarr, xdc_Int i ); /* Object__first__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__first__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__first__S") __extern xdc_Ptr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__first__S( void ); /* Object__next__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__next__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__next__S") __extern xdc_Ptr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__next__S( xdc_Ptr obj ); /* Params__init__S */ xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params__init__S, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params__init__S") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params__init__S( xdc_Ptr dst, const xdc_Void *src, xdc_SizeT psz, xdc_SizeT isz ); /* registerEvent__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_registerEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_registerEvent__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_registerEvent__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_registerEvent") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_registerEvent__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId ); /* unregisterEvent__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_unregisterEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_unregisterEvent__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_unregisterEvent__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_unregisterEvent") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_unregisterEvent__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId ); /* sendEvent__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_sendEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_sendEvent__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_sendEvent__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_sendEvent") __extern xdc_Int ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_sendEvent__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId, xdc_UInt32 payload, xdc_Bool waitClear ); /* disable__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disable ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disable__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disable__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disable") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disable__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst ); /* enable__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enable ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enable__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enable__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enable") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enable__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst ); /* disableEvent__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disableEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disableEvent__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disableEvent__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disableEvent") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disableEvent__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId ); /* enableEvent__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enableEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enableEvent__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enableEvent__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enableEvent") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enableEvent__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_UInt32 eventId ); /* setNotifyHandle__E */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_setNotifyHandle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_setNotifyHandle__E xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_setNotifyHandle__E, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_setNotifyHandle") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_setNotifyHandle__E( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle __inst, xdc_Ptr driverHandle ); /* isr__I */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_isr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_isr__I xdc__CODESECT(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_isr__I, "ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_isr") __extern xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_isr__I( xdc_UArg arg ); /* * ======== CONVERTORS ======== */ /* Module_upCast */ static inline ti_sdo_ipc_interfaces_INotifyDriver_Module ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_upCast(void); static inline ti_sdo_ipc_interfaces_INotifyDriver_Module ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_upCast(void) { return (ti_sdo_ipc_interfaces_INotifyDriver_Module)&ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__FXNS__C; } /* Module_to_ti_sdo_ipc_interfaces_INotifyDriver */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_to_ti_sdo_ipc_interfaces_INotifyDriver ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_upCast /* Handle_upCast */ static inline ti_sdo_ipc_interfaces_INotifyDriver_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_upCast(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle i); static inline ti_sdo_ipc_interfaces_INotifyDriver_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_upCast(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle i) { return (ti_sdo_ipc_interfaces_INotifyDriver_Handle)i; } /* Handle_to_ti_sdo_ipc_interfaces_INotifyDriver */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_to_ti_sdo_ipc_interfaces_INotifyDriver ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_upCast /* Handle_downCast */ static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_downCast(ti_sdo_ipc_interfaces_INotifyDriver_Handle i); static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_downCast(ti_sdo_ipc_interfaces_INotifyDriver_Handle i) { ti_sdo_ipc_interfaces_INotifyDriver_Handle i2 = (ti_sdo_ipc_interfaces_INotifyDriver_Handle)i; return (const void*)i2->__fxns == (const void*)&ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__FXNS__C ? (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle)i : (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle)0; } /* Handle_from_ti_sdo_ipc_interfaces_INotifyDriver */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_from_ti_sdo_ipc_interfaces_INotifyDriver ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_downCast /* * ======== SYSTEM FUNCTIONS ======== */ /* Module_startupDone */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startupDone() ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__startupDone__S() /* Object_heap */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_heap() ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__C /* Module_heap */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_heap() ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__heap__C /* Module_id */ static inline CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_id(void); static inline CT__ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_id( void ) { return ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__id__C; } /* Module_hasMask */ static inline xdc_Bool ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_hasMask(void); static inline xdc_Bool ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_hasMask(void) { return (xdc_Bool)(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C != NULL); } /* Module_getMask */ static inline xdc_Bits16 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_getMask(void); static inline xdc_Bits16 ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_getMask( void ) { return ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C != NULL ? *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C : (xdc_Bits16)0; } /* Module_setMask */ static inline xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_setMask(xdc_Bits16 mask); static inline xdc_Void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_setMask(xdc_Bits16 mask) { if (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C != NULL) { *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__diagsMask__C = mask; } } /* Params_init */ static inline void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params_init(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *prms); static inline void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params_init( ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *prms ) { if (prms) { ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params__init__S(prms, 0, sizeof(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params), sizeof(xdc_runtime_IInstance_Params)); } } /* Params_copy */ static inline void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params_copy(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *dst, const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *src); static inline void ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params_copy(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *dst, const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params *src) { if (dst) { ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params__init__S(dst, (const void *)src, sizeof(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params), sizeof(xdc_runtime_IInstance_Params)); } } /* Object_count */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_count() ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__count__C /* Object_sizeof */ #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_sizeof() ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__sizeof__C /* Object_get */ static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_get(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_State *oarr, int i); static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_get(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_State *oarr, int i) { return (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle)ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__get__S(oarr, i); } /* Object_first */ static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_first(void); static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_first(void) { return (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle)ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__first__S(); } /* Object_next */ static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_next(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object *obj); static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_next(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object *obj) { return (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle)ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object__next__S(obj); } /* Handle_label */ static inline xdc_runtime_Types_Label *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_label(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle inst, xdc_runtime_Types_Label *lab); static inline xdc_runtime_Types_Label *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_label(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle inst, xdc_runtime_Types_Label *lab) { return ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle__label__S(inst, lab); } /* Handle_name */ static inline xdc_String ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_name(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle inst); static inline xdc_String ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_name(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle inst) { xdc_runtime_Types_Label lab; return ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle__label__S(inst, &lab)->iname; } /* handle */ static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_handle(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct *str); static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_handle(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct *str) { return (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle)str; } /* struct */ static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_struct(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle inst); static inline ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct *ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_struct(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle inst) { return (ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct*)inst; } /* * ======== EPILOGUE ======== */ #ifdef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__top__ #undef __nested__ #endif #endif /* ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__include */ /* * ======== STATE STRUCTURES ======== */ #if defined(__config__) || (!defined(__nested__) && defined(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__internalaccess)) #ifndef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__include_state #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__include_state /* Module_State */ struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State { __TA_ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__drvHandles drvHandles; char __dummy; }; /* Module__state__V */ #ifndef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__state__VR extern struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__ ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__state__V; #else #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__state__V (*((struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State__*)(xdcRomStatePtr + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__state__V_offset))) #endif /* Object */ struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object { const ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Fxns__ *__fxns; xdc_Bits32 evtRegMask; ti_sdo_ipc_Notify_Handle notifyHandle; xdc_UInt16 remoteProcId; }; /* Module_State_hwi */ #ifndef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State_hwi__OR __extern __FAR__ const xdc_SizeT ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State_hwi__O; #endif static inline ti_sysbios_hal_Hwi_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State_hwi(); static inline ti_sysbios_hal_Hwi_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State_hwi() { return (ti_sysbios_hal_Hwi_Handle)(((char*)&ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module__state__V) + ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State_hwi__O); } #endif /* ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__include_state */ #endif /* * ======== PREFIX ALIASES ======== */ #if !defined(__nested__) && !defined(ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__nolocalnames) #ifndef ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__localnames__done #define ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__localnames__done /* module prefix */ #define NotifyDriverMbx_Instance ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance #define NotifyDriverMbx_Handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle #define NotifyDriverMbx_Module ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module #define NotifyDriverMbx_Object ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object #define NotifyDriverMbx_Struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Struct #define NotifyDriverMbx_Instance_State ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_State #define NotifyDriverMbx_Module_State ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State #define NotifyDriverMbx_A_notSupported ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_A_notSupported #define NotifyDriverMbx_mailboxBaseAddr ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_mailboxBaseAddr #define NotifyDriverMbx_intVectorId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_intVectorId #define NotifyDriverMbx_dspProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_dspProcId #define NotifyDriverMbx_hostProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_hostProcId #define NotifyDriverMbx_videoProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_videoProcId #define NotifyDriverMbx_vpssProcId ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_vpssProcId #define NotifyDriverMbx_Module_State_hwi ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_State_hwi #define NotifyDriverMbx_Params ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params #define NotifyDriverMbx_registerEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_registerEvent #define NotifyDriverMbx_unregisterEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_unregisterEvent #define NotifyDriverMbx_sendEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_sendEvent #define NotifyDriverMbx_disable ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disable #define NotifyDriverMbx_enable ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enable #define NotifyDriverMbx_disableEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_disableEvent #define NotifyDriverMbx_enableEvent ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_enableEvent #define NotifyDriverMbx_setNotifyHandle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_setNotifyHandle #define NotifyDriverMbx_Module_name ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_name #define NotifyDriverMbx_Module_id ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_id #define NotifyDriverMbx_Module_startup ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startup #define NotifyDriverMbx_Module_startupDone ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_startupDone #define NotifyDriverMbx_Module_hasMask ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_hasMask #define NotifyDriverMbx_Module_getMask ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_getMask #define NotifyDriverMbx_Module_setMask ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_setMask #define NotifyDriverMbx_Object_heap ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_heap #define NotifyDriverMbx_Module_heap ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_heap #define NotifyDriverMbx_construct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_construct #define NotifyDriverMbx_create ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_create #define NotifyDriverMbx_handle ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_handle #define NotifyDriverMbx_struct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_struct #define NotifyDriverMbx_Handle_label ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_label #define NotifyDriverMbx_Handle_name ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_name #define NotifyDriverMbx_Instance_init ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_init #define NotifyDriverMbx_Object_count ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_count #define NotifyDriverMbx_Object_get ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_get #define NotifyDriverMbx_Object_first ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_first #define NotifyDriverMbx_Object_next ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_next #define NotifyDriverMbx_Object_sizeof ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Object_sizeof #define NotifyDriverMbx_Params_copy ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params_copy #define NotifyDriverMbx_Params_init ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Params_init #define NotifyDriverMbx_Instance_finalize ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Instance_finalize #define NotifyDriverMbx_delete ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_delete #define NotifyDriverMbx_destruct ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_destruct #define NotifyDriverMbx_Module_upCast ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_upCast #define NotifyDriverMbx_Module_to_ti_sdo_ipc_interfaces_INotifyDriver ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Module_to_ti_sdo_ipc_interfaces_INotifyDriver #define NotifyDriverMbx_Handle_upCast ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_upCast #define NotifyDriverMbx_Handle_to_ti_sdo_ipc_interfaces_INotifyDriver ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_to_ti_sdo_ipc_interfaces_INotifyDriver #define NotifyDriverMbx_Handle_downCast ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_downCast #define NotifyDriverMbx_Handle_from_ti_sdo_ipc_interfaces_INotifyDriver ti_sdo_ipc_family_ti81xx_NotifyDriverMbx_Handle_from_ti_sdo_ipc_interfaces_INotifyDriver #endif /* ti_sdo_ipc_family_ti81xx_NotifyDriverMbx__localnames__done */ #endif
7c889e89d7333f621b97f13f1202c2045ada70c0
48a4172b68fedf063c0b0d4d8e4f2310d8c7701a
/hw2/task_10/main.c
1f830a005de4da83ca2b4a8683f8de6e67e65672
[]
no_license
biskvitka/C-and-C-PLDA-course
373b30667addbd2cb4fe85d660a3dd5b25bd34c8
b25c82d22ee06aa7c71b48f2387bcd4407d2f32f
refs/heads/master
2020-04-12T15:06:18.621529
2015-09-15T13:06:36
2015-09-15T13:06:36
null
0
0
null
null
null
null
UTF-8
C
false
false
1,451
c
main.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { int *p = NULL; int n = 5; p = malloc(sizeof *p * n); if(p == NULL){ printf("Memory allocation error\n"); exit(0); } int i; for(i=0; i<n; i++){ *(p+i) = rand() %100; printf("%d -> %d address:%p\n", i, *(p+i), (p+i)); } //----min and max---- int *min; int *max ; max = p; min = p; for(i=0; i<n; i++){ if(*min > *(p+i)){ min = (p+i); } if(*max < *(p+i)){ max = (p+i); } } printf("min = %d \nmax = %d\n", *(min), *(max)); //---reverse--- int *q = NULL; q = malloc(sizeof *q * n); if(p == NULL){ printf("Memory allocation error\n"); exit(0); } for(i=0; i<n; i++){ *(q+i) = *(p+n-1-i); } p = q; for(i=0; i<n; i++){ printf("%d -> %d address:%p\n", i, *(p+i), (p+i)); } //---SORT int t = 0; int j; for(i = 0; i < n-1; i++ ){ for(j = i +1; j < n; j++){ if (*(p+i) > *(p+j)){ t = *(p+i); *(p+i) = *(p+j); *(p+j) = t; } } } printf("Sorted : \n"); for(i=0; i<n; i++){ printf("%d -> %d address:%p\n", i, *(p+i), (p+i)); } free(p); free(max); free(min); free(q); return 0; }
0bb5bbe3b1d175cf17b24d31897a491981c7df4d
f36c443f37d20c2174781e9e8087c80f1dd36c1d
/lib/libft/ft_itoa_base.c
37d01e27608b2598134c545ba5b08c8e7c422720
[]
no_license
dutenrapha/minishell
1bd6c2125e041c4c2ffcbde6a574055d8cc5b59e
4e81fc02869a71f9dcc99fdcadb043d593bfd420
refs/heads/master
2023-09-01T00:10:15.831991
2021-09-19T18:35:18
2021-09-19T18:35:18
365,288,386
1
1
null
2021-09-18T20:03:07
2021-05-07T16:11:22
C
UTF-8
C
false
false
1,487
c
ft_itoa_base.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_itoa_base.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rdutenke <rdutenke@student.42sp.org.br> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/11 18:26:36 by rdutenke #+# #+# */ /* Updated: 2020/07/24 13:34:48 by rdutenke ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf.h" static void ft_aux(char *base, uintmax_t *base_len, int *cont_num) { *base_len = ft_strlen(base); *cont_num = 1; } char *ft_itoa_base(uintmax_t nb, char *base) { int cont_num; uintmax_t base_len; uintmax_t aux; char *str; ft_aux(base, &base_len, &cont_num); aux = nb / base_len; while (aux > 0) { cont_num++; aux = aux / base_len; } str = (char *)ft_calloc((cont_num + 1), sizeof(char)); if (!str) return (NULL); cont_num--; while (cont_num >= 0) { str[cont_num] = base[nb % base_len]; nb = nb / base_len; cont_num--; } return (str); }
ca19f5e969e93c5e0f84de49112bee8505128232
d9da69ea5921d397e3e41086fd45b9fd361e1932
/libft/src/ft_strdel.c
aa68459357a6de15e7c588dcdd62ee94eb1bbf95
[]
no_license
tbeauzam/42-project---lem-in
6be700353eca37b6ba9c0879cffa9b8ecf8fd716
423246c6b70d5043762dbc52fab669aa5bcc1a66
refs/heads/master
2021-01-20T02:49:36.194578
2018-09-10T10:37:16
2018-09-10T10:37:16
101,336,704
0
0
null
null
null
null
UTF-8
C
false
false
984
c
ft_strdel.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdel.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tbeauzam <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 15:07:48 by tbeauzam #+# #+# */ /* Updated: 2016/11/10 01:20:45 by chkropok ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_strdel(char **as) { if (as) { free(*as); *as = NULL; } }