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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9f7eb83ba05888d2b9ddbd953ecbabb60bab3a2b
|
d862e7e02b7c4a8c4e2ef8713a29bfdde9e58106
|
/src/scp.h
|
2a6577aee212ba8541795ad98bf05616fee80704
|
[] |
no_license
|
GregBowyer/turbovax
|
84cfb3dc2efe81f809bc57b4bb59189c82ceaf3d
|
6bfbc3a37440ae9ab7f2d786e5a24a97db7a554d
|
refs/heads/master
| 2021-01-15T17:41:02.811469 | 2016-07-04T02:14:00 | 2016-07-04T02:14:00 | 62,477,398 | 8 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 8,767 |
h
|
scp.h
|
/* scp.h: simulator control program headers
Copyright (c) 1993-2008, Robert M Supnik
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
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Robert M Supnik shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
05-Dec-10 MP Added macro invocation of sim_debug
09-Aug-06 JDB Added assign_device and deassign_device
14-Jul-06 RMS Added sim_activate_abs
06-Jan-06 RMS Added fprint_stopped_gen
Changed arg type in sim_brk_test
07-Feb-05 RMS Added ASSERT command
09-Sep-04 RMS Added reset_all_p
14-Feb-04 RMS Added debug prototypes (from Dave Hittner)
02-Jan-04 RMS Split out from SCP
*/
#ifndef _SIM_SCP_H_
#define _SIM_SCP_H_ 0
/* run_cmd parameters */
#define RU_RUN 0 /* run */
#define RU_GO 1 /* go */
#define RU_STEP 2 /* step */
#define RU_CONT 3 /* continue */
#define RU_BOOT 4 /* boot */
/* get_sim_opt parameters */
#define CMD_OPT_SW 001 /* switches */
#define CMD_OPT_OF 002 /* output file */
#define CMD_OPT_SCH 004 /* search */
#define CMD_OPT_DFT 010 /* defaults */
typedef enum
{
RescheduleCosched_RequeueOnProcessEvent = 1,
RescheduleCosched_OnCancelClock = 2,
RescheduleCosched_OnSynClk = 3
}
RescheduleCoschedHow;
/* Command processors */
t_stat reset_cmd (int32 flag, char *ptr);
t_stat exdep_cmd (int32 flag, char *ptr);
t_stat eval_cmd (int32 flag, char *ptr);
t_stat load_cmd (int32 flag, char *ptr);
t_stat run_cmd (int32 flag, char *ptr);
t_stat attach_cmd (int32 flag, char *ptr);
t_stat detach_cmd (int32 flag, char *ptr);
t_stat assign_cmd (int32 flag, char *ptr);
t_stat deassign_cmd (int32 flag, char *ptr);
t_stat save_cmd (int32 flag, char *ptr);
t_stat restore_cmd (int32 flag, char *ptr);
t_stat exit_cmd (int32 flag, char *ptr);
t_stat set_cmd (int32 flag, char *ptr);
t_stat show_cmd (int32 flag, char *ptr);
t_stat perf_cmd (int32 flag, char *ptr);
t_stat cpu_cmd (int32 flag, char *ptr);
t_stat brk_cmd (int32 flag, char *ptr);
t_stat do_cmd (int32 flag, char *ptr);
t_stat do_script (int32 flag, sim_cstream* script, const char* prompt);
t_stat assert_cmd (int32 flag, char *ptr);
t_stat help_cmd (int32 flag, char *ptr);
t_stat spawn_cmd (int32 flag, char *ptr);
t_stat echo_cmd (int32 flag, char *ptr);
t_stat process_new_brk_actions (int flag);
t_stat process_brk_actions (int flag, char** ppcmd);
/* Utility routines */
t_stat sim_process_event (RUN_DECL);
t_stat sim_activate (UNIT *uptr, int32 interval, int32 nticks = 0);
t_stat sim_activate_abs (UNIT *uptr, int32 interval);
t_stat sim_activate_clk_cosched (UNIT *uptr, int32 nticks);
t_stat sim_activate_clk_cosched_abs (UNIT *uptr, int32 nticks);
t_stat sim_cancel (UNIT *uptr);
int32 sim_is_active (UNIT *uptr);
void sim_asynch_activate (UNIT *uptr, int32 interval);
void sim_asynch_activate_abs (UNIT *uptr, int32 interval);
void sim_reschedule_cosched(RUN_DECL, RescheduleCoschedHow how);
void sim_flush_migrated_clock_queue_entries(RUN_DECL);
int32 sim_calculate_device_activity_protection_interval(RUN_DECL);
void sim_requeue_syswide_events(RUN_DECL);
void sim_async_process_io_events(RUN_DECL, t_bool* any = NULL, t_bool current_only = FALSE);
void sim_async_post_io_event(UNIT* uptr);
void sim_async_process_io_events_for_console();
double sim_gtime (RUN_DECL);
uint32 sim_grtime (RUN_DECL);
void sim_bind_devunits_lock(DEVICE *dptr, smp_lock* lock);
t_stat attach_unit (UNIT *uptr, char *cptr);
t_stat detach_unit (UNIT *uptr);
t_stat assign_device (DEVICE *dptr, char *cptr);
t_stat deassign_device (DEVICE *dptr);
t_stat reset_all (uint32 start_device);
t_stat reset_all_p (uint32 start_device);
const char *sim_dname (DEVICE *dptr);
t_stat get_yn (char *ques, t_stat deflt);
char *get_sim_opt (int32 opt, char *cptr, t_stat *st);
char *get_glyph (char *iptr, char *optr, char mchar);
char *get_glyph_nc (char *iptr, char *optr, char mchar);
t_value get_uint (char *cptr, uint32 radix, t_value max, t_stat *status);
t_stat get_double(char *cptr, double* pval);
char *get_range (DEVICE *dptr, char *cptr, t_addr *lo, t_addr *hi,
uint32 rdx, t_addr max, char term);
t_stat get_ipaddr (char *cptr, uint32 *ipa, uint32 *ipp);
t_value strtotv (char *cptr, char **endptr, uint32 radix);
t_stat fprint_val (SMP_FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
CTAB *find_cmd (char *gbuf);
DEVICE *find_dev (char *ptr);
DEVICE *find_dev (DIB* dibp);
DEVICE *find_unit (char *ptr, UNIT **uptr);
DEVICE *find_dev_from_unit (UNIT *uptr);
REG *find_reg (char *ptr, char **optr, DEVICE *dptr);
CTAB *find_ctab (CTAB *tab, const char *gbuf);
C1TAB *find_c1tab (C1TAB *tab, const char *gbuf);
SHTAB *find_shtab (SHTAB *tab, const char *gbuf);
BRKTAB *sim_brk_fnd (t_addr loc);
uint32 sim_brk_test (RUN_DECL, t_addr bloc, uint32 btyp);
void sim_brk_clrspc (RUN_DECL, uint32 spc);
char *match_ext (char *fnam, char *ext);
const char *sim_error_text (t_stat stat);
t_stat sim_string_to_stat (char *cptr, t_stat *cond);
void sim_debug_u16 (uint32 dbits, DEVICE* dptr, const char* const* bitdefs, uint16 before, uint16 after, int terminate);
#if defined (__DECC) && defined (__VMS) && (defined (__VAX) || (__DECC_VER < 60590001))
# define CANT_USE_MACRO_VA_ARGS 1
#endif
#ifdef CANT_USE_MACRO_VA_ARGS
# define _sim_debug sim_debug
void sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...);
#else
void _sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...);
# define sim_debug(dbits, dptr, ...) if (unlikely(sim_deb != NULL) && ((dptr)->dctrl & dbits)) _sim_debug (dbits, dptr, __VA_ARGS__)
#endif
void fprint_stopped_gen (SMP_FILE *st, REG *pc, DEVICE *dptr);
char* read_line (char *ptr, int32 size, SMP_FILE *stream);
SMP_THREAD_ROUTINE_DECL sim_cpu_work_thread_proc (void* arg);
SMP_THREAD_ROUTINE_DECL sim_clock_thread_proc (void* arg);
void sim_ws_setup();
void sim_prefault_memory();
t_stat xdev_cmd(int32 flag, char *ptr);
/* SIM <-> CPU routines */
t_stat sim_instr(RUN_DECL);
void cpu_backstep_pc(RUN_DECL);
void init_cpu_unit_0();
void sim_init_interrupt_info();
t_bool cpu_create_cpus(uint32 ncpus);
t_stat cpu_cmd_info (SMP_FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
void cpu_sync_flags(CPU_UNIT* uptr);
void sim_mp_active_update();
void cpu_update_cycles_per_second(RUN_DECL, uint32 ips, t_bool valid, uint32 os_msec);
uint32 cpu_get_cycles_per_second(RUN_DECL);
void cpu_stopping_ips_rate_update(RUN_DECL);
/* CPU state database */
extern smp_lock* cpu_database_lock;
extern uint32 cpu_cycles_mark[SIM_MAX_CPUS];
extern uint32 cpu_cycles_sleepexit[SIM_MAX_CPUS];
extern cpu_set cpu_waitset[SIM_MAX_CPUS];
extern cpu_set cpu_running_set;
extern atomic_bool sim_mp_active;
/* CPU cycles per second rate */
extern smp_lock* cpu_cycles_per_second_lock;
extern atomic_uint32_var cpu_cycles_per_second;
/* Synchronization objects to control CPUs <-> console interaction */
extern smp_semaphore* cpu_attention;
extern smp_barrier* cpu_pause_sync_barrier;
extern smp_semaphore* cpu_clock_run_gate;
extern t_bool sim_ttrun_mode;
extern t_bool use_clock_thread;
extern t_bool sim_clock_thread_created;
extern smp_thread_t sim_clock_thread;
/* VCPU affinity control */
extern t_bool sim_vcpu_per_core;
/* other globals */
extern SMP_FILE* sim_deb;
extern uint32 sim_vsmp_os;
#endif
|
5d4912686600042351ecfc950c447db5822ba012
|
a96f7686a9192ffa020c6131300e08146f9e14b5
|
/ft_toupper.c
|
f98a80ddbc73c960939649ee894086318609073d
|
[] |
no_license
|
rgelin/19_Libft
|
493429339cc3ffba6199fb2aab88955697df650c
|
0827e7754889927463e39a70b22d0876999b4d75
|
refs/heads/master
| 2023-03-26T19:26:56.138462 | 2020-12-17T13:59:38 | 2020-12-17T13:59:38 | 350,168,891 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,017 |
c
|
ft_toupper.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_toupper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rgelin <rgelin@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/18 15:25:33 by rgelin #+# #+# */
/* Updated: 2020/11/18 15:25:52 by rgelin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_toupper(int c)
{
if (c >= 'a' && c <= 'z')
{
c -= 32;
return (c);
}
else
return (c);
}
|
8da055fbe95c4db5218b26226bd55b8bbad0ec04
|
c23fe91baf24a1a51f91feb8936b0e64f48b617e
|
/task02.c
|
0ead5a1419bdfb6fbe97c19f3e217573725bd254
|
[] |
no_license
|
hitme/USACO
|
03fff60e87666208c096e0086e9e4e9494852817
|
e9dd4be621b021c72ad3fcdf29d2f9646545aaa9
|
refs/heads/master
| 2020-06-05T02:03:28.079769 | 2012-10-28T15:39:21 | 2012-10-28T15:39:21 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 425 |
c
|
task02.c
|
/*
ID: zltsang1
LANG: C
TASK: ride
*/
#include <stdio.h>
int s2n(char* s){
int res=1;
while(*s){
res*=*s++-'A'+1;
}
return res;
}
main () {
FILE *fin = fopen ("ride.in", "r");
FILE *fout = fopen ("ride.out", "w");
char a[7]={0}, b[7]={0};
fscanf (fin, "%s", a);
fscanf (fin, "%s", b);
if((s2n(a)-s2n(b))%47)
fprintf (fout, "%s\n", "STAY");
else
fprintf (fout, "%s\n", "GO");
exit (0);
}
|
91ed57ab33622677ba05ad92e5d8e5850e9f1724
|
c1ec59b4dc4a3dd62ed2964882a4b498999ae9a0
|
/PIC18F/07 - SENSOR TEMP/main.c
|
b8136bbe5924b78f49c4d2fab4025caca8cd93ba
|
[] |
no_license
|
th-sato/graduate-projects
|
34b86ded560b0affe443b17338624f492da7faae
|
75cf9c0ae1d0a3dd691250f622578cfca1ad4503
|
refs/heads/master
| 2022-02-01T03:56:08.689905 | 2018-04-08T20:19:35 | 2018-04-08T20:19:35 | null | 0 | 0 | null | null | null | null |
ISO-8859-1
|
C
| false | false | 4,631 |
c
|
main.c
|
/*
Microgenios Soluções Eletrônicas Ltda.
********************************************************************************
PROGRAMA EXEMPLO: Leitura do canal A/D AN2 para ler temperatura através do lm35
e usar o CUSTOM CHAR para mostrar o simbolo de graus.
OBJETIVO: Aprender a ler temperatura e usar o CUSTOM CHAR.
AUTOR: Fabio Mulero.[fabio@microgenios.com.br]
********************************************************************************
MICROCONTROLADOR: PIC18F4520.
http://ww1.microchip.com/downloads/en/DeviceDoc/39631E.pdf
PLACA DE DESENVOLVIMENTO: KIT PICgenios - PIC18F
http://www.microgenios.com.br/news/index.php?option=com_content&task=view&id=88&Itemid=134
SOFTWARE: MikroC PRO for PIC
http://www.mikroe.com/en/compilers/mikroc/pro/pic/
************************ Configurações do KIT Picgenios ************************
CRISTAL: 8Mhz.
CHAVES DE FUNÇÃO:
--------------------- ----------------------
|GLCD\LCD ( 1) = ON |DIS1 ( 1) = OFF |
|RX ( 2) = OFF |DIS2 ( 2) = OFF |
|TX ( 3) = OFF |DIS3 ( 3) = OFF |
|REL1 ( 4) = OFF |DIS4 ( 4) = OFF |
|REL2 ( 5) = OFF |INFR ( 5) = OFF |
|SCK ( 6) = OFF |RESIS ( 6) = ON |
|SDA ( 7) = OFF |TEMP ( 7) = ON |
|RTC ( 8) = OFF |VENT ( 8) = OFF |
|LED1 ( 9) = OFF |AN0 ( 9) = OFF |
|LED2 (10) = OFF |AN1 (10) = OFF |
--------------------- ----------------------
********************************************************************************
OBS:
- HABILITAR BIBLIOTECA LCD.
- HABILITAR BIBLIOTECA A/D.
- HABILITAR BIBLIOTECA CONVERTIONS.
- JUMPER LIGADO DO BUZZER.
********************************************************************************
*/
// VARIAVEIS GLOBAIS
unsigned char ucTexto[10]; // Matriz para armazenamento de texto.
unsigned int iLeituraAD = 0; // Define variável para armazenamento da leitura AD.
// PROTOTIPOS DE FUNÇÃO
void GRAUS();
// CONFIGURAÇÃO DOS PINOS DO LCD.
sbit LCD_RS at RE2_bit;
sbit LCD_EN at RE1_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;
// DIREÇÃO DOS PINOS.
sbit LCD_RS_Direction at TRISE2_bit;
sbit LCD_EN_Direction at TRISE1_bit;
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
void main(){
TRISB = 0; // Define PORTB como saida.
TRISD = 0; // Define PORTD como saida.
TRISC.RC5 = 0; // Define PORTC.RC5 como saida.
TRISC.RC1 = 0; // Define PORTC.RC1 como saida.
TRISE = 0; // Define PORTE como saida.
PORTB = 0; // Limpa PORTB.
ADCON0 = 0b00000001; // Configura conversor A/D Canal 0, conversão desligada, A/D ligado.
ADCON1 = 0b00001100; // Configura todos canais como Digital menos AN0,AN1 E AN2 e REF Interna.
ADCON2 = 0b10111110; // Configura conversor A/D para resultado justificado a direita, clock de 20 TAD, clock de Fosc/64.
// Config. LCD no modo 4 bits
Lcd_Init(); // Inicializa LCD.
Lcd_Cmd(_LCD_CLEAR); // Apaga display.
Lcd_Cmd(_LCD_CURSOR_OFF); // Desliga cursor.
Lcd_Out(1, 1, "TEMP: "); // Escreve mensagem no LCD.
PORTC.RC5 = 1; // Liga resistencia de aquecimento.
GRAUS(); // Armazena simbolo de graus.
while(1){ // Aqui Definimos Uma Condição Sempre Verdadeira Como Parametro, Portanto Todo O Bloco Será Repetido Indefinidamente.
iLeituraAD= ADC_Read(2); // Lê Canal AD 2
iLeituraAD/=2; // Converte valor do sensor LM35
WordToStr(iLeituraAD, ucTexto); // Converte o valor lido no A/D em string
Lcd_Out(1,8,ucTexto); // Imprime no LCD o valor do Duty Cycle.
Lcd_Chr_CP(0); // Imprime simbolo de graus.
Lcd_Chr_CP('C'); // Unidade.
Delay_ms(100); // Delay de 0,1 segundo.
PORTC.RC1 = ~PORTC.RC1; // Alterna som do buzzer.
}
}
void GRAUS() {
char i;
const char character[] = {7,5,7,0,0,0,0,0}; // ARMAZENA SIMBOLO DE GRAUS.
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]);
}
|
ca436d386f4e91cd8936db2e53bd40c2e0407781
|
28fa372d86966d8d272fdbe8ef5f3af981101a92
|
/BSQ/includes/bsq_lib.h
|
186dfd7ed4f9185f27d16f1ee117fa801fc8241d
|
[] |
no_license
|
CRSylar/My-piscine-Experience
|
8e4f026738b5667e233f1700231e5142b6f60af4
|
31f9cbe7ea52272888a738cb047f82412f7a51cd
|
refs/heads/main
| 2023-01-22T07:26:18.576800 | 2020-11-16T12:50:44 | 2020-11-16T12:50:44 | 313,290,124 | 2 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,489 |
h
|
bsq_lib.h
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* library.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: etaranti <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/10 09:15:10 by etaranti #+# #+# */
/* Updated: 2020/11/11 20:49:01 by etaranti ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BSQ_LIB_H
# define BSQ_LIB_H
# include <unistd.h>
# include <stdlib.h>
# include <fcntl.h>
char g_full;
char g_obst;
char g_empty;
int g_row;
int **g_board;
int ft_atoi(char *str);
void ft_putchar(char c);
void ft_putstr(char *str);
int ft_rowlen(char *str, int fd);
int ft_strerror(void);
int ft_setok(void);
int ft_lsrow(int fd, char *file);
int ft_fullboard(int len, int fd);
void ft_printboard(int len);
int ft_charsafe(char c, int *col, int len, int *row);
void ft_findsquare(int col);
void ft_spcase(int *max, int col);
int ft_checklen(int *j, int len, int *i);
#endif
|
a3567a67c43758f957bb67ae54927c79a971f847
|
0e5d57f19081b7c811f7785a3a820fdff3dcbc79
|
/lesson2/led.c
|
c37d733a9e71edbf2a62c2c409efa5d42ca2d8ea
|
[] |
no_license
|
reV0us/20009100841
|
c0123616cc36fab9b6d91fc7aca1c2be294f990a
|
e7dd3248e0b021c208909ad43977c789ba4432b8
|
refs/heads/main
| 2023-06-27T00:06:23.374648 | 2021-07-31T03:54:20 | 2021-07-31T03:54:20 | 384,704,134 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 478 |
c
|
led.c
|
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
byte i;
void loop()
{
for(i=9;i>=2;i--)
{
digitalWrite(i, HIGH);
delay(100); // Wait for 1000 millisecond(s)
digitalWrite(i, LOW);
}
for(i=2;i<=9;i++)
{
digitalWrite(i, HIGH);
delay(100); // Wait for 1000 millisecond(s)
digitalWrite(i, LOW);
}
}
|
58ad29cbb91f4e0e54371655b2de1c36e10d74f8
|
563fa7b69ff7f9d517a81892f57af98242dda34c
|
/Exerc7.c
|
ad52df218c4d67b221eb2fed0de92f623ba75be0
|
[] |
no_license
|
yokaiw/ListadeExercicios-20_05
|
6d97c13f079ec95af5d0e1d592c270460528c491
|
f9c54b08122db68f994f2f12157cdc339e30e235
|
refs/heads/main
| 2023-05-30T20:50:11.185909 | 2021-06-01T19:50:54 | 2021-06-01T19:50:54 | 372,945,327 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 586 |
c
|
Exerc7.c
|
#include <stdio.h>
/*
Faça um algoritmo que solicite dois números ao usuário e exiba apenas o maior deles. Caso eles sejam
iguais exiba a mensagem “Números Iguais”.
*/
int main (){
int numero1, numero2;
printf("Digite o primeiro numero: ");
scanf("%d", &numero1);
printf("Digite o segundo numero: ");
scanf("%d", &numero2);
if( numero1 > numero2){
printf("%d ", numero1);
}
else if(numero2 > numero1){
printf("%d", numero2);
}
else{
printf("Os numeros sao iguais");
}
return 0;
}
|
95162cefb239f7e339ec4d251633ed27f6a46212
|
b91115a475d4e73f9a614149ef03e1e04a826f5b
|
/cmds/adm/_mesgfix.c
|
3cc587f91768212bc6edba4a4231a71e6ad691cd
|
[] |
no_license
|
MudRen/tmi-2
|
c09355531aaa2d97fb379005808c3ffb624c5038
|
ce6129518d798ce6d36e1be32f3080d46b244501
|
refs/heads/master
| 2023-08-24T09:37:46.981845 | 2021-09-30T02:36:46 | 2021-09-30T02:36:46 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,163 |
c
|
_mesgfix.c
|
// This must be run AFTER you install mail_package.c, data.c
// and then update simul_efun.c
//
#define WHO (find_player( "inspiral" ))
#define TELL(x) if( WHO ) tell_object( WHO, x + "\n");
#include <mudlib.h>
#include <mailer.h>
inherit DAEMON;
int cmd_mesgfix( string x ) {
int i;
string *list;
if( to_int( x ) < 0 || to_int( x ) > 9 )
return notify_fail( "0 - 9 please.\n" );
printf( "%s\n", x );
list = get_dir( MESGDIR + x + "/*.o" );
i = sizeof( list );
while( i-- )
call_out( "move_em", 2+ (2*i), list[i], x );
return 1;
}
void move_em( string f, string dir ) {
string x, y;
x = MESGDIR + dir + "/" + f ;
y = mail_mesg_file( f ) + __SAVE_EXTENSION__;
TELL( "Moving: " + x + " to " + y );
rename( x, y );
}
string help() {
return(
"Command: mesgfix\n"
"Syntax: mesgfix [0-9]\n\n"
"This command moves mailmesg files (1.1.1 mailer form) to the new (1.1.2)\n"
"directory format. This command should be run in such a fashion:\n\n"
"> mesgfix 0\n"
"(Wait until it is complete)\n"
"> mesgfix 1\n"
"...etc thru 9\n"
"\nIt is recommended that you set the WHO debug macro to the admin\n"
"initiating the command.\n" );
}
|
99b6d79e7ca91c8e19a148dd7c3173ba54464ad1
|
b725ba18b99398ce8459b8877691135e0cdf4d51
|
/uisimulator/buttonmap/ipod.c
|
1fc95d8dd1809c6b311f3662414b8418ff889f12
|
[
"BSD-3-Clause"
] |
permissive
|
Rockbox-Chinese-Community/Rockbox-RCC
|
8d3069271d14144281a40694c60128cac852cd3a
|
a701aefe45f03ca391a8e2f1a6e3da1b8774b2f2
|
refs/heads/lab-general
| 2020-12-01T22:59:14.427025 | 2017-04-29T06:17:24 | 2017-04-29T06:17:24 | 1,565,842 | 29 | 16 |
NOASSERTION
| 2019-03-21T03:45:53 | 2011-04-04T06:19:32 |
C
|
UTF-8
|
C
| false | false | 5,305 |
c
|
ipod.c
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2006 by Barry Wardell
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <SDL.h>
#include "button.h"
#include "config.h"
#include "buttonmap.h"
int key_to_button(int keyboard_button)
{
int new_btn = BUTTON_NONE;
switch (keyboard_button)
{
case SDLK_KP4:
case SDLK_LEFT:
new_btn = BUTTON_LEFT;
break;
case SDLK_KP6:
case SDLK_RIGHT:
new_btn = BUTTON_RIGHT;
break;
case SDLK_KP8:
case SDLK_UP:
new_btn = BUTTON_SCROLL_BACK;
break;
case SDLK_KP2:
case SDLK_DOWN:
new_btn = BUTTON_SCROLL_FWD;
break;
case SDLK_KP_PLUS:
case SDLK_F8:
new_btn = BUTTON_PLAY;
break;
case SDLK_KP5:
case SDLK_SPACE:
new_btn = BUTTON_SELECT;
break;
case SDLK_KP_PERIOD:
case SDLK_INSERT:
new_btn = BUTTON_MENU;
break;
case SDL_BUTTON_WHEELUP:
new_btn = BUTTON_SCROLL_BACK;
break;
case SDL_BUTTON_WHEELDOWN:
new_btn = BUTTON_SCROLL_FWD;
break;
}
return new_btn;
}
struct button_map bm[] = {
#if defined (IPOD_VIDEO)
{ SDLK_KP_PERIOD, 174, 350, 35, "Menu" },
{ SDLK_KP8, 110, 380, 33, "Scroll Back" },
{ SDLK_KP2, 234, 377, 34, "Scroll Fwd" },
{ SDLK_KP4, 78, 438, 47, "Left" },
{ SDLK_KP5, 172, 435, 43, "Select" },
{ SDLK_KP6, 262, 438, 52, "Right" },
{ SDLK_KP_PLUS, 172, 519, 43, "Play" },
#elif defined (IPOD_MINI) || defined(IPOD_MINI2G)
{ SDLK_KP5, 92, 267, 29, "Select" },
{ SDLK_KP4, 31, 263, 37, "Left" },
{ SDLK_KP6, 150, 268, 33, "Right" },
{ SDLK_KP_PERIOD, 93, 209, 30, "Menu" },
{ SDLK_KP_PLUS, 93, 324, 25, "Play" },
{ SDLK_KP8, 53, 220, 29, "Scroll Back" },
{ SDLK_KP2, 134, 219, 31, "Scroll Fwd" },
#elif defined (IPOD_3G)
{ SDLK_KP5, 108, 296, 26, "Select" },
{ SDLK_KP8, 70, 255, 26, "Scroll Back" },
{ SDLK_KP2, 149, 256, 28, "Scroll Fwd" },
{ SDLK_KP4, 27, 186, 22, "Left" },
{ SDLK_KP_PERIOD, 82, 185, 22, "Menu" },
{ SDLK_KP_PERIOD, 133, 185, 21, "Play" },
{ SDLK_KP6, 189, 188, 21, "Right" },
#elif defined (IPOD_4G)
{ SDLK_KP5, 96, 269, 27, "Select" },
{ SDLK_KP4, 39, 267, 30, "Left" },
{ SDLK_KP6, 153, 270, 27, "Right" },
{ SDLK_KP_PERIOD, 96, 219, 30, "Menu" },
{ SDLK_KP_PLUS, 95, 326, 27, "Play" },
{ SDLK_KP8, 57, 233, 29, "Scroll Back" },
{ SDLK_KP2, 132, 226, 29, "Scroll Fwd" },
#elif defined (IPOD_COLOR)
{ SDLK_KP5, 128, 362, 35, "Select" },
{ SDLK_KP4, 55, 358, 38, "Left" },
{ SDLK_KP6, 203, 359, 39, "Right" },
{ SDLK_KP_PERIOD, 128, 282, 34, "Menu" },
{ SDLK_KP_PLUS, 129, 439, 41, "Play" },
{ SDLK_KP8, 76, 309, 34, "Scroll Back" },
{ SDLK_KP2, 182, 311, 45, "Scroll Fwd" },
#elif defined (IPOD_1G2G)
{ SDLK_KP5, 112, 265, 31, "Select" },
{ SDLK_KP8, 74, 224, 28, "Scroll Back" },
{ SDLK_KP2, 146, 228, 28, "Scroll Fwd" },
/* Dummy button to make crescent shape */
{ SDLK_y, 112, 265, 76, "None" },
{ SDLK_KP8, 74, 224, 28, "Scroll Back" },
{ SDLK_KP2, 146, 228, 28, "Scroll Fwd" },
{ SDLK_KP6, 159, 268, 64, "Right" },
{ SDLK_KP4, 62, 266, 62, "Left" },
{ SDLK_KP_PERIOD, 111, 216, 64, "Menu" },
{ SDLK_KP_PLUS, 111, 326, 55, "Down" },
#elif defined (IPOD_NANO)
{ SDLK_KP5, 98, 316, 37, "Select" },
{ SDLK_KP4, 37, 312, 28, "Left" },
{ SDLK_KP6, 160, 313, 25, "Right" },
{ SDLK_KP_PERIOD,102, 256, 23, "Menu" },
{ SDLK_KP_PLUS, 99, 378, 28, "Play" },
{ SDLK_KP8, 58, 272, 24, "Scroll Back" },
{ SDLK_KP2, 141, 274, 22, "Scroll Fwd" },
#elif defined (IPOD_NANO2G)
{ SDLK_KP5, 118, 346, 37, "Select" },
{ SDLK_KP4, 51, 345, 28, "Left" },
{ SDLK_KP6, 180, 346, 26, "Right" },
{ SDLK_KP_PERIOD, 114, 286, 23, "Menu" },
{ SDLK_KP_PLUS, 115, 412, 27, "Down" },
{ SDLK_KP8, 67, 303, 28, "Scroll Back" },
{ SDLK_KP2, 163, 303, 27, "Scroll Fwd" },
#endif
{ 0, 0, 0 , 0, "None" }
};
|
5ab9f62004d184b38acecea67af8a16f64178049
|
d23b5678ca77c683f500ff4c123170b0d01e778d
|
/AmazonTop100Crawler/src/lxml/includes/lxml-version.h
|
4e47fa88f33510a8815e5963d42c180e1dbbe1ad
|
[] |
no_license
|
nicolasriousset/AmazonStats
|
ba544804e8397fbf1d6aef5f1cf8a697ac174afe
|
5a0e8bea7eee1aa20d38a03ca738759283d0ca47
|
refs/heads/master
| 2021-01-13T01:50:03.067930 | 2014-07-16T10:37:08 | 2014-07-16T10:37:08 | 18,785,740 | 2 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 74 |
h
|
lxml-version.h
|
#ifndef LXML_VERSION_STRING
#define LXML_VERSION_STRING "3.1.2"
#endif
|
46411851af1ff9f250c78d3e4afc509e41c675cf
|
8575f9754c2ec233815a490c89b4de99a8181d30
|
/Advanced_C/Project/LSB_Steganography/encode_raw.c
|
a26a697487bd6a9bfb465a20e1120b58312eb035
|
[] |
no_license
|
ShashiKumarMani/Emertxe
|
764cc0714e2eac8fd07c937a7971dbcec9367888
|
274e9c7a9211222c9955d6bbd137591756ba8281
|
refs/heads/master
| 2020-07-21T18:02:19.039897 | 2020-06-27T12:07:15 | 2020-06-27T12:07:15 | 206,938,034 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 15,062 |
c
|
encode_raw.c
|
#include <stdio.h>
#include <string.h>
#include "encode.h"
#include "types.h"
#include "common.h"
/* Function Definitions */
/* Get image size
* Input: Image file ptr
* Output: width * height * bytes per pixel (3 in case of RGB color image)
* Description: In BMP Image, width is stored in offset 18,
* and height after that. size is 4 bytes
* bpp is at offset 28, size is 2 bytes
*/
long get_image_size_for_bmp(EncodeInfo *encInfo)
{
FILE *fptr_src_image = encInfo->fptr_src_image; // Copy to local var. Just to shorten the code
uint width, height, size;
unsigned short bpp;
long img_size;
//Seek to 34 byte return image size in bytes.
// Seek to 18th byte
fseek(fptr_src_image, 18, SEEK_SET);
// Read the width (an int)
fread(&width, sizeof(int), 1, fptr_src_image);
//printf("width = %u\n", width);
// Read the height (an int)
fread(&height, sizeof(int), 1, fptr_src_image);
//printf("height = %u\n", height);
// Get bits per pixel
fseek(fptr_src_image, 28, SEEK_SET);
fread(&bpp, sizeof(short), 1, fptr_src_image);
//printf("bpp = %hu\n", bpp);
// Store values in encInfo
encInfo->width = width;
encInfo->height = height;
encInfo->bpp = bpp;
//fseek(encInfo->fptr_src_image, 34, SEEK_SET);
//fread(&size, sizeof(int), 1, encInfo->fptr_src_image);
//printf("img_size from 34 pos - %u\n", size);
img_size = width * height * bpp / 8; // Calculate image size
//printf("img_size - %ld\n", img_size);
return img_size;
}
/* Description: Open files
* Inputs: Source image filename, Secret filename and Stego Image file name
* Output: FILE pointers for above files
* Return Value:
* e_success - If all files are opened,
* e_failure - On file errors
*/
Status open_encode_files(EncodeInfo *encInfo)
{
printf("INFO : Opening required files.\n");
// Src Image file
encInfo->fptr_src_image = fopen(encInfo->src_image_fname, "rb");
//Do Error handling
if (encInfo->fptr_src_image == NULL)
{
perror("fopen");
fprintf(stderr, "ERROR: Unable to open file %s\n", encInfo->src_image_fname);
return e_failure;
}
printf("INFO : Opened Source file.\n");
// Secret file
encInfo->fptr_secret = fopen(encInfo->secret_fname, "rb");
//Do Error handling
if (encInfo->fptr_secret == NULL)
{
perror("fopen");
fprintf(stderr, "ERROR: Unable to open file %s\n", encInfo->secret_fname);
return e_failure;
}
printf("INFO : Secret file opened\n");
// Stego Image file
encInfo->fptr_stego_image = fopen(encInfo->stego_image_fname, "wb");
//Do Error handling
if (encInfo->fptr_stego_image == NULL)
{
perror("fopen");
fprintf(stderr, "ERROR: Unable to open file %s\n", encInfo->stego_image_fname);
return e_failure;
}
printf("INFO : Steg file opened\n");
// All files opened, return e_success
return e_success;
}
/*
Check type of operation
Input:Array of command line arguments
Ouput:Integer indicating type of operation
*/
OperationType check_operation_type(char *argv[])
{
//If first argument is encode
if(strcmp(argv[1],"-e") == 0)
{
return e_encode;
}
else if(strcmp(argv[1], "-d") == 0)
{
return e_decode;
}
else
{
return e_unsupported;
}
}
/*
Read and validate command line arguments.
Input: Command line arguments, Structure pointer.
Output: Validate args and return -e_success/e_failure.
*/
Status read_and_validate_encode_args(char *argv[], EncodeInfo *encInfo)
{
// Encoding - ./a.out -e beautiful.bmp secret.txt [steg.bmp]
char *ptr = NULL, *str = NULL, arr[2];
printf("INFO : Validating encode arguments...\n");
//Input image
if(argv[2])
{
//printf("argv[2] - %s\n", argv[2]);
encInfo->src_image_fname = argv[2];
ptr = strchr(argv[2], '.');
//printf("extension is %s\n", ptr);
//Check if file is bmp
if(strcmp(".bmp", ptr) != 0)
{
return e_failure;
}
}
//If no arg
else
{
return e_failure;
}
if(argv[3])
{
//printf("argv[3] - %s\n", argv[3]);
int i = 0;
encInfo->secret_fname = argv[3];
ptr = strchr(argv[3], '.');
//printf("Extension - %s\n", ptr);
//Assuming file extn is always less than 4 bytes - given value
for(i = 0;*(ptr + i) != '\0';i++)
{
//printf("%d - %c\n", i, *(ptr + i));
encInfo->extn_secret_file[i] = *(ptr + i);
}
//printf("extn size - %d\n", i);
//Extension length
encInfo->extn_size = i;
//printf("extn_secret_file - %s\n", encInfo->extn_secret_file);
//printf("After strcat - %s\n", argv[3]);
}
else
{
return e_failure;
}
if(argv[4])
{
//printf("argv[4] - %s\n", argv[4]);
encInfo->stego_image_fname = argv[4];
ptr = strchr(argv[4], '.');
//printf("Extension - %s\n", ptr);
if(strcmp(".bmp", ptr) != 0)
{
//If output file is not bmp
return e_failure;
}
//printf("After strcat - %s\n", argv[4]);
return e_success;
}
else
{
//Default name
encInfo->stego_image_fname = "steg_def.bmp";
//printf("Def - name - %s\n", encInfo->stego_image_fname);
return e_success;
}
}
/*
Check image capacity to hold secret file
Input: Structure pointer
Output: validate and return success/failure.
*/
Status check_capacity(EncodeInfo *encInfo)
{
//Find image size
long image_size = get_image_size_for_bmp(encInfo);
//printf("Image size - %ld\n", image_size);
encInfo->size_secret_file = get_file_size(encInfo->fptr_secret);
//printf("File size - %ld\n", encInfo->size_secret_file);
// If image size >= all_data * 8
if(image_size >= ((strlen(MAGIC_STRING) + sizeof(encInfo->extn_size) + strlen(encInfo->extn_secret_file) + sizeof(encInfo->size_secret_file) + encInfo->size_secret_file + 2)* 8))
{
return e_success;
}
else
{
return e_failure;
}
}
/*
Get secret file size
Input: File pointer of secret file
Output: Length of the file.
*/
long get_file_size(FILE *fptr)
{
//printf("=========get file size ==============\n");
char ch;
long count = 0;
//Loop till EOF
while((ch = fgetc(fptr)) != EOF)
{
count++;
}
return count;
}
/*
Copy 54 bytes header to destination file.
Input: File pointer to source and destination files.
Output: Copy header and return success/failure.
*/
Status copy_bmp_header(FILE *fptr_src_image, FILE *fptr_dest_image)
{
//printf("==============Copy image header==============\n");
char ch[54];
if(fseek(fptr_src_image, 0L, SEEK_SET) == -1 && fseek(fptr_dest_image, 0L, SEEK_SET) == -1)
{
return e_failure;
}
fread(ch, 54, 1, fptr_src_image);
fwrite(ch, 54, 1, fptr_dest_image);
//printf("Header written -\n");
//printf("file 1 point - %ld\n", ftell(fptr_src_image));
//printf("file 2 point - %ld\n", ftell(fptr_dest_image));
return e_success;
}
/*
Function to encode 1byte into lsb's of 8bytes
Input: Data to be encoded, 8 byte image data.
Output: The data is encoded into 8 bytes.
*/
Status encode_byte_to_lsb(char data, char *image_buffer)
{
unsigned char mask = 1;
for(int i = 0;i < 8;i++)
{
image_buffer[i] = (data >> 7 - i) & 1 | (image_buffer[i] & ~mask);
}
}
/*
Encode magic string.
Input: Magic string and structure pointer.
Output: magic string is encoded.
*/
Status encode_magic_string(const char *magic_string, EncodeInfo *encInfo)
{
//printf("============Encode magic string ================\n");
//printf("Encode magic string\n");
//printf("---fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//If the source and dest file are not in same location
if(ftell(encInfo->fptr_src_image) != ftell(encInfo->fptr_stego_image))
{
return e_failure;
}
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//Encode magic string
for(int i = 0;i < (int)strlen(magic_string);i++)
{
//printf("i - %d - %c\n", i, *(magic_string + i));
//Read 8 bytes
fread(encInfo->image_data, 8, 1, encInfo->fptr_src_image);
encode_byte_to_lsb(*(magic_string + i), encInfo->image_data);
fwrite(encInfo->image_data, 8, 1, encInfo->fptr_stego_image);
}
//Write null character
//fread(encInfo->image_data, 8, 1, encInfo->fptr_src_image);
//encode_byte_to_lsb(0, encInfo->image_data);
//fwrite(encInfo->image_data, 8, 1, encInfo->fptr_stego_image);
return e_success;
}
/*
Encode secret file extension.
Input: File extension, structure pointer.
Output: Encode extn into destination file.
*/
Status encode_secret_file_extn(const char *file_extn, EncodeInfo *encInfo)
{
//printf("============Encode secret file extn===============\n");
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//printf("----fptr_stego - %ld\n", ftell(encInfo->fptr_stego_image));
//Encode extension length - max len - 255
fread(encInfo->image_data, 8, 1, encInfo->fptr_src_image);
encode_byte_to_lsb((char)encInfo->extn_size, encInfo->image_data);
fwrite(encInfo->image_data, 8, 1, encInfo->fptr_stego_image);
//Encode magic string
for(int i = 0;i < encInfo->extn_size;i++)
{
//printf("i - %d - %c\n", i, *(file_extn + i));
//Read 8 bytes
fread(encInfo->image_data, 8, 1, encInfo->fptr_src_image);
encode_byte_to_lsb(*(file_extn + i), encInfo->image_data);
fwrite(encInfo->image_data, 8, 1, encInfo->fptr_stego_image);
}
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//printf("----fptr_stego - %ld\n", ftell(encInfo->fptr_stego_image));
return e_success;
}
/*
Encode secret file size.
Input: Long integer -file size, Structure pointer.
Ouput: Encode file size and return e_success/e_failure.
*/
Status encode_secret_file_size(long file_size, EncodeInfo *encInfo)
{
//printf("========Encode secret file size==============\n");
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//printf("----fptr_steg- %ld\n", ftell(encInfo->fptr_stego_image));
//If file is empty
if(file_size <= 0)
{
return e_failure;
}
//printf("File - size - %ld\n", file_size);
//Error
char *ptr = (char *)&file_size;
for(int i = 0;i < (int)sizeof(long);i++)
{
fread(encInfo->image_data, 8, 1, encInfo->fptr_src_image);
//printf("Encoding - size - %d\n", *(ptr + i));
encode_byte_to_lsb(*(ptr + i), encInfo->image_data);
fwrite(encInfo->image_data, 8, 1, encInfo->fptr_stego_image);
}
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//printf("----fptr_steg- %ld\n", ftell(encInfo->fptr_stego_image));
return e_success;
}
/*
Encode secret file data into the destination image
Input : Structure pointer.
Output: Encode secret data into destination file and return e_success/e_failure.
*/
Status encode_secret_file_data(EncodeInfo *encInfo)
{
//printf("==========Encode secret file data============\n");
char ch;
fseek(encInfo->fptr_secret, 0L, SEEK_SET);
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//printf("----fptr_steg- %ld\n", ftell(encInfo->fptr_stego_image));
//printf("----fptr_secret - %ld\n", ftell(encInfo->fptr_secret));
for(int i = 0;i < encInfo->size_secret_file;i++)
{
//Read char from secret file
ch = fgetc(encInfo->fptr_secret);
//Read byte 8 bytes from image, encode char, write to steg file
fread(encInfo->image_data, 8, 1, encInfo->fptr_src_image);
//printf("Encoding - %d to image\n", ch);
encode_byte_to_lsb(ch, encInfo->image_data);
fwrite(encInfo->image_data, 8, 1, encInfo->fptr_stego_image);
}
//printf("----fptr_src - %ld\n", ftell(encInfo->fptr_src_image));
//printf("----fptr_steg- %ld\n", ftell(encInfo->fptr_stego_image));
return e_success;
}
Status encode_data_to_image(char *data, int size, FILE *fptr_src_image, FILE *fptr_stego_image)
{
}
/*
Copy remaing data into destination image
Input : File pointers to source and destination images.
Output: Copy remaining image data into destination image.
*/
Status copy_remaining_imag_data(FILE *fptr_src, FILE *fptr_dest)
{
//printf("============Copy remaining image data===============\n");
long pres, end, i;
char ch;
//printf("----fptr_src - %ld\n", ftell(fptr_src));
//printf("----fptr_steg- %ld\n", ftell(fptr_dest));
//Find the length of remaining bytes
pres = ftell(fptr_src);
//printf("pres - %ld\n", pres);
fseek(fptr_src, 0L, SEEK_END);
end = ftell(fptr_src);
//printf("end - %ld\n", end);
//Bring the pointer to the previous location
fseek(fptr_src, pres, SEEK_SET);
//printf("after fseek - %ld\n", ftell(fptr_src));
//Copy byte- from current pos to end
for(i = pres;i < end;i++)
{
fread(&ch, 1, 1, fptr_src);
fwrite(&ch, 1, 1, fptr_dest);
}
//printf("----fptr_src - %ld\n", ftell(fptr_src));
//printf("----fptr_steg- %ld\n", ftell(fptr_dest));
return e_success;
}
Status do_encoding(EncodeInfo *encInfo)
{
printf("INFO : Encoding started.\n");
//Open files
if(open_encode_files(encInfo) == e_success)
{
printf("INFO : Open_files success\n");
}
else
{
printf("ERROR : Open_files failure\n");
return e_failure;
}
if(check_capacity(encInfo) == e_success)
{
printf("INFO : Image has capacity to hold secret data.\n");
}
else
{
printf("ERROR : Image capacity error\n");
return e_failure;
}
if(copy_bmp_header(encInfo->fptr_src_image, encInfo->fptr_stego_image) == e_success)
{
printf("INFO : Header copied\n");
}
else
{
printf("ERROR : Copy image header\n");
return e_failure;
}
if(encode_magic_string(MAGIC_STRING, encInfo) == e_success)
{
printf("INFO : Magic String encoded\n");
}
else
{
printf("ERROR : Encode magic string\n");
return e_failure;
}
if(encode_secret_file_extn(encInfo->extn_secret_file, encInfo) == e_success)
{
printf("INFO : Secret file extension encoded\n");
}
else
{
printf("ERROR : Secret file extension\n");
return e_failure;
}
if(encode_secret_file_size(encInfo->size_secret_file, encInfo) == e_success)
{
printf("INFO : Secret file size encoded\n");
}
else
{
printf("ERROR : Secret file size.\n");
return e_failure;
}
if(encode_secret_file_data(encInfo) == e_success)
{
printf("INFO : Secret file encoded\n");
fclose(encInfo->fptr_secret);
}
else
{
printf("ERROR : Encode Secret file data\n");
return e_failure;
}
if(copy_remaining_imag_data(encInfo->fptr_src_image, encInfo->fptr_stego_image) == e_success)
{
printf("INFO : Remaining data copied\n");
fclose(encInfo->fptr_src_image);
fclose(encInfo->fptr_stego_image);
}
else
{
printf("ERROR : Copy remaining data\n");
return e_failure;
}
}
|
b0b4f34d9b8b5e328831b0050a6e11939c32162a
|
1a452d289519068d5370204410bd43182ae3c3e3
|
/geoff/internals/mem/gdt.c
|
1fb5d1e02e434d197a8a0b53efa71a809c962f7f
|
[] |
no_license
|
akrs/cmsi387
|
b4f85190f840e48a21e833b8c6992b918506b910
|
34aff97b2b2c965367f7d4a9ad35b4ca52cafff0
|
refs/heads/master
| 2016-09-11T02:39:36.077548 | 2015-03-24T23:35:40 | 2015-03-24T23:35:40 | 29,322,229 | 1 | 0 | null | 2015-03-24T23:35:56 | 2015-01-15T22:51:28 |
C
|
UTF-8
|
C
| false | false | 1,635 |
c
|
gdt.c
|
#include <stdint.h>
#include "setgdt.h"
struct GDT {
uint32_t base;
uint32_t limit;
uint8_t type;
};
/**
* \param target A pointer to the 8-byte GDT entry
* \param source An arbitrary structure describing the GDT entry
*/
void encode_gdt_entry(uint8_t *target, struct GDT source) {
// Check the limit to make sure that it can be encoded
if (source.limit > 65536) {
// Adjust granularity if required
source.limit = source.limit >> 12;
target[6] = 0xC0;
} else {
target[6] = 0x40;
}
// Encode the limit
target[0] = source.limit & 0xFF;
target[1] = (source.limit >> 8) & 0xFF;
target[6] |= (source.limit >> 16) & 0xF;
// Encode the base
target[2] = source.base & 0xFF;
target[3] = (source.base >> 8) & 0xFF;
target[4] = (source.base >> 16) & 0xFF;
target[7] = (source.base >> 24) & 0xFF;
// And... Type
target[5] = source.type;
}
uint64_t global_descriptor_table[4];
void gdt_load() {
struct GDT source[4];
source[0].base=0;
source[0].limit=0;
source[0].type=0; // Selector 0x00 cannot be used
source[1].base=0;
source[1].limit=0xffffffff;
source[1].type=0x9A; // Selector 0x08 will be our code
source[2].base=0;
source[2].limit=0xffffffff;
source[2].type=0x92; // Selector 0x10 will be our data
// TODO: Task State Segment after we get context swtiching stuff
for (int i = 0; i < 4; i++) {
encode_gdt_entry((uint8_t*)&global_descriptor_table[i], source[i]);
}
set_gdt(&global_descriptor_table, sizeof(global_descriptor_table));
}
|
1f701e4cec1401e285fc6268cb3fa68c809d845f
|
31f449e61b3c45659d2c2ed21204960b2ad64421
|
/c/ws7/ws2_arch/ws2_string_test.c
|
c282b9cb05e740b5d2bd5aa0c0fe70d11b9b2913
|
[] |
no_license
|
MedulaOblogota/yap
|
62ae0745a82e8507fa1dbb746846bcc09cdac601
|
5396401cca1f304aed00bb43627abf2a0b9b927e
|
refs/heads/master
| 2023-06-07T04:19:53.780118 | 2021-06-21T10:13:58 | 2021-06-21T10:13:58 | 370,606,403 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 11,965 |
c
|
ws2_string_test.c
|
/********************************************************************/
/* */
/* Name: Roy Yablonka */
/* Reviewer: Eliav */
/* Version: Sent */
/* Title: WS2_STRING Test File */
/* */
/********************************************************************/
#include <stdio.h>
#include <string.h> /* to check against my functions */
#include <strings.h>
#include <stdlib.h>
#include "ws2_string.h"
/********************************************************************/
/* */
/* Function Declarations */
/* */
/********************************************************************/
void TestStrLen();
void TestStrCmp();
void TestStrCpy();
void TestStrNCpy();
void TestStrCaseCmp();
void TestStrChr();
void TestStrDup();
void TestStrCat();
void TestStrNCat();
void TestStrStr();
void TestStrSpn();
void TestStrTok();
/********************************************************************/
/* */
/* Main Function */
/* */
/********************************************************************/
int main()
{
TestStrLen();
TestStrCmp();
TestStrCpy();
TestStrNCpy();
TestStrCaseCmp();
TestStrChr();
TestStrDup();
TestStrCat();
TestStrNCat();
TestStrStr();
TestStrSpn();
TestStrTok();
return(1);
}
/********************************************************************/
/* */
/* Function Definitions */
/* */
/********************************************************************/
void TestStrLen()
{
char str1[] = "HelloWorld";
char str2[] = "a";
char str3[] = "";
printf("StrLen -> ");
if (strlen(str1) != StrLen(str1))
printf("1. %s DOESNT WORK\n", str1);
if (strlen(str2) != StrLen(str2))
printf("2. %s DOESNT WORK\n", str2);
if (strlen(str3) != StrLen(str3))
printf("3. %s DOESNT WORK\n", str3);
printf("\n");
}
void TestStrCmp()
{
char str1[] = "Hello";
char str2[] = "man";
char str3[] = "MaN";
char str4[] = "";
char str5[] = "Hellooo";
printf("StrCmp -> ");
if (StrCmp(str1,str2) != strcmp(str1,str2))
printf("1. %s with %s DOESNT WORK\n", str1, str2);
if (StrCmp(str1,str3) != strcmp(str1,str3))
printf("2. %s with %s DOESNT WORK\n", str1, str3);
if (StrCmp(str1,str4) != strcmp(str1,str4))
printf("3. %s with %s DOESNT WORK\n", str1, str4);
if (StrCmp(str1,str5) != strcmp(str1,str5))
printf("4. %s with %s DOESNT WORK\n", str1, str5);
if (StrCmp(str3,str2) != strcmp(str3,str2))
printf("5. %s with %s DOESNT WORK\n", str3, str2);
if (StrCmp(str4,str5) != strcmp(str4,str5))
printf("6. %s with %s DOESNT WORK\n", str4, str5);
if (StrCmp(str4,str3) != strcmp(str4,str3))
printf("7. %s with %s DOESNT WORK\n", str4, str3);
printf("\n");
}
void TestStrCpy()
{
char str1[] = "HelloWorld";
char str2[] = "";
char str3[20];
printf("StrCpy -> ");
if (0 != StrCmp(StrCpy(str3, str1), strcpy(str3, str1)))
printf("1. %s DOESNT WORK\n", str3);
if (0 != StrCmp(StrCpy(str3, str2), strcpy(str3, str2)))
printf("2. %s DOESNT WORK\n", str2);
printf("\n");
}
void TestStrNCpy()
{
char str1[] = "HelloWorld";
char str2[] = "";
char str3[20];
printf("StrNCpy -> ");
if (0 != StrCmp(StrNCpy(str3, str1, 0), strncpy(str3, str1, 0)))
printf("1. %s and %s and 0 DOESNT WORK\n", str3, str1);
if (0 != StrCmp(StrNCpy(str3, str2, 0), strncpy(str3, str2, 0)))
printf("2. %s and %s and 0 DOESNT WORK\n", str3, str2);
if (0 != StrCmp(StrNCpy(str3, str2, 4), strncpy(str3, str2, 4)))
printf("3. %s and %s and 4 DOESNT WORK\n", str3, str2);
if (0 != StrCmp(StrNCpy(str3, str1, 12), strncpy(str3, str1, 12)))
printf("4. %s and %s and 12 DOESNT WORK\n", str3, str1);
printf("\n");
}
void TestStrCaseCmp()
{
char str1[] = "hEllO";
char str2[] = "helLo";
char str3[] = "";
char str4[] = "hello Buddy";
printf("StrCaseCmp -> ");
if (StrCaseCmp(str1, str2) != strcasecmp(str1,str2))
printf("1. %s and %s DOESNT WORK\n", str1, str2);
if (StrCaseCmp(str1, str3) != strcasecmp(str1,str3))
printf("2. %s and %s DOESNT WORK\n", str1, str3);
if (StrCaseCmp(str1, str4) != strcasecmp(str1,str4))
printf("3. %s and %s DOESNT WORK\n", str1, str4);
if (StrCaseCmp(str4, str2) != strcasecmp(str4,str2))
printf("4. %s and %s DOESNT WORK\n", str4, str2);
printf("\n");
}
void TestStrChr()
{
char str1[] = "hello";
char str2[] = "";
char c1 = 'e';
char c2 = 'd';
printf("StrChr -> ");
if ((StrChr(str1, c1) != NULL) && (strchr(str1, c1) != NULL))
if (0 != StrCmp(StrChr(str1, c1), strchr(str1, c1)))
printf("1. %s and %c DOESNT WORK\n", str1, c1);
if ((StrChr(str1, c2) != NULL) && (strchr(str1, c2) != NULL))
if (0 != StrCmp(StrChr(str1, c2), strchr(str1, c2)))
printf("2. %s and %c DOESNT WORK\n", str1, c2);
if ((StrChr(str2, c1) != NULL) && (strchr(str2, c1) != NULL))
if (0 != StrCmp(StrChr(str2, c1), strchr(str2, c1)))
printf("3. %s and %c DOESNT WORK\n", str2, c1);
printf("\n");
}
void TestStrDup()
{
char str1[] = "hello";
char str2[] = "";
char str3[] = "a";
printf("StrDup -> ");
if (0 != StrCmp(StrDup(str1), strdup(str1)))
printf("1. %s DOESNT WORK\n", str1);
if (0 != StrCmp(StrDup(str2), strdup(str2)))
printf("2. %s DOESNT WORK\n", str2);
if (0 != StrCmp(StrDup(str3), strdup(str3)))
printf("3. %s DOESNT WORK\n", str3);
printf("\n");
}
void TestStrCat()
{
char str1[]="hello";
char str2[]="man";
char str3[] = "man";
char str4[]="";
char str5[] = "";
char str6[] = "";
printf("StrCat -> ");
if (0 != StrCmp(StrCat(str2, str1), strcat(str2, str1)))
printf("1. %s and %s DOESNT WORK\n", str2, str1);
if (0 != StrCmp(StrCat(str3, str4), strcat(str3, str4)))
printf("2. %s and %s DOESNT WORK\n", str3, str4);
if (0 != StrCmp(StrCat(str5, str6), strcat(str5, str6)))
printf("3. %s and %s DOESNT WORK\n", str5, str6);
printf("\n");
}
void TestStrNCat()
{
char str1[]="hello";
char str2[]="man";
char str3[] = "man";
char str4[]="";
char str5[] = "";
char str6[] = "";
printf("StrNCat -> ");
if (0 != StrCmp(StrNCat(str2, str1,3), strncat(str2, str1,3)))
printf("1. %s and %s and 3 DOESNT WORK\n", str2, str1);
if (0 != StrCmp(StrNCat(str3, str4,2), strncat(str3, str4,2)))
printf("2. %s and %s and 2 DOESNT WORK\n", str3, str4);
if (0 != StrCmp(StrNCat(str5, str6,7), strncat(str5, str6,7)))
printf("3. %s and %s and 7 DOESNT WORK\n", str5, str6);
printf("\n");
}
void TestStrStr()
{
char str1[] = "hello man man";
char str2[] = "mann";
char str3[] = "man";
char str4[] = "hi my friend";
char str5[] = "my";
char str6[] = "Something";
char str7[] = "";
char str8[] = "y";
printf("StrStr -> ");
/*printf("StrStr for %s and %s is %s\n", str1, str2, StrStr(str1, str2));
printf("strstr for %s and %s is %s\n", str1, str2, strstr(str1, str2));*/
/*printf("StrStr(%s, %s) = %s\n", str6, str7, StrStr(str6, str7));*/
if ((NULL != StrStr(str1, str2)) && (NULL != strstr(str1, str2)))
if (0 != StrCmp(StrStr(str1, str2), strstr(str1, str2)))
printf("1. %s and %s DOESNT WORK\n", str1, str2);
if ((NULL != StrStr(str1, str3)) && (NULL != strstr(str1, str3)))
if (0 != StrCmp(StrStr(str1, str3), strstr(str1, str3)))
printf("2. %s and %s DOESNT WORK\n", str1, str2);
if ((NULL != StrStr(str4, str5)) && (NULL != strstr(str4, str5)))
if (0 != StrCmp(StrStr(str4, str5), strstr(str4, str5)))
printf("3. %s and %s DOESNT WORK\n", str4, str5);
if ((NULL != StrStr(str2, str3)) && (NULL != strstr(str2, str3)))
if (0 != StrCmp(StrStr(str2, str3), strstr(str2, str3)))
printf("4. %s and %s DOESNT WORK\n", str2, str3);
if ((NULL != StrStr(str6, str7)) && (NULL != strstr(str6, str7)))
if (0 != StrCmp(StrStr(str6, str7), strstr(str6, str7)))
printf("5. %s and %s DOESNT WORK\n", str6, str7);
if ((NULL != StrStr(str6, str8)) && (NULL != strstr(str6, str8)))
if (StrStr(str6, str8) != strstr(str6, str8))
printf("6. %s and %s DOESNT WORK\n", str6, str8);
printf("\n");
}
void TestStrSpn()
{
char str1[] = "my man wassup?";
char str2[] = "m yn";
char str3[] = "";
char str4[] = "this is my site";
char str5[] = " ts.ith";
char str6[] = "a.";
char str7[] = "";
printf("StrSpn -> ");
if (StrSpn(str1, str2) != strspn(str1, str2))
printf("1. %s and %s DOESNT WORK\n", str1, str2);
if (StrSpn(str1, str3) != strspn(str1, str3))
printf("2. %s and %s DOESNT WORK\n", str1, str3);
if (StrSpn(str2, str3) != strspn(str2, str3))
printf("3. %s and %s DOESNT WORK\n", str2, str3);
if (StrSpn(str4, str5) != strspn(str4, str5))
printf("4. %s and %s DOESNT WORK\n", str4, str5);
if (StrSpn(str3, str6) != strspn(str3, str6))
printf("5. %s and %s DOESNT WORK\n", str3, str6);
if (StrSpn(str3, str7) != strspn(str3, str7))
printf("6. %s and %s DOESNT WORK\n", str3, str7);
printf("\n");
}
void TestStrTok()
{
char Str1[] = "this. i.s - y.net - .website";
char Str2[] = "$-^.";
char str1[] = "this. i.s - y.net - .website";
char str2[] = "$-^.";
char Str4[] = "Hello. my - fri.end-";
char Str5[] = ".l-";
char str4[] = "Hello. my - fri.end-";
char str5[] = ".l-";
char Str7[] = "one-two-three";
char Str8[] = "-";
char str7[] = "one-two-three";
char str8[] = "-";
char *Str3 = StrTok(Str1, Str2);
char *str3 = strtok(str1, str2);
char *Str6 = StrTok(Str4, Str5);
char *str6 = strtok(str4, str5);
char *Str9 = StrTok(Str7, Str8);
char *str9 = strtok(str7, str8);
printf("StrTok -> ");
printf("%s\n", StrTok(Str1, Str2));
printf("%s\n", StrTok(NULL, Str2));
printf("%s\n", StrTok(NULL, Str2));
while (Str9 != NULL)
{
Str9 = StrTok(NULL, Str8);
str9 = strtok(NULL, str8);
if ((Str9 != NULL) && (str9 != NULL))
if (strcmp(Str9, str9) != 0)
printf("DIDNT WORK");
}
while (Str3 != NULL)
{
Str3 = StrTok(NULL, Str2);
str3 = strtok(NULL, str2);
if ((Str3 != NULL) && (str3 != NULL))
if (strcmp(Str3, str3) != 0)
printf("DIDNT WORK");
}
while (Str6 != NULL)
{
Str6 = StrTok(NULL, Str5);
str6 = strtok(NULL, str5);
if ((Str6 != NULL) && (str6 != NULL))
if (strcmp(Str5, str5) != 0)
printf("DIDNT WORK");
}
/*
if (StrCmp(Str9, str9) != 0)
printf("DIDNT WORK");
Str9 = StrTok(NULL, Str8);
str9 = strtok(NULL, str8);
if (StrCmp(Str9, str9) != 0)
printf("DIDNT WORK");
Str9 = StrTok(NULL, Str8);
str9 = strtok(NULL, str8);
if (StrCmp(Str9, str9) != 0)
printf("DIDNT WORK");
Str9 = StrTok(NULL, Str8);
str9 = strtok(NULL, str8);
if (strcmp(Str9, str9) != 0)
printf("DIDNT WORK");
*/
/*Str9 = StrTok(NULL, Str8);
str9 = strtok(NULL, str8);
if (StrCmp(Str9, str9) != 0)
printf("DIDNT WORK"); */
/*int counter = 1;
int counter2 = 1;
int counter3 = 1;
printf("StrTok -> \n");
if (StrCmp(Str3, str3) != 0)
{
printf("%d. DIDNT WORK\n", counter);
++counter;
}
if (StrCmp(Str6, str6) != 0)
{
printf("%d. DIDNT WORK\n", counter2);
++counter2;
}
if (StrCmp(Str9, str9) != 0)
{
printf("%d. DIDNT WORK\n", counter3);
++counter3;
}
while ((str3 != NULL) && (Str3 != NULL))
{
Str3 = StrTok(NULL, Str2);
str3 = strtok(NULL, str2);
Str6 = StrTok(NULL, Str5);
str6 = strtok(NULL, str5);
Str9 = StrTok(NULL, Str8);
str9 = strtok(NULL, str8);
if ((Str3 != NULL) && (str3 != NULL))
if ((StrCmp(Str3, str3) != 0))
{
printf("%d. DIDNT WORK\n", counter);
++counter;
}
if ((Str6 != NULL) && (str6 != NULL))
if ((StrCmp(Str6, str6) != 0))
{
printf("%d. DIDNT WORK\n", counter2);
++counter2;
}
if ((Str9 != NULL) && (str9 != NULL))
if ((StrCmp(Str9, str9) != 0))
{
printf("%d. DIDNT WORK\n", counter2);
++counter2;
}
}*/
}
|
9f5d5a1b2f436808acb83ac33cea52269eee6aab
|
3aa0ee48aa17c9c3c0885a65bf7c15ca1d93ddf0
|
/guitar_tuner.X/tuner_display.c
|
c2534995d5998653f80f1823a8f84dcff206d0ce
|
[
"MIT"
] |
permissive
|
tahull/PIC8-guitar-tuner
|
93195349f109cd58b30779bf3a8c27cc2f212569
|
aa519d091fd3fd410311d4be8c81a6a0ee79405b
|
refs/heads/master
| 2022-11-30T02:41:06.879077 | 2022-10-28T03:04:02 | 2022-10-28T03:04:02 | 214,485,920 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 5,439 |
c
|
tuner_display.c
|
#include "tuner_display.h"
// TODO alternate tunings
static uint16_t notes[] = {E2, A2, D3, G3, B3, E4};
static uint16_t trans[] = {680, 960, 1280, 1710, 2210, 2880, 3700};
/* Given a frequency, compare with a tuning table, format and output.
* output to ssd1306 oled
*/
void tuner_display(uint16_t f){
uint8_t string_to_char[6] = {75,55,70,85,60,75}; //E, A, D, G, B, E
int16_t x,y;
int8_t b;
//find the tuning range that the frequency 'f' falls into
for(uint8_t i = 0; i < 6; i++){
//if frequency is between lower_range and upper_range
if(f >= trans[i] && f < trans[i+1]){
ssd1306_draw_char(0,0,90, 2,true); //draw "f"
ssd1306_draw_char(11,0,95, 2,true); //draw "="
tuner_display_freq(f);
ssd1306_draw_char(49,2,string_to_char[i], 6,true);
x = (int16_t)(f - notes[i]);
//within "accurate" tuning range
if(abs(x) <= TUNING_ACCURACY){
tuner_display_bars(0);
}
else{//too high or too low
if(f > notes[i])
b = 1;
else
b = -1;
if(abs(x) >= TUNING_RANGE)
y = TUNING_INDICATORS*(b);
else//distance to target frequency is above minimum range. draw more bars
y = (x/TUNING_POINTS)+b;
//printf("f: %u m: %d diff: %d y: %d\n",f, TUNING_POINTS, x, y);
tuner_display_bars((int8_t)y);
}
break;
}
}
}
void tuner_display_mode(uint8_t string_id){
uint8_t string_to_char[6] = {75,55,70,85,60,75}; //E, A, D, G, B, E
ssd1306_clr(106,0,127,1);
if(string_id == 6){ // display A for auto range mode
ssd1306_draw_char(118,0,55, 2,true); //draw "A"
//ssd1306_draw_char(0,0,105, 2,true); //draw "u"
//ssd1306_draw_char(0,0,110, 2,true); //draw "t"
//ssd1306_draw_char(0,0,115, 2,true); //draw "o"
}
else{ // display user selected string to tune
ssd1306_draw_char(106,0,string_to_char[string_id], 2,true);
if(string_id < 2)
ssd1306_draw_char(118,0,10, 2,true);
else if(string_id < 5)
ssd1306_draw_char(118,0,15, 2,true);
else
ssd1306_draw_char(118,0,20, 2,true);
}
}
//num 24 - 4*12 or 5*12
void tuner_display_freq(uint16_t f){
uint8_t pos,val, deci = false;
ssd1306_clr(22,0,100,1);
if(f > 999)
pos = 6*(SSD1306_CHAR_WIDTH*2+1);
else
pos = 5*(SSD1306_CHAR_WIDTH*2+1);
while(f){
val = f%10;
f /=10;
ssd1306_draw_char(pos,0,num_to_char[val], 2,true);
pos -= (SSD1306_CHAR_WIDTH*2+1);
if(!deci){
deci = true;
ssd1306_draw_char(pos,0,100, 2,true);
pos -= (SSD1306_CHAR_WIDTH*2+1);
}
}
}
void tuner_display_bars(int8_t val){
uint8_t pos;
ssd1306_clr(0,2,48,7);
ssd1306_clr(80,2,127,7);
if (val == 0){ //center tune
ssd1306_draw_char(39,4,50, 3,false);
ssd1306_draw_char(83,4,50, 3,false);
}
else{
if (val < 0)
pos = 37;
else
pos = 83;
while(val){
ssd1306_draw_char(pos,3,50, 4,false);
if(val < 0){
pos -= (SSD1306_CHAR_WIDTH*2+1);
val++;
}
else{
pos += (SSD1306_CHAR_WIDTH*2+1);
val--;
}
}
}
}
// UART output for testing
#ifdef TUNE_DISPLAY
void tuner_display_uart(uint16_t f){
uint8_t note_name[][3] = {"E2","A2","D3","G3","B3","E4"};
//uint16_t trans[] = {E2-(A2-E2)/2, E2+(A2-E2)/2, A2+(D3-A2)/2, D3+(G3-D3)/2, G3+(B3-G3)/2, B3+(E4-B3)/2, E4+(E4-B3)/2};
//find the tuning range that the frequency 'f' falls into
for(uint8_t i = 0; i < 6; i++){
//if frequency is between lower_range and upper_range
if(f >= trans[i] && f < trans[i+1]){
#ifdef TUNE_DISPLAY_VERBOSE
printf("found: %u.%u target: %u.%u between: %u to %u\n", \
(uint16_t)(f/10),(uint16_t)(f%10), \
(uint16_t)(notes[i]/10),(uint16_t)(notes[i]%10),\
(uint16_t)(trans[i]/10),(uint16_t)(trans[i+1]/10));
#endif
//check if frequency 'f' is in an acceptable accuracy range for 'good tuning
if(f >= notes[i] - (TUNING_ACCURACY+i) && f <= notes[i] + (TUNING_ACCURACY+i)){
printf("---(%s)---\n",note_name[i]);
}
//pitch too high
else if(f >= notes[i] + (TUNING_ACCURACY*3+i)){
printf("---(%s)<<<\n",note_name[i]);
}
else if(f >= notes[i] + (TUNING_ACCURACY*2+i)){
printf("---(%s)<<-\n",note_name[i]);
}
else if(f >= notes[i] + (TUNING_ACCURACY+i)){
printf("---(%s)<--\n",note_name[i]);
}
//pitch too low
else if(f <= notes[i] - (TUNING_ACCURACY*3+i)){
printf(">>>(%s)---\n",note_name[i]);
}
else if(f <= notes[i] - (TUNING_ACCURACY*2+i)){
printf("->>(%s)---\n",note_name[i]);
}
else if(f <= notes[i] - (TUNING_ACCURACY+i)){
printf("-->(%s)---\n",note_name[i]);
}
break;
}
}
}
#endif
|
b01ad41a539ec783a570c85853dd7c5bac5bcaee
|
a2db453f6b018263bf09e28d1b4f070b373bc80f
|
/src/event_loop/event_loop_kqueue.c
|
71c52b4782dac732948bacfb2746cc94b126e8a7
|
[] |
no_license
|
darius98/ndc
|
16e185f9bc375d61af02bf6b60f8fcd64bfd4936
|
923b86e8a5c9d43484cbffe05e7bde1a0780eb90
|
refs/heads/master
| 2023-03-30T16:11:06.950463 | 2021-03-30T14:14:12 | 2021-03-30T14:14:12 | 313,638,550 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,881 |
c
|
event_loop_kqueue.c
|
#include <sys/event.h>
#include "event_loop.h"
#include "event_loop_internal.h"
const char* event_loop_ctl_syscall_name = "kevent";
const char* event_loop_run_syscall_name = "kevent";
const char* event_loop_create_loop_syscall_name = "kqueue";
const int event_loop_sizeof_event = sizeof(struct kevent);
int event_loop_create_loop_fd() {
return kqueue();
}
static int event_loop_ctl(struct event_loop* loop, int fd, void* data, int16_t filter, uint16_t flags) {
struct kevent event;
EV_SET(&event, fd, filter, flags, 0, 0, data);
return kevent(loop->fd, &event, 1, 0, 0, 0);
}
int event_loop_add_read_fd(struct event_loop* loop, int fd, void* data) {
return event_loop_ctl(loop, fd, data, EVFILT_READ, EV_ADD);
}
int event_loop_remove_read_fd(struct event_loop* loop, int fd, void* data) {
return event_loop_ctl(loop, fd, data, EVFILT_READ, EV_DELETE);
}
int event_loop_add_write_fd(struct event_loop* loop, int fd, void* data) {
return event_loop_ctl(loop, fd, data, EVFILT_WRITE, EV_ADD);
}
int event_loop_remove_write_fd(struct event_loop* loop, int fd, void* data) {
return event_loop_ctl(loop, fd, data, EVFILT_WRITE, EV_DELETE);
}
int event_loop_run(struct event_loop* loop, void* cb_data, event_loop_event_cb event_cb,
event_loop_notification_ready_cb notification_ready_cb) {
struct kevent* events = (struct kevent*)loop->events;
while (1) {
int n_ev = kevent(loop->fd, 0, 0, events, loop->max_events, 0);
if (n_ev < 0) {
return -1;
}
int should_process_notification = 0;
for (int i = 0; i < n_ev; i++) {
int event_fd = (int)events[i].ident;
if (event_fd == loop->notify_pipe[0]) {
should_process_notification = 1;
} else {
int event_flags = 0;
if (events[i].filter & EVFILT_READ) {
event_flags |= evf_read;
}
if (events[i].filter & EVFILT_WRITE) {
event_flags |= evf_write;
}
if (events[i].flags & EV_EOF) {
event_flags |= evf_eof;
}
int event_cb_status = event_cb(events[i].udata, event_flags, cb_data);
if (event_cb_status != 0) {
return event_cb_status;
}
}
}
if (should_process_notification) {
// Process notifications last, because in case we free memory attached to an event
// because of a notification, the user data in other events might become dangling
// pointers.
int notification_ready_cb_status = notification_ready_cb(cb_data);
if (notification_ready_cb_status != 0) {
return notification_ready_cb_status;
}
}
}
}
|
283e9a55bd635bae5964d203ab7c0b756d2a0e25
|
1bf99dde6b2d2fc3ecf59e5d5fa2492258294e10
|
/liang.c/liang_C/liang18.c/liang18.c/main.c
|
6d9d71e2a509a76b3634ddf069ad191258c70918
|
[] |
no_license
|
Hekatoncheir/C-C-
|
2c7b5d29aef534095946ceacf792dc30ef8e2390
|
453a366d5bc8157c85a9b50f77dad4fd237a802f
|
refs/heads/master
| 2021-01-23T23:03:03.875283 | 2017-09-09T12:07:05 | 2017-09-09T12:07:05 | 102,952,009 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 691 |
c
|
main.c
|
//
// main.c
// liang18.c
//
// Created by OurEDA on 16/10/16.
// Copyright (c) 2016年 jackie. All rights reserved.
//
#include <stdio.h>
void copy_arr (double ar[], double br[], int n)
{
int m;
for (m=0;m<n;m++)
br[m] = ar[m];
}
void copy_ptr (double *pa, double *pb, int n)
{
int m;
for (m=0;m<n;m++)
{
*pb = *pa;
pb++;
pa++;
}
}
int main ()
{
int a, n;
double do1 [5] = {1.2,1.3,1.4,1.5,1.36};
double do2 [5];
double do3 [5];
copy_arr (do1,do2,5);
copy_ptr (do1,do3,5);
for (a=0,n=5;a<n;a++)
printf("%lf ",do2[a]);
putchar(10);
for (a=0,n=5;a<n;a++)
printf("%lf ",do3[a]);
}
|
d51db37614cde45d2241f942aa4267ab2406e3f3
|
f2f7be4a46fa2a20a4c160f998b238b110725b27
|
/ios/Pods/Headers/Public/Flipper-Folly/folly/detail/DiscriminatedPtrDetail.h
|
fef754dd0d0e05a53dfa816eace28eccc58d6146
|
[] |
no_license
|
shashankgogi/PushNotificationDemo
|
0ae6b2959fc76192ec09a07830a3504a27167fb4
|
72009945f2d46b0a3d6298879b38f1b957126547
|
refs/heads/main
| 2023-08-22T06:15:17.283708 | 2021-10-13T10:15:40 | 2021-10-13T10:15:40 | 416,678,197 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,067 |
h
|
DiscriminatedPtrDetail.h
|
XSym
0066
a225b978594cb95fd7a01a2827d02300
../../../../../Flipper-Folly/folly/detail/DiscriminatedPtrDetail.h
|
fcbdc532a5e685ee5483ebc13c5eeaf5c6f892a7
|
57f1872c681228f3b6dcc47c6931353b7085b11f
|
/C01/ex00/ft_ft.c
|
e06355cbaa9f707a34d2a731ccfe423c0f2826c3
|
[] |
no_license
|
Nutynuxxy/Piscine_42
|
a66b7c36788993299ba3c70ce2d79670a2976ff9
|
b2a4c1ccdb47a85ba3b933408606eb3e92303424
|
refs/heads/master
| 2022-12-08T15:02:53.092234 | 2020-09-02T12:47:20 | 2020-09-02T12:47:20 | 292,277,067 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 929 |
c
|
ft_ft.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ft.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcoet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/15 10:07:28 by mcoet #+# #+# */
/* Updated: 2020/08/15 17:27:20 by mcoet ### ########lyon.fr */
/* */
/* ************************************************************************** */
void ft_ft(int *nbr)
{
*nbr = 42;
}
|
5ce15d2291f7f28b27e918c72ba24387a0f082ea
|
e1a476e53585f181f94fd380403917746f939f78
|
/hangman/wordlist.c
|
278197524002a59145de5e91952b600ec6ffc9ae
|
[] |
no_license
|
nerd-oreo/c-projects
|
b77e37a967009006ab195f9f3d33605d35f853a0
|
8362f6dc82b9f97b7f4d91a10aea7dd8f8416db0
|
refs/heads/master
| 2020-12-01T15:59:12.633273 | 2020-01-16T08:00:58 | 2020-01-16T08:00:58 | 230,690,968 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 5,996 |
c
|
wordlist.c
|
#include "wordlist.h"
const char WORD_LIST[WORD_LIST_SIZE][WORD_SIZE] = {
{"accept"},{"accurate"},{"adjust"},{"adopt"},{"adult"},{"advice"},{"adviser"},{"affinity"},{"agenda"},{"ambiguity"},{"ambition"},{"amputate"},{"anxiety"},{"appearance"},{"arm"},{"article"},{"ash"},{"assault"},{"assessment"},{"asset"},{"attic"},{"auditor"},{"autonomy"},{"aware"},{"bake"},{"bald"},{"bare"},{"basic"},{"bay"},{"beach"},{"bed"},{"begin"},{"behave"},{"bet"},{"bible"},{"bike"},{"bind"},{"birthday"},{"bishop"},{"bloody"},{"board"},{"boat"},{"bolt"},{"bond"},{"book"},{"bowel"},{"brake"},{"branch"},{"breakdown"},{"breast"},{"broadcast"},{"broken"},{"budge"},{"building"},{"bush"},{"buttocks"},{"calf"},{"cap"},{"captain"},{"car"},{"career"},{"carpet"},{"cave"},{"ceiling"},{"champion"},{"change"},{"chapter"},{"charity"},{"chemistry"},{"chest"},{"chief"},{"chimpanzee"},{"chip"},{"chorus"},{"civilian"},{"clerk"},{"climb"},{"clinic"},{"clue"},{"cluster"},{"coast"},{"coffee"},{"coma"},{"commerce"},{"compensation"},{"compose"},{"comprehensive"},{"concrete"},{"condition"},{"conductor"},{"confront"},{"confrontation"},{"connection"},{"conscious"},{"consumption"},{"contact"},{"control"},{"convention"},{"convulsion"},{"cooperation"},{"cooperative"},{"coverage"},{"crackpot"},{"cream"},{"create"},{"credit"},{"crew"},{"criticism"},{"culture"},{"cunning"},{"current"},{"dairy"},{"damn"},{"danger"},{"dead"},{"decade"},{"decay"},{"decide"},{"decorative"},{"decrease"},{"definite"},{"delay"},{"deliver"},{"delivery"},{"deprive"},{"designer"},{"despair"},{"deteriorate"},{"deviation"},{"diameter"},{"difficulty"},{"dignity"},{"dine"},{"diplomat"},{"disorder"},{"displace"},{"disposition"},{"distinct"},{"division"},{"doctor"},{"doubt"},{"dragon"},{"draw"},{"dribble"},{"drown"},{"duke"},{"dynamic"},{"earthquake"},{"earwax"},{"east"},{"eavesdrop"},{"economics"},{"egg"},{"elbow"},{"election"},{"empire"},{"encourage"},{"endure"},{"energy"},{"enfix"},{"engineer"},{"environment"},{"environmental"},{"epicalyx"},{"equinox"},{"establish"},{"eternal"},{"execute"},{"expansion"},{"expertise"},{"explicit"},{"export"},{"extent"},{"extraterrestrial"},{"fade"},{"falsify"},{"familiar"},{"family"},{"far"},{"fastidious"},{"feedback"},{"ferry"},{"final"},{"financial"},{"finger"},{"fish"},{"flat"},{"flood"},{"flourish"},{"fly"},{"food"},{"foot"},{"formation"},{"forum"},{"fragment"},{"freckle"},{"freight"},{"fresh"},{"freshman"},{"frog"},{"gap"},{"gas"},{"gesture"},{"girl"},{"glass"},{"glimpse"},{"grandfather"},{"graphic"},{"grateful"},{"ground"},{"guideline"},{"habit"},{"hall"},{"hand"},{"harbor"},{"have"},{"headquarters"},{"heaven"},{"hell"},{"herd"},{"hiccup"},{"highway"},{"hill"},{"hip"},{"hole"},{"holiday"},{"horror"},{"huge"},{"husband"},{"hypnothize"},{"impact"},{"increase"},{"infect"},{"infection"},{"injury"},{"insert"},{"insistence"},{"integrity"},{"introduce"},{"investment"},{"jelly"},{"jockey"},{"junior"},{"justice"},{"killer"},{"king"},{"knit"},{"knock"},{"laborer"},{"lack"},{"language"},{"late"},{"laundry"},{"leg"},{"lemon"},{"level"},{"lick"},{"lift"},{"limited"},{"list"},{"listen"},{"lobby"},{"lonely"},{"loot"},{"looting"},{"lose"},{"lost"},{"lump"},{"magazine"},{"manager"},{"Mars"},{"mastermind"},{"material"},{"mature"},{"meet"},{"member"},{"message"},{"minimize"},{"ministry"},{"miracle"},{"model"},{"modernize"},{"monarch"},{"monopoly"},{"mood"},{"moon"},{"moving"},{"multimedia"},{"mutter"},{"nature"},{"navy"},{"neighborhood"},{"net"},{"network"},{"north"},{"notebook"},{"novel"},{"nuclear"},{"nun"},{"oak"},{"obscure"},{"observer"},{"occupation"},{"officer"},{"open"},{"operational"},{"opponent"},{"oppose"},{"order"},{"original"},{"outfit"},{"owe"},{"pace"},{"pack"},{"parachute"},{"paragraph"},{"parallel"},{"pardon"},{"patrol"},{"pavement"},{"payment"},{"peak"},{"percent"},{"philosophy"},{"physical"},{"piece"},{"pierce"},{"pigeon"},{"pill"},{"pillow"},{"pioneer"},{"place"},{"planet"},{"platform"},{"please"},{"plot"},{"policeman"},{"poll"},{"pool"},{"premature"},{"prescription"},{"presence"},{"presentation"},{"president"},{"price"},{"proclaim"},{"psychology"},{"public"},{"purpose"},{"push"},{"quaint"},{"qualified"},{"quarter"},{"queen"},{"quotation"},{"rack"},{"rank"},{"reactor"},{"ready"},{"real"},{"realism"},{"receipt"},{"recruit"},{"referee"},{"refrigerator"},{"refuse"},{"regular"},{"reject"},{"relation"},{"relinquish"},{"remark"},{"repetition"},{"resident"},{"responsibility"},{"responsible"},{"restless"},{"retired"},{"review"},{"revoke"},{"revolution"},{"revolutionary"},{"reward"},{"roof"},{"rotate"},{"rumor"},{"rush"},{"sacred"},{"salt"},{"say"},{"scale"},{"scan"},{"scholar"},{"school"},{"science"},{"screw"},{"script"},{"section"},{"sense"},{"shape"},{"sharp"},{"shelter"},{"short circuit"},{"shy"},{"sickness"},{"side"},{"sight"},{"silk"},{"sister"},{"site"},{"skilled"},{"slap"},{"sleep"},{"smash"},{"smoke"},{"sodium"},{"soprano"},{"source"},{"sow"},{"speaker"},{"spectrum"},{"speed"},{"sphere"},{"spontaneous"},{"spy"},{"squeeze"},{"stab"},{"stable"},{"stadium"},{"staircase"},{"statement"},{"stay"},{"steam"},{"sting"},{"stock"},{"stool"},{"strap"},{"strategic"},{"stream"},{"strength"},{"strict"},{"stride"},{"string"},{"strip"},{"struggle"},{"stubborn"},{"student"},{"stuff"},{"suggest"},{"suit"},{"supplementary"},{"surface"},{"survival"},{"swallow"},{"swop"},{"systematic"},{"table"},{"talkative"},{"tap"},{"teach"},{"tear"},{"technology"},{"television"},{"tell"},{"tenant"},{"thaw"},{"theme"},{"therapist"},{"thinker"},{"ticket"},{"tired"},{"tolerant"},{"tool"},{"top"},{"toss"},{"total"},{"tradition"},{"transparent"},{"trap"},{"treat"},{"trustee"},{"turkey"},{"understanding"},{"unique"},{"unlike"},{"update"},{"urge"},{"urgency"},{"valid"},{"value"},{"van"},{"vegetable"},{"venture"},{"video"},{"village"},{"vision"},{"volume"},{"volunteer"},{"wagon"},{"wall"},{"warm"},{"wash"},{"weak"},{"weapon"},{"wear out"},{"wedding"},{"whole"},{"widen"},{"wild"},{"wine"},{"wing"},{"winner"},{"withdrawal"},{"worker"},{"worry"},{"wrestle"},{"yearn"},
};
|
9e7d4d5a396a20ab3bce455ea61898151b80dbba
|
24ab937d4c47937f248941e5fc077adc670235a9
|
/learning-c-cpp/malloc-structure.c
|
5f052c2b3b7403488e5840b1e02edc704db58298
|
[] |
no_license
|
lobo-old/undergrad
|
3fb4545c6164a6db21e88e87cb9dbb0e83c41ac0
|
b741b54d4205247f6b97c479848181ec018c3f5b
|
refs/heads/main
| 2023-05-06T10:01:26.141512 | 2021-05-25T03:18:54 | 2021-05-25T03:18:54 | 370,431,772 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 670 |
c
|
malloc-structure.c
|
#include<stdio.h>
#include<stdlib.h>
typedef struct {
int a ;
double b ;
struct MaStructure* suivant;
} MaStructure ;
int main(){
MaStructure *ptr1 = NULL;
MaStructure* ptr2 = NULL;
ptr1 = ( MaStructure *) malloc ( sizeof( MaStructure ) );
if ( ptr1 != NULL){
ptr1->a = 10;
ptr1->b = 3.1415 ;
ptr1->suivant = NULL;
}
printf("%d %f %x\n",(*ptr1).a,(*ptr1).b,(*ptr1).suivant);
ptr1->suivant = (MaStructure*)malloc(sizeof(MaStructure));
printf("%d %f %x\n",(*ptr1).a,(*ptr1).b,(*ptr1).suivant);
(*ptr1.suivant)->a = 40;
printf("%d %f %x\n",(*((*ptr1).suivant)).a,(*ptr1).b,(*ptr1).suivant);
}
|
65b782e5efb32b8cd946b8541ff13143a8cb72f7
|
e76f60f84abebd245a353d9c05cbe56cf59a4bc3
|
/src/Part_2_Assembler/utilities.h
|
0818c482a2369c9a97534d4f00b9d11f08546ae9
|
[] |
no_license
|
Zubair100/ARM11-Assembler-Emulator
|
8bae368a85bdc14243a9aa001571b97d9cc77bd6
|
fc14bfa43e6efc8122a0924dbf36869a0461707a
|
refs/heads/master
| 2020-09-24T10:55:46.614425 | 2016-09-02T21:14:12 | 2016-09-02T21:14:12 | 67,255,033 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 540 |
h
|
utilities.h
|
#ifndef UTILITIES_H
#define UTILITIES_H
/* ******************************************************************** */
/* PROTOTYPES FOR UTILITY FUNCTIONS */
/* ******************************************************************** */
uint32_t string_length(char *str);
uint32_t gen_reg_no(char *str);
uint32_t check_if_hex(char *word);
uint32_t rotate_left(uint32_t num, uint32_t rotate_amount);
uint32_t get_rotate_amount(uint32_t binary_number);
uint32_t gen_shift_op_code(char* string_op_code);
#endif
|
ad0c73ea07f701bc705e4b0376ce4cf77c5ad0ad
|
0ff371dd9ecb42c809da2cd84732102e97fb0031
|
/src/utils_common/src/stat_collector_utils/sci.h
|
20bff6ea213f5d201de3a471ef572fac5bc3dd62
|
[] |
no_license
|
ryuhs74/vision_sdk
|
0aa19e4fdbaed9b018d9241a05d11a798a4cf395
|
4cc3878c974083d0c0cdeb984960d83399146e5b
|
refs/heads/master
| 2020-07-07T02:12:40.716282 | 2016-05-19T04:44:28 | 2016-05-19T04:44:28 | 66,444,176 | 3 | 4 | null | null | null | null |
UTF-8
|
C
| false | false | 41,546 |
h
|
sci.h
|
/*
* sci.h
*
* Statistic Collector Instrumentation Library
* - API Definitions
*
* Copyright (C) 2011-2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*! \file sci.h
CPT Library Function Prototypes
*/
/* The following defines the generic APIs. sci_dev.h contains
* device specific definitions.
*/
#ifndef SCI_H
#define SCI_H
#include <stdlib.h>
#include <stdint.h> // The library uses C99 exact-width integer types
#include <stdbool.h>
#ifdef _STM_Logging
#include "StmLibrary.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
//Using forward slashes in the relative search path for Linux compatibility
#ifdef _OMAP4430
#include "../../SCILib/include/sci_omap4430.h"
#endif
#ifdef _OMAP4460
#include "../../SCILib/include/sci_omap4460.h"
#endif
#ifdef _OMAP4470
#include "../../SCILib/include/sci_omap4470.h"
#endif
#ifdef _OMAP5430
#include "../../SCILib/include/sci_omap5430.h"
#endif
#ifdef _DRA7xx
#include "sci_dra7xx.h"
#endif
#ifdef _AM437x
#include "../../SCILib/include/sci_am437x.h"
#endif
#ifdef _TDA3x
#include "sci_tda3x.h"
#endif
#if defined(_AM437x) || defined(_DRA7xx) || defined(_TDA3x)
/*! \par LAT_SC_HAS_SLAVE_PROBES
For devices that provide LAT Statistic Counter probes on slaves,
the sci_filter_mstr structure is expanded to include master filter
parameters.
*/
#define LAT_SC_HAS_SLAVE_PROBES
#endif
/* Note - the version definitions must have the end of line immediately
* after the value (packaging script requirement)
*/
#define SCILIB_MAJOR_VERSION (0x1)
/*!< Major version number
- Incremented for API changes*/
#define SCILIB_MINOR_VERSION (0x5)
/*!< Minor version number
- Incremented for bug fixes */
/*! \par sci_handle
sci handle object. This is an incomplete structure, thus making the actual
implementation private to the library.
*/
typedef struct sci_handle_t sci_handle;
/*! \par psci_handle
Pointer to a sci handle object
*/
typedef sci_handle * psci_handle;
/*! \par sci_err
SCILib error codes
*/
enum sci_err {
SCI_SUCCESS, /*!< Function completed with no errors */
SCI_ERR_INVALID_HANDLE = -1, /*!< Invalid sci handle */
SCI_ERR_INVALID_PARM = -2, /*!< Invalid function parameter */
SCI_ERR_MAPPING = -3, /*!< Memory mapping error */
SCI_ERR_SC_NOT_AVAILABLE = -4, /*!< SC module not avaiable */
SCI_ERR_MEM_ALLOC = -5, /*!< Memory allocation error */
SCI_ERR_ACCESS = -6, /*!< SC module access error */
SCI_ERR_REVISION = -7, /*!< SC module unexpected revision */
SCI_ERR_MODULE_ENABLED = -8, /*!< Module must be disabled for operation */
SCI_ERR_FILTER_NOT_ALLOWED = -9, /*!< Use case does not allow filters */
SCI_ERR_STM = -10 /*!< STM error */
};
/*! \par sci_callback
\param[in] phandle SCILib handle.
\param[in] func Constant char pointer to the function name, normally
provided by the compiler using the __FUNCTION__ macro.
\param[in] ::sci_err error returned by calling routine
Definition of the user implmented callback funtion. See ::sci_config.
*/
typedef void(*sci_callback)(psci_handle phandle, const char * func, enum sci_err);
/*! \par sci_mode
SCI Library operating mode. Allows user to select SC Module
counter export mode.
*/
#ifdef _SC_VER_1_16
enum sci_mode {
SCI_MODE_STM, /*!< Export SC Module counters periodically
via STM (normal operating mode). */
SCI_MODE_DUMP, /*!< Export SC Module counters on demand
via STM (see ::sci_dump()). */
SCI_MODE_STM_COND, /*!< Export SC Module counters conditionally
via STM */
SCI_MODE_DUMP_COND /*!< Export SC Module counters conditionally
on demand (see ::sci_dump()).
*/
};
#else
enum sci_mode {
SCI_MODE_STM, /*!< Export SC Module counters periodically
via STM (normal operating mode). */
SCI_MODE_DUMP /*!< Export SC Module counters on demand
via STM (see ::sci_dump() */
};
#endif
/*! \par sci_config
SCI Library configuration structure. If sci_open()is called
with a NULL sci_config pointer then the default value for
each parameter is utilized.
*/
struct sci_config {
sci_callback errhandler; /*!< Called by any SCI Library function
prior to returning an error. May be set to
NULL to disable this feature. Default is NULL.
*/
uint32_t sdram_msg_rate; /*!< 32-bit non-zero value used to set the
rate at which messages are generated (based
on SC Module clock rate).
Setting to 0 is not legal and will result
in sci_open() returning ::SCI_ERR_INVALID_PARM.
Default is the maximum value the module
supports. A value that is too large may cause
counter saturation. Reducing this value may
reduce or eliminate saturation errors, and
will increase the data resolution.
*/
uint32_t mstr_msg_rate; /*!< 32-bit non-zero value used to set the
rate at which messages are generated (based
on SC Module clock rate).
Setting to 0 is not legal and will result
in sci_open() returning ::SCI_ERR_INVALID_PARM.
Default is the maximum value the module
supports. A value that is too large may cause
counter saturation. Reducing this value may
reduce or eliminate saturation errors, and
will increase the data resolution.
*/
bool trigger_enable; /*!< Cross triggers enable/disable. Default
is disable. If Enabled EMU0 trigger enables,
EMU1 trigger disables the SC module.
*/
uint32_t data_options; /*!< This is a bit field that enables sw
filtering of certain data characteristics.
Bit 0 - If 1 suppress zero data, if 0 don't
suppress zero data. If a SC Module is
enabled during cycles where no accesses
are performed this option allows the zero
data provided in these cases to be suppressed
from the data provided on the host.
This option will have no effect on the actual
STM bandwidth (in other words all data is
transmitted), but it may reduce host file
sizes significantly and in some cases decrease
data processing times.
*/
enum sci_mode mode; /*!< See ::sci_mode */
#ifdef _STM_Logging
bool stm_log_enable; /*!< Enable/disable library generated STM
logging messages. The default is disabled */
STMHandle * pstm_handle; /*!< A pointer to a STM Handle for logging
and providing meta data (required by host
tools). The default is NULL.*/
int stm_ch; /*!< A STM channel to use for SCI Library
logging messages.
*/
#endif
};
/*! \par sci_open
Open an instance of the SCI Library.
\param[out] pphandle A pointer to a NULL ::psci_handle. If sci_open
exits with a return value of ::SCI_SUCCESS,
the ::psci_handle pointer is set to a valid
sci handle object pointer.
\param[in] pconfig A pointer to a ::sci_config structure.
If pconfig is NULL all parameters are set to
their default values.
\return enum ::sci_err
See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\li ::SCI_ERR_INVALID_PARM
\li ::SCI_ERR_MEM_ALLOC
\li ::SCI_ERR_SC_NOT_AVAILABLE
\li ::SCI_ERR_REVISION
\li ::SCI_ERR_MAPPING
\par Details:
This function must be called and return ::SCI_SUCCESS prior to calling any
other SCI Library function that requires a ::psci_handle.
If this function is called with a non-NULL ppHandle pointer this function
will exit and return ::SCI_ERR_INVALID_HANDLE.
Any errors found with pconfig parameters will cause the function to exit
and return ::SCI_ERR_INVALID_PARM.
If the device's SC module is not compatible with this version of the
library, this function will exit and return ::SCI_ERR_REVISION.
The Library initialize each module in the system for operation. Note that
if the module is already in use, the library will override and take control
of the module.
Storage for sci_handle is allocated through a call to the client provided
external function cTools_memAlloc(). If a memory allocation error occurs
this function will exit and returns ::SCI_ERR_MEM_ALLOC.
cTools_memMap(), also a client provided function, is called to map the
physical SC Module base address to a virtual address space. If a mapping
error occurs this function exits returns ::SCI_ERR_MAPPING.
If there are no errors detected the function exits with ::SCI_SUCCESS.
If pconfig is a NULL pointer, the default configuration parameters are:
\li errhandler is NULL.
\li pstm_handle is NULL.
\li SC STM message rate is set to the max value.
*/
enum sci_err sci_open (psci_handle * const pphandle,
struct sci_config * const pconfig);
/*! \par sci_close
Close the SCI Library API.
\param[out] pphandle A pointer to a ::psci_handle.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\par Details:
This function must be called and return ::SCI_SUCCESS to release resources
acquired with sci_open(). Any usecases that have not been removed, see
sci_remove_usecase(), will also be removed.
This function will also set the phandle pointed to by pphandle to NULL.
If pphandle points to a NULL phandle this function
will exit and return ::SCI_ERR_INVALID_HANDLE.
*/
enum sci_err sci_close (psci_handle * const pphandle);
/*! \par sci_get_version
Get version information ofthe SCILib and SC module.
\param[out] phandle A pointer to a handle provided by sci_open.
\param[in] plib_major_ver A pointer to the location used to store the
libraries major version number.
\param[in] plib_minor_ver A pointer to the location used to store the
libraries minor version number.
\param[in] plib_func_id A pointer to the location used to store the
libraries functional id value.
\param[in] pmod_func_id A pointer to the location used to store the
SC module's functional id value.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_ACCESS
\li ::SCI_ERR_REVISION
\par Details:
This function assumes that all the SC modules in a device are the same
revision and func id, so it only looks at the first module sci_open
acquired ownership for. This function will acquire the module's func id and
it's type identifier. If either do not match the values expected
for this device, this function will exit with ::SCI_ERR_REVISION.
If no SC modules are accessible (owned by an other application or debugger)
this function exits with ::SCI_ERR_ACCESS.
*/
enum sci_err sci_get_version (psci_handle const phandle,
uint32_t * const plib_major_ver,
uint32_t * const plib_minor_ver,
uint32_t * const plib_func_id,
uint32_t * const pmod_func_id );
/*! \par sci_sdram_usecase
Selects for sdram usecases.
*/
/* Note that the usecase enums are encoded. The LS 16 bits are the normal
* usecase enumeration, and the MS 16 bits is a compatibility code. If the
* compatibility code is 0 the usecase is not compatible with any others.
* Bits 8:15 indicate the module type the usecase can be applied to, where:
* 0x00 is the SDRAM module
* 0x01 is the LAT module
*/
enum sci_sdram_usecase {
SCI_SDRAM_THROUGHPUT = 0x00010000, /*!< Throughput in bytes per
sample window usecase select */
SCI_SDRAM_LINKOCCUPY_REQUEST = 0x00000001, /*!< Request Port Link occupancy
percentage usecase select */
SCI_SDRAM_LINKOCCUPY_RESPONSE = 0x00000002, /*!< Response Port Link occupancy
percentage usecase select */
SCI_SDRAM_AVGBURST_LENGTH = 0x00010003 /*!< Average burst length in
bytes usecase select */
/* Since SDRAM does not support latency usecase must skip enum 0x00000004 */
#ifdef _SC_VER_1_16
,
SCI_SDRAM_THROUGHPUT_MINALARM = 0x00000005, /*!< Throughput minimum alarm
usecase */
SCI_SDRAM_THROUGHPUT_MAXALARM = 0x00000006 /*!< Throughput maximum alarm
usecase */
/* Since SDRAM does not support latency usecase must skip enum 0x00000007 */
#endif
};
/*! \par sci_mstr_usecase
Selects for master usecases.
*/
enum sci_mstr_usecase {
SCI_MSTR_THROUGHPUT = 0x00010100, /*!< Throughput in bytes per
sample window usecase select */
SCI_MSTR_LINKOCCUPY_REQUEST = 0x00000101, /*!< Request Port Link occupancy
percentage usecase select */
SCI_MSTR_LINKOCCUPY_RESPONSE = 0x00000102, /*!< Response Port Link occupancy
percentage usecase select */
SCI_MSTR_AVGBURST_LENGTH = 0x000010103, /*!< Average burst length in
bytes usecase select */
SCI_MSTR_AVGLATENCY = 0x00000104 /*!< Average latency in
cycles usecase select */
#ifdef _SC_VER_1_16
,
SCI_MSTR_THROUGHPUT_MINALARM = 0x00000105, /*!< Throughput minimum alarm
usecase select*/
SCI_MSTR_THROUGHPUT_MAXALARM = 0x00000106, /*!< Throughput maximum alarm
usecase select*/
SCI_MSTR_LATENCY_MAXALARM = 0x00000107, /*< Average latency maximum
alarm usecase select */
SCI_MSTR_ARBITRATION_CONFLICT = 0x00000108, /* Arbitration conflict - Request link busy */
SCI_MSTR_INITIATOR_BUSY = 0x0000109, /* Initiator busy - Response link busy */
SCI_MSTR_TRANSACTION_UNDERFLOW = 0x000010A /* Transaction Underflow - Request link wait */
#ifdef _TEST
,SCI_MSTR_TRANSFER_CYCLES = 0x000010B, /* Transfer cycles on request link */
SCI_MSTR_TOTAL_CLOCKS = 0x0000010C /* Total clock cycles */
#endif
#endif //_SC_VER_1_16
};
/*! \par sci_trans_qual
Transaction qualification selects for both sdram and
master usecases.
*/
enum sci_trans_qual {
SCI_RD_ONLY, /*!< Read transactions only */
SCI_WR_ONLY, /*!< Write transactions only */
SCI_RD_OR_WR_NONE, /*!< No read or write transactions - only errors*/
SCI_RD_OR_WR_DONTCARE /*!< Either read or write transactions*/
};
/*! \par sci_error_qual
Error qualification selects for sdram and master
usecases.
*/
enum sci_error_qual {
SCI_ERR_ONLY, /*!< Error transactions only */
SCI_ERR_NONE, /*!< No error transactions */
SCI_ERR_DONTCARE}; /*!< Error transactions don't care */
/*! \par sci_filter_sdram
Filter configuration structure for sdram usecases.
*/
struct sci_filter_sdram
{
enum sci_master_addr mstr_addr_match; /*!< Master address match */
uint32_t mstr_addr_mask; /*!< Master address mask */
enum sci_trans_qual trans_qaul; /*!< Transaction qualifier */
enum sci_error_qual error_qual; /*!< Error qualifier */
};
/*! \par sci_filter_mstr
Filter configuration structure for master usecases.
*/
struct sci_filter_mstr {
#ifdef LAT_SC_HAS_SLAVE_PROBES
enum sci_master_addr mstr_addr_match; /*!< Master address match */
uint32_t mstr_addr_mask; /*!< Master address mask */
#endif
enum sci_slave_addr slave_addr_match; /*!< Slave address match */
uint32_t slave_addr_mask; /*!< Slave address mask */
enum sci_trans_qual trans_qaul; /*!< Transaction qualifier */
enum sci_error_qual error_qual; /*!< Error qualifier */
};
#ifdef _SC_VER_1_16
/*! \par sci_alarm
Alarm configuration structure.
*/
struct sci_alarm {
uint32_t alarm_min; /*!< Minimum alarm threshold */
uint32_t alarm_max; /*!< Maximum alarm threshold */
bool alarm_msg_enable; /*!< Enable STM messages on alarm */
};
#endif
/*! \par sci_config_sdram
Configuration structure for sdram usecases.
*/
struct sci_config_sdram {
enum sci_sdram_usecase usecase; /*!< sdram usecase selection */
enum sci_probeid_sdram probe_id; /*!< sdram probe selection */
int num_filters; /*!< Number of filters required
for the usecase (0,1 or 2). */
struct sci_filter_sdram filter[2]; /*!< sdram filters configuration*/
#ifdef _SC_VER_1_16
bool addr_filter_enable; /*!< Probe address filter enable */
uint32_t addr_filter_min; /*!< Probe System address minimum
(note: SCILib only supports conversion of system address
to physical address required by the SC modules. Virtual
and TILER address conversion is not supported. */
uint32_t addr_filter_max; /*!< Probe System address maximum
(note: SCILib only supports conversion of system address
to physical address required by the SC modules. Virtual
and TILER address conversion is not supported.*/
struct sci_alarm alarm; /*!< Alarm configuration */
#endif
};
/*! \par sci_config_mstr
Configuration structure for master usecases.
*/
struct sci_config_mstr {
enum sci_mstr_usecase usecase; /*!< Master usecase selection */
enum sci_probeid_mstr probe_id; /*!< Master probe selection */
int num_filters; /*!< Number of filters required
for the usecase (0 or 1). */
struct sci_filter_mstr filter; /*!< Master filter configuration */
#ifdef _SC_VER_1_16
struct sci_alarm alarm; /*!< Alarm configuration */
#endif
};
/*! \par sci_usecase_key
Usecase key opaque structure.
*/
typedef struct sci_usecase_key_t sci_usecase_key;
/*! \par sci_usecase_key
Usecase key structure pointer.
*/
typedef sci_usecase_key * psci_usecase_key;
/*! \par sci_reg_usecase_sdram
Register a sdram usecase.
\param[in] phandle A pointer to a handle provided by sci_open.
\param[in] pcfg A pointer to the sci_config_sdram structure
that defines this usecase.
\param[out] usecase_key A pointer to a usecase_key pointer. The
usecase_key pointer must be initialized
to NULL.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\li ::SCI_ERR_INVALID_PARM
\li ::SCI_ERR_MODULE_ENABLED
\li ::SCI_ERR_SC_NOT_AVAILABLE
\li ::SCI_ERR_MEM_ALLOC
\par Details:
This function registers use cases for the sdram Statistic Collectors.
If ::SCI_SUCCESS is returned the function successfully registered and
programmed the usecase. This function may only be called if the module
has not been enabled (see sci_global_enable())or has been disabled
(see sci_global_disable()).
If the number of filters is set to zero a default filter is used
(all filter masks set to 0 which enables all cycles, or in other words
disables all filtering).
If phandle is NULL the function exots with ::SCI_ERR_INVALID_HANDLE.
if pcfg is NULL or the usecase key pointer is not NULL this function will
exit with ::SCI_ERR_INVALID_PARM.
If this function is called while the modules are enabled this function
exits with ::SCI_ERR_MODULE_ENABLED.
If a statistic counter that meets the requirements of the usecase is not
available then this function exits with ::SCI_ERR_SC_NOT_AVAILABLE.
If memory allocation for the usecase key fails the function exits with
::SCI_ERR_MEM_ALLOC.
*/
enum sci_err sci_reg_usecase_sdram(psci_handle const phandle,
struct sci_config_sdram * const pcfg,
psci_usecase_key * usecase_key );
/*! \par sci_reg_usecase_mstr
Register a master usecase.
\param[in] phandle A pointer to a handle provided by sci_open.
\param[in] pcfg A pointer to the sci_config_sdram structure
that defines this usecase.
\param[out] usecase_key A pointer to a usecase_key pointer. The
usecase_key pointer must be initialized
to NULL.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\li ::SCI_ERR_INVALID_PARM
\li ::SCI_ERR_MODULE_ENABLED
\li ::SCI_ERR_SC_NOT_AVAILABLE
\li ::SCI_ERR_MEM_ALLOC
\par Details:
This function registers use cases for the master Statistic Collectors.
If ::SCI_SUCCESS is returned the function successfully registered and
programmed the usecase. This function may only be called if the module
has not been enabled (see sci_global_enable())or has been disabled
(see sci_global_disable()).
If the number of filters is set to zero a default filter is used
(all filter masks set to 0 which enables all cycles, or in other words
disables all filtering).
If phandle is NULL the function exports with ::SCI_ERR_INVALID_HANDLE.
if pcfg is NULL or the usecase key pointer is not NULL this function will
exit with ::SCI_ERR_INVALID_PARM.
If this function is called while the modules are enabled this function
exits with ::SCI_ERR_MODULE_ENABLED.
If a statistic counter that meets the requirements of the usecase is not
available then this function exits with ::SCI_ERR_SC_NOT_AVAILABLE.
If memory allocation for the usecase key fails the function exits with
::SCI_ERR_MEM_ALLOC.
*/
enum sci_err sci_reg_usecase_mstr(psci_handle const phandle,
struct sci_config_mstr * const pcfg,
psci_usecase_key * usecase_key );
/*! \par sci_remove_usecase
Remove a registered sdram or master usecase.
\param[in] phandle A pointer to a handle provided by sci_open.
\param[in] usecase_key A usecase_key pointer.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\li ::SCI_ERR_INVALID_PARM
\li ::SCI_ERR_MODULE_ENABLED
\par Details:
This function removes a registered use case for the sdram or master
Statistic Collectors.
If ::SCI_SUCCESS is returned the function successfully removed the
registered usecase.
This function may only be called if the module has not been enabled
(see sci_global_enable())or has been disabled (see sci_global_disable()).
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
If this function is called while the modules are enabled this function
exits with ::SCI_ERR_MODULE_ENABLED.
If this function is called with a NULL usecase_key it exits with
::SCI_ERR_INVALID_PARM.
*/
enum sci_err sci_remove_usecase (psci_handle const phandle,
psci_usecase_key * usecase_key);
/*! \par sci_global_enable
Enabled all registered sdram and master usecase.
\param[in] phandle A pointer to a handle provided by sci_open.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\par Details:
This function enables all registered use case and starts STM message
generation (per sci_mode parameter set with sci_open()).
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
*/
enum sci_err sci_global_enable(psci_handle const phandle);
/*! \par sci_global_disable
Disable all registered sdram and master usecase.
\param[in] phandle A pointer to a handle provided by sci_open.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\par Details:
This function disables all registered use case and terminates STM message
generation (per sci_mode parameter set with sci_open).
This function also causes meta data (data required for host post processing)
to be broadcast through STMLib if pstm_handle is not null (see ::sci_config).
If pstm_handle is null, then meta data will not be made avaiable for post
processing and only the raw counter values will be displayed.
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
*/
enum sci_err sci_global_disable(psci_handle const phandle);
/*! \par sci_dump
Manually dump the counters for each module that has use cases enabled.
\param[in] phandle A pointer to a handle provided by sci_open.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\par Details:
This function manually dumps (verses allowing the statistic counters
to be dumped to STM periodically) the counters out STM. If the
Library is opened in a dump mode then this function must be called
to export the statistic counters out STM. If opened in STM mode this
function has no effect.
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
*/
enum sci_err sci_dump(psci_handle const phandle );
#ifdef _SC_VER_1_16
/*! \par sci_dump_info
For the provided usecase_key retrive the number of statistic counters used.
\param[in] phandle A pointer to a handle provided by sci_open.
\param[in] usecase_key Pointer to nn array of usecase keys.
\param[in] usecase_key_num Number of usecase keys in usecase_key array.
\param[out] pnum_sci_cntrs Pointer to store the number of counters utilized
by the use cases in the usecase_key array.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\li ::SCI_ERR_INVALID_PARM
\par Details:
This function retrieves the combined number of counters used by all
use cases from the usecase_key array.
This information is needed by the client to provide a large enough
buffer (pnum_sci_cntrs * number of samples) for the sci_dump_cntrs() function.
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
If usecase_key is NULL this function exits with ::SCI_ERR_INVALID_PARM.
*/
enum sci_err sci_dump_info(psci_handle const phandle,
psci_usecase_key * usecase_key, int usecase_key_num,
int * pnum_sci_cntrs);
/*! \par sci_dump_cntrs
Manually dump the counters for the provided use case to a buffer.
\param[in] phandle A pointer to a handle provided by sci_open.
\param[in] usecase_key Pointer to nn array of usecase keys.
\param[in] usecase_key_num Number of usecase keys in usecase_key array.
\param[out] pbuf Pointer to the where this function stores the
statistic counters if pbuf is not NULL.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\li ::SCI_ERR_INVALID_PARM
\par Details:
This function retrieves the counters used by all use cases provided by the
usecase_key array and dumps them to pbuf. It's the clients responsibility
to advance the pbuf pointer prior to calling this function.
The number of counters dumped per call to sci_dump_cntrs can be found
by calling sci_dump_info().
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
If usecase_key is NULL this function exits with ::SCI_ERR_INVALID_PARM.
*/
enum sci_err sci_dump_cntrs(psci_handle const phandle,
psci_usecase_key * usecase_key, int usecase_key_num,
uint32_t * pbuf);
/*! \par sci_dump_disabled
For each module that has usecases enabled, disable STM message dumping.
\param[in] phandle A pointer to a handle provided by sci_open.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\par Details:
This function disables STM message dumping for each statistic collector
module that has a usecase registered for it.
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
*/
enum sci_err sci_dump_disable(psci_handle const phandle);
/*! \par sci_dump_enabled
For each module that has usecases enabled, enable STM message dumping.
\param[in] phandle A pointer to a handle provided by sci_open.
\return enum ::sci_err See details for conditions that cause the
following errors:
\li ::SCI_SUCCESS
\li ::SCI_ERR_INVALID_HANDLE
\par Details:
This function enables STM message dumping for each statistic collector
module that has a usecase registered for it.
If phandle is NULL the function exits with ::SCI_ERR_INVALID_HANDLE.
*/
enum sci_err sci_dump_enable(psci_handle const phandle);
#endif
/*! \mainpage
\section intro Introduction
The Statistic Collector Instrumentation (SCI) Library provides a use case
based programming API for the sdram and master Statistic Collector modules.
A Statistic Collector provide bus statistics for the selected probe that
can be filtered. Filtering parameters are dependent on the statistic collector
type. Depending on the operating mode messages that contain the counter values
can be export via STM periodically or on demand (dump mode).
\par Devices Supported
Devices currently supported by the library are:
\li OMAP4430
\li OMAP4460
\li OMAP4470
\li OMAP5430
\li DRA7xx
\li AM437x
\li TDA3x
\par Conventions
The following public naming conventions are used by the API
\li sci_ - Prefix for public CPT Library functions, structures and enumerations
\par Build Notes
SCILib supports the following pre-defined symbols that if defined
enable the functionality at compile time.
\li _STM_Logging - If defined the SCILib will depend on the STMLib.
\n Note - The minimum revision STMLib that supports SCILib meta data
transport is version 3.1.
The library must be configure for a specific device by providing at compile
time one of the following pre-defined symbols:
\li _OMAP4430
\li _OMAP4460
\li _OMAP4470
\li _OMAP5430
\li _DRA7xx
\li _AM437x
\li _TDA3x
\li SCI_VER_1_16 (note only valid for OMAP4460, OMAP4470, OMAP5430, DRA7xx, AM437x and TDA3x builds)
\par Directory Structure
SCILib is a component of cTools so it resides within the cTools directory structure.
@code
|--cTools
|
|-- SCILib
| |
| |-- doc
| | |
| | |--sci_omap4430_html
| | |--sci_omap4460_html
| | |--sci_omap5430_html
| | |--sci_dra7xx_html
| | |--sci_am437x_html
| | |--sci_tda3x_html
| | |
| | |-index.html (Doxygen API documentation)
| |
| |-- include (Public API include file)
| |-- src (Private .c and .h files )
| |-- projects (Target specific library builds)
| |
| |--omap4430_A9
| |--omap4460_A9
| |--omap5430_A15
| |--dra7xx_A15
| |--am437x_A9
| |--tda3x_M4
|-- Examples (Target specific stand-alone example projects)
|
|--common (files common across examples)
|--OMAP4430
|--OMAP5430
|--DRA7xx
|--AM437x
|--TDA3x
@endcode
\par Helper Functions
Helper functions allow the library to be ported easily to different
operating environments without modifications to the library directly.
Within the library these functions are declared extern so the library
will build but can not be linked without implementations for the following
helper functions:
\li void * cTools_memAlloc(size_t sizeInBytes); \n\n
If allocation successful returns pointer to allocated memory, else if not
successful return NULL.
\li void * cTools_memMap(unsigned int phyAddr, unsigned int mapSizeInBytes); \n\n
Map a physical address to a virtual address space. Return the virtual pointer
if successful, else return NULL. Return phyAddr if virtual mapping not required.
\li void cTools_memFree(void * ptr); \n\n
Free the memory at the ptr (returned from cTools_memAlloc()) call.
\li void cTools_memUnMap(void * vAddr, unsigned int mapSizeInBytes); \n\n
Unmap virtual address space starting at vAddr (returned from cTools_memMap())
of mapSizeInBytes length. If virtual address mapping not required simply return.
\par CPT Export Notes
The Statistic Collector STM messages are enabled by CCS when the STM module is
connected by default. If you have modified the defaults you may need to enable
the export of Statistic Collector STM messages through the CSS Breakpoint view by
creating a Trace job with the following Trace Properties:
\li Trace Type: System
\li STM Trace Type: Trace Export Configuration
\li Enable HW Message Sources:
\li Message Source N: Statistic Collection
If you are working remotely from CCS and using the ETB to capture STM data
then you must provide your own application code to enable the CPT module's STM messages.
\par CPT Library Revision History
<TABLE>
<TR><TD> Revision </TD> <TD>Date</TD> <TD>Notes</TD></TR>
<TR><TD> 0.0 </TD> <TD> 9/14/2011 </TD> <TD> Alpha, OMAP4430 validation only</TD>
<TR><TD> 0.1 </TD> <TD> 10/06/2011 </TD> <TD> Alpha, OMAP4430 and OMAP5430 validation.
Modified dump API from version 0.0.
Fixed Latency usecase bug. </TD>
<TR><TD> 1.0 </TD> <TD> 8/31/2011 </TD> <TD> In sci_open(), replaced module ownership
check with module override if in use.
Fixed sci_dump_cntr() to dump only the counters
used by the usecase.
Added OMAP4470 support (identical to OMAP5430).
Added address translation for the address filters
for OMAP4460, OMAP4470 and OMAP5430.</TD>
<TR><TD> 1.1 </TD> <TD> 2/06/2013 </TD> <TD> Added support for OMAP4470 and OMAP54xx.</TD>
<TR><TD> 1.2 </TD> <TD> 9/26/2013 </TD> <TD> Add support for DRA7xx.</TD>
<TR><TD> 1.3 </TD> <TD> 12/11/2013 </TD><TD> Add support for AM437x.</TD>
<TR><TD> 1.4 </TD> <TD> 9/29/2014 </TD><TD> Added missing CCS project files.</TD>
<TR><TD> 1.5 </TD> <TD> 10/2/2014 </TD><TD> Add support for TDA3x.</TD>
</TABLE>
*/
#ifdef __cplusplus
}
#endif
#endif /*SCI_H*/
|
12df1897156fe031e19b455cd304137e2c6c5240
|
cde441183a5bc0ba89349c1b44efa00e2149f96f
|
/1108.c
|
ce2df056ae724dd06cd27e85a7ee29dfdebc220b
|
[] |
no_license
|
luoxufeiyan/HDOJ
|
46852eac93d8e4454ba9437758f3eaa31f5d1d4c
|
17567abbe2365cdcd82bdd2a877c31444cb80eb0
|
refs/heads/master
| 2021-08-19T00:39:10.289377 | 2021-06-23T14:07:44 | 2021-06-23T14:07:44 | 22,404,276 | 3 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 229 |
c
|
1108.c
|
#include <stdio.h>
int main()
{
int a,b,ai,bi,temp;
while (scanf ("%d %d",&a,&b) != EOF)
{
ai = a;
bi = b;
while (bi != 0)
{
temp = bi;
bi = ai % bi;
ai = temp;
}
printf ("%d\n",a*b/ai);
}
return 0;
}
|
d5de8648b6b4f40f68e5e269b5adc5d6cf59d9e4
|
2deab4ea39001b1c41cf11b4c849824c8ac9e292
|
/lr2-v14-2.c
|
0a2821721233bb9a82daa7f8d740306f23b8c4bd
|
[] |
no_license
|
ZapilinEntertainment/USATU-C-course
|
2130b9f1b6999aa967e9dcad8eb9077e3c53d12a
|
3cc5b9549c727fa6d8c4376ec9e11b1620b5f610
|
refs/heads/master
| 2021-01-12T07:26:48.298336 | 2017-05-08T08:44:12 | 2017-05-08T08:44:12 | 76,963,035 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 468 |
c
|
lr2-v14-2.c
|
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
//using dev-C++
inline double RingSquare(double r_out,double r_in,double s)
{
s=(r_out*r_out-r_in*r_in)*M_PI;
}
int main(int argc, char *argv[]) {
double r1,r2,s;
printf("Enter the outside radius: ");
scanf("%lf",&r1);
printf ("Enter the inside radius: ");
scanf("%lf",&r2);
s=RingSquare(r1,r2,s);
printf ("ring square is %lf",s);
_getch();
return 0;
}
|
10a325da3d60373af1ef307537354d4167fd2408
|
32c7d34bf71ccfc71d6d2e0058377bdea8c5ee93
|
/srcs/split_minishell.c
|
4ce8544070ee46f8ed0e9230577d99537cf114af
|
[] |
no_license
|
mnaji42/minishell
|
9a4bfc1f5b87a803d74ef853545b668844f95ad0
|
bd37f332e5f90907c1af730e7a684a689468a5bc
|
refs/heads/main
| 2023-02-03T03:17:31.941752 | 2020-12-21T18:12:34 | 2020-12-21T18:12:34 | 323,413,747 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 3,192 |
c
|
split_minishell.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* split_minishell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchudant <cchudant@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/11 16:36:29 by mnaji #+# #+# */
/* Updated: 2020/01/13 18:53:44 by cchudant ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
static int ft_count_word(char const *s, char c)
{
int count_word;
t_quote q;
q = (t_quote) {.squote = -1, .dquote = -1};
count_word = 0;
while (s[q.i] != '\0')
{
while (s[q.i] == c && (q.dquote == -1 || q.squote == -1))
if (s[++q.i] == '\0')
return (count_word);
while ((s[q.i] != c || q.dquote == 1 || q.squote == 1) && s[q.i])
{
if (s[q.i] == '"' && q.squote == -1 && !q.escaped)
q.dquote *= -1;
else if (s[q.i] == '\'' && q.dquote == -1)
q.squote *= -1;
if (s[q.i] == '\0')
return (count_word + 1);
q.escaped = s[q.i++] == '\\' ? !q.escaped : 0;
}
count_word++;
}
return (count_word);
}
static int ft_size_word(char *str, char c)
{
int count;
t_quote q;
q = (t_quote) {.squote = -1, .dquote = -1};
count = 0;
while ((str[q.i] != c || q.dquote == 1 || q.squote == 1) && str[q.i])
{
if (str[q.i] == '"' && q.squote == -1 && !q.escaped)
q.dquote *= -1;
else if (str[q.i] == '\'' && q.dquote == -1)
q.squote *= -1;
q.escaped = str[q.i] == '\\' ? !q.escaped : 0;
count++;
q.i++;
}
return (count);
}
static int ft_cpy_ligne(char *tab1, char *s, int i, char c)
{
t_quote q;
q = (t_quote) {.squote = -1, .dquote = -1};
while ((s[i] != c || q.dquote == 1 || q.squote == 1) && s[i] != 0)
{
if (s[i] == '"' && q.squote == -1 && !q.escaped)
q.dquote *= -1;
else if (s[i] == '\'' && q.dquote == -1)
q.squote *= -1;
q.escaped = s[q.i] == '\\' ? !q.escaped : 0;
tab1[q.i] = s[i];
i++;
q.i++;
}
tab1[q.i] = '\0';
return (i);
}
static char **ft_return_tab(char *s, char **tab1, int ligne, char c)
{
if (*s - 1 != c)
tab1[ligne] = 0;
else
tab1[ligne - 1] = 0;
return (tab1);
}
char **split_minishell(char const *s, char c)
{
char **tab1;
int i;
int ligne;
if (!s || !c || !(tab1 = (char**)malloc(sizeof(char*) *\
(ft_count_word(s, c) + 1))))
return (NULL);
ligne = 0;
i = 0;
while (ligne < ft_count_word(s, c))
{
while (s[i] == c && s[i] != 0)
i++;
if (!(tab1[ligne] = (char*)malloc(sizeof(char) * \
ft_size_word((char*)&s[i], c) + 1)))
{
while (ligne-- >= 0)
free(tab1[ligne]);
free(tab1);
return (NULL);
}
i = ft_cpy_ligne(tab1[ligne], (char*)s, i, c);
ligne++;
}
return (ft_return_tab((char*)&s[i], tab1, ligne, c));
}
|
3d0293d750fbe3b2f2ea1cb9c36bc4fbeef6eb8f
|
6430b2fb09a09e867f0601286c97b147f5caa599
|
/libft/ft_memalloc.c
|
d2071dfe7eb9e602204e157187a3bcc70a9c4530
|
[] |
no_license
|
kaoliiny/lem_in
|
4df130ad0c57f4e8fe68d475aeee90fd3a60629b
|
f0739b85fb75bff6b5cd427ab7ba23aabef93af7
|
refs/heads/master
| 2020-05-27T02:51:50.963925 | 2019-08-20T16:11:29 | 2019-08-20T16:11:29 | 188,457,445 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,045 |
c
|
ft_memalloc.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memalloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kaoliiny <kaoliiny@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/05 16:26:25 by vbrazas #+# #+# */
/* Updated: 2019/06/18 17:48:20 by kaoliiny ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memalloc(size_t size)
{
void *buf;
buf = (void *)malloc(size);
if (buf != NULL)
ft_bzero(buf, size);
return (buf);
}
|
457ceb4d2237b4543afe4c8625c70fe28564b030
|
301b22e18241d5b63bc4bc5c46db946b44789510
|
/ADC/main.c
|
7256620c8d8eaf17934e85e669c0d1bb12edca2f
|
[] |
no_license
|
yara-alaa/embedded-projects
|
e41cb719fb89be39c94c4ef950bfec72412ca337
|
baf5519afb0cbde0b6b76263d2aa4078564ce1ca
|
refs/heads/master
| 2022-02-21T18:38:56.471669 | 2019-09-17T01:37:52 | 2019-09-17T01:37:52 | 208,927,838 | 0 | 0 | null | null | null | null |
WINDOWS-1252
|
C
| false | false | 987 |
c
|
main.c
|
/*
* main.c
*
* Created on: ??þ/??þ/????
* Author: yara
*/
#include "std_types.h"
#include "registers.h"
#include"utils.h"
#include"DIO.h"
#include"ADC.h"
#include<avr/delay.h>
u16 DigitalValue;
const float step=4.8;
float VIN_mv;
void main (void)
{
ADC_init();
DIO_vidsetportdir(c,0b11111111);
//DIO_vidsetportdir(c,0b11111111);
while (1)
{
DigitalValue=ADC_Read(0);
VIN_mv=DigitalValue*step;
if((VIN_mv>1000)&&(VIN_mv<2000))
{
DIO_vidwriteportvalues(c,0b00000001);
// DIO_vidwritepinvalue (c, 0, high);
}
else if((VIN_mv>2000)&&(VIN_mv<3000))
{
DIO_vidwriteportvalues(c,0b00000011);
// DIO_vidwritepinvalue (c, 1, high);
}
else if((VIN_mv>3000)&&(VIN_mv<4000))
{
// DIO_vidwritepinvalue (c, 2, high);
DIO_vidwriteportvalues(c,0b00000111);
}
else if((VIN_mv>4000)&&(VIN_mv<5000))
{
DIO_vidwriteportvalues(c,0b00001111);
// DIO_vidwritepinvalue (c, 3, high);
}
}
}
|
8bed16d36dfb64a296705973ed7e35dcfa9707d1
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/libcpu/risc-v/t-head/c906/symbol_analysis.h
|
a9db46ffd39db4435c1e451353ede2ac56586e40
|
[
"Apache-2.0"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801 | 2023-08-31T16:20:55 | 2023-08-31T16:20:55 | 7,408,108 | 9,599 | 5,805 |
Apache-2.0
| 2023-09-14T13:37:26 | 2013-01-02T14:49:21 |
C
|
UTF-8
|
C
| false | false | 1,721 |
h
|
symbol_analysis.h
|
/*
* Copyright lizhirui
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-05-18 lizhirui the first version
* 2021-05-20 lizhirui add os debug support
*/
#ifndef __SYMBOL_ANALYSIS_H__
#define __SYMBOL_ANALYSIS_H__
#include <rtthread.h>
//osdebug节区头描述结构体
typedef struct os_symtab_header
{
rt_size_t function_table_offset;//函数表的偏移地址(相对于节区起始地址,下同)
rt_size_t function_table_num;//函数表中的符号数量
rt_size_t object_table_offset;//对象表的偏移地址
rt_size_t object_table_num;//对象表中的符号数量
rt_size_t general_symbol_table_offset;//一般符号(指代类型虽为NONE但带有GLOBAL的符号)表的偏移地址
rt_size_t general_symbol_table_num;//一般符号表中的符号数量
rt_size_t string_table_offset;//字符串表的偏移地址
rt_size_t string_table_size;//字符串表的大小(字节为单位)
}os_symtab_header;
//符号描述结构体
typedef struct os_symtab_item
{
rt_size_t name_offset;//符号名称在字符串表中的偏移地址
rt_size_t address;//该符号所代表的地址
rt_size_t size;//该符号所代表的大小
}os_symtab_item;
os_symtab_item *find_symbol_table(rt_size_t symbol_table_addr,rt_size_t symbol_num,rt_size_t address);
const char *get_symbol_name(os_symtab_item *symbol);
void print_symbol(os_symtab_item *symbol,rt_size_t address);
void print_symbol_info(rt_size_t address,rt_bool_t function);
void print_stacktrace(rt_size_t epc,rt_size_t fp);
#endif
|
af0514a947f6e5ce812e302a894dfc1e20a18aa5
|
e4ef929f124859c35bf25d822073760e7ca00dba
|
/GGCompiler/GGUtils.h
|
ce3b84567e3056fa9bbbbb18a602b198534f69b2
|
[] |
no_license
|
gatesjef/gglang
|
843b1ce3798860a4133e0940140b02d5c8c784d7
|
4718acb89123dd21c3efc1600e399451cd8decc5
|
refs/heads/master
| 2016-09-03T06:28:11.107345 | 2015-02-16T07:29:33 | 2015-02-16T07:29:33 | 25,091,549 | 1 | 1 | null | 2015-02-09T01:02:49 | 2014-10-11T19:07:00 |
C++
|
UTF-8
|
C
| false | false | 30 |
h
|
GGUtils.h
|
// GGUtils.h
void halt();
|
caed693cb9902c8b6be466873c35796b8a4de7d9
|
6c66224b86df294c3cb0c8050b07780f21d24cbc
|
/modules/standard.lib.cripto/src/bn_openssl097beta1/hmf_rand.c
|
796ed147e49ae5caa5e1cbdd3038180f84638ab7
|
[
"BSD-2-Clause"
] |
permissive
|
Devronium/ConceptApplicationServer
|
46f3ef49816c153ff4d8b4b1f6c09f025a4ea0ad
|
e20e5104051fbaf7d4602c12ccc5778f762f2309
|
refs/heads/master
| 2023-08-03T09:21:19.404092 | 2023-07-29T05:37:49 | 2023-07-29T05:37:49 | 50,105,314 | 12 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 4,015 |
c
|
hmf_rand.c
|
#include <math.h> // sqrt()
#include "hmf_prime.h"
#include "hmf_rand.h"
static unsigned long N = 0;
#ifdef _WIN32
static unsigned __int64 X = 0;
#else
static unsigned long long X = 0;
#endif
/* check whether the value is prime or not
return zero if prime else return the divider
This function uses normal divider by small prime because
the value to check is small (32-bits), another special
algorithm is required to check a greater value */
/*
unsigned long isPrime32(unsigned long value)
{
unsigned long limit;
unsigned long ul;
unsigned long result = 0;
// check for even value
if(!(value & 1))
{
if(value == 2)
return(0); // 2 = prime .. the ONLY even number that is prime !!!
else
return(2); // it is an even number .. NOT a prime
}
// get limit
limit = (unsigned long) sqrt(value);
// check it by its limit
if(limit * limit == value)
return(limit);
for(ul = 1; ul <= 6542; ul++)
{
result = value % first6542prime[ul];
if(!result)
{
if(value == first6542prime[ul])
return(0);
else
return(first6542prime[ul]);
}
// check for limit
if(first6542prime[ul] >= limit)
return(0);
}
// this line should never be reached
// if reached, it means (one of below)
// 1. list of prime is NOT enough
// 2. this algorithm is wrong (bug)
return(0);
}
unsigned long pseudorandom_BBS32_preinit(unsigned short p, unsigned short q)
{
int remainder;
//check prime
if(isPrime32(p))
return(0);
if(isPrime32(q))
return(0);
remainder = (p % 4);
if(remainder != 3)
return(0);
if(remainder != (q % 4))
return(0); // failed
N = p * q;
return(N);
}
unsigned long pseudorandom_BBS32_init(unsigned long init)
{
unsigned long prevX;
prevX = (unsigned long) X;
// rule no 1
if(init < sqrt(N))
return(0);
// rule no 2
if(init > N)
return(0);
X = init;
// return previous value of X
// plus 1 to avoid zero because 0 = error
return(prevX + 1);
}
unsigned long pseudorandom_BBS32_random_value()
{
X = (X * X) % N;
return((unsigned long) X);
}
unsigned long pseudorandom_BBS32_random_bit(unsigned long totalBit)
{
unsigned long value;
unsigned long i;
if(totalBit < 1)
return(0);
if(totalBit > 32)
return(0);
//get first bit
value = (pseudorandom_BBS32_random_value() & 1);
//get the rest of the bit
for(i = 1; i < totalBit; i++)
{
value <<= 1;
value |= (pseudorandom_BBS32_random_value() & 1);
}
return(value);
}
*/
//===========================================end of bbs
//===========================================start of linear congruent
// X = (16807 * X) % 2147483647
// a full period value ...
const unsigned long modulus = 2147483647;
const unsigned long multiplier = 16807;
static unsigned long lastValue;
unsigned long random32_bit(unsigned long totalBit) {
unsigned long value;
unsigned long i;
value = 0;
for (i = 0; i < totalBit; i++) {
value <<= 1;
value |= (random32_value() & 1);
}
return value;
}
unsigned long random32_value() {
lastValue = (multiplier * lastValue) % modulus;
return lastValue;
}
void random32_init(unsigned long seed) {
lastValue = seed;
}
|
6ca38a61e0836d83839080c39313176f758cabe4
|
5801c6f6857a071f19ae0ba60ecdd37757437505
|
/B_FMI/~FMUOutput/sources/integration.h
|
f017ba732e36ee7edce8fd707804443c772d66f9
|
[
"BSD-3-Clause"
] |
permissive
|
mpodlaski/Modelica-Drone-3D-FMI
|
143cf0ae0a35e2745242866ae4bfff0af813eb43
|
0da67139345eb9b57d537286a54a8c7008ea3f22
|
refs/heads/master
| 2023-05-25T08:41:22.867856 | 2023-05-11T03:16:21 | 2023-05-11T03:16:21 | 213,958,168 | 0 | 0 |
BSD-3-Clause
| 2019-10-09T15:42:26 | 2019-10-09T15:42:24 | null |
UTF-8
|
C
| false | false | 3,390 |
h
|
integration.h
|
/* Internal header file for integration part of Dymosim FMI implementation. */
/*
All functions handle the case when the number of continuos states are 0, for convenience.
*/
#ifndef integration_h
#define integration_h
#include "types.h"
/* ----------------- function delcarations ----------------- */
/**
* Sets up integration.
*
* @param c the FMI component
* @param relTol the relative tolerance, if non-positive, a default value is used
* @return status
*/
DYMOLA_STATIC IntegrationStatus integration_setup(FMIComponent c, FMIReal relTol);
/**
* Tears down integration. May be called also if comp or its iData pointer is NULL.
*
* @param c the FMI component
*/
DYMOLA_STATIC void integration_teardown(FMIComponent c);
/**
* Integrates a time step forward. Time events are supposed to be handled outside
* this function, i.e. h should be set not to pass those. Also step events shall
* be handled outside. State events however are handled inside this function,
* effectively re-initializing integration when needed.
*
* @param comp the FMI component
* @param tout the end time
* @return status
*/
DYMOLA_STATIC IntegrationStatus integration_step(Component* comp, FMIReal tout);
/* re-initialize integration due to events
() */
/**
* Re-initialize the integration. Necessary at events.
* In particular multistep methods will otherwise use obsolete derivatives.
*
* @param comp the FMI component
* @return status
*/
DYMOLA_STATIC IntegrationStatus integration_reinit(Component* comp, int updateStatistics);
/**
* Synchronizes the value used as a base for input extrapolation. This is necessary when input is updated
* externally and in particular handles the case when input is set after the input derivatives.
*
* @param comp the FMI component
* @param ix the index
*/
DYMOLA_STATIC void integration_sync_extrapolation_input(Component* comp, size_t ix);
/**
* Updates the inputs according to input derivatives, if these are set recent enough.
*
* @param comp the FMI component
* @param t the current time
*/
DYMOLA_STATIC void integration_extrapolate_inputs(Component* comp, double t);
/**
* util function for updating integrationStatistics, only use at end of simulation or to store statistics before event
*
* @param comp the FMI component
*/
DYMOLA_STATIC void updateIntegrationStatistics(Component* comp, Statistics* stat);
#ifdef FMI_2
/**
* Gets the integration part of the FMU state.
*
* @param source the source
* @param target the target
* @return status
*/
DYMOLA_STATIC FMIStatus integration_get_state(Component* source, Component* target);
/**
* Sets the integration part of the previously saved FMU state.
*
* @param source the source
* @param target the target
* @return status
*/
DYMOLA_STATIC FMIStatus integration_set_state(Component* source, Component* target);
/**
* Frees the integration part of the previously saved FMU state.
*
* @param comp the FMI component to log status on
* @param target the component to free
*/
DYMOLA_STATIC void integration_free_state(Component* comp, Component* target);
/**
* Experimental function for HybridCosimulation
*
* @param tout is the propsed entime
* @param tRet is the returned endTime
*/
DYMOLA_STATIC IntegrationStatus integration_step_return_at_event(Component* comp, FMIReal tout, FMIReal* tRet);
#endif /* FMI_2 */
#endif /* integration_h */
|
f6f591726997978f90d31a7cdad5dd9bc659bbd9
|
9eb2245869dcc3abd3a28c6064396542869dab60
|
/benchspec/CPU/602.gcc_s/build/build_base_mytest-64.0000/reload.c
|
88aed4baff0be46972090a82e26487bbea092480
|
[] |
no_license
|
lapnd/CPU2017
|
882b18d50bd88e0a87500484a9d6678143e58582
|
42dac4b76117b1ba4a08e41b54ad9cfd3db50317
|
refs/heads/master
| 2023-03-23T23:34:58.350363 | 2021-03-24T10:01:03 | 2021-03-24T10:01:03 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 131 |
c
|
reload.c
|
version https://git-lfs.github.com/spec/v1
oid sha256:549cfd87dac82d176faca321fc0a9f456f53434c46954e9aebf19c45e58e9468
size 248617
|
ec862dd0ce9a3941b99b189ae7314c88992cd2a4
|
469ae4657f066eab5adac631b032cf9489f4a3d6
|
/push_swap/srcs/use.c
|
507228a779af16a95eed6f9924262a8b40167b2e
|
[] |
no_license
|
Nacyo/42_projects
|
fefeeb7f70ab8bc83c678f9ec60eaf80e0bc87f4
|
49ccafb49f862e4d12de3d5064cd2d984d6ad008
|
refs/heads/master
| 2021-01-24T08:29:39.034255 | 2018-06-24T15:29:35 | 2018-06-24T15:29:35 | 122,981,558 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,156 |
c
|
use.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_use.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ynacache <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/09 14:54:57 by ynacache #+# #+# */
/* Updated: 2018/01/21 19:05:39 by ynacache ### ########.fr */
/* */
/* ************************************************************************** */
#include <checker.h>
void ft_error(int nb)
{
if (nb == ERROR)
{
write(STDERR_FILENO, "Error\n", 6);
exit(1);
}
}
int ft_add_move(char *instruc, t_all *all)
{
t_move *tmp;
if (!(tmp = (t_move *)malloc(sizeof(t_move))))
return (ERROR);
ft_strcpy(tmp->instruc, instruc);
tmp->next = NULL;
if (all->move == NULL)
{
all->move = tmp;
all->move_end = tmp;
}
else
{
all->move_end->next = tmp;
all->move_end = tmp;
}
all->nb_move++;
if (all->option == 1)
ft_affiche_move(all);
return (SUCCESS);
}
int ft_add_a(int val, t_all *all)
{
t_stack *tmp;
if (!(tmp = (t_stack *)malloc(sizeof(t_stack))))
return (ERROR);
tmp->val = val;
tmp->next = NULL;
if (all->a == NULL)
{
all->a = tmp;
all->a_end = tmp;
}
else
{
all->a_end->next = tmp;
all->a_end = tmp;
}
all->nb_a++;
return (SUCCESS);
}
int ft_doublon(int val, t_all *all)
{
t_stack *current;
current = all->a;
while (current->next != NULL)
{
if (current->val == val)
return (ERROR);
current = current->next;
}
return (SUCCESS);
}
int ft_order(t_stack *stack)
{
t_stack *current;
current = stack;
while (current->next != NULL)
{
if (current->val > current->next->val)
return (ERROR);
current = current->next;
}
return (SUCCESS);
}
|
17e64cf15819fc55d8937a34ea6c6a4c6e6003cb
|
205798618411cd76c20bb2af66a6b9a5208f111c
|
/Proyecto/Compost/inc/Control_tasks.h
|
395f51a14b352ce844800e6d7679d32af4523419
|
[
"MIT"
] |
permissive
|
sebastianmuratore/td2-2018r4051-grupo1
|
a1801c98531085feb2f27cf1e21a97062d6df987
|
f522fc7e63c4bcf94545314f5cf6517055da9eba
|
refs/heads/master
| 2020-03-19T10:41:57.341830 | 2018-12-12T19:34:58 | 2018-12-12T19:34:58 | 136,393,725 | 2 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 411 |
h
|
Control_tasks.h
|
/*
* Control_tasks.h
*
* Created on: 16 de nov. de 2018
* Author: sebas
*/
#ifndef TPS_TD2_2018R4051_GRUPO1_PROYECTO_COMPOST_INC_CONTROL_TASKS_H_
#define TPS_TD2_2018R4051_GRUPO1_PROYECTO_COMPOST_INC_CONTROL_TASKS_H_
typedef struct
{
uint16_t temperatura;
uint16_t humedad;
}Datos;
void vGetReport(void *parametros);
#endif /* TPS_TD2_2018R4051_GRUPO1_PROYECTO_COMPOST_INC_CONTROL_TASKS_H_ */
|
2e5fcf33ea29ab52ff7f304f3f3f7268c89ece81
|
84a916d8ab8e325e53aae2c10386032bf97deba4
|
/output.h
|
47a2ab015410a0197810c7ac5ce56858f7b36c2e
|
[] |
no_license
|
BAzili073/STM32_PotPrj
|
2b4b8add42d646c9730b84ea64ec7cc063aa6eb8
|
6ac7fad471ad041e5aa4f3ed1aa878cd4e4f58dc
|
refs/heads/master
| 2021-01-19T21:00:18.703669 | 2017-04-18T12:41:26 | 2017-04-18T12:41:26 | 88,587,131 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 544 |
h
|
output.h
|
#ifdef OUTPUT
#else
#define OUTPUT
#include "defines.h"
#include INCLUDED_FILE_1
#include INCLUDED_FILE_2
void output_on_mode(uint8_t mode);
void output_off_mode(uint8_t mode);
void output_on_hand(uint8_t output);
void output_off_hand(uint8_t output);
void control_out_by_id_and_mode(uint8_t output_t,uint8_t mode,uint8_t state);
void read_output_settings();
void set_output_settings(uint8_t output_t, uint8_t mode_t);
void sms_control_output(uint8_t number, uint32_t state);
void check_time_output_on();
#endif
|
a1dae692508231846fb1f22943e5dfeb75b36a26
|
1a77b5eac40055032b72e27e720ac5d43451bbd6
|
/C/Chap8/Rei61.c
|
0f6c58b9621e7327660ac1daa417f985fe375411
|
[] |
no_license
|
motonobu-t/algorithm
|
8c8d360ebb982a0262069bb968022fe79f2c84c2
|
ca7b29d53860eb06a357eb268f44f47ec9cb63f7
|
refs/heads/master
| 2021-01-22T21:38:34.195001 | 2017-05-15T12:00:51 | 2017-05-15T12:01:00 | 85,451,237 | 0 | 0 | null | null | null | null |
SHIFT_JIS
|
C
| false | false | 616 |
c
|
Rei61.c
|
/*
* --------------------
* 3次元関数 *
* --------------------
*/
#include "glib.h"
void main(void)
{
double x,y,z,px,py,ax,ay,rd=3.1415927/180;
ax=30*rd;
ay=-30*rd;
ginit(); cls();
window(-320,-200,320,200);
for (z=200.0;z>=-200.0;z=z-10.0){
for (x=-200.0;x<=200.0;x=x+5.0){
y=30*(cos(sqrt(x*x+z*z)*rd)+cos(3*sqrt(x*x+z*z)*rd));
px=x*cos(ay)+z*sin(ay); /* 回転変換 */
py=y*cos(ax)-(-x*sin(ay)+z*cos(ay))*sin(ax);
if ((int)x==-200)
setpoint(px,py);
else
moveto(px,py);
}
}
}
|
2fc918673bbd99c26bc4c67b71bb762ad4593876
|
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
|
/source/lwan/src/bin/lwan/extr_main.c_print_help.c
|
773d105dc4bb72a277cb0939d22cff6a81726f94
|
[] |
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,277 |
c
|
extr_main.c_print_help.c
|
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct lwan_config {char* listener; } ;
typedef int /*<<< orphan*/ path_buf ;
/* Variables and functions */
int PATH_MAX ;
int /*<<< orphan*/ free (char*) ;
char* get_current_dir_name () ;
char* lwan_get_config_path (char*,int) ;
int /*<<< orphan*/ printf (char*,...) ;
__attribute__((used)) static void
print_help(const char *argv0, const struct lwan_config *config)
{
char path_buf[PATH_MAX];
char *current_dir = get_current_dir_name();
const char *config_file = lwan_get_config_path(path_buf, sizeof(path_buf));
printf("Usage: %s [--root /path/to/root/dir] [--listen addr:port]\n", argv0);
printf("\t[--config] [--user username] [--chroot] [--modules|--handlers]\n");
printf("Serve files through HTTP.\n\n");
printf("Options:\n");
printf("\t-r, --root Path to serve files from (default: ./wwwroot).\n");
printf("\t-l, --listen Listener (default: %s).\n", config->listener);
printf("\t-c, --config Path to config file path.\n");
printf("\t-u, --user Username to drop privileges to (root required).\n");
printf("\t-C, --chroot Chroot to path passed to --root (root required).\n");
printf("\t-m, --modules Print information about available modules.\n");
printf("\t-H, --handlers Print information about available handlers.\n");
printf("\t-h, --help This.\n");
printf("\n");
printf("Examples:\n");
printf(" Serve system-wide documentation:\n");
printf(" %s -r /usr/share/doc\n", argv0);
printf(" Serve on a different port:\n");
printf(" %s -l '*:1337'\n", argv0);
printf(" Use %s from %s:\n", config_file, current_dir);
printf(" %s\n", argv0);
printf(" Use /etc/%s:\n", config_file);
printf(" %s -c /etc/%s\n", argv0, config_file);
printf("\n");
printf("Report bugs at <https://github.com/lpereira/lwan>.\n");
free(current_dir);
}
|
c3e9f32a773b0c1256dd8c4e736cb7137c5838a6
|
a0b35a9ee12576fb1a31f4fae49ecdbc93bb5d25
|
/filehandler.h
|
e120396fb80b739b660c18933d3d2cd9b93d7648
|
[
"WTFPL"
] |
permissive
|
qubodup/falling
|
1c6c1f254cc87b009f7a3fc1357146afda75a46a
|
bf5f1588cce9e83f37335965f6bcf564d5971f23
|
refs/heads/master
| 2021-01-20T04:49:51.859969 | 2010-06-03T21:53:58 | 2010-06-03T21:53:58 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 651 |
h
|
filehandler.h
|
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2010 Sauer2
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
*/
/*The header of 'filehandler.c'*/
#ifndef FILEHANDLER_H
#define FILEHANDLER_H
void FreeImage (SDL_Surface* surface);
SDL_Surface* LoadImage(char* file);
#endif //FILEHANDLER_H
|
f4bda16bc142a6d04da83cacbc97bf9f465e30aa
|
556b467b0e31835de656c71a8f4e0bfd4acb7442
|
/d/tangmen/zhuang.c
|
af09a3fa6aa06324f53baad0474b9527186bde9a
|
[] |
no_license
|
afeizh/txmud
|
a4a48cb663eccfdf5aa0b951d34e93437a17c9fa
|
717c8ef173bff8abe27e00fb8dc150cbf02b3c3a
|
refs/heads/main
| 2023-08-07T20:33:48.154233 | 2021-09-16T15:34:37 | 2021-09-16T15:34:37 | null | 0 | 0 | null | null | null | null |
GB18030
|
C
| false | false | 809 |
c
|
zhuang.c
|
// Room: /d/tangmen/zhuang.c
inherit ROOM;
void init()
{
object me = this_player();
if(!userp(me))
return;
call_out("show_msg", 1, me);
}
protected void show_msg(object me)
{
int sk, n;
if(!me || (environment(me) != this_object()))
return;
sk = me->query_skill("dodge", 1);
if( ((n=me->query("kee")) <= 5) || (sk < 40) || (random(10) > (sk - 35)) )
{
message_vision("$N一个没站稳,倒栽冲摔了下去。\n", me);
me->receive_damage("kee", n>25?25:n, "trip");
me->move(__DIR__"lianwu");
tell_room(environment(me), me->name()+"摔了下来。\n", ({me}));
return;
}
message_vision("$N扎了个马步,纹丝不动。\n", me);
}
int valid_leave(object ob,string dir)
{
if(dir != "down")
{
ob->receive_damage("kee",20, "tire");
ob->start_busy(2);
}
return 1;
}
|
017ecbc4beb7253b7c62d538d0c8480db35dfd83
|
401445ae337fe0ede6b9360af6606f7a30983b9c
|
/php-5.0.5/ext/sockets/php_sockets.h
|
136ec0ff98af08b8ee1f52f54d7cf25c802adf75
|
[
"PHP-3.0"
] |
permissive
|
liexusong/open-source-reading-comments
|
76bbb0f055967e680d26b246313be256e0fe5695
|
8bad537ab86037c4a70c030a3c34ea94cff26cad
|
refs/heads/master
| 2020-05-20T02:23:07.706360 | 2015-03-17T19:46:38 | 2015-03-17T19:46:38 | 30,737,430 | 3 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 3,616 |
h
|
php_sockets.h
|
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Chris Vandomelen <chrisv@b0rked.dhs.org> |
| Sterling Hughes <sterling@php.net> |
| |
| WinSock: Daniel Beulshausen <daniel@php4win.de> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SOCKETS_H
#define PHP_SOCKETS_H
/* $Id: php_sockets.h,v 1.34.2.1 2005/02/14 08:25:30 sniper Exp $ */
#if HAVE_SOCKETS
extern zend_module_entry sockets_module_entry;
#define phpext_sockets_ptr &sockets_module_entry
#ifdef PHP_WIN32
#define PHP_SOCKETS_API __declspec(dllexport)
#include <winsock.h>
#else
#define PHP_SOCKETS_API
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#endif
PHP_MINIT_FUNCTION(sockets);
PHP_MINFO_FUNCTION(sockets);
PHP_RINIT_FUNCTION(sockets);
PHP_RSHUTDOWN_FUNCTION(sockets);
PHP_FUNCTION(socket_select);
PHP_FUNCTION(socket_create_listen);
PHP_FUNCTION(socket_create_pair);
PHP_FUNCTION(socket_accept);
PHP_FUNCTION(socket_set_nonblock);
PHP_FUNCTION(socket_set_block);
PHP_FUNCTION(socket_listen);
PHP_FUNCTION(socket_close);
PHP_FUNCTION(socket_write);
PHP_FUNCTION(socket_read);
PHP_FUNCTION(socket_getsockname);
PHP_FUNCTION(socket_getpeername);
PHP_FUNCTION(socket_create);
PHP_FUNCTION(socket_connect);
PHP_FUNCTION(socket_strerror);
PHP_FUNCTION(socket_bind);
PHP_FUNCTION(socket_recv);
PHP_FUNCTION(socket_send);
PHP_FUNCTION(socket_recvfrom);
PHP_FUNCTION(socket_sendto);
PHP_FUNCTION(socket_get_option);
PHP_FUNCTION(socket_set_option);
PHP_FUNCTION(socket_shutdown);
PHP_FUNCTION(socket_last_error);
PHP_FUNCTION(socket_clear_error);
#ifndef PHP_WIN32
typedef int PHP_SOCKET;
#else
typedef SOCKET PHP_SOCKET;
#endif
typedef struct {
PHP_SOCKET bsd_socket;
int type;
int error;
} php_socket;
/* Prototypes */
#ifdef ilia_0 /* not needed, only causes a compiler warning */
static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC);
static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC);
static int php_read(int bsd_socket, void *buf, size_t maxlen, int flags);
static char *php_strerror(int error TSRMLS_DC);
#endif
ZEND_BEGIN_MODULE_GLOBALS(sockets)
int last_error;
char *strerror_buf;
ZEND_END_MODULE_GLOBALS(sockets)
#ifdef ZTS
#define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v)
#else
#define SOCKETS_G(v) (sockets_globals.v)
#endif
#else
#define phpext_sockets_ptr NULL
#endif
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
|
057e900211b34a22dc512a8f73e3f3a1766661e9
|
8d7514271b08caaa8c757d0747853d54642e9e63
|
/plutommi/Framework/GDI/GDISrc/gd_primitive24.c
|
d2f6e3d0e6ac8b04424de9dc68b6ef71b745fc6e
|
[] |
no_license
|
npnet/MyCode
|
0bd3e32d5890c411b16e01cdb8acf5624c7c0a02
|
9fa7aa78d62f1cd3c2a39a36875cb41cf00522fe
|
refs/heads/master
| 2023-07-23T13:19:29.575050 | 2018-07-05T13:01:09 | 2018-07-05T13:01:09 | 140,229,839 | 1 | 2 | null | 2023-07-21T10:21:01 | 2018-07-09T04:07:28 |
C
|
UTF-8
|
C
| false | false | 23,438 |
c
|
gd_primitive24.c
|
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* gd_primitive24.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* GD Primitive related.
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#include "gdi_internal.h"
#include "gd_primitive.h"
#include "MMIDataType.h"
#include "gdi_datatype.h"
#include "gdi_include.h"
#if defined(__MTK_TARGET__)
#pragma arm section code = "INTERNCODE"
#endif
/*****************************************************************************
* FUNCTION
* gd_color_from_rgb_24
* DESCRIPTION
*
* PARAMETERS
* A [IN]
* R [IN]
* G [IN]
* B [IN]
* RETURNS
*
*****************************************************************************/
gdi_color gd_color_from_rgb_24(U32 A, U32 R, U32 G, U32 B)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return (gdi_color) ((R << 16) | (G << 8) | B);
}
/*****************************************************************************
* FUNCTION
* gd_color_to_rgb_24
* DESCRIPTION
*
* PARAMETERS
* A [?]
* R [?]
* G [?]
* B [?]
* c [IN]
* RETURNS
* void
*****************************************************************************/
void gd_color_to_rgb_24(U32 *A, U32 *R, U32 *G, U32 *B, gdi_color c)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
*A = 0xFF;
*R = (U32) ((U8) (c >> 16));
*G = (U32) ((U8) (c >> 8));
*B = (U32) ((U8) (c));
}
#if !defined(GDI_SLIM_COLOR_FORMAT)
/*****************************************************************************
* FUNCTION
* gd_get_pixel_24
* DESCRIPTION
*
* PARAMETERS
* x [IN]
* y [IN]
* RETURNS
*
*****************************************************************************/
gdi_color gd_get_pixel_24(int x, int y)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 *ptr = (U32*) (gdi_act_layer->buf_ptr + ((y * gdi_act_layer->width + x) * 3));
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (((U32) ptr) & 0x3)
{
case 0:
return ((*ptr) & 0x00ffffff);
case 1:
ptr = (U32*) (((U32) ptr) & (~0x3));
return ((*ptr) >> 8);
case 2:
ptr = (U32*) (((U32) ptr) & (~0x3));
return ((*ptr) >> 16) | ((*(ptr + 1) & 0x0ff) << 16);
default:
ptr = (U32*) (((U32) ptr) & (~0x3));
return ((*ptr) >> 24) | ((*(ptr + 1) & 0x0ffff) << 8);
}
}
/*****************************************************************************
* FUNCTION
* gd_put_pixel_24
* DESCRIPTION
*
* PARAMETERS
* x [IN]
* y [IN]
* c [IN]
* RETURNS
* void
*****************************************************************************/
void gd_put_pixel_24(int x, int y, gdi_color c)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 *ptr = (U32*) (gdi_act_layer->buf_ptr + ((y * gdi_act_layer->width + x) * 3));
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (((U32) ptr) & 0x3)
{
case 0:
*ptr = (*ptr & 0xff000000) | (c & 0x00ffffff);
break;
case 1:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x000000ff) | (c << 8);
break;
case 2:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x0000ffff) | (c << 16);
ptr++;
*ptr = (*ptr & 0xffffff00) | ((c & 0x00ff0000) >> 16);
break;
default:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x00ffffff) | (c << 24);
ptr++;
*ptr = (*ptr & 0xffff0000) | ((c & 0x00ffff00) >> 8);
}
}
/*****************************************************************************
* FUNCTION
* gd_put_pixel_to_layer_24
* DESCRIPTION
*
* PARAMETERS
* x [IN]
* y [IN]
* c [IN]
* RETURNS
* void
*****************************************************************************/
void gd_put_pixel_to_layer_24(gdi_handle layer_handle, int x, int y, gdi_color c)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
gdi_layer_struct *layer = (gdi_layer_struct*)layer_handle;
U32 *ptr = (U32*) (layer->buf_ptr + ((y * layer->width + x) * 3));
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (((U32) ptr) & 0x3)
{
case 0:
*ptr = (*ptr & 0xff000000) | (c & 0x00ffffff);
break;
case 1:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x000000ff) | (c << 8);
break;
case 2:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x0000ffff) | (c << 16);
ptr++;
*ptr = (*ptr & 0xffffff00) | ((c & 0x00ff0000) >> 16);
break;
default:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x00ffffff) | (c << 24);
ptr++;
*ptr = (*ptr & 0xffff0000) | ((c & 0x00ffff00) >> 8);
}
}
/*****************************************************************************
* FUNCTION
* gd_get_buf_pixel_24
* DESCRIPTION
*
* PARAMETERS
* buf_ptr [?]
* buf_width [IN]
* x [IN]
* y [IN]
* RETURNS
*
*****************************************************************************/
gdi_color gd_get_buf_pixel_24(U8 *buf_ptr, U32 buf_width, int x, int y)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 *ptr = (U32*) (buf_ptr + ((y * buf_width + x) * 3));
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (((U32) ptr) & 0x3)
{
case 0:
return ((*ptr) & 0x00ffffff);
case 1:
ptr = (U32*) (((U32) ptr) & (~0x3));
return ((*ptr) >> 8);
case 2:
ptr = (U32*) (((U32) ptr) & (~0x3));
return ((*ptr) >> 16) | ((*(ptr + 1) & 0x0ff) << 16);
default:
ptr = (U32*) (((U32) ptr) & (~0x3));
return ((*ptr) >> 24) | ((*(ptr + 1) & 0x0ffff) << 8);
}
}
/*****************************************************************************
* FUNCTION
* gd_put_buf_pixel_24
* DESCRIPTION
*
* PARAMETERS
* buf_ptr [?]
* buf_width [IN]
* x [IN]
* y [IN]
* c [IN]
* RETURNS
* void
*****************************************************************************/
void gd_put_buf_pixel_24(U8 *buf_ptr, U32 buf_width, int x, int y, gdi_color c)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 *ptr = (U32*) (buf_ptr + ((y * buf_width + x) * 3));
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (((U32) ptr) & 0x3)
{
case 0:
*ptr = (*ptr & 0xff000000) | (c & 0x00ffffff);
break;
case 1:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x000000ff) | (c << 8);
break;
case 2:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x0000ffff) | (c << 16);
ptr++;
*ptr = (*ptr & 0xffffff00) | ((c & 0x00ff0000) >> 16);
break;
default:
ptr = (U32*) (((U32) ptr) & (~0x3));
*ptr = (*ptr & 0x00ffffff) | (c << 24);
ptr++;
*ptr = (*ptr & 0xffff0000) | ((c & 0x00ffff00) >> 8);
}
}
#define REPLACE_U24_0(PTR,SRCKEY) \
{ \
gdi_color c = (*PTR)&0x00ffffff; \
if (SRCKEY == c) \
{ \
*PTR = (*PTR&0xff000000)|((c^1)&0x00ffffff);\
} \
}while(0) \
#define REPLACE_U24_1(PTR,SRCKEY) \
{ \
U32 *temp_ptr = (U32*)(((U32)PTR)&(~0x3)); \
gdi_color c = (*temp_ptr)>>8; \
if (SRCKEY == c) \
{ \
*temp_ptr = (*temp_ptr&0x000000ff)|((c^1)<<8);\
} \
}while(0) \
#define REPLACE_U24_2(PTR,SRCKEY) \
{ \
U32 *temp_ptr = (U32*)(((U32)PTR)&(~0x3)); \
gdi_color c = ((*temp_ptr)>>16) | ((*(temp_ptr+1)&0x0ff ) <<16);\
if (SRCKEY == c) \
{ \
*temp_ptr = (*temp_ptr&0x0000ffff)|((c^1)<<16); temp_ptr++; \
*temp_ptr = (*temp_ptr&0xffffff00)|(((c^1)&0x00ff0000)>>16); \
} \
}while(0) \
#define REPLACE_U24_3(PTR,SRCKEY) \
{ \
U32 *temp_ptr = (U32*)(((U32)PTR)&(~0x3)); \
gdi_color c = ((*temp_ptr)>>24) | ((*(temp_ptr+1)&0x0ffff) << 8);\
if (SRCKEY == c) \
{ \
*temp_ptr = (*temp_ptr&0x00ffffff)|((c^1)<<24); temp_ptr++; \
*temp_ptr = (*temp_ptr&0xffff0000)|(((c^1)&0x00ffff00)>>8); \
} \
}while(0) \
/*****************************************************************************
* FUNCTION
* gd_replace_src_key_24
* DESCRIPTION
*
* PARAMETERS
* dest_ptr [?]
* dest_pitch [IN]
* dest_offset_x [IN]
* dest_offset_y [IN]
* clipx1 [IN]
* clipy1 [IN]
* clipx2 [IN]
* clipy2 [IN]
* src_key [IN]
* width [IN]
* height [IN]
* RETURNS
* void
*****************************************************************************/
void gd_replace_src_key_24(
U8 *dest_ptr,
S32 dest_pitch,
S32 dest_offset_x,
S32 dest_offset_y,
S32 clipx1,
S32 clipy1,
S32 clipx2,
S32 clipy2,
gdi_color src_key,
S32 width,
S32 height)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *dest_line_start_ptr;
S32 jump_size;
S32 start_x, start_y, end;
S32 x_draw_count, y_draw_count;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* if not totally out of clip region */
if (!((dest_offset_x > clipx2) ||
(dest_offset_y > clipy2) || (dest_offset_x + width < clipx1) || (dest_offset_y + height < clipy1)))
{
/* find x_draw_count and y_draw_count */
start_x = (dest_offset_x < clipx1) ? clipx1 : dest_offset_x;
end = (dest_offset_x + (S32) width - 1 > clipx2) ? clipx2 : dest_offset_x + (S32) width - 1;
x_draw_count = end - start_x + 1;
start_y = (dest_offset_y < clipy1) ? clipy1 : dest_offset_y;
end = (dest_offset_y + (S32) height - 1 > clipy2) ? clipy2 : dest_offset_y + (S32) height - 1;
y_draw_count = end - start_y + 1;
/* adjust dest ptr to the start of drawing point */
/* find start ptr for actual drawing */
jump_size = ((start_y * dest_pitch + start_x) * 24) >> 3;
dest_line_start_ptr = dest_ptr + jump_size;
{
U8 *dest;
S32 x, y;
S32 x_draw_count_afer_shift;
for (y = 0; y < y_draw_count; y++)
{
dest = (dest_line_start_ptr + ((dest_pitch * y * 24) >> 3));
x = 0;
switch (((U32) dest) & 0x3)
{
case 3:
REPLACE_U24_3(dest, src_key);
dest += 3;
if (++x >= x_draw_count)
{
break;
}
case 2:
REPLACE_U24_2(dest, src_key);
dest += 3;
if (++x >= x_draw_count)
{
break;
}
case 1:
REPLACE_U24_1(dest, src_key);
dest += 3;
if (++x >= x_draw_count)
{
break;
}
break;
}
x_draw_count_afer_shift = x_draw_count - x;
if (x_draw_count_afer_shift > 3)
{
for (x = 0; x < (x_draw_count_afer_shift & (~0x3)); x += 4)
{
REPLACE_U24_0(dest, src_key);
dest += 3;
REPLACE_U24_3(dest, src_key);
dest += 3;
REPLACE_U24_2(dest, src_key);
dest += 3;
REPLACE_U24_1(dest, src_key);
dest += 3;
}
}
switch (((U32) x_draw_count_afer_shift) & 0x3)
{
case 3:
REPLACE_U24_2(dest + 6, src_key);
case 2:
REPLACE_U24_3(dest + 3, src_key);
case 1:
REPLACE_U24_0(dest, src_key);
break;
}
}
}
}
}
#define PIXEL_TYPE U32
#define PIXEL_BYTES 3
#define GET_PIXEL(C,PTR) \
do \
{ \
U32 *SS = (U32*)PTR; \
switch(((U32)SS)&0x3) \
{ \
case 0: \
C = ((*SS)&0x00ffffff); \
break; \
case 1: \
SS= (U32*)(((U32)SS)&(~0x3)); \
C =((*SS)>>8); \
break; \
case 2: \
SS= (U32*)(((U32)SS)&(~0x3)); \
C = ((*SS)>>16) | ((*(SS+1)&0x0ff ) <<16);\
break; \
default: \
SS= (U32*)(((U32)SS)&(~0x3)); \
C = ((*SS)>>24) | ((*(SS+1)&0x0ffff) << 8);\
break; \
} \
}while(0)
#define PUT_PIXEL(C,PTR) \
do \
{ \
U32 *DD = (U32*)PTR; \
switch(((U32)DD)&0x3) \
{ \
case 0: \
*DD = (*DD&0xff000000)|(C&0x00ffffff); \
break; \
case 1: \
DD = (U32*)(((U32)DD)&(~0x3)); \
*DD = (*DD&0x000000ff)|(C<<8); \
break; \
case 2: \
DD = (U32*)(((U32)DD)&(~0x3)); \
*DD = (*DD&0x0000ffff)|(C<<16); DD++; \
*DD = (*DD&0xffffff00)|((C&0x00ff0000)>>16);\
break; \
default: \
DD = (U32*)(((U32)DD)&(~0x3)); \
*DD = (*DD&0x00ffffff)|(C<<24); DD++; \
*DD = (*DD&0xffff0000)|((C&0x00ffff00)>>8); \
break; \
} \
}while(0)
#define JUMP_PIXEL(PTR,N) PTR = (((U8*)PTR)+(N)* PIXEL_BYTES)
#define GD_RESIZE_BITBLT gd_resize_bitblt_24
#define GD_BITBLT gd_bitblt_24
#define GD_MEMSET gd_memset_24
#define GD_FILL_DOT_RECTANGLE gd_fill_dot_rect_24
#define GD_IMAGE_BITS_DRAW gd_image_bits_draw_24
#include "gd_primitive_internal.h"
#endif
#if defined(__MTK_TARGET__)
#pragma arm section code
#endif
|
5184058247cac20ae1a51e3d9e0eb513c966eb20
|
bd30f52755e3844330c2db11bbe87c7fe4110173
|
/OneToOneCallSample/ios/Pods/Headers/Private/RNStringee/RNStringeeClient.h
|
bc9d9d3e8aaeda190f30d9480bacf1f11c86ddd3
|
[] |
no_license
|
phamdocaohiep/react-native-samples
|
e36cc39490c0af53b0bb1faf71b5f494a13c3170
|
9b7f7d49580cca9b115488ddeb01c4bc6d734d71
|
refs/heads/master
| 2023-03-10T04:48:08.441278 | 2020-07-28T03:36:16 | 2020-07-28T03:36:16 | 342,523,311 | 2 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 72 |
h
|
RNStringeeClient.h
|
../../../../../node_modules/stringee-react-native/ios/RNStringeeClient.h
|
78428fe182c22c6aebe548d25c6aa02f6fea3293
|
d0b398dd37a7dcccadc2f2c8c74de2e23c3a44f4
|
/第2章-信息的表示和处理/家庭作业2.84/main.c
|
9b5de741639a4c11907cf6f941943055b697c468
|
[] |
no_license
|
iOSPrincekin/CSAPP-3e-Solutions
|
c520f121c8c8a5d5158c419b38e5e6f730469105
|
d66aa71cffe23af54628f17c61ec9a72cfd2f1a5
|
refs/heads/master
| 2021-01-06T07:41:56.960210 | 2020-02-26T05:43:10 | 2020-02-26T05:43:10 | 241,247,709 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,161 |
c
|
main.c
|
#include <stdio.h>
#include <assert.h>
/*
* 填写下列程序的返回值,这个程序测试它的第一个参数是否小于或者等于第二个参数。假定函数
* f2u 返回一个无符号32位数字,其位表示与它的浮点参数相同。你可以假设两个参数都不是
* NaN。两种0,+0和-0被认为是相等的。
*
* */
unsigned f2u(float x)
{
}
int float_le(float x, float y)
{
unsigned ux = f2u(x);
unsigned uy = f2u(y);
/* Get the sign bits */
unsigned sx = ux >> 31;
unsigned sy = uy >> 31;
/* Give an expression using only ux,uy,sx, and sy */
int is_le = 0;
// 如果 x 是负数
if (sx == 1 && sy == 0){
is_le = 1;
}
// 如果 y 是负数
else if (sx == 0 && sy == 1)
{
is_le = 0;
} else if(sx == 0 && sy == 0)
{
is_le = ux <= uy;
} else if(sx == 1 && sy == 1)
{
is_le = ux >= uy;
}
return is_le;
}
int main() {
printf("Hello, World!\n");
assert(float_le(-0, +0));
assert(float_le(+0, -0));
assert(float_le(0, 3));
assert(float_le(-4, -0));
assert(float_le(-4, 4));
return 0;
}
|
6c56063c1a83adced758678838266443baaf7e9d
|
42c9ed45e5e0ad149741862b93f5a2bf90e39f8a
|
/algorithm/algorithm/main.c
|
e36eaec524c6aa76c29fd956e8d59b0c72df56ff
|
[] |
no_license
|
gervarg/macrotis-embedded-orientation-mockexam
|
bc7fe654fca634c0625dd5fccc9dc266a2dd9f56
|
5524500036119cc852a3073ebaed9af5d315444e
|
refs/heads/master
| 2020-03-11T18:30:31.398630 | 2018-04-19T09:03:40 | 2018-04-19T09:03:40 | 130,178,823 | 0 | 0 | null | 2018-04-19T07:52:36 | 2018-04-19T07:52:36 | null |
UTF-8
|
C
| false | false | 854 |
c
|
main.c
|
#include <stdio.h>
#include <stdlib.h>
/* Write a function which is called "get_fibonacci_number". It returns the "N"th
* Fibonacci number, where "N" is received as a paramter.
* For example:
* - get_fibonacci_number(1) returns 0
* - get_fibonacci_number(2) returns 1
* - get_fibonacci_number(3) returns 1
* - get_fibonacci_number(4) returns 2
* - get_fibonacci_number(5) returns 3
* - get_fibonacci_number(6) returns 5
*
* If the function gets invalid parameter it returns -1.
*/
int fibonacci(int);
int main()
{
int n = 8;
printf("The fibonacci number of %d is: %d\n", n, fibonacci(n));
}
int fibonacci(int number)
{
if (number == 0)
return 0;
else if (number == 1)
return 1;
else if (number < 0)
return -1;
else
return (fibonacci(number - 1) + fibonacci(number - 2));
}
|
f2ae82433a2f12a186e608f157e4c24f7abbba4f
|
e8cc605b38972a5963edc6f81164e2adfc6b23a7
|
/c_programming/is_prime.c
|
38c087652a648caa45ec0d0f0836988dc679f255
|
[] |
no_license
|
vonnenaut/c_learning
|
73b6d97623f2408f5aceb736128e9087f35ad601
|
f8c97a4201d8fc89dddd8f35ebd8e0a20f1fe0cb
|
refs/heads/master
| 2023-06-25T05:30:05.753727 | 2021-07-26T11:58:03 | 2021-07-26T11:58:03 | 326,361,266 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 397 |
c
|
is_prime.c
|
#include <stdio.h>
int is_prime(int value)
{
int divisor;
for (divisor = 2; divisor < (value / 2) + 1; divisor++)
{
if (value % divisor == 0)
{
return 0;
}
}
return 1;
}
void main()
{
printf("%d\n", is_prime(4) == 0);
printf("%d\n", is_prime(5) == 1);
printf("%d\n", is_prime(6) == 0);
printf("%d\n", is_prime(7) == 1);
}
|
8c4a857003790e511993e572463e4b49db9f015a
|
41d6193de7f38713dbe5089e8da7ce96afa16ac5
|
/kernel/generic/mig/server.c
|
07e4964f1ede06b596a20c547e01b1d14bfe1eb7
|
[
"BSD-3-Clause"
] |
permissive
|
neozeed/xMach
|
2be67bfdcb329b8952d0a384bfc76e6ce025a3e9
|
2283fb558392a5412f06007bb1d55fb5c670bc0a
|
refs/heads/main
| 2023-07-25T07:38:59.593412 | 2022-11-12T23:10:10 | 2022-11-12T23:10:10 | 374,872,648 | 11 | 5 |
BSD-3-Clause
| 2021-07-14T02:58:10 | 2021-06-08T03:46:04 |
C
|
UTF-8
|
C
| false | false | 37,793 |
c
|
server.c
|
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
#include <assert.h>
#include "write.h"
#include "utils.h"
#include "global.h"
#include "error.h"
#include "cpu.h"
static void
WriteIncludes(FILE *file)
{
fprintf(file, "#define EXPORT_BOOLEAN\n");
fprintf(file, "#include <mach/boolean.h>\n");
fprintf(file, "#include <mach/kern_return.h>\n");
fprintf(file, "#include <mach/message.h>\n");
fprintf(file, "#include <mach/mig_errors.h>\n");
fprintf(file, "#include <mach/mig_support.h>\n");
if (IsKernelServer)
fprintf(file, "#include <ipc/ipc_port.h>\n");
fprintf(file, "\n");
}
static void
WriteGlobalDecls(FILE *file)
{
if (RCSId != strNULL)
WriteRCSDecl(file, strconcat(SubsystemName, "_server"), RCSId);
/* Used for locations in the request message, *not* reply message.
Reply message locations aren't dependent on IsKernelServer. */
if (IsKernelServer)
{
fprintf(file, "#define msgh_request_port\tmsgh_remote_port\n");
fprintf(file, "#define MACH_MSGH_BITS_REQUEST(bits)");
fprintf(file, "\tMACH_MSGH_BITS_REMOTE(bits)\n");
fprintf(file, "#define msgh_reply_port\t\tmsgh_local_port\n");
fprintf(file, "#define MACH_MSGH_BITS_REPLY(bits)");
fprintf(file, "\tMACH_MSGH_BITS_LOCAL(bits)\n");
}
else
{
fprintf(file, "#define msgh_request_port\tmsgh_local_port\n");
fprintf(file, "#define MACH_MSGH_BITS_REQUEST(bits)");
fprintf(file, "\tMACH_MSGH_BITS_LOCAL(bits)\n");
fprintf(file, "#define msgh_reply_port\t\tmsgh_remote_port\n");
fprintf(file, "#define MACH_MSGH_BITS_REPLY(bits)");
fprintf(file, "\tMACH_MSGH_BITS_REMOTE(bits)\n");
}
fprintf(file, "\n");
}
static void
WriteProlog(FILE *file)
{
fprintf(file, "/* Module %s */\n", SubsystemName);
fprintf(file, "\n");
WriteIncludes(file);
WriteBogusDefines(file);
WriteGlobalDecls(file);
}
static void
WriteSymTabEntries(FILE *file, const statement_t *stats)
{
register const statement_t *stat;
register u_int current = 0;
for (stat = stats; stat != stNULL; stat = stat->stNext)
if (stat->stKind == skRoutine) {
register num = stat->stRoutine->rtNumber;
const char *name = stat->stRoutine->rtName;
while (++current <= num)
fprintf(file,"\t\t\t{ \"\", 0, 0 },\n");
fprintf(file, "\t{ \"%s\", %d, _X%s },\n",
name,
SubsystemBase + current - 1,
name);
}
while (++current <= rtNumber)
fprintf(file,"\t{ \"\", 0, 0 },\n");
}
static void
WriteArrayEntries(FILE *file, const statement_t *stats)
{
register u_int current = 0;
register const statement_t *stat;
for (stat = stats; stat != stNULL; stat = stat->stNext)
if (stat->stKind == skRoutine)
{
register const routine_t *rt = stat->stRoutine;
while (current++ < rt->rtNumber)
fprintf(file, "\t\t0,\n");
fprintf(file, "\t\t_X%s,\n", rt->rtName);
}
while (current++ < rtNumber)
fprintf(file, "\t\t\t0,\n");
}
static void
WriteEpilog(FILE *file, const statement_t *stats)
{
fprintf(file, "\n");
/*
* First, the symbol table
*/
fprintf(file, "static mig_routine_t %s_routines[] = {\n", ServerDemux);
WriteArrayEntries(file, stats);
fprintf(file, "};\n");
fprintf(file, "\n");
/*
* Then, the server routine
*/
fprintf(file, "mig_external boolean_t %s\n", ServerDemux);
fprintf(file, "\t(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)\n");
fprintf(file, "{\n");
fprintf(file, "\tregister mach_msg_header_t *InP = InHeadP;\n");
fprintf(file, "\tregister mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP;\n");
fprintf(file, "\n");
WriteStaticDecl(file, itRetCodeType,
itRetCodeType->itDeallocate, itRetCodeType->itLongForm,
!IsKernelServer, "RetCodeType");
fprintf(file, "\n");
fprintf(file, "\tregister mig_routine_t routine;\n");
fprintf(file, "\n");
fprintf(file, "\tOutP->Head.msgh_bits = ");
fprintf(file, "MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0);\n");
fprintf(file, "\tOutP->Head.msgh_size = sizeof *OutP;\n");
fprintf(file, "\tOutP->Head.msgh_remote_port = InP->msgh_reply_port;\n");
fprintf(file, "\tOutP->Head.msgh_local_port = MACH_PORT_NULL;\n");
fprintf(file, "\tOutP->Head.msgh_seqno = 0;\n");
fprintf(file, "\tOutP->Head.msgh_id = InP->msgh_id + 100;\n");
fprintf(file, "\n");
WritePackMsgType(file, itRetCodeType,
itRetCodeType->itDeallocate, itRetCodeType->itLongForm,
!IsKernelServer, "OutP->RetCodeType", "RetCodeType");
fprintf(file, "\n");
fprintf(file, "\tif ((InP->msgh_id > %d) || (InP->msgh_id < %d) ||\n",
SubsystemBase + rtNumber - 1, SubsystemBase);
fprintf(file, "\t ((routine = %s_routines[InP->msgh_id - %d]) == 0)) {\n",
ServerDemux, SubsystemBase);
fprintf(file, "\t\tOutP->RetCode = MIG_BAD_ID;\n");
fprintf(file, "\t\treturn FALSE;\n");
fprintf(file, "\t}\n");
/* Call appropriate routine */
fprintf(file, "\t(*routine) (InP, &OutP->Head);\n");
fprintf(file, "\treturn TRUE;\n");
fprintf(file, "}\n");
fprintf(file, "\n");
/*
* Then, the <subsystem>_server_routine routine
*/
fprintf(file, "mig_external mig_routine_t %s_routine\n", ServerDemux);
fprintf(file, "\t(const mach_msg_header_t *InHeadP)\n");
fprintf(file, "{\n");
fprintf(file, "\tregister int msgh_id;\n");
fprintf(file, "\n");
fprintf(file, "\tmsgh_id = InHeadP->msgh_id - %d;\n", SubsystemBase);
fprintf(file, "\n");
fprintf(file, "\tif ((msgh_id > %d) || (msgh_id < 0))\n",
rtNumber - 1);
fprintf(file, "\t\treturn 0;\n");
fprintf(file, "\n");
fprintf(file, "\treturn %s_routines[msgh_id];\n", ServerDemux);
fprintf(file, "}\n");
fprintf(file, "\n");
/* symtab */
if (GenSymTab) {
fprintf(file,"\nmig_symtab_t _%sSymTab[] = {\n",SubsystemName);
WriteSymTabEntries(file,stats);
fprintf(file,"};\n");
fprintf(file,"int _%sSymTabBase = %d;\n",SubsystemName,SubsystemBase);
fprintf(file,"int _%sSymTabEnd = %d;\n",SubsystemName,SubsystemBase+rtNumber);
}
}
/*
* Returns the return type of the server-side work function.
* Suitable for "extern %s serverfunc()".
*/
static const char *
ServerSideType(const routine_t *rt)
{
if (rt->rtServerReturn == argNULL)
return "void";
else
return rt->rtServerReturn->argType->itTransType;
}
static void
WriteLocalVarDecl(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
if (it->itInLine && it->itVarArray)
{
register const ipc_type_t *btype = it->itElement;
fprintf(file, "\t%s %s[%d]", btype->itTransType,
arg->argVarName, it->itNumber/btype->itNumber);
}
else
fprintf(file, "\t%s %s", it->itTransType, arg->argVarName);
}
static void
WriteLocalPtrDecl(FILE *file, register const argument_t *arg)
{
fprintf(file, "\t%s *%sP",
FetchServerType(arg->argType->itElement),
arg->argVarName);
}
static void
WriteServerArgDecl(FILE *file, const argument_t *arg)
{
fprintf(file, "%s %s%s",
arg->argType->itTransType,
arg->argByReferenceServer ? "*" : "",
arg->argVarName);
}
/*
* Writes the local variable declarations which are always
* present: InP, OutP, the server-side work function.
*/
static void
WriteVarDecls(FILE *file, const routine_t *rt)
{
int i;
boolean_t NeedMsghSize = FALSE;
boolean_t NeedMsghSizeDelta = FALSE;
fprintf(file, "\tregister Request *In0P = (Request *) InHeadP;\n");
for (i = 1; i <= rt->rtMaxRequestPos; i++)
fprintf(file, "\tregister Request *In%dP;\n", i);
fprintf(file, "\tregister Reply *OutP = (Reply *) OutHeadP;\n");
fprintf(file, "\tmig_external %s %s\n",
ServerSideType(rt), rt->rtServerName);
fprintf(file, "\t\t(");
WriteList(file, rt->rtArgs, WriteServerArgDecl, akbServerArg, ", ", "");
fprintf(file, ");\n");
fprintf(file, "\n");
if (!rt->rtSimpleFixedReply)
fprintf(file, "\tboolean_t msgh_simple;\n");
else if (!rt->rtSimpleCheckRequest)
{
fprintf(file, "#if\tTypeCheck\n");
fprintf(file, "\tboolean_t msgh_simple;\n");
fprintf(file, "#endif\t/* TypeCheck */\n");
fprintf(file, "\n");
}
/* if either request or reply is variable, we may need
msgh_size_delta and msgh_size */
if (rt->rtNumRequestVar > 0)
NeedMsghSize = TRUE;
if (rt->rtMaxRequestPos > 0)
NeedMsghSizeDelta = TRUE;
if (rt->rtNumReplyVar > 1)
NeedMsghSize = TRUE;
if (rt->rtMaxReplyPos > 0)
NeedMsghSizeDelta = TRUE;
if (NeedMsghSize)
fprintf(file, "\tunsigned int msgh_size;\n");
if (NeedMsghSizeDelta)
fprintf(file, "\tunsigned int msgh_size_delta;\n");
if (NeedMsghSize || NeedMsghSizeDelta)
fprintf(file, "\n");
}
static void
WriteMsgError(FILE *file, const char *error_msg)
{
fprintf(file, "\t\t{ OutP->RetCode = %s; return; }\n", error_msg);
}
static void
WriteReplyInit(FILE *file, const routine_t *rt)
{
boolean_t printed_nl = FALSE;
if (rt->rtSimpleFixedReply)
{
if (!rt->rtSimpleSendReply) /* complex reply message */
{
printed_nl = TRUE;
fprintf(file, "\n");
fprintf(file,
"\tOutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX;\n");
}
}
else
{
printed_nl = TRUE;
fprintf(file, "\n");
fprintf(file, "\tmsgh_simple = %s;\n",
strbool(rt->rtSimpleSendReply));
}
if (rt->rtNumReplyVar == 0)
{
if (!printed_nl)
fprintf(file, "\n");
fprintf(file, "\tOutP->Head.msgh_size = %d;\n", rt->rtReplySize);
}
}
static void
WriteReplyHead(FILE *file, const routine_t *rt)
{
if ((!rt->rtSimpleFixedReply) ||
(rt->rtNumReplyVar > 1))
{
fprintf(file, "\n");
if (rt->rtMaxReplyPos > 0)
fprintf(file, "\tOutP = (Reply *) OutHeadP;\n");
}
if (!rt->rtSimpleFixedReply)
{
fprintf(file, "\tif (!msgh_simple)\n");
fprintf(file,
"\t\tOutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX;\n");
}
if (rt->rtNumReplyVar > 1)
fprintf(file, "\tOutP->Head.msgh_size = msgh_size;\n");
}
static void
WriteCheckHead(FILE *file, const routine_t *rt)
{
fprintf(file, "#if\tTypeCheck\n");
if (rt->rtNumRequestVar > 0)
fprintf(file, "\tmsgh_size = In0P->Head.msgh_size;\n");
if (!rt->rtSimpleCheckRequest)
fprintf(file, "\tmsgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX);\n");
if (rt->rtNumRequestVar > 0)
fprintf(file, "\tif ((msgh_size < %d)",
rt->rtRequestSize);
else
fprintf(file, "\tif ((In0P->Head.msgh_size != %d)",
rt->rtRequestSize);
if (rt->rtSimpleCheckRequest)
fprintf(file, " ||\n\t %s(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)",
rt->rtSimpleReceiveRequest ? "" : "!");
fprintf(file, ")\n");
WriteMsgError(file, "MIG_BAD_ARGUMENTS");
fprintf(file, "#endif\t/* TypeCheck */\n");
fprintf(file, "\n");
}
static void
WriteTypeCheck(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
register const routine_t *rt = arg->argRoutine;
fprintf(file, "#if\tTypeCheck\n");
if (akCheck(arg->argKind, akbRequestQC))
fprintf(file, "\tif (* (int *) &In%dP->%s != * (int *) &%sCheck)\n",
arg->argRequestPos, arg->argTTName, arg->argVarName);
else
{
fprintf(file, "\tif (");
if (!it->itIndefinite) {
fprintf(file, "(In%dP->%s%s.msgt_inline != %s) ||\n\t ",
arg->argRequestPos, arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "",
strbool(it->itInLine));
}
fprintf(file, "(In%dP->%s%s.msgt_longform != %s) ||\n",
arg->argRequestPos, arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "",
strbool(arg->argLongForm));
if (it->itOutName == MACH_MSG_TYPE_POLYMORPHIC)
{
if (!rt->rtSimpleCheckRequest)
fprintf(file, "\t (MACH_MSG_TYPE_PORT_ANY(In%dP->%s.msgt%s_name) && msgh_simple) ||\n",
arg->argRequestPos, arg->argTTName,
arg->argLongForm ? "l" : "");
}
else
fprintf(file, "\t (In%dP->%s.msgt%s_name != %s) ||\n",
arg->argRequestPos, arg->argTTName,
arg->argLongForm ? "l" : "",
it->itOutNameStr);
if (!it->itVarArray)
fprintf(file, "\t (In%dP->%s.msgt%s_number != %d) ||\n",
arg->argRequestPos, arg->argTTName,
arg->argLongForm ? "l" : "",
it->itNumber);
fprintf(file, "\t (In%dP->%s.msgt%s_size != %d))\n",
arg->argRequestPos, arg->argTTName,
arg->argLongForm ? "l" : "",
it->itSize);
}
WriteMsgError(file, "MIG_BAD_ARGUMENTS");
fprintf(file, "#endif\t/* TypeCheck */\n");
fprintf(file, "\n");
}
static void
WriteCheckArgSize(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *ptype = arg->argType;
register const ipc_type_t *btype = ptype->itElement;
const argument_t *count = arg->argCount;
int multiplier = btype->itTypeSize / btype->itNumber;
if (ptype->itIndefinite) {
/*
* Check descriptor. If out-of-line, use standard size.
*/
fprintf(file, "(In%dP->%s%s.msgt_inline) ? ",
arg->argRequestPos,
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
}
if (btype->itTypeSize % 4 != 0)
fprintf(file, "(");
if (multiplier > 1)
fprintf(file, "%d * ", multiplier);
fprintf(file, "In%dP->%s", arg->argRequestPos, count->argMsgField);
/* If the base type size of the data field isn`t a multiple of 4,
we have to round up. */
if (btype->itTypeSize % 4 != 0)
fprintf(file, " + 3) & ~3");
if (ptype->itIndefinite) {
fprintf(file, " : sizeof(%s *)", FetchServerType(btype));
}
}
static void
WriteCheckMsgSize(FILE *file, register const argument_t *arg)
{
register const routine_t *rt = arg->argRoutine;
/* If there aren't any more In args after this, then
we can use the msgh_size_delta value directly in
the TypeCheck conditional. */
if (arg->argRequestPos == rt->rtMaxRequestPos)
{
fprintf(file, "#if\tTypeCheck\n");
fprintf(file, "\tif (msgh_size != %d + (", rt->rtRequestSize);
WriteCheckArgSize(file, arg);
fprintf(file, "))\n");
WriteMsgError(file, "MIG_BAD_ARGUMENTS");
fprintf(file, "#endif\t/* TypeCheck */\n");
}
else
{
/* If there aren't any more variable-sized arguments after this,
then we must check for exact msg-size and we don't need to
update msgh_size. */
boolean_t LastVarArg = arg->argRequestPos+1 == rt->rtNumRequestVar;
/* calculate the actual size in bytes of the data field. note
that this quantity must be a multiple of four. hence, if
the base type size isn't a multiple of four, we have to
round up. note also that btype->itNumber must
divide btype->itTypeSize (see itCalculateSizeInfo). */
fprintf(file, "\tmsgh_size_delta = ");
WriteCheckArgSize(file, arg);
fprintf(file, ";\n");
fprintf(file, "#if\tTypeCheck\n");
/* Don't decrement msgh_size until we've checked that
it won't underflow. */
if (LastVarArg)
fprintf(file, "\tif (msgh_size != %d + msgh_size_delta)\n",
rt->rtRequestSize);
else
fprintf(file, "\tif (msgh_size < %d + msgh_size_delta)\n",
rt->rtRequestSize);
WriteMsgError(file, "MIG_BAD_ARGUMENTS");
if (!LastVarArg)
fprintf(file, "\tmsgh_size -= msgh_size_delta;\n");
fprintf(file, "#endif\t/* TypeCheck */\n");
}
fprintf(file, "\n");
}
static const char *
InArgMsgField(register const argument_t *arg)
{
static char buffer[100];
/*
* Inside the kernel, the request and reply port fields
* really hold ipc_port_t values, not mach_port_t values.
* Hence we must cast the values.
*/
if (IsKernelServer &&
((akIdent(arg->argKind) == akeRequestPort) ||
(akIdent(arg->argKind) == akeReplyPort)))
sprintf(buffer, "(ipc_port_t) In%dP->%s",
arg->argRequestPos, arg->argMsgField);
else
sprintf(buffer, "In%dP->%s",
arg->argRequestPos, arg->argMsgField);
return buffer;
}
static void
WriteExtractArgValue(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
if (arg->argMultiplier > 1)
WriteCopyType(file, it, "%s", "/* %s */ %s / %d",
arg->argVarName, InArgMsgField(arg), arg->argMultiplier);
else if (it->itInTrans != strNULL)
WriteCopyType(file, it, "%s", "/* %s */ %s(%s)",
arg->argVarName, it->itInTrans, InArgMsgField(arg));
else
WriteCopyType(file, it, "%s", "/* %s */ %s",
arg->argVarName, InArgMsgField(arg));
fprintf(file, "\n");
}
static void
WriteInitializeCount(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *ptype = arg->argParent->argType;
register const ipc_type_t *btype = ptype->itElement;
/*
* Initialize 'count' argument for variable-length inline OUT parameter
* with maximum allowed number of elements.
*/
fprintf(file, "\t%s = %d;\n", arg->argVarName,
ptype->itNumber/btype->itNumber);
/*
* If the user passed in a count, then we use the minimum.
* We can't let the user completely override our maximum,
* or the user might convince the server to overwrite the buffer.
*/
if (arg->argCInOut != argNULL) {
const char *msgfield = InArgMsgField(arg->argCInOut);
fprintf(file, "\tif (%s < %s)\n", msgfield, arg->argVarName);
fprintf(file, "\t\t%s = %s;\n", arg->argVarName, msgfield);
}
fprintf(file, "\n");
}
static void
WriteInitializePtr(FILE *file, register const argument_t *arg)
{
if (akCheck(arg->argKind, akbVarNeeded))
fprintf(file, "\t%sP = %s;\n",
arg->argVarName, arg->argVarName);
else
fprintf(file, "\t%sP = OutP->%s;\n",
arg->argVarName, arg->argMsgField);
}
static void
WriteTypeCheckArg(FILE *file, register const argument_t *arg)
{
if (akCheck(arg->argKind, akbRequest)) {
WriteTypeCheck(file, arg);
if (akCheck(arg->argKind, akbVariable))
WriteCheckMsgSize(file, arg);
}
}
static void
WriteAdjustRequestMsgPtr(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *ptype = arg->argType;
fprintf(file,
"\tIn%dP = (Request *) ((char *) In%dP + msgh_size_delta - %d);\n\n",
arg->argRequestPos+1, arg->argRequestPos,
ptype->itTypeSize + ptype->itPadSize);
}
static void
WriteTypeCheckRequestArgs(FILE *file, register const routine_t *rt)
{
register const argument_t *arg;
register const argument_t *lastVarArg;
lastVarArg = argNULL;
for (arg = rt->rtArgs; arg != argNULL; arg = arg->argNext) {
/*
* Advance message pointer if the last request argument was
* variable-length and the request position will change.
*/
if (lastVarArg != argNULL &&
lastVarArg->argRequestPos < arg->argRequestPos)
{
WriteAdjustRequestMsgPtr(file, lastVarArg);
lastVarArg = argNULL;
}
/*
* Type-check the argument.
*/
WriteTypeCheckArg(file, arg);
/*
* Remember whether this was variable-length.
*/
if (akCheckAll(arg->argKind, akbVariable|akbRequest))
lastVarArg = arg;
}
}
static void
WriteExtractArg(FILE *file, register const argument_t *arg)
{
if (akCheckAll(arg->argKind, akbSendRcv|akbVarNeeded))
WriteExtractArgValue(file, arg);
if ((akIdent(arg->argKind) == akeCount) &&
akCheck(arg->argKind, akbReturnSnd))
{
register ipc_type_t *ptype = arg->argParent->argType;
if (ptype->itInLine && ptype->itVarArray)
WriteInitializeCount(file, arg);
}
if (akCheckAll(arg->argKind, akbReturnSnd|akbPointer))
WriteInitializePtr(file, arg);
}
static void
WriteServerCallArg(FILE *file, register const argument_t *arg)
{
const ipc_type_t *it = arg->argType;
boolean_t NeedClose = FALSE;
if (arg->argByReferenceServer)
fprintf(file, "&");
if ((it->itInTrans != strNULL) &&
akCheck(arg->argKind, akbSendRcv) &&
!akCheck(arg->argKind, akbVarNeeded))
{
fprintf(file, "%s(", it->itInTrans);
NeedClose = TRUE;
}
if (akCheck(arg->argKind, akbPointer))
fprintf(file, "%sP", arg->argVarName);
else if (akCheck(arg->argKind, akbVarNeeded))
fprintf(file, "%s", arg->argVarName);
else if (akCheck(arg->argKind, akbSendRcv)) {
if (akCheck(arg->argKind, akbIndefinite)) {
fprintf(file, "(In%dP->%s%s.msgt_inline) ",
arg->argRequestPos,
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
fprintf(file, "? %s ", InArgMsgField(arg));
fprintf(file, ": *((%s **)%s)",
FetchServerType(arg->argType->itElement),
InArgMsgField(arg));
}
else
fprintf(file, "%s", InArgMsgField(arg));
}
else
fprintf(file, "OutP->%s", arg->argMsgField);
if (NeedClose)
fprintf(file, ")");
if (!arg->argByReferenceServer && (arg->argMultiplier > 1))
fprintf(file, " / %d", arg->argMultiplier);
}
static void
WriteDestroyArg(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
if (akCheck(arg->argKind, akbIndefinite)) {
/*
* Deallocate only if out-of-line.
*/
argument_t *count = arg->argCount;
ipc_type_t *btype = it->itElement;
int multiplier = btype->itTypeSize / btype->itNumber;
fprintf(file, "\tif (!In%dP->%s%s.msgt_inline)\n",
arg->argRequestPos,
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
fprintf(file, "\t\t%smig_deallocate(* (vm_offset_t *) %s, ",
SubrPrefix, InArgMsgField(arg));
if (multiplier > 1)
fprintf(file, "%d * ", multiplier);
fprintf(file, " %s);\n", InArgMsgField(count));
} else {
if (akCheck(arg->argKind, akbVarNeeded))
fprintf(file, "\t%s(%s);\n", it->itDestructor, arg->argVarName);
else
fprintf(file, "\t%s(%s);\n", it->itDestructor,
InArgMsgField(arg));
}
}
static void
WriteDestroyPortArg(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
/*
* If a translated port argument occurs in the body of a request
* message, and the message is successfully processed, then the
* port right should be deallocated. However, the called function
* didn't see the port right; it saw the translation. So we have
* to release the port right for it.
*/
if ((it->itInTrans != strNULL) &&
(it->itOutName == MACH_MSG_TYPE_PORT_SEND))
{
fprintf(file, "\n");
fprintf(file, "\tif (IP_VALID(%s))\n", InArgMsgField(arg));
fprintf(file, "\t\t%sipc_port_release_send(%s);\n",
SubrPrefix, InArgMsgField(arg));
}
}
/*
* Check whether WriteDestroyPortArg would generate any code for arg.
*/
static boolean_t
CheckDestroyPortArg(register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
if ((it->itInTrans != strNULL) &&
(it->itOutName == MACH_MSG_TYPE_PORT_SEND))
{
return TRUE;
}
return FALSE;
}
static void
WriteServerCall(FILE *file, const routine_t *rt)
{
boolean_t NeedClose = FALSE;
fprintf(file, "\t");
if (rt->rtServerReturn != argNULL)
{
const argument_t *arg = rt->rtServerReturn;
const ipc_type_t *it = arg->argType;
fprintf(file, "OutP->%s = ", arg->argMsgField);
if (it->itOutTrans != strNULL)
{
fprintf(file, "%s(", it->itOutTrans);
NeedClose = TRUE;
}
}
fprintf(file, "%s(", rt->rtServerName);
WriteList(file, rt->rtArgs, WriteServerCallArg, akbServerArg, ", ", "");
if (NeedClose)
fprintf(file, ")");
fprintf(file, ");\n");
}
static void
WriteGetReturnValue(FILE *file, register const routine_t *rt)
{
if (rt->rtServerReturn != rt->rtRetCode)
fprintf(file, "\tOutP->%s = KERN_SUCCESS;\n",
rt->rtRetCode->argMsgField);
}
static void
WriteCheckReturnValue(FILE *file, register const routine_t *rt)
{
if (rt->rtServerReturn == rt->rtRetCode)
{
fprintf(file, "\tif (OutP->%s != KERN_SUCCESS)\n",
rt->rtRetCode->argMsgField);
fprintf(file, "\t\treturn;\n");
}
}
static void
WritePackArgType(FILE *file, register const argument_t *arg)
{
fprintf(file, "\n");
WritePackMsgType(file, arg->argType,
arg->argType->itIndefinite ? d_NO : arg->argDeallocate,
arg->argLongForm, !IsKernelServer,
"OutP->%s", "%s", arg->argTTName);
}
static void
WritePackArgValue(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *it = arg->argType;
fprintf(file, "\n");
if (it->itInLine && it->itVarArray) {
if (it->itString) {
/*
* Copy variable-size C string with mig_strncpy.
* Save the string length (+ 1 for trailing 0)
* in the argument`s count field.
*/
fprintf(file,
"\tOutP->%s = %smig_strncpy(OutP->%s, %s, %d);\n",
arg->argCount->argMsgField,
SubrPrefix,
arg->argMsgField,
arg->argVarName,
it->itNumber);
}
else {
register argument_t *count = arg->argCount;
register ipc_type_t *btype = it->itElement;
/* Note btype->itNumber == count->argMultiplier */
if (it->itIndefinite) {
/*
* If we are packing argument, it must be from
* a local variable.
*/
fprintf(file, "\tif (%sP != %s) {\n",
arg->argVarName,
arg->argVarName);
fprintf(file, "\t\tOutP->%s%s.msgt_inline = FALSE;\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
if (arg->argDeallocate == d_YES)
fprintf(file, "\t\tOutP->%s%s.msgt_deallocate = TRUE;\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
else if (arg->argDeallocate == d_MAYBE)
fprintf(file, "\t\tOutP->%s%s.msgt_deallocate = %s;\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "",
arg->argDealloc->argVarName);
fprintf(file, "\t\t*((%s **)OutP->%s) = %sP;\n",
FetchServerType(btype),
arg->argMsgField,
arg->argVarName);
if (!arg->argRoutine->rtSimpleFixedReply)
fprintf(file, "\t\tmsgh_simple = FALSE;\n");
fprintf(file, "\t}\n\telse {\n\t");
}
fprintf(file, "\tmemcpy(OutP->%s, %s, ",
arg->argMsgField, arg->argVarName);
if (btype->itTypeSize > 1)
fprintf(file, "%d * ",
btype->itTypeSize);
fprintf(file, "%s);\n",
count->argVarName);
if (it->itIndefinite)
fprintf(file, "\t}\n");
}
}
else if (arg->argMultiplier > 1)
WriteCopyType(file, it, "OutP->%s", "/* %s */ %d * %s",
arg->argMsgField,
arg->argMultiplier,
arg->argVarName);
else if (it->itOutTrans != strNULL)
WriteCopyType(file, it, "OutP->%s", "/* %s */ %s(%s)",
arg->argMsgField, it->itOutTrans, arg->argVarName);
else
WriteCopyType(file, it, "OutP->%s", "/* %s */ %s",
arg->argMsgField, arg->argVarName);
}
static void
WriteCopyArgValue(FILE *file, register const argument_t *arg)
{
fprintf(file, "\n");
WriteCopyType(file, arg->argType, "/* %d */ OutP->%s", "In%dP->%s",
arg->argRequestPos, arg->argMsgField);
}
static void
WriteAdjustMsgSimple(FILE *file, register const argument_t *arg)
{
/* akbVarNeeded must be on */
if (!arg->argRoutine->rtSimpleFixedReply)
{
fprintf(file, "\n");
fprintf(file, "\tif (MACH_MSG_TYPE_PORT_ANY(%s))\n", arg->argVarName);
fprintf(file, "\t\tmsgh_simple = FALSE;\n");
}
}
static void
WriteAdjustMsgCircular(FILE *file, register const argument_t *arg)
{
fprintf(file, "\n");
if (arg->argType->itOutName == MACH_MSG_TYPE_POLYMORPHIC)
fprintf(file, "\tif (%s == MACH_MSG_TYPE_PORT_RECEIVE)\n",
arg->argPoly->argVarName);
/*
* The carried port right can be accessed in OutP->XXXX. Normally
* the server function stuffs it directly there. If it is InOut,
* then it has already been copied into the reply message.
* If the server function deposited it into a variable (perhaps
* because the reply message is variable-sized) then it has already
* been copied into the reply message. Note we must use InHeadP
* (or In0P->Head) and OutHeadP to access the message headers,
* because of the variable-sized messages.
*/
fprintf(file, "\tif (IP_VALID((ipc_port_t) InHeadP->msgh_reply_port) &&\n");
fprintf(file, "\t IP_VALID((ipc_port_t) OutP->%s) &&\n", arg->argMsgField);
fprintf(file, "\t %sipc_port_check_circularity((ipc_port_t) OutP->%s, (ipc_port_t) InHeadP->msgh_reply_port))\n",
SubrPrefix, arg->argMsgField);
fprintf(file, "\t\tOutHeadP->msgh_bits |= MACH_MSGH_BITS_CIRCULAR;\n");
}
/*
* Calculate the size of a variable-length message field.
*/
static void
WriteArgSize(FILE *file, register const argument_t *arg)
{
register const ipc_type_t *ptype = arg->argType;
register int bsize = ptype->itElement->itTypeSize;
register const argument_t *count = arg->argCount;
if (ptype->itIndefinite) {
/*
* Check descriptor. If out-of-line, use standard size.
*/
fprintf(file, "(OutP->%s%s.msgt_inline) ? ",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
}
if (bsize % 4 != 0)
fprintf(file, "(");
if (bsize > 1)
fprintf(file, "%d * ", bsize);
if (ptype->itString)
/* get count from descriptor in message */
fprintf(file, "OutP->%s", count->argMsgField);
else
/* get count from argument */
fprintf(file, "%s", count->argVarName);
/*
* If the base type size is not a multiple of sizeof(int) [4],
* we have to round up.
*/
if (bsize % 4 != 0)
fprintf(file, " + 3) & ~3");
if (ptype->itIndefinite) {
fprintf(file, " : sizeof(%s *)",
FetchServerType(ptype->itElement));
}
}
/*
* Adjust message size and advance reply pointer.
* Called after packing a variable-length argument that
* has more arguments following.
*/
static void
WriteAdjustMsgSize(FILE *file, register const argument_t *arg)
{
register routine_t *rt = arg->argRoutine;
register ipc_type_t *ptype = arg->argType;
/* There are more Out arguments. We need to adjust msgh_size
and advance OutP, so we save the size of the current field
in msgh_size_delta. */
fprintf(file, "\tmsgh_size_delta = ");
WriteArgSize(file, arg);
fprintf(file, ";\n");
if (rt->rtNumReplyVar == 1)
/* We can still address the message header directly. Fill
in the size field. */
fprintf(file, "\tOutP->Head.msgh_size = %d + msgh_size_delta;\n",
rt->rtReplySize);
else
if (arg->argReplyPos == 0)
/* First variable-length argument. The previous msgh_size value
is the minimum reply size. */
fprintf(file, "\tmsgh_size = %d + msgh_size_delta;\n",
rt->rtReplySize);
else
fprintf(file, "\tmsgh_size += msgh_size_delta;\n");
fprintf(file,
"\tOutP = (Reply *) ((char *) OutP + msgh_size_delta - %d);\n",
ptype->itTypeSize + ptype->itPadSize);
}
/*
* Calculate the size of the message. Called after the
* last argument has been packed.
*/
static void
WriteFinishMsgSize(FILE *file, register const argument_t *arg)
{
/* No more Out arguments. If this is the only variable Out
argument, we can assign to msgh_size directly. */
if (arg->argReplyPos == 0) {
fprintf(file, "\tOutP->Head.msgh_size = %d + (",
arg->argRoutine->rtReplySize);
WriteArgSize(file, arg);
fprintf(file, ");\n");
}
else {
fprintf(file, "\tmsgh_size += ");
WriteArgSize(file, arg);
fprintf(file, ";\n");
}
}
static void
WritePackArg(FILE *file, register const argument_t *arg)
{
if (akCheck(arg->argKind, akbReplyInit))
WritePackArgType(file, arg);
if ((akIdent(arg->argKind) == akePoly) &&
akCheck(arg->argKind, akbReturnSnd))
WriteAdjustMsgSimple(file, arg);
if (akCheckAll(arg->argKind, akbReturnSnd|akbVarNeeded))
WritePackArgValue(file, arg);
else if (akCheckAll(arg->argKind, akbReturnSnd|akbVariable)) {
register const ipc_type_t *it = arg->argType;
if (it->itString) {
/* Need to call strlen to calculate the size of the argument. */
fprintf(file, "\tOutP->%s = strlen(OutP->%s) + 1;\n",
arg->argCount->argMsgField, arg->argMsgField);
} else if (it->itIndefinite) {
/*
* We know that array is in reply message.
*/
fprintf(file, "\tif (%sP != OutP->%s) {\n",
arg->argVarName,
arg->argMsgField);
fprintf(file, "\t\tOutP->%s%s.msgt_inline = FALSE;\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
if (arg->argDeallocate == d_YES)
fprintf(file, "\t\tOutP->%s%s.msgt_deallocate = TRUE;\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
else if (arg->argDeallocate == d_MAYBE)
fprintf(file, "\t\tOutP->%s%s.msgt_deallocate = %s;\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "",
arg->argDealloc->argVarName);
fprintf(file, "\t\t*((%s **)OutP->%s) = %sP;\n",
FetchServerType(it->itElement),
arg->argMsgField,
arg->argVarName);
if (!arg->argRoutine->rtSimpleFixedReply)
fprintf(file, "\t\tmsgh_simple = FALSE;\n");
fprintf(file, "\t}\n");
}
}
if (akCheck(arg->argKind, akbReplyCopy))
WriteCopyArgValue(file, arg);
/*
* If this is a KernelServer, and the reply message contains
* a receive right, we must check for the possibility of a
* port/message circularity. If queueing the reply message
* would cause a circularity, we mark the reply message
* with the circular bit.
*/
if (IsKernelServer &&
akCheck(arg->argKind, akbReturnSnd) &&
((arg->argType->itOutName == MACH_MSG_TYPE_PORT_RECEIVE) ||
(arg->argType->itOutName == MACH_MSG_TYPE_POLYMORPHIC)))
WriteAdjustMsgCircular(file, arg);
}
/*
* Handle reply arguments - fill in message types and copy arguments
* that need to be copied.
*/
static void
WritePackReplyArgs(FILE *file, register const routine_t *rt)
{
register const argument_t *arg;
register const argument_t *lastVarArg;
lastVarArg = argNULL;
for (arg = rt->rtArgs; arg != argNULL; arg = arg->argNext) {
/*
* Adjust message size and advance message pointer if
* the last reply argument was variable-length and the
* request position will change.
*/
if (lastVarArg != argNULL &&
lastVarArg->argReplyPos < arg->argReplyPos)
{
WriteAdjustMsgSize(file, lastVarArg);
lastVarArg = argNULL;
}
/*
* Copy the argument
*/
WritePackArg(file, arg);
/*
* Remember whether this was variable-length.
*/
if (akCheckAll(arg->argKind, akbReturnSnd|akbVariable))
lastVarArg = arg;
}
/*
* Finish the message size.
*/
if (lastVarArg != argNULL)
WriteFinishMsgSize(file, lastVarArg);
}
static void
WriteFieldDecl(FILE *file, const argument_t *arg)
{
WriteFieldDeclPrim(file, arg, FetchServerType);
}
static void
WriteRoutine(FILE *file, register const routine_t *rt)
{
fprintf(file, "\n");
fprintf(file, "/* %s %s */\n", rtRoutineKindToStr(rt->rtKind), rt->rtName);
fprintf(file, "mig_internal void _X%s\n", rt->rtName);
fprintf(file, "\t(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)\n");
fprintf(file, "{\n");
WriteStructDecl(file, rt->rtArgs, WriteFieldDecl, akbRequest, "Request");
WriteStructDecl(file, rt->rtArgs, WriteFieldDecl, akbReply, "Reply");
WriteVarDecls(file, rt);
WriteList(file, rt->rtArgs, WriteCheckDecl, akbRequestQC, "\n", "\n");
WriteList(file, rt->rtArgs,
IsKernelServer ? WriteTypeDeclOut : WriteTypeDeclIn,
akbReplyInit, "\n", "\n");
WriteList(file, rt->rtArgs, WriteLocalVarDecl,
akbVarNeeded, ";\n", ";\n\n");
WriteList(file, rt->rtArgs, WriteLocalPtrDecl,
akbPointer, ";\n", ";\n\n");
WriteCheckHead(file, rt);
WriteTypeCheckRequestArgs(file, rt);
WriteList(file, rt->rtArgs, WriteExtractArg, akbNone, "", "");
WriteServerCall(file, rt);
WriteGetReturnValue(file, rt);
WriteReverseList(file, rt->rtArgs, WriteDestroyArg, akbDestroy, "", "");
/*
* For one-way routines, it doesn`t make sense to check the return
* code, because we return immediately afterwards. However,
* kernel servers may want to deallocate port arguments - and the
* deallocation must not be done if the return code is not KERN_SUCCESS.
*/
if (rt->rtOneWay || rt->rtNoReplyArgs)
{
if (IsKernelServer)
{
if (rtCheckMaskFunction(rt->rtArgs, akbSendBody|akbSendRcv,
CheckDestroyPortArg))
{
WriteCheckReturnValue(file, rt);
}
WriteReverseList(file, rt->rtArgs, WriteDestroyPortArg,
akbSendBody|akbSendRcv, "", "");
}
}
else
{
WriteCheckReturnValue(file, rt);
if (IsKernelServer)
WriteReverseList(file, rt->rtArgs, WriteDestroyPortArg,
akbSendBody|akbSendRcv, "", "");
WriteReplyInit(file, rt);
WritePackReplyArgs(file, rt);
WriteReplyHead(file, rt);
}
fprintf(file, "}\n");
}
void
WriteServer(FILE *file, const statement_t *stats)
{
register const statement_t *stat;
WriteProlog(file);
for (stat = stats; stat != stNULL; stat = stat->stNext)
switch (stat->stKind)
{
case skRoutine:
WriteRoutine(file, stat->stRoutine);
break;
case skImport:
case skSImport:
WriteImport(file, stat->stFileName);
break;
case skUImport:
break;
default:
fatal("WriteServer(): bad statement_kind_t (%d)",
(int) stat->stKind);
}
WriteEpilog(file, stats);
}
|
baa6efe1841d8b6f06593671a4820e3e0cdd70d0
|
978fdaf3b3c1c94d93054a15ae5e2d02e44e7420
|
/sm_os.h
|
d25e8bc92986aca43f6e7cbb37ef553cc9662fe6
|
[] |
no_license
|
mwennrich/milter-greylist-geoip2
|
cbcd592f3a8e1b09c8de300a5c6cd6d513b21e0a
|
2e001b631041d142cea03b25ddab449bffc333f3
|
refs/heads/master
| 2021-07-09T00:28:24.696935 | 2020-07-28T05:37:26 | 2020-07-28T05:37:26 | 165,856,083 | 1 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 86 |
h
|
sm_os.h
|
/* $Id: sm_os.h,v 1.1 2008/08/21 21:05:35 manu Exp $ */
#define SM_CONF_STDBOOL_H 1
|
8135eb0280dac0ea9fe7de384eba60692ffaef4a
|
1608dfc2ddbccd9587de08bb0e5d41f33d729ec9
|
/validation/.svn/pristine/81/8135eb0280dac0ea9fe7de384eba60692ffaef4a.svn-base
|
ca119a2d70935ba624f7dee03a80f1a93d954034
|
[] |
no_license
|
dkhaldi/PIPS_TaskParallelization
|
d623d3ae334d0e1c63772bae86bb0c115e928708
|
f324f3374cc8cbb58498b9dde172b1e7596abe1c
|
refs/heads/master
| 2020-07-03T14:16:30.427670 | 2016-11-18T21:44:34 | 2016-11-18T21:44:34 | 74,167,837 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 99 |
8135eb0280dac0ea9fe7de384eba60692ffaef4a.svn-base
|
//Size of array should be known and should not be dynamic
#define N 10
void foo()
{
int * A[N];
}
|
|
91832b5957d73f2c83b4313c0db0d6370f5e772e
|
255edefcf3de60c4a6afae55fe2ea946d417d425
|
/libft/ft_strtrim.c
|
9fbedb3b47f32e47fbf51d3e3ab7b2936466bb32
|
[] |
no_license
|
tbayet/npuzzle
|
07c16389a2c0285358d5caa63f234c261313bd8c
|
ed50f4cc6262aa54a1ab5611c6684e3f31471f5d
|
refs/heads/master
| 2020-07-06T06:43:58.316330 | 2017-01-08T16:28:12 | 2017-01-08T16:28:12 | 74,055,548 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,402 |
c
|
ft_strtrim.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tbayet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/25 12:57:11 by tbayet #+# #+# */
/* Updated: 2015/12/07 09:47:11 by tbayet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
char *ft_strtrim(char const *s)
{
unsigned int len;
unsigned int start;
unsigned int end;
char *res;
if (!s)
return (NULL);
start = 0;
while (s[start] != '\0' && (s[start] == ' '
|| s[start] == '\n' || s[start] == '\t'))
start++;
len = ft_strlen(s);
if (s[start] == '\0')
return (ft_strdup(""));
end = len - 1;
while (s[end] == ' ' || s[end] == '\n' || s[end] == '\t')
end--;
res = ft_strsub(s, start, (end - start) + 1);
return (res);
}
|
a32173d4d9dd9b420bc39699b532959054570b5f
|
03fb11c39bdf59b6d1b7e98e420992e4f4653f2b
|
/src/rlibc/debugger.h
|
905aef93753a8f0e5f5d5846ea381e9dfaa30437
|
[] |
no_license
|
Msiavashi/LISA-OS
|
14a59cc0e4c5688654f46a3456776eccae92c7f9
|
a31955e3a7a5f38ea2df228dd830823e2f37a057
|
refs/heads/master
| 2021-01-01T18:17:41.320035 | 2015-09-01T16:11:33 | 2015-09-01T16:11:33 | 41,747,336 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 120 |
h
|
debugger.h
|
extern int debug_flag = 0;
void print_data(struct data *head);
void print_line(struct text *head);
void debugger(void);
|
d947d630854e2d74605d7f9c994fd695efb8376d
|
843abe9562e13a616d938f838d761c0da807e3da
|
/Mozzi-1.0.3rc6/tables/AKWF_0240_512.h
|
a7696b80404ea07ac765c50aeef0cacae33e1d5f
|
[] |
no_license
|
Tolsi/Ellitone-Multi-Synth-Firmware
|
5958fbb4ba9f90c7a1000044290f0b3d65fc955e
|
525ade4866457cacaa5314d2ea92e78120da65c0
|
refs/heads/main
| 2023-04-06T15:58:16.839640 | 2021-04-16T17:12:13 | 2021-04-16T17:12:13 | 358,667,419 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,685 |
h
|
AKWF_0240_512.h
|
#ifndef AKWF_0240_512_H_
#define AKWF_0240_512_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <avr/pgmspace.h>
#define AKWF_0240_512_NUM_CELLS 512
#define AKWF_0240_512_SAMPLERATE 512
const char __attribute__((section(".progmem.data"))) AKWF_0240_512_DATA [] = {0,
1, 1, 2, 3, 3, 4, 4, 6, 6, 7, 8, 9, 10, 9, 11, 12, 12, 13, 13, 15, 15, 16, 16,
17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 25, 26, 27, 27, 28, 29, 30, 31, 32, 32,
33, 34, 35, 35, 37, 37, 38, 39, 40, 40, 42, 42, 44, 45, 44, 46, 47, 48, 49, 50,
51, 52, 52, 53, 55, 55, 56, 57, 58, 59, 60, 62, 62, 62, 63, 65, 65, 67, 68, 69,
69, 70, 71, 73, 74, 75, 75, 77, 77, 79, 80, 81, 81, 83, 84, 84, 86, 87, 88, 89,
90, 91, 93, 93, 95, 96, 97, 98, 99, 100, 101, 103, 104, 106, 107, 109, 111, 112,
114, 116, 117, 119, 120, 122, 123, 123, 124, 125, 126, 126, 127, 127, 127, 127,
127, 127, 127, 127, 127, 125, 125, 124, 122, 122, 120, 119, 118, 117, 116, 115,
113, 111, 109, 108, 107, 104, 104, 101, 99, 98, 95, 93, 92, 90, 88, 87, 84, 83,
81, 79, 77, 75, 74, 72, 70, 68, 67, 64, 62, 61, 58, 56, 55, 53, 52, 49, 48, 47,
45, 43, 41, 39, 37, 36, 34, 32, 31, 29, 27, 25, 23, 22, 21, 19, 18, 16, 14, 13,
11, 10, 8, 6, 4, 3, 2, 1, 0, -3, -4, -5, -6, -8, -9, -10, -12, -13, -15, -16,
-17, -19, -21, -22, -23, -25, -25, -27, -28, -29, -30, -31, -33, -33, -36, -36,
-37, -38, -40, -41, -43, -43, -44, -45, -45, -47, -48, -48, -50, -51, -52, -53,
-54, -55, -56, -56, -57, -58, -59, -60, -61, -61, -62, -63, -64, -65, -65, -67,
-68, -68, -69, -70, -70, -71, -71, -72, -72, -74, -74, -75, -75, -75, -77, -77,
-78, -78, -79, -79, -80, -80, -81, -81, -82, -82, -83, -83, -84, -84, -84, -86,
-85, -85, -86, -87, -87, -87, -88, -88, -88, -88, -88, -88, -89, -89, -88, -88,
-88, -86, -86, -85, -84, -84, -83, -81, -80, -80, -79, -78, -76, -75, -74, -73,
-72, -71, -69, -68, -67, -67, -67, -66, -65, -64, -63, -63, -63, -61, -61, -61,
-60, -59, -59, -59, -58, -58, -57, -57, -57, -57, -57, -56, -57, -56, -55, -55,
-55, -55, -55, -55, -54, -54, -54, -54, -53, -53, -52, -52, -52, -51, -52, -51,
-51, -51, -50, -51, -50, -50, -51, -50, -49, -49, -48, -49, -48, -48, -48, -48,
-48, -47, -46, -46, -46, -45, -46, -46, -45, -44, -45, -45, -44, -43, -43, -43,
-42, -42, -43, -42, -42, -41, -40, -41, -40, -39, -40, -38, -38, -38, -38, -37,
-37, -37, -36, -37, -35, -35, -35, -34, -34, -33, -33, -33, -32, -32, -31, -32,
-30, -30, -30, -29, -28, -28, -28, -27, -27, -26, -26, -25, -26, -24, -24, -24,
-23, -22, -22, -21, -21, -20, -20, -19, -18, -18, -18, -17, -17, -17, -15, -15,
-14, -13, -14, -13, -12, -12, -11, -11, -9, -9, -9, -7, -7, -7, -6, -5, -5, -3,
-3, -3, -2, -2, 0, 0, };
#endif /* AKWF_0240_512_H_ */
|
801c4474f8ba8727d0185437798be6b4171980e9
|
1794f0d4449273f8a39ba38229b0ff0b98cf87a0
|
/mu_bitmap.c
|
7d51a596957bdedde4914e9d8d45918ac892c150
|
[
"Apache-2.0"
] |
permissive
|
ihavec/mu-bitmap
|
213ea815f5fb6f980b79678e6281b4bc2ac20247
|
5927ab78db937078f0612a3b7392701a1a9d15eb
|
refs/heads/master
| 2023-03-20T02:41:26.539972 | 2014-02-13T03:59:33 | 2014-02-13T03:59:33 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 8,095 |
c
|
mu_bitmap.c
|
/*
* bitmap.c is a part of Mu-BitMap - a multi-level bitmap library
*
* Copyright (C) 2014 Sharath Chandrashekhara <sharathcshekhar@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdbool.h>
#include <features.h>
#include <fcntl.h>
#include <assert.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include "mu_bitmap.h"
#include "mu_bitmap_priv.h"
/*
* Structure of the BitMap in disk:
* 0-7 bytes : Magic Number
* 8-39 bytes : Reserved
* 40-47 bytes : size of the bitmap
* 48 bytes+ : Bitmap
*/
struct m_bitmap *mbm_create_bitmap(uint32_t size, char *filename, uint64_t offset)
{
assert((size % BITMAP_WIDTH) == 0);
struct m_bitmap *bm = malloc(sizeof(struct m_bitmap));
assert(bm);
bm->size = size;
bm->low_map = malloc(size * sizeof(uint64_t));
memset(bm->low_map, 0, size * sizeof(uint64_t));
if (filename != NULL) {
strncpy(bm->filename, filename, MAX_FILE_NAME);
bm->fd = open(bm->filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
assert(bm->fd > 0);
lseek(bm->fd, offset, SEEK_SET);
//TODO: write the magic number and advance by 32 bytes
//for the reserved bits. For now, just advance by 40 bytes
lseek(bm->fd, 40, SEEK_CUR);
write(bm->fd, &(bm->size), sizeof(bm->size));
write(bm->fd, bm->low_map, size * sizeof(uint64_t));
} else {
/* non-persistent bitmap */
bm->fd = -1;
}
init_bitmap(bm);
return bm;
}
bool mbm_is_bit_set(struct m_bitmap *bm, uint64_t bit)
{
int index = bit/BITMAP_WIDTH;
int bit_offset = bit % BITMAP_WIDTH;
uint64_t mask = (uint64_t)1 << bit_offset;
if (index >= bm->size) {
return false;
}
if (bm->low_map[index] & mask) {
return true;
}
return false;
}
int mbm_clear_bit(struct m_bitmap *bm, uint64_t bit)
{
int index = bit / BITMAP_WIDTH;
int bit_offset = bit % BITMAP_WIDTH;
uint64_t mask = (uint64_t)1 << bit_offset;
if (index >= bm->size) {
return -1;
}
(bm->low_map)[index] &= (~mask);
if (bm->fd != -1)
write_word_to_disk(bm, index);
/* set the associated mid-level bit */
if (bm->mid_map == NULL) {
return 0;
}
int mid_index = bit / (16 * 1024);
int mid_offset = bit % (16 * 1024);
mask = (uint64_t)1 << mid_offset;
(bm->mid_map)[mid_index] &= (~mask);
/* set the associated top-level bit */
if (bm->top_map == NULL) {
return 0;
}
int top_index = (mid_index + mid_offset) / (16 * 1024);
int top_offset = (mid_index + mid_offset) % (16 * 1024);
mask = (uint64_t)1 << top_offset;
(bm->top_map)[top_index] &= (~mask);
//TODO: WRITE THIS TO FILE
return 0;
}
uint64_t mbm_set_first_clear(struct m_bitmap *bm)
{
int offset;
int i;
uint64_t blk;
uint64_t mid_index = 0, low_index = 0;
int n_low_ints = bm->size / BITMAP_WIDTH;
int n_mid_ints = (n_low_ints + (LOWMAP_SZ * BITMAP_WIDTH) - 1) / (LOWMAP_SZ * BITMAP_WIDTH);
int n_top_ints = (n_mid_ints + (MIDMAP_SZ * BITMAP_WIDTH) - 1) / (MIDMAP_SZ * BITMAP_WIDTH);
/* Find first free block in top level map */
if (bm->top_map != NULL) {
T(("Entered top level\n"));
for (i = 0; i < n_top_ints; i++) {
if ((bm->top_map)[i] != MAX_VAL_64BIT) {
offset = ffsl(~(bm->top_map)[i]) - 1;
mid_index = (i * BITMAP_WIDTH + offset) * 16;
break;
}
}
}
/* Find the first free block in mid level map */
T(("Mid index = %lu\n", mid_index));
if (bm->mid_map != NULL) {
for (i = mid_index; i < 16; i++) {
if ((bm->mid_map)[mid_index+i] != MAX_VAL_64BIT) {
offset = ffsl(~(bm->mid_map)[mid_index+i]) - 1;
T(("Offset = %d, iteration = %d\n", offset, i));
low_index = ((mid_index + i) * BITMAP_WIDTH + offset) * 16;
break;
}
}
}
T(("low index = %lu\n", low_index));
/* Find the exact free block in the low level map */
for (i = 0; i < 16; i++) {
if ((bm->low_map)[low_index+i] != MAX_VAL_64BIT) {
offset = ffsl(~(bm->low_map)[low_index + i]) - 1;
blk = set_bit(bm, low_index+i, offset);
return blk;
}
}
return 0;
}
void mbm_free_bitmap(struct m_bitmap *bm)
{
assert(bm);
if (bm->top_map) {
free(bm->top_map);
}
if (bm->mid_map) {
free(bm->mid_map);
}
free(bm->low_map);
if (bm->fd != -1) {
close(bm->fd);
}
free(bm);
}
struct m_bitmap* mbm_load_bitmap(char *filename, uint64_t offset)
{
struct m_bitmap *bm = malloc(sizeof(struct m_bitmap));
assert(bm);
int ret = 0;
bm->fd = open(filename, O_RDWR);
assert(bm->fd > 0);
lseek(bm->fd, offset, SEEK_SET);
//TODO: Verify magic number, advance by 32 unused bytes.
lseek(bm->fd, 40, SEEK_CUR);
ret = read(bm->fd, &(bm->size), sizeof(uint64_t));
bm->low_map = malloc(bm->size * sizeof(uint64_t));
//TODO: write the magic number
ret = read(bm->fd, bm->low_map, bm->size * sizeof(uint64_t));
strncpy(bm->filename, filename, MAX_FILE_NAME);
init_bitmap(bm);
return bm;
}
int mbm_flush_to_disk(struct m_bitmap *bm)
{
fsync(bm->fd);
return 0;
}
/*
* Private functions
*/
static uint64_t set_bit(struct m_bitmap *bm, int index, int offset)
{
uint64_t mid_index = 0;
uint64_t mid_offset = 0;
(bm->low_map)[index] |= ((uint64_t)1 << offset);
if (bm->fd != -1)
write_word_to_disk(bm, index);
if ((bm->mid_map != NULL) && is_block_group_full(bm->low_map, index)) {
/* do this if all blocks in the group are in use */
uint64_t tmp = index / LOWMAP_SZ;
mid_index = tmp / BITMAP_WIDTH;
mid_offset = tmp % BITMAP_WIDTH;
T(("Updating the mid-index = %lu, offset = %lu, index = %d, tmp = %lu\n", mid_index, mid_offset, index, tmp));
(bm->mid_map)[mid_index] |= ((uint64_t)1 << mid_offset);
if ((bm->top_map != NULL) && is_block_group_full(bm->mid_map, index)) {
T(("Updating the top index\n"));
uint64_t tmp = mid_index / MIDMAP_SZ;
uint64_t top_index = tmp / BITMAP_WIDTH;
uint64_t top_offset = tmp % BITMAP_WIDTH;
(bm->top_map)[top_index] |= ((uint64_t)1 << top_offset);
}
}
//TODO: WRITE THIS TO FILE
return ((index * BITMAP_WIDTH) + offset);
}
static bool is_block_group_full(uint64_t *bm, int index)
{
int i;
index = (index/16) * 16;
for (i = 0; i < 16; i++){
if (bm[index+i] != MAX_VAL_64BIT) {
return false;
}
}
T(("Block group is full\n"));
return true;
}
static void init_bitmap(struct m_bitmap *bm)
{
/* Number of 64 bit ints in lowest bitmap */
int n_low_ints = bm->size;
T(("Number of low ints = %d\n", n_low_ints));
/* Number of 64 bit ints in mid bitmap */
int n_mid_ints = 0;
int n_mid_bits = (n_low_ints + LOWMAP_SZ - 1) / LOWMAP_SZ;
T(("Number of mid bits = %d\n", n_mid_bits));
if (n_mid_bits > 1) {
n_mid_ints = (n_mid_bits + BITMAP_WIDTH - 1) / BITMAP_WIDTH;
}
T(("Number of mid ints = %d\n", n_mid_ints));
/* Number of 64 bit ints in top bitmap */
int n_top_ints = 0;
int n_top_bits = (n_mid_ints + MIDMAP_SZ - 1) / MIDMAP_SZ;
T(("Number of top bits = %d\n", n_top_bits));
if (n_top_bits > 1) {
n_top_ints = (n_top_bits + BITMAP_WIDTH - 1) / BITMAP_WIDTH;
}
T(("Number of top ints = %d\n", n_top_ints));
if (n_mid_ints == 0) {
bm->mid_map = NULL;
bm->top_map = NULL;
} else {
bm->mid_map = malloc(n_mid_ints * sizeof(uint64_t));
if (n_top_ints == 0) {
bm->top_map = NULL;
} else {
bm->top_map = malloc(n_mid_ints * sizeof(uint64_t));
}
}
}
static void write_word_to_disk(struct m_bitmap *bm, uint64_t word_idx)
{
int ret = 0;
uint64_t word = (bm->low_map)[word_idx];
uint64_t offset = bm->offset + BITMAP_INDEX_TO_OFFSET(word_idx);
assert(bm->fd > 0);
lseek(bm->fd, offset, SEEK_SET);
ret = write(bm->fd, &word, sizeof(uint64_t));
assert(ret > 0);
}
|
3039c4c912ac4274d8388d79528e8f9006e9c81c
|
3573af014d8a49db81ede18cad135b33a20b8e3e
|
/Main/Main_2.c
|
7473b98b736c5e205a883719b7b33f9702a130b5
|
[] |
no_license
|
68kPoker/CodeBase
|
de0c8504fdbbef3a01cc523dfd6286f357586628
|
d8822f2eb24bad3aab25e9a8bc08bc2c29218ce7
|
refs/heads/master
| 2023-04-27T08:20:59.815083 | 2021-05-29T09:41:01 | 2021-05-29T09:41:01 | 233,803,947 | 3 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 4,465 |
c
|
Main_2.c
|
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <dos/dos.h>
#include <libraries/iffparse.h>
#include <exec/interrupts.h>
#include <exec/memory.h>
#include <graphics/gfxmacros.h>
#include <hardware/intbits.h>
#include <hardware/custom.h>
#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/layers_protos.h>
#include <clib/graphics_protos.h>
#include <clib/exec_protos.h>
#include "IFF.h"
#include "Blit.h"
#define DEPTH 5
#define ESC_KEY 0x45
int main(void);
struct copperData
{
struct ViewPort *vp;
WORD signal;
struct Task *task;
};
__far extern struct Custom custom;
extern void myCopper(void);
struct Screen *openScreen(void)
{
struct Screen *s;
struct Rectangle dclip =
{
0, 0, 319, 255
};
if (s = OpenScreenTags(NULL,
SA_DClip, &dclip,
SA_Depth, DEPTH,
SA_DisplayID, LORES_KEY,
SA_Quiet, TRUE,
SA_ShowTitle, FALSE,
SA_Exclusive, TRUE,
SA_BackFill, LAYERS_NOBACKFILL,
SA_Interleaved, TRUE,
TAG_DONE))
{
/* Make Bar layer 16 pixel height */
SizeLayer(0, s->BarLayer, 0, 16 - (s->BarHeight + 1));
return(s);
}
return(NULL);
}
BOOL addCopper(struct Screen *s, struct Interrupt *is, struct copperData *cd)
{
is->is_Code = myCopper;
is->is_Data = (APTR)cd;
is->is_Node.ln_Pri = 0;
cd->vp = &s->ViewPort;
if ((cd->signal = AllocSignal(-1)) != -1)
{
struct UCopList *ucl;
cd->task = FindTask(NULL);
if (ucl = AllocMem(sizeof(*ucl), MEMF_PUBLIC|MEMF_CLEAR))
{
CINIT(ucl, 3);
CWAIT(ucl, 128, 0);
CMOVE(ucl, custom.intreq, INTF_SETCLR|INTF_COPER);
CEND(ucl);
Forbid();
s->ViewPort.UCopIns = ucl;
Permit();
RethinkDisplay();
AddIntServer(INTB_COPER, is);
return(TRUE);
}
FreeSignal(cd->signal);
}
return(FALSE);
}
void remCopper(struct Interrupt *is)
{
struct copperData *cd = (struct copperData *)is->is_Data;
RemIntServer(INTB_COPER, is);
FreeSignal(cd->signal);
}
struct Window *openBackdropWindow(struct Screen *s)
{
struct Window *w;
if (w = OpenWindowTags(NULL,
WA_CustomScreen, s,
WA_Left, 0,
WA_Top, 16,
WA_Width, 320,
WA_Height, 240,
WA_AutoAdjust, FALSE,
WA_Backdrop, TRUE,
WA_Borderless, TRUE,
WA_RMBTrap, TRUE,
WA_SimpleRefresh, TRUE,
WA_BackFill, LAYERS_NOBACKFILL,
WA_Activate, TRUE,
WA_IDCMP, IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE,
WA_ReportMouse, TRUE,
TAG_DONE))
{
return(w);
}
return(NULL);
}
struct BitMap *loadGfx(struct Window *w, STRPTR name)
{
struct IFFHandle *iff;
if (iff = openIFile(name, IFFF_READ))
{
if (scanILBM(iff))
{
UBYTE *cmap;
WORD colors;
if (obtainCMAP(iff, &cmap, &colors))
{
struct BitMap *gfx;
UBYTE cmp, depth;
WORD bpr, rows;
loadCMAP(w->WScreen->ViewPort.ColorMap, cmap, colors);
MakeScreen(w->WScreen);
RethinkDisplay();
if (obtainBMHD(iff, &cmp, &bpr, &rows, &depth))
{
if (gfx = loadILBM(iff, cmp, bpr, rows, depth))
{
closeIFile(iff);
return(gfx);
}
}
}
}
closeIFile(iff);
}
return(NULL);
}
void waitVBlank(struct copperData *cd)
{
ULONG mask = 1L << cd->signal;
SetSignal(0L, mask);
Wait(mask);
}
void handleWindow(struct Window *w, struct BitMap *gfx)
{
ULONG signals[] =
{
1L << w->UserPort->mp_SigBit
};
BOOL done = FALSE;
do
{
struct IntuiMessage *msg;
WaitPort(w->UserPort);
while ((!done) && (msg = (struct IntuiMessage *)GetMsg(w->UserPort)))
{
ULONG class = msg->Class;
WORD code = msg->Code;
WORD mx = msg->MouseX, my = msg->MouseY;
ReplyMsg((struct Message *)msg);
if (class == IDCMP_RAWKEY)
{
if (code == ESC_KEY)
{
done = TRUE;
}
}
else if (class == IDCMP_MOUSEBUTTONS)
{
if (code == IECODE_LBUTTON)
{
bltTileRastPort(gfx, 3 << 4, 1 << 4, w->RPort, mx & 0xfff0, my & 0xfff0, 16, 16);
}
}
}
}
while (!done);
}
int main(void)
{
struct Screen *s;
if (s = openScreen())
{
struct copperData cd;
struct Interrupt is;
if (addCopper(s, &is, &cd))
{
struct Window *w;
if (w = openBackdropWindow(s))
{
struct BitMap *gfx;
if (gfx = loadGfx(w, "Dane/Magazyn.iff"))
{
waitVBlank(&cd);
bltTileRastPort(gfx, 0, 0, s->BarLayer->rp, 0, 0, 320, 16);
bltBoardRastPort(gfx, 0, 0, w->RPort, 0, 0, 320, 240);
handleWindow(w, gfx);
FreeBitMap(gfx);
}
CloseWindow(w);
}
remCopper(&is);
}
CloseScreen(s);
}
return(RETURN_OK);
}
|
5b8e0b174f25ec8ac7375663d0ad463b54ed46de
|
825a5d93151d2337d82c36dedc49935cd7971896
|
/src/unuran-src/utils/unur_fp.c
|
071d89881abf23ad3428e660a8a199338912f1b6
|
[] |
no_license
|
cran/Runuran
|
bb5c9300d236fb9ad149e9f79ef849f186940778
|
3a7d1e7409fe97a4ac272e571698bc9984e3f506
|
refs/heads/master
| 2023-01-24T19:12:22.159869 | 2023-01-17T12:10:02 | 2023-01-17T12:10:02 | 17,693,454 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,532 |
c
|
unur_fp.c
|
/* Copyright (c) 2000-2023 Wolfgang Hoermann and Josef Leydold */
/* Department of Statistics and Mathematics, WU Wien, Austria */
#include <unur_source.h>
int
_unur_FP_cmp( double x1, double x2, double eps)
{
double fx1 = (x1>=0.) ? x1 : -x1;
double fx2 = (x2>=0.) ? x2 : -x2;
double delta = eps * _unur_min(fx1,fx2);
double difference = x1 - x2;
if (_unur_isinf(delta)) {
delta = eps * DBL_MAX;
}
if (fx1 <= 2.*DBL_MIN && fx2 <= 2.*DBL_MIN)
return 0;
if (difference > delta)
return +1;
else if (difference < -delta)
return -1;
else
return 0;
}
#ifndef _unur_iszero
int _unur_iszero (const double x)
{
return (x==0.);
}
#endif
#ifndef _unur_isone
int _unur_isone (const double x)
{
return (x==1.);
}
#endif
#ifndef _unur_isfsame
int _unur_isfsame (const double x, const double y)
{
return (x==y);
}
#endif
int
_unur_isfinite (const double x)
{
#if HAVE_DECL_ISFINITE
return (isfinite(x) ? TRUE : FALSE);
#elif defined(_MSC_VER)
return (_finite(x) ? TRUE : FALSE);
#elif HAVE_IEEE_COMPARISONS
if (x < UNUR_INFINITY && x > -UNUR_INFINITY)
return TRUE;
else
return FALSE;
#else
# error
# error +--------------------------------------------+
# error ! Sorry, Cannot handle INFINITY correctly! . !
# error ! Please contact <unuran@statmath.wu.ac.at>. !
# error +--------------------------------------------+
# error
#endif
}
int
_unur_isnan (const double x)
{
#if HAVE_DECL_ISNAN
return (isnan(x) ? TRUE : FALSE);
#elif defined(_MSC_VER)
return (_isnan(x) ? TRUE : FALSE);
#elif HAVE_IEEE_COMPARISONS
return ((x!=x) ? TRUE : FALSE);
#else
# error
# error +--------------------------------------------+
# error ! Sorry, Cannot handle NaN correctly! ...... !
# error ! Please contact <unuran@statmath.wu.ac.at>. !
# error +--------------------------------------------+
# error
#endif
}
int
_unur_isinf (const double x)
{
#if HAVE_DECL_ISINF
return isinf(x);
#elif defined(_MSC_VER)
int fpc = _fpclass(x);
if (fpc == _FPCLASS_PINF)
return +1;
else if (fpc == _FPCLASS_NINF)
return -1;
else
return 0;
#elif HAVE_IEEE_COMPARISONS
if (x>=UNUR_INFINITY)
return 1;
else if (x<=-UNUR_INFINITY)
return -1;
else
return 0;
#else
# error
# error +--------------------------------------------+
# error ! Sorry, Cannot handle INFINITY correctly! . !
# error ! Please contact <unuran@statmath.wu.ac.at>. !
# error +--------------------------------------------+
# error
#endif
}
|
54d78ce60e8d4b6281be286dc177dee2951e51ec
|
bb4450b90e7ddf0079df27b8e6ee0fe25b458da3
|
/t/level_test.c
|
501118a8d9f9cc0109438e25afc9887d89c4b681
|
[] |
no_license
|
k3ut0i/liblog
|
d403bac2baf95c110660e58d5daf5c51e01a8af6
|
151c1db303081e30b6a8062cf480d7b26440d59c
|
refs/heads/master
| 2021-05-08T22:28:24.049475 | 2018-01-31T10:40:14 | 2018-01-31T10:40:14 | 119,673,660 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 582 |
c
|
level_test.c
|
#include "log.h"
void test_print()
{
log_print(LL_ALL, "%s\n", "all");
log_print(LL_TRACE, "%s\n", "trace");
log_print(LL_DEBUG, "%s\n", "debug");
log_print(LL_INFO, "%s\n", "info");
log_print(LL_WARN, "%s\n", "warn");
log_print(LL_ERROR, "%s\n", "error");
log_print(LL_FATAL, "%s\n", "fatal");
log_print(LL_OFF, "%s\n", "off");
}
int main()
{
log_initialize();
log_set_color_support(true);
for(int i = LL_ALL; i <= LL_OFF; i++){
fprintf(stdout, "testing enum level: %d\n", i);
log_set_level(i);
test_print();
}
log_clean_up();
return 0;
}
|
8210778fa31140e3f138dadd436c0bc2c0a7d239
|
841fab87b64530e17e43495d6b3a3c8fdcd1ea61
|
/code/WPILib/CInterfaces/CAnalogChannel.h
|
55206b071b777fc55b0337e58df6685930e1a940
|
[
"MIT"
] |
permissive
|
trc492/Frc2012ReboundRumble
|
86c8058a04cee0b63a67de28688df7137e49ee75
|
b1e60e8bcd43a0a86d0dfefe094a017f9ecf34c8
|
refs/heads/master
| 2021-01-25T04:36:35.642962 | 2018-05-27T19:34:53 | 2018-05-27T19:34:53 | 93,456,764 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,345 |
h
|
CAnalogChannel.h
|
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef C_ANALOG_CHANNEL_H
#define C_ANALOG_CHANNEL_H
#include "AnalogChannel.h"
#include "CWrappers.h"
AnalogChannel *AllocateAnalogChannel(UINT8 moduleNumber, UINT32 channel /*,SensorCreator createObject*/);
INT16 GetAnalogValue(UINT8 moduleNumber, UINT32 channel);
INT32 GetAnalogAverageValue(UINT8 moduleNumber, UINT32 channel);
float GetAnalogVoltage(UINT8 moduleNumber, UINT32 channel);
float GetAnalogAverageVoltage(UINT8 moduleNumber, UINT32 channel);
void SetAnalogAverageBits(UINT8 moduleNumber, UINT32 channel, UINT32 bits);
UINT32 GetAnalogAverageBits(UINT8 moduleNumber, UINT32 channel);
void SetAnalogOversampleBits(UINT8 moduleNumber, UINT32 channel, UINT32 bits);
UINT32 GetAnalogOversampleBits(UINT8 moduleNumber, UINT32 channel);
INT16 GetAnalogValue(UINT32 channel);
INT32 GetAnalogAverageValue(UINT32 channel);
float GetAnalogVoltage(UINT32 channel);
float GetAnalogAverageVoltage(UINT32 channel);
void SetAnalogAverageBits(UINT32 channel, UINT32 bits);
UINT32 GetAnalogAverageBits(UINT32 channel);
void SetAnalogOversampleBits(UINT32 channel, UINT32 bits);
UINT32 GetAnalogOversampleBits(UINT32 channel);
UINT32 GetAnalogLSBWeight();
INT32 GetAnalogOffset();
void DeleteAnalogChannel(UINT8 moduleNumber, UINT32 channel);
void DeleteAnalogChannel(UINT32 channel);
typedef void *AnalogChannelObject;
AnalogChannelObject CreateAnalogChannel(UINT8 moduleNumber, UINT32 channel);
AnalogChannelObject CreateAnalogChannel(UINT32 channel);
INT16 GetAnalogValue(AnalogChannelObject o);
INT32 GetAnalogAverageValue(AnalogChannelObject o);
float GetAnalogVoltage(AnalogChannelObject o);
float GetAnalogAverageVoltage(AnalogChannelObject o);
void SetAnalogAverageBits(AnalogChannelObject o, UINT32 bits);
UINT32 GetAnalogAverageBits(AnalogChannelObject o);
void SetAnalogOversampleBits(AnalogChannelObject o, UINT32 bits);
UINT32 GetAnalogOversampleBits(AnalogChannelObject o);
void DeleteAnalogChannel(AnalogChannelObject o);
#endif
|
4420ab58a5e035310946b9e4514930c6b6eb512d
|
2725c71518a23fbafa547c9bf71dc40bf76ee16b
|
/DLuaEngine/DLuaEngine.h
|
9cf236c139dd9fc277490cebd885cabba9f5bf7a
|
[
"MIT"
] |
permissive
|
Down-s/DLuaEngine
|
f02149b71c65e40895c10b84d8fef0a97111cea1
|
660351b72f367951f5eae46bf5a0444df58ee79a
|
refs/heads/main
| 2023-04-13T02:38:49.958647 | 2021-04-30T23:47:44 | 2021-04-30T23:47:44 | 363,283,025 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 235 |
h
|
DLuaEngine.h
|
#pragma once
#pragma comment(lib, "Vendor/liblua54.a")
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
lua_State* GetState();
void CallDEFunctionArg(lua_State* Ls, const char* FuncName, int arg);
|
452308374d8e4d87a97a595db68a8523e7446b49
|
068ed39aa80c8382a39e9b1d5857fa5812e901c2
|
/uebung5/sched_tests.c
|
faa5911bf8da4743e2556f2c23d905b846dfc6cd
|
[] |
no_license
|
luisherrmann/SS17_BKS
|
db9b02610e8a6d202f0ce032c92a2351e856ed4f
|
e7d1a1c4178463920639586022fd85f73bd6f126
|
refs/heads/master
| 2021-01-20T04:00:08.684512 | 2017-07-26T14:22:06 | 2017-07-26T14:22:06 | 89,620,287 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 3,292 |
c
|
sched_tests.c
|
/*
* Autor: Thomas Tegethoff
* Idee & Vorlage: Heiko Will
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
#include "scheduler.h"
#define NUM_PROCESSES 4
#define ALGO_NUM 4
#define RED "\033[31m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN "\033[36m"
#define NORMAL "\033[39m"
//uint64_t processes[NUM_PROCESSES][2] = {{0, 3}, {2, 7}, {4, 1}, {6, 5}};
void (*sched_func[ALGO_NUM])(Process*) = {
rr,
fcfs,
spn,
hrrn
};
char* algo_names[ALGO_NUM] = {
"Round Robin",
"First Come First Serve",
"Shortest Process Next",
"Highest Response Ratio Next"
};
void runtest(size_t pnum, uint64_t processes[][2]) {
printf(CYAN "ID (done, todo, waited)" NORMAL "\n\n");
for(size_t ai=0; ai<ALGO_NUM; ai++) {
Process* head = malloc(sizeof(Process));
head->pID = 0;
head->cycles_done = head->cycles_todo = head->cycles_waited = 0;
head->next = head->prev = head;
head->state = DEAD;
printf(CYAN "%s: " NORMAL "\n", algo_names[ai]);
size_t tick = 0;
size_t ticks_todo = 0;
do {
// evtl neue Prozess einfuegen
for(size_t pi=0; pi<pnum; pi++) {
if(processes[pi][0] == tick) {
Process* new_process = malloc(sizeof(Process));
new_process->pID = pi;
new_process->cycles_done = new_process->cycles_waited = 0;
new_process->cycles_todo = processes[pi][1];
new_process->state = READY;
new_process->prev = head->prev;
new_process->next = head;
head->prev->next = new_process;
head->prev = new_process;
ticks_todo += processes[pi][1];
}
}
sched_func[ai](head);
printf(CYAN "Tick %zu:%s" NORMAL, tick, (tick<10)?" ":" ");
Process* current = head->next;
while(current != head) {
if(current->state == RUNNING) {
current->cycles_done++;
current->cycles_todo--;
} else if(current->state == READY) {
current->cycles_waited++;
}
printf(
MAGENTA "%"PRIu64" (%"PRIu64", %"PRIu64", %"PRIu64"): "\
NORMAL,
current->pID,
current->cycles_done,
current->cycles_todo,
current->cycles_waited
);
if(current->state == DEAD) {
printf(RED "DEAD\t" NORMAL);
} else if(current->state == RUNNING) {
printf(BLUE "RUNNING\t" NORMAL);
} else if(current->state == READY) {
printf(GREEN "READY\t" NORMAL);
}
current = current->next;
}
printf("\n");
tick++;
ticks_todo--;
} while(ticks_todo);
if(ai != ALGO_NUM-1) {
printf("\n" CYAN "Press any key for next algorithm." NORMAL "\n\n");
getchar();
}
}
}
int main(void){
uint64_t test_def[NUM_PROCESSES][2] = {{0, 3}, {2, 7}, {4, 1}, {6, 5}};
uint64_t test1[5][2] = {{0, 3},{2, 6},{4, 4},{6, 5},{8, 2}};
uint64_t test2[3][2] = {{0, 3},{0, 3},{0, 3}};
char c;
while(true){
printf("\nTests 0 to 2 available. Enter the desired test number to run test. Enter q to finish.\n");
c = getchar();
if(c == 'q') break;
switch(c){
case '0': runtest((size_t)(sizeof(test_def)/(2*sizeof(uint64_t))),test_def); break;
case '1': runtest((size_t)(sizeof(test1)/(2*sizeof(uint64_t))),test1); break;
case '2': runtest((size_t)(sizeof(test2)/(2*sizeof(uint64_t))),test2); break;
}
}
}
|
9dc2e32077f6cfc54218fc297d4b1655106367cf
|
9cd53be6feb12d089efa2ecebc54229953f756e9
|
/Module 1/cardio.c
|
c3864961e9305b174f93a4c6e96b459144f56d60
|
[] |
no_license
|
xXxPierre-AlainDu59xXx/Le-groupe-des-freros
|
da57db4167e47b6f5f2e12666a614e2c85706508
|
5498d77ee11bee92591ea29929c1cbfd07e7a17d
|
refs/heads/master
| 2021-08-15T05:47:29.501737 | 2017-11-17T12:27:50 | 2017-11-17T12:27:50 | 110,521,727 | 0 | 1 | null | 2017-11-16T21:38:16 | 2017-11-13T08:37:17 |
C
|
UTF-8
|
C
| false | false | 510 |
c
|
cardio.c
|
#include "cardio.h"
const int SORTIE=0; // La macro pour le pin de sortie
void calculPulsation(int pouls, int battement) {
for(int temps=0;temps!=600;temps++) { //On teste le programme pendant 6 secondes (en fonction du delay en dessous)
delay(10); // On teste le programme toutes les 0.01 secondes
battement=analogRead(SORTIE); // La valeur en sortie est stockée dans "battement" (égal à 0 ou 1)
if (battement==1) { // Si "battement" = , on incrémente "pouls"
pouls++;
}
}
}
|
19b8ff7c827d147ce8ce2bf378a236b46efde44d
|
a9b6d79c59a45a25e902b2809de43f62a8e77289
|
/parsec/data.c
|
525b04bfd24895d6de032b703b6d1e2054399f00
|
[
"BSD-3-Clause-Open-MPI"
] |
permissive
|
ICLDisco/parsec
|
23d7aa1b11422f0553e6341ee4eafda6646359c0
|
e59bed9d4934775792a58980cf5500bd41381bc4
|
refs/heads/master
| 2023-09-01T19:01:05.100961 | 2023-08-21T22:56:29 | 2023-08-21T22:56:29 | 460,250,198 | 33 | 14 |
NOASSERTION
| 2023-09-12T19:31:40 | 2022-02-17T02:16:03 |
C
|
UTF-8
|
C
| false | false | 19,527 |
c
|
data.c
|
/*
* Copyright (c) 2012-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
*/
#include "parsec/parsec_config.h"
#include "parsec/class/lifo.h"
#include "parsec/constants.h"
#include "parsec/mca/device/device.h"
#include "parsec/utils/debug.h"
#include "parsec/data_internal.h"
#include "parsec/arena.h"
#include "parsec/parsec_description_structures.h"
#include "parsec/sys/atomic.h"
#include "parsec/remote_dep.h"
#include "parsec/parsec_internal.h"
static parsec_lifo_t parsec_data_lifo;
static parsec_lifo_t parsec_data_copies_lifo;
static void parsec_data_copy_construct(parsec_data_copy_t* obj)
{
obj->device_index = 0;
obj->flags = 0;
obj->coherency_state = PARSEC_DATA_COHERENCY_INVALID;
obj->readers = 0;
obj->version = 0;
obj->older = NULL;
obj->original = NULL;
obj->device_private = NULL;
obj->arena_chunk = NULL;
obj->data_transfer_status = PARSEC_DATA_STATUS_NOT_TRANSFER;
obj->push_task = NULL;
obj->dtt = PARSEC_DATATYPE_NULL;
PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, "Allocate data copy %p", obj);
}
static void parsec_data_copy_destruct(parsec_data_copy_t* obj)
{
PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, "Destruct data copy %p (attached to %p)", obj, obj->original);
/* If the copy is still attached to a data we should detach it first */
if( NULL != obj->original) {
parsec_data_copy_detach(obj->original, obj, obj->device_index);
assert( NULL == obj->original );
}
if( obj->flags & PARSEC_DATA_FLAG_ARENA ) {
/* It is an arena that is now unused.
* give the chunk back to the arena memory management.
* obj is already detached from obj->original, but this frees the arena chunk */
parsec_arena_release(obj);
}
}
PARSEC_OBJ_CLASS_INSTANCE(parsec_data_copy_t, parsec_list_item_t,
parsec_data_copy_construct,
parsec_data_copy_destruct);
static void parsec_data_construct(parsec_data_t* obj )
{
parsec_atomic_lock_t unlocked = PARSEC_ATOMIC_UNLOCKED;
obj->owner_device = -1;
obj->preferred_device = -1;
obj->key = 0;
obj->nb_elts = 0;
for( uint32_t i = 0; i < parsec_nb_devices;
obj->device_copies[i] = NULL, i++ );
obj->dc = NULL;
obj->lock = unlocked; /* Can't directly assign to PARSEC_ATOMIC_UNLOCKED because of C syntax */
PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, "Allocate data %p", obj);
}
static void parsec_data_destruct(parsec_data_t* obj )
{
PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, "Release data %p", obj);
for( uint32_t i = 0; i < parsec_nb_devices; i++ ) {
parsec_data_copy_t *copy = NULL;
parsec_device_module_t *device = parsec_mca_device_get(i);
#if !defined(PARSEC_DEBUG_PARANOID)
if(NULL == device) {
assert(NULL == obj->device_copies[i]);
continue;
}
#endif /* !defined(PARSEC_DEBUG_PARANOID) */
while( (copy = obj->device_copies[i]) != NULL ) {
#if defined(PARSEC_DEBUG_PARANOID)
if( NULL == device ) { /* complain if data copies exists for devices that have been removed */
parsec_output(1, "Data copy %p for data_t %p reside on an non-valid device (%d).\n",
copy, copy->original, i);
}
#endif /* defined(PARSEC_DEBUG_PARANOID) */
assert(obj->super.obj_reference_count > 1);
parsec_data_copy_detach( obj, copy, i );
if ( !(device->type & PARSEC_DEV_CUDA)
&& !(device->type & PARSEC_DEV_HIP) ) {
/**
* GPU copies are normally stored in LRU lists, and must be
* destroyed by the release list to free the memory on the device
*/
PARSEC_OBJ_RELEASE( copy );
}
}
assert(NULL == obj->device_copies[i]);
}
}
PARSEC_OBJ_CLASS_INSTANCE(parsec_data_t, parsec_object_t,
parsec_data_construct,
parsec_data_destruct
);
int parsec_data_init(parsec_context_t* context)
{
PARSEC_OBJ_CONSTRUCT(&parsec_data_lifo, parsec_lifo_t);
PARSEC_OBJ_CONSTRUCT(&parsec_data_copies_lifo, parsec_lifo_t);
/**
* This is a trick. Now that we know the number of available devices
* we can update the size of the parsec_data_t class to the correct value.
*/
if( !parsec_mca_device_registration_completed(context) ) {
parsec_warning("Cannot configure the data infrastructure as the devices layer has not yet been froze.");
return PARSEC_ERROR;
}
parsec_data_t_class.cls_sizeof += sizeof(parsec_data_copy_t*) * parsec_nb_devices;
return PARSEC_SUCCESS;
}
int parsec_data_fini(parsec_context_t* context)
{
PARSEC_OBJ_DESTRUCT(&parsec_data_lifo);
PARSEC_OBJ_DESTRUCT(&parsec_data_copies_lifo);
(void)context;
return PARSEC_SUCCESS;
}
/**
*
*/
parsec_data_t* parsec_data_new(void)
{
parsec_data_t* item = (parsec_data_t*)parsec_lifo_pop(&parsec_data_lifo);
if( NULL == item ) {
item = PARSEC_OBJ_NEW(parsec_data_t);
if( NULL == item ) return NULL;
} else {
PARSEC_OBJ_CONSTRUCT(item, parsec_object_t);
}
return item;
}
/**
*
*/
void parsec_data_delete(parsec_data_t* data)
{
PARSEC_LIST_ITEM_SINGLETON((parsec_list_item_t*)data);
parsec_lifo_push(&parsec_data_lifo, (parsec_list_item_t*)data);
}
inline int
parsec_data_copy_attach(parsec_data_t* data,
parsec_data_copy_t* copy,
uint8_t device)
{
assert(NULL == copy->original);
assert(NULL == copy->older);
copy->device_index = device;
copy->original = data;
/* Atomically set the device copy */
copy->older = data->device_copies[device];
if( !parsec_atomic_cas_ptr(&data->device_copies[device], copy->older, copy) ) {
copy->older = NULL;
return PARSEC_ERROR;
}
PARSEC_OBJ_RETAIN(data);
return PARSEC_SUCCESS;
}
/**
* In the current version only the latest copy of a data for each device can
* be safely removed.
*/
int parsec_data_copy_detach(parsec_data_t* data,
parsec_data_copy_t* copy,
uint8_t device)
{
parsec_data_copy_t* obj = data->device_copies[device];
if( obj != copy ) {
return PARSEC_ERR_NOT_FOUND;
}
data->device_copies[device] = copy->older;
copy->original = NULL;
copy->older = NULL;
PARSEC_OBJ_RELEASE(data);
return PARSEC_SUCCESS;
}
/**
* Allocate a data copy and attach it as a device specific copy. The data must
* not be NULL in order for this operation to be relevant.
* Data copy type is set to the specified one.
*/
parsec_data_copy_t* parsec_data_copy_new(parsec_data_t* data, uint8_t device,
parsec_datatype_t dtt, parsec_data_flag_t flags)
{
parsec_data_copy_t* copy;
copy = (parsec_data_copy_t*)parsec_lifo_pop(&parsec_data_copies_lifo);
if( NULL == copy ) {
copy = PARSEC_OBJ_NEW(parsec_data_copy_t);
if( NULL == copy ) {
return NULL;
}
} else {
PARSEC_OBJ_CONSTRUCT(copy, parsec_data_copy_t);
}
copy->flags = flags;
if( PARSEC_SUCCESS != parsec_data_copy_attach(data, copy, device) ) {
PARSEC_OBJ_RELEASE(copy);
return NULL;
}
copy->dtt = dtt;
return copy;
}
#if 0
/*
* WARNING: Is this function usefull or should it be removed ?
*/
/**
* Find the corresponding copy of the data on the requested device. If the
* copy is not available in the access mode requested, a new version will
* be created. If no transfer is required the correct version will be set
* into dest and the function returns 0. If a transfer is necessary, dest
* will contain the pointer to the copy to be transferred to, and the function
* will return 1. All other cases should be considered as errors, and a
* negative value must be returned (corresponding to a specific PARSEC_
* error code.
*/
int parsec_data_get_device_copy(parsec_data_copy_t* source,
parsec_data_copy_t** dest,
uint8_t device,
uint8_t access_mode)
{
parsec_data_copy_t* copy;
parsec_data_t* original;
int transfer = 0;
if( device == source->device_index ) {
*dest = source;
return 0;
}
original = source->original;
/* lock the original data */
copy = original->device_copies[device];
while( NULL != copy ) {
if( source->version == copy->version )
break;
copy = copy->older;
}
if( NULL == copy ) {
*dest = copy = parsec_data_copy_new(original, device);
transfer = 1;
} else if( source->version == copy->version ) {
*dest = copy;
}
/* unlock the original data */
return transfer;
}
#endif
/**
* Beware: Before calling this function the owner of the data must be
* saved in order to know where to transfer the data from. Once this
* function returns, the ownership is transfered based on the access
* mode and the knowledge about the location of the most up-to-date
* version of the data is lost.
*/
int parsec_data_transfer_ownership_to_copy(parsec_data_t* data,
uint8_t device,
uint8_t access_mode)
{
int transfer_required;
parsec_atomic_lock(&data->lock);
transfer_required = parsec_data_start_transfer_ownership_to_copy(data, device, access_mode);
parsec_data_end_transfer_ownership_to_copy(data, device, access_mode);
parsec_atomic_unlock(&data->lock);
return transfer_required;
}
void parsec_data_end_transfer_ownership_to_copy(parsec_data_t* data,
uint8_t device,
uint8_t access_mode)
{
parsec_data_copy_t* copy;
assert(NULL != data);
copy = data->device_copies[device];
PARSEC_DEBUG_VERBOSE(10, parsec_debug_output,
"DEV[%d]: end transfer ownership of data %p to copy %p in mode %d",
device, data, copy, access_mode);
assert( NULL != copy );
if( PARSEC_FLOW_ACCESS_READ & access_mode ) {
copy->coherency_state = PARSEC_DATA_COHERENCY_SHARED;
}
if( PARSEC_FLOW_ACCESS_WRITE & access_mode ) {
copy->coherency_state = PARSEC_DATA_COHERENCY_OWNED;
}
}
int parsec_data_start_transfer_ownership_to_copy(parsec_data_t* data,
uint8_t device,
uint8_t access_mode)
{
uint32_t i;
int transfer_required = 0;
int valid_copy = data->owner_device;
parsec_data_copy_t* copy;
assert(NULL != data);
copy = data->device_copies[device];
assert( NULL != copy );
PARSEC_DEBUG_VERBOSE(10, parsec_debug_output,
"DEV[%d]: start transfer ownership of data %p to copy %p in mode %d",
device, data, copy, access_mode);
switch( copy->coherency_state ) {
case PARSEC_DATA_COHERENCY_INVALID:
transfer_required = 1;
if( -1 == valid_copy ) {
for( i = 0; i < parsec_nb_devices; i++ ) {
if( NULL == data->device_copies[i] ) continue;
if( PARSEC_DATA_COHERENCY_INVALID == data->device_copies[i]->coherency_state ) continue;
assert( PARSEC_DATA_COHERENCY_EXCLUSIVE == data->device_copies[i]->coherency_state
|| PARSEC_DATA_COHERENCY_SHARED == data->device_copies[i]->coherency_state );
valid_copy = i;
}
}
break;
case PARSEC_DATA_COHERENCY_SHARED:
for( i = 0; i < parsec_nb_devices; i++ ) {
if( NULL == data->device_copies[i] ) continue;
if( PARSEC_DATA_COHERENCY_OWNED == data->device_copies[i]->coherency_state
&& data->device_copies[i]->version > copy->version ) {
assert( (int)i == valid_copy );
transfer_required = 1;
}
#if defined(PARSEC_DEBUG_PARANOID)
else {
assert( PARSEC_DATA_COHERENCY_INVALID == data->device_copies[i]->coherency_state
|| PARSEC_DATA_COHERENCY_SHARED == data->device_copies[i]->coherency_state
|| data->device_copies[i]->version == copy->version
|| copy->data_transfer_status );
}
#endif /* defined(PARSEC_DEBUG_PARANOID) */
}
break;
case PARSEC_DATA_COHERENCY_EXCLUSIVE:
#if defined(PARSEC_DEBUG_PARANOID)
for( i = 0; i < parsec_nb_devices; i++ ) {
if( device == i || NULL == data->device_copies[i] ) continue;
assert( PARSEC_DATA_COHERENCY_INVALID == data->device_copies[i]->coherency_state );
}
#endif /* defined(PARSEC_DEBUG_PARANOID) */
break;
case PARSEC_DATA_COHERENCY_OWNED:
assert( device == data->owner_device ); /* memory is owned, better be me otherwise 2 writters: wrong JDF */
#if defined(PARSEC_DEBUG_PARANOID)
for( i = 0; i < parsec_nb_devices; i++ ) {
if( device == i || NULL == data->device_copies[i] ) continue;
assert( PARSEC_DATA_COHERENCY_INVALID == data->device_copies[i]->coherency_state
|| PARSEC_DATA_COHERENCY_SHARED == data->device_copies[i]->coherency_state );
assert( copy->version >= data->device_copies[i]->version );
}
#endif /* defined(PARSEC_DEBUG_PARANOID) */
break;
}
if( PARSEC_FLOW_ACCESS_READ & access_mode ) {
for( i = 0; i < parsec_nb_devices; i++ ) {
if( device == i || NULL == data->device_copies[i] ) continue;
if( PARSEC_DATA_COHERENCY_INVALID == data->device_copies[i]->coherency_state ) continue;
if( PARSEC_DATA_COHERENCY_OWNED == copy->coherency_state
&& !(PARSEC_FLOW_ACCESS_WRITE & access_mode) ) {
if( data->device_copies[i]->version < copy->version ) {
data->device_copies[i]->coherency_state = PARSEC_DATA_COHERENCY_INVALID;
}
data->owner_device = -1;
}
if( PARSEC_DATA_COHERENCY_EXCLUSIVE == data->device_copies[i]->coherency_state ) {
data->device_copies[i]->coherency_state = PARSEC_DATA_COHERENCY_SHARED;
}
}
}
else transfer_required = 0; /* finally we'll just overwrite w/o read */
if( PARSEC_FLOW_ACCESS_WRITE & access_mode ) {
for( i = 0; i < parsec_nb_devices; i++ ) {
if( NULL == data->device_copies[i] ) continue;
if( PARSEC_DATA_COHERENCY_INVALID == data->device_copies[i]->coherency_state ) continue;
data->device_copies[i]->coherency_state = PARSEC_DATA_COHERENCY_SHARED;
}
}
assert( (!transfer_required) || (data->device_copies[valid_copy]->version >= copy->version) );
if( PARSEC_FLOW_ACCESS_READ & access_mode ) {
copy->readers++;
}
if( PARSEC_FLOW_ACCESS_WRITE & access_mode ) {
data->owner_device = (uint8_t)device;
}
if( !transfer_required ) {
return -1;
}
assert( -1 != valid_copy );
return valid_copy;
}
static char dump_coherency_codex(parsec_data_coherency_t state)
{
if( PARSEC_DATA_COHERENCY_INVALID == state ) return 'I';
if( PARSEC_DATA_COHERENCY_OWNED == state ) return 'O';
if( PARSEC_DATA_COHERENCY_EXCLUSIVE == state ) return 'E';
if( PARSEC_DATA_COHERENCY_SHARED == state ) return 'S';
return 'X';
}
void parsec_dump_data_copy(parsec_data_copy_t* copy)
{
parsec_debug_verbose(0, 0, "- [%d]: copy %p state %c readers %d version %u\n",
(int)copy->device_index, copy, dump_coherency_codex(copy->coherency_state), copy->readers, copy->version);
}
void parsec_dump_data(parsec_data_t* data)
{
parsec_debug_verbose(0, 0, "data %p key %lu owner %d\n", data, data->key, data->owner_device);
for( uint32_t i = 0; i < parsec_nb_devices; i++ ) {
if( NULL != data->device_copies[i])
parsec_dump_data_copy(data->device_copies[i]);
}
}
parsec_data_copy_t*
parsec_data_get_copy(parsec_data_t* data, uint32_t device)
{
return PARSEC_DATA_GET_COPY(data, device);
}
void parsec_data_copy_release(parsec_data_copy_t* copy)
{
/* TODO: Move the copy back to the CPU before destroying it */
PARSEC_DATA_COPY_RELEASE(copy);
}
void* parsec_data_copy_get_ptr(parsec_data_copy_t* data)
{
return PARSEC_DATA_COPY_GET_PTR(data);
}
/* Return the pointer on the selected device */
void* parsec_data_get_ptr(parsec_data_t* data, uint32_t device)
{
parsec_data_copy_t *copy = parsec_data_get_copy( data, device );
return PARSEC_DATA_COPY_GET_PTR(copy);
}
parsec_data_t*
parsec_data_create( parsec_data_t **holder,
parsec_data_collection_t *desc,
parsec_data_key_t key,
void *ptr, size_t size, parsec_data_flag_t flags )
{
parsec_data_t *data = *holder;
if( NULL == data ) {
parsec_data_copy_t* data_copy = PARSEC_OBJ_NEW(parsec_data_copy_t);
data = PARSEC_OBJ_NEW(parsec_data_t);
data_copy->coherency_state = PARSEC_DATA_COHERENCY_OWNED;
data_copy->device_private = ptr;
data_copy->dtt = desc->default_dtt;
data_copy->flags = flags;
data->owner_device = 0;
data->key = key;
data->dc = desc;
data->nb_elts = size;
parsec_data_copy_attach(data, data_copy, 0);
if( !parsec_atomic_cas_ptr(holder, NULL, data) ) {
parsec_data_copy_detach(data, data_copy, 0);
PARSEC_OBJ_RELEASE(data_copy);
data = *holder;
}
} else {
/* Do we have a copy of this data */
if( NULL == data->device_copies[0] ) {
parsec_data_copy_t* data_copy = parsec_data_copy_new(data, 0, desc->default_dtt, flags);
data_copy->device_private = ptr;
}
}
assert( data->key == key );
return data;
}
parsec_data_t*
parsec_data_create_with_type( parsec_data_collection_t *desc,
parsec_data_key_t key, void *ptr, size_t size,
parsec_datatype_t dtt)
{
parsec_data_t *clone;
parsec_data_copy_t* data_copy = PARSEC_OBJ_NEW(parsec_data_copy_t);
clone = PARSEC_OBJ_NEW(parsec_data_t);
data_copy->coherency_state = PARSEC_DATA_COHERENCY_OWNED;
data_copy->device_private = ptr;
data_copy->dtt = dtt;
clone->owner_device = 0;
clone->key = key;
clone->dc = desc;
clone->nb_elts = size;
parsec_data_copy_attach(clone, data_copy, 0);
return clone;
}
void
parsec_data_destroy( parsec_data_t *data )
{
/*
* Need to call destruct before release due to circular
* dependency between the parsec_data_copy_t and the parsec_data_t
*/
PARSEC_OBJ_DESTRUCT(data);
#if defined(PARSEC_DEBUG_PARANOID)
((parsec_object_t *)(data))->obj_magic_id = PARSEC_OBJ_MAGIC_ID;
#endif
PARSEC_OBJ_RELEASE(data);
}
|
ca195a003a265d7700abaae491dffbc8f9b17c97
|
62d8e95f52a206fa1b623b4c8e7a643a6ea1d34f
|
/structures.h
|
6ce83dd897f369f30ae5736ab2f09fcca33549d6
|
[] |
no_license
|
highlightz/useAllClasses
|
90ae5e1fc8303f395497c40f636d8d1374f871c6
|
f8ad751efdd1689143d70c708b41e75a68fc1b7d
|
refs/heads/master
| 2021-01-02T08:39:20.672602 | 2015-09-06T15:05:17 | 2015-09-06T15:05:17 | 42,005,235 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,342 |
h
|
structures.h
|
#ifndef STRUCTURES_H
#define STRUCTURES_H
#include <opencv2/core/core.hpp>
struct GroundPlanePoints
{
CvPoint3D32f planePointA;
int numOfEffectivePointsAourndA;
CvPoint3D32f planePointB;
int numOfEffectivePointsAourndB;
CvPoint3D32f planePointC;
int numOfEffectivePointsAourndC;
};
struct GroundPlane
{
float coefs_0;
float coefs_1;
float coefs_2;
float coefs_3;
};
// The point cloud refers to camera as a reference coordinate frame.
struct PointCloud
{
float x, y, z;
int r, g, b;
int row, col;
};
// Such a struct object represents a neighborhood of an interest point,
// which serves to determine the ground plane.
// Three of them are needed.
struct DepthWindow
{
float avrgDepth; // Average depth of a window
int numOfPoints; // Number of points of this window
int numPixelLessThanFixedDepthThreshold; // Number of points with depth less than a fixed value
DepthWindow( )
{
avrgDepth = 0.0f;
numOfPoints = 0;
numPixelLessThanFixedDepthThreshold = 0;
}
};
// This struct stores the necessary pose information of a gound vehicle.
struct odometry
{
double x; // axis of which points to the right
double y; // axis of which points to the earth
double z; // axis of which points to the front
double yaw_rad; // around y axis, positive when turning right horizontally
};
#endif // STRUCTURES_H
|
54b56baf4f4643e892df118ecf34bd56068bab7b
|
708148e391d38875da09716fd6062c0059e164f9
|
/EventQueue.h
|
99fa0e49f3c997bd303588283fb3852ffb303b45
|
[] |
no_license
|
BlockWorksCo/Playground
|
87bf2cdadbc33f020e5d8fb7f3ff875f054ad77d
|
c968e22cd923ee184fe9362905a4d58e9f69cb27
|
refs/heads/master
| 2021-01-23T14:39:05.530058 | 2020-05-13T22:21:54 | 2020-05-13T22:21:54 | 22,513,247 | 1 | 0 | null | 2021-01-04T22:59:52 | 2014-08-01T14:25:57 |
C
|
UTF-8
|
C
| false | false | 370 |
h
|
EventQueue.h
|
//
// Copyright (C) BlockWorks Consulting Ltd - All Rights Reserved.
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
// Written by Steve Tickle <Steve@BlockWorks.co>, September 2014.
//
#ifndef __EVENTQUEUE_H__
#define __EVENTQUEUE_H__
void Call( Handler handler );
void DispatchHandlers();
#endif
|
cf91909552510d6d2147d25aab9fab993e1c352b
|
cffbdb9d56e2e6b6f82a102cbdb63955e9c9e68c
|
/riakClient.h
|
9871c46c8743b85a44519d1628c6bafed4f7028c
|
[] |
no_license
|
maxbeutel/ext.riak
|
4d8ad0fc6bd9532e77d98048358b333a784480e6
|
fe559a561d1776c561d9002c364d1862bedb774c
|
refs/heads/master
| 2020-04-06T03:34:24.006400 | 2011-10-27T20:42:02 | 2011-10-27T20:42:02 | 2,388,193 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,439 |
h
|
riakClient.h
|
#ifndef RIAK_CLIENT_H
#define RIAK_CLIENT_H
zend_class_entry *riak_ce_riakClient;
#define RIAK_CLIENT_HOST "host"
#define RIAK_CLIENT_HOST_LEN strlen(RIAK_CLIENT_HOST)
#define RIAK_CLIENT_PORT "port"
#define RIAK_CLIENT_PORT_LEN strlen(RIAK_CLIENT_PORT)
#define RIAK_CLIENT_PREFIX "prefix"
#define RIAK_CLIENT_PREFIX_LEN strlen(RIAK_CLIENT_PREFIX)
#define RIAK_CLIENT_MAPRED_PREFIX "mapred_prefix"
#define RIAK_CLIENT_MAPRED_PREFIX_LEN strlen(RIAK_CLIENT_MAPRED_PREFIX)
#define RIAK_CLIENT_CLIENT_ID "clientid"
#define RIAK_CLIENT_CLIENT_ID_LEN strlen(RIAK_CLIENT_CLIENT_ID)
#define RIAK_CLIENT_R "r"
#define RIAK_CLIENT_R_LEN strlen(RIAK_CLIENT_R)
#define RIAK_CLIENT_W "w"
#define RIAK_CLIENT_W_LEN strlen(RIAK_CLIENT_W)
#define RIAK_CLIENT_DW "dw"
#define RIAK_CLIENT_DW_LEN strlen(RIAK_CLIENT_DW)
PHPAPI int riak_client_base_address(zval *object, int add_prefix, char **base_address TSRMLS_DC);
PHP_METHOD(riakClient, __construct);
PHP_METHOD(riakClient, getR);
PHP_METHOD(riakClient, setR);
PHP_METHOD(riakClient, getW);
PHP_METHOD(riakClient, setW);
PHP_METHOD(riakClient, getDW);
PHP_METHOD(riakClient, setDW);
PHP_METHOD(riakClient, getClientId);
PHP_METHOD(riakClient, isAlive);
PHP_METHOD(riakClient, bucket);
PHP_METHOD(riakClient, buckets);
PHP_METHOD(riakClient, add);
PHP_METHOD(riakClient, search);
PHP_METHOD(riakClient, link);
PHP_METHOD(riakClient, map);
PHP_METHOD(riakClient, reduce);
#endif
|
c74107b8c18e07019f1c2691864380ad90a68dad
|
4117ef17caeda8401f316f69de2eecb2393a7ab6
|
/Demo/api/iot_bc260.c
|
b3d99ba6cd425891a9b08d01f181090ff59da8fd
|
[] |
no_license
|
794627991/FDW_BSP
|
4afadebd4b0583eb567b51f4f980cf471a33aa86
|
e99dced9f03ac1d38507b7fd226267ee5f51fba3
|
refs/heads/main
| 2023-05-03T05:06:14.798776 | 2021-05-12T07:44:28 | 2021-05-12T07:44:28 | 341,042,382 | 0 | 1 | null | null | null | null |
GB18030
|
C
| false | false | 25,444 |
c
|
iot_bc260.c
|
#include "iot_bc260.h"
/*全局变量声明*/
/*bc260_dat_type IOTDAT(MODULE);*/
IOTDATTYPE(MODULE)
IOTDAT(MODULE);
/*静态函数声明*/
static uint8_t bc260iotRst(iot_type *iot);
static uint8_t bc260rxdeal(iot_type *iot);
static uint8_t bc260SendUdpTcpIpPort(iot_type *iot);
static uint8_t bc260OneNetojb1Rec(iot_type *iot);
static uint8_t bc260OneNetojb2Rec(iot_type *iot);
static uint8_t bc260SendCoapIPort(iot_type *iot);
static uint8_t bc260OberveSend(iot_type *iot);
/*字典声明*/
const cmd_type DIC_TCUDP(MODULE)[] = {
{"rst", NULL, bc260iotRst, NULL, NULL, 0, 1, "nrb", "end2", "end2"},
{"nrb", "AT+NRB\r\n", NULL, "RDY", NULL, 10, 1, "at", "at", "at"},
{"at", "AT\r\n", NULL, "OK", NULL, 2, 3, "creg", "end3", "end3"},
{"creg", "AT+CEREG=1\r\n", NULL, "OK", NULL, 2, 3, "cfunx", "cfunx", "cfunx"},
{"cfunx", "AT+CFUN?\r\n", NULL, "CFUN: 1", NULL, 3, 3, "qsclk", "end3", "end3"},
{"qsclk", "AT+QSCLK=0\r\n", NULL, "OK", NULL, 2, 1, "cpsm", "cpsm", "cpsm"},
{"cpsm", "AT+CPSMS=1,,,\"01000011\",\"01000011\"\r\n", NULL, "OK", NULL, 2, 1, "qevent", "qevent", "qevent"},
{"qevent", "AT+QNBIOTEVENT=1,1\r\n", NULL, "OK", NULL, 1, 1, "cgsn", "cgsn", "cgsn"},
{"cgsn", "AT+CGSN=1\r\n", NULL, NULL, bc260rxdeal, 2, 3, "nccid", "rst", "rst"},
{"nccid", "AT+QCCID\r\n", NULL, NULL, bc260rxdeal, 2, 3, "cimi", "rst", "rst"},
{"cimi", "AT+CIMI\r\n", NULL, "OK", NULL, 2, 3, "con0", "con0", "con0"},
{"con0", "AT+CSCON=0\r\n", NULL, "OK", NULL, 2, 1, "cgatt", "cgatt", "cgatt"},
{"cgatt", "AT+CGATT?\r\n", NULL, NULL, bc260rxdeal, 2, 60, "csq", "end", "isyp"},
{"isyp", "AT+CSQ\r\n", NULL, NULL, bc260rxdeal, 2, 3, "yp1", "end2", "end2"},
{"yp1", "AT+CFUN=0\r\n", NULL, "OK", NULL, 10, 2, "yp2", "end3", "end3"},
{"yp2", "AT+QCSEARFCN\r\n", NULL, "OK", NULL, 2, 2, "rst", "end3", "end3"},
{"csq", "AT+CSQ\r\n", NULL, NULL, bc260rxdeal, 1, 1, "clk", "clk", "clk"},
{"clk", "AT+CCLK?\r\n", NULL, NULL, bc260rxdeal, 1, 1, "nustat", "nustat", "nustat"},
{"nustat", "AT+QENG=0\r\n", NULL, NULL, bc260rxdeal, 2, 1, "udp1", "udp1", "udp1"},
{"udp1", "AT+QICFG=\"dataformat\",1,1\r\n", NULL, "OK", NULL, 2, 3, "udp2", "rst", "rst"},
{"udp2", NULL, bc260SendUdpTcpIpPort, NULL, bc260rxdeal, 5, 1, "con1", "rst", "rst"},
{"con1", "AT+CSCON=1\r\n", NULL, "OK", NULL, 2, 1, "txdat", "txdat", "txdat"},
{"txdat", NULL, iotSend, "OK", NULL, 10, 3, "wait", "end", "end"},
{"wait", NULL, NULL, NULL, bc260rxdeal, 1, 60, "txdat", "end", "end"},
/*{"rxdat", NULL, iotRead, NULL, NULL, 0, 1, "wait", "end", "wait"},*/
{"end", "AT+QICLOSE=0\r\n", NULL, "OK", NULL, 2, 1, "end1", "end1", "end1"},
{"end1", "AT+QSCLK=1\r\n", NULL, "OK", NULL, 2, 1, "end2", "end2", "end2"},
{"end2", "AT+CFUN=0\r\n", NULL, "OK", NULL, 10, 1, "end3", "end3", "end3"},
{"end3", NULL, iotEnd, NULL, NULL, 0, 1, NULL, NULL, NULL}};
const cmd_type DIC_COAP(MODULE)[] = {
{"rst", NULL, bc260iotRst, NULL, NULL, 0, 1, "nrb", "end2", "end2"},
{"nrb", "AT+NRB\r\n", NULL, "RDY", NULL, 10, 1, "at", "at", "at"},
{"at", "AT\r\n", NULL, "OK", NULL, 2, 3, "creg", "end3", "end3"},
{"creg", "AT+CEREG=1\r\n", NULL, "OK", NULL, 2, 3, "cfunx", "cfunx", "cfunx"},
{"cfunx", "AT+CFUN?\r\n", NULL, "CFUN: 1", NULL, 3, 3, "qsclk", "end3", "end3"},
{"qsclk", "AT+QSCLK=0\r\n", NULL, "OK", NULL, 2, 1, "cpsm", "cpsm", "cpsm"},
{"cpsm", "AT+CPSMS=1,,,\"01000011\",\"01000011\"\r\n", NULL, "OK", NULL, 2, 1, "qevent", "qevent", "qevent"},
{"qevent", "AT+QNBIOTEVENT=1,1\r\n", NULL, "OK", NULL, 1, 1, "cgsn", "cgsn", "cgsn"},
{"cgsn", "AT+CGSN=1\r\n", NULL, NULL, bc260rxdeal, 2, 3, "nccid", "rst", "rst"},
{"nccid", "AT+QCCID\r\n", NULL, NULL, bc260rxdeal, 2, 3, "cimi", "rst", "rst"},
{"cimi", "AT+CIMI\r\n", NULL, "OK", NULL, 2, 3, "con0", "con0", "con0"},
{"con0", "AT+CSCON=0\r\n", NULL, "OK", NULL, 2, 1, "cgatt", "cgatt", "cgatt"},
{"cgatt", "AT+CGATT?\r\n", NULL, NULL, bc260rxdeal, 2, 60, "csq", "end", "isyp"},
{"isyp", "AT+CSQ\r\n", NULL, NULL, bc260rxdeal, 2, 3, "yp1", "end2", "end2"},
{"yp1", "AT+CFUN=0\r\n", NULL, "OK", NULL, 10, 2, "yp2", "end3", "end3"},
{"yp2", "AT+QCSEARFCN\r\n", NULL, "OK", NULL, 2, 2, "rst", "end3", "end3"},
{"csq", "AT+CSQ\r\n", NULL, NULL, bc260rxdeal, 1, 1, "clk", "clk", "clk"},
{"clk", "AT+CCLK?\r\n", NULL, NULL, bc260rxdeal, 1, 1, "nustat", "nustat", "nustat"},
{"nustat", "AT+QENG=0\r\n", NULL, NULL, bc260rxdeal, 2, 1, "coap1", "coap1", "coap1"},
{"coap1", "AT+QLACFG=\"platform\",0\r\n", NULL, "OK", NULL, 2, 3, "coap2", "rst", "rst"},
{"coap2", NULL, bc260SendCoapIPort, "OK", NULL, 2, 3, "coap3", "rst", "rst"},
{"coap3", "AT+QLAADDOBJ=19,0,1,0\r\n", NULL, "OK", NULL, 2, 3, "coap4", "rst", "rst"},
{"coap4", "AT+QLAREG\r\n", NULL, NULL, bc260rxdeal, 5, 1, "coap5", "rst", "rst"}, //只允许发一次失败就重来
{"coap5", NULL, bc260OberveSend, "OK", NULL, 5, 1, "con1", "rst", "rst"}, //只允许发一次失败就重来
{"con1", "AT+CSCON=1\r\n", NULL, "OK", NULL, 2, 1, "txdat", "txdat", "txdat"},
{"txdat", NULL, iotSend, "OK", NULL, 10, 3, "wait", "end", "end"},
{"wait", NULL, NULL, NULL, bc260rxdeal, 1, 60, "txdat", "end", "end"},
/*{"rxdat", NULL, iotRead, NULL, NULL, 0, 1, "wait", "end", "wait"},*/
{"end", "AT+QICLOSE=0\r\n", NULL, "OK", NULL, 2, 1, "end1", "end1", "end1"},
{"end1", "AT+QSCLK=1\r\n", NULL, "OK", NULL, 2, 1, "end2", "end2", "end2"},
{"end2", "AT+CFUN=0\r\n", NULL, "OK", NULL, 10, 1, "end3", "end3", "end3"},
{"end3", NULL, iotEnd, NULL, NULL, 0, 1, NULL, NULL, NULL}};
const cmd_type DIC_ONET(MODULE)[] = {
{"rst", NULL, bc260iotRst, NULL, NULL, 0, 1, "nrb", "end2", "end2"},
{"nrb", "AT+NRB\r\n", NULL, "RDY", NULL, 10, 1, "at", "at", "at"},
{"at", "AT\r\n", NULL, "OK", NULL, 2, 3, "creg", "end3", "end3"},
{"creg", "AT+CEREG=1\r\n", NULL, "OK", NULL, 2, 3, "cfunx", "cfunx", "cfunx"},
{"cfunx", "AT+CFUN?\r\n", NULL, "CFUN: 1", NULL, 3, 3, "qsclk", "end3", "end3"},
{"qsclk", "AT+QSCLK=0\r\n", NULL, "OK", NULL, 2, 1, "cpsm", "cpsm", "cpsm"},
{"cpsm", "AT+CPSMS=1,,,\"01000011\",\"01000011\"\r\n", NULL, "OK", NULL, 2, 1, "qevent", "qevent", "qevent"},
{"qevent", "AT+QNBIOTEVENT=1,1\r\n", NULL, "OK", NULL, 1, 1, "cgsn", "cgsn", "cgsn"},
{"cgsn", "AT+CGSN=1\r\n", NULL, NULL, bc260rxdeal, 2, 3, "nccid", "rst", "rst"},
{"nccid", "AT+QCCID\r\n", NULL, NULL, bc260rxdeal, 2, 3, "cimi", "rst", "rst"},
{"cimi", "AT+CIMI\r\n", NULL, "OK", NULL, 2, 3, "con0", "con0", "con0"},
{"con0", "AT+CSCON=0\r\n", NULL, "OK", NULL, 2, 1, "cgatt", "cgatt", "cgatt"},
{"cgatt", "AT+CGATT?\r\n", NULL, NULL, bc260rxdeal, 2, 60, "csq", "end", "isyp"},
{"isyp", "AT+CSQ\r\n", NULL, NULL, bc260rxdeal, 2, 3, "yp1", "end2", "end2"},
{"yp1", "AT+CFUN=0\r\n", NULL, "OK", NULL, 10, 2, "yp2", "end3", "end3"},
{"yp2", "AT+QCSEARFCN\r\n", NULL, "OK", NULL, 2, 2, "rst", "end3", "end3"},
{"csq", "AT+CSQ\r\n", NULL, NULL, bc260rxdeal, 1, 1, "clk", "clk", "clk"},
{"clk", "AT+CCLK?\r\n", NULL, NULL, bc260rxdeal, 1, 1, "nustat", "nustat", "nustat"},
{"nustat", "AT+QENG=0\r\n", NULL, NULL, bc260rxdeal, 2, 1, "onet0", "onet0", "onet0"},
{"onet0", "AT+MIPLCONFIG=0,1\r\n", NULL, "OK", NULL, 2, 1, "onet1", "onet1", "onet1"},
{"onet1", "AT+MIPLCREATE\r\n", NULL, NULL, bc260rxdeal, 5, 1, "onet2", "rst", "rst"}, //只允许发一次失败就重来
{"onet2", "AT+MIPLADDOBJ=0,3200,1,\"1\",1,0\r\n", NULL, "OK", NULL, 5, 1, "onet3", "rst", "rst"}, //只允许发一次失败就重来
{"onet3", "AT+MIPLOPEN=0,3600\r\n", NULL, NULL, bc260rxdeal, 30, 1, "onet4", "rst", "rst"}, //需要多等待一段时间 客户端注册 OneNET 平台
{"onet4", NULL, bc260OneNetojb1Rec, NULL, bc260rxdeal, 5, 1, "onet5", "rst", "rst"}, //只允许发送一次,失败就重来
{"onet5", NULL, bc260OneNetojb2Rec, "OK", NULL, 2, 3, "con1", "rst", "rst"},
{"con1", "AT+CSCON=1\r\n", NULL, "OK", NULL, 2, 1, "txdat", "txdat", "txdat"},
{"txdat", NULL, iotSend, "OK", NULL, 10, 3, "wait", "end", "end"},
{"wait", NULL, NULL, NULL, bc260rxdeal, 1, 60, "txdat", "end", "end"},
/*{"rxdat", NULL, iotRead, NULL, NULL, 0, 1, "wait", "end", "wait"},*/
{"end", "AT+QICLOSE=0\r\n", NULL, "OK", NULL, 2, 1, "end1", "end1", "end1"},
{"end1", "AT+QSCLK=1\r\n", NULL, "OK", NULL, 2, 1, "end2", "end2", "end2"},
{"end2", "AT+CFUN=0\r\n", NULL, "OK", NULL, 10, 1, "end3", "end3", "end3"},
{"end3", NULL, iotEnd, NULL, NULL, 0, 1, NULL, NULL, NULL}};
/* bc260如果不硬复位,某些命令不好使 */
static uint8_t bc260iotRst(iot_type *iot)
{
if (iotRst(iot) == 1)
{
NB_OFF;
delay_ms(100);
NB_ON;
return 1;
}
return 0;
}
/*返回1 收到成功的数据
返回0 收到失败的数据
返回2 未收到有效数据*/
static uint8_t bc260rxdeal(iot_type *iot)
{
char *buf = iot->core.rxbuf;
volatile uint8_t re = 2;
if (strstr(buf, "QLAURC: \"write\""))
{
if (iotRead(iot) == 0)
{
/*说明收到结束包*/
re = 0;
}
}
else if (strstr(buf, "QIURC: \"recv\""))
{
if (iotRead(iot) == 0)
{
/*说明收到结束包*/
re = 0;
}
}
else if (strstr(buf, "MIPLWRITE: "))
{
if (iotRead(iot) == 0)
{
/*说明收到结束包*/
re = 0;
}
//+MIPLWRITE: 0,11535,3200,0,5750,2,8,3131323233333434,0,0
}
else if (strstr(buf, "QIOPEN: 0,0"))
{
re = 1;
}
else if (strstr(buf, "CFUN: 1"))
{
re = 1;
}
else if (strstr(buf, "MIPLCREATE: 0"))
{
//+MIPLCREATE: 0
re = 1;
}
else if (strstr(buf, "MIPLOBSERVE:"))
{
//+MIPLOBSERVE: 0,81895,1,3200,0,-1
char *Location, *Locationl;
int len = strlen("MIPLOBSERVE: 0,");
Location = strstr(buf, "MIPLOBSERVE: 0,");
Locationl = strstr(&Location[len], ",");
if ((Locationl != NULL) && (Locationl > (Location + len)))
{
memset(IOTDAT(MODULE).msgid1, 0, 20);
memcpy(IOTDAT(MODULE).msgid1, &Location[len], Locationl - Location - len);
re = 1;
}
else
{
re = 0;
}
}
else if (strstr(buf, "MIPLDISCOVER:"))
{
//+MIPLDISCOVER: 0,31605,3311
char *Location, *Locationl;
int len = strlen("MIPLDISCOVER: 0,");
Location = strstr(buf, "MIPLDISCOVER: 0,");
Locationl = strstr(&Location[len], ",");
if ((Locationl != NULL) && (Locationl > (Location + len)))
{
memset(IOTDAT(MODULE).msgid2, 0, 20);
memcpy(IOTDAT(MODULE).msgid2, &Location[len], Locationl - Location - len);
re = 1;
}
else
{
re = 0;
}
}
else if (strstr(buf, "CGSN: ")) //+CGSN: 869951040044046
{
char *Location;
int len = strlen("CGSN: "), c = 0;
Location = strstr(buf, "CGSN: ");
memcpy(IOTDAT(MODULE).CGSNNum, &Location[len], 15);
for (c = 0; c < 15; c++)
{
if ((IOTDAT(MODULE).CGSNNum[c] <= 0x30) && (IOTDAT(MODULE).CGSNNum[c] >= 0x39))
{
break; //当使用coap连接时,必须保证模块号正确
}
}
if (c == 15)
{
re = 1;
}
}
else if (strstr(buf, "QCCID: ")) //+QCCID: 89860317482032831892
{
char *Location;
int len = strlen("QCCID: "), c = 0;
Location = strstr(buf, "QCCID: ");
for (c = 0; c < 20; c++)
{
if ((Location[c] <= 0x30) && (Location[c] >= 0x39))
{
break;
}
}
if (c == 20)
{
CharToBety((uint8_t *)&Location[len], IOTDAT(MODULE).Simword, 10);
re = 1;
}
}
else if (strstr(buf, "CGATT: 1")) //+CGATT: 1
{
re = 1;
}
else if (strstr(buf, "CEREG: "))
{
char *Location;
int len = strlen("CEREG: ");
Location = strstr(buf, "CEREG: ");
if ((Location[len] == '0') || (Location[len] == '3'))
{
re = 0; //未注册,直接关
}
if ((Location[len] == '1') || (Location[len] == '5'))
{
re = 1;
}
}
else if (strstr(buf, "CSQ: ")) //+CSQ: 31,0
{
char *Location;
int len = strlen("CSQ: ");
Location = strstr(buf, "CSQ: ");
if (Location[len + 1] == ',')
IOTDAT(MODULE).RSSI = Location[len] - 0x30;
else
IOTDAT(MODULE).RSSI = ((Location[len] - 0x30) << 4) + (Location[len + 1] - 0x30);
if ((IOTDAT(MODULE).RSSI >= 0x20) && (IOTDAT(MODULE).RSSI != 0x99))
re = 1; /* 信号大于20才异频 */
else
re = 0;
}
else if (strstr(buf, "QLAURC:"))
{
//+QLAURC: "observe",60722,0,19,0,0
char *Location, *Locationl;
int len = strlen("\"observe\",");
Location = strstr(buf, "\"observe\",");
Locationl = strstr(&Location[len], ",");
if ((Locationl != NULL) && (Locationl > (Location + len)))
{
memset(IOTDAT(MODULE).oberve, 0, 6);
memcpy(IOTDAT(MODULE).oberve, &Location[len], Locationl - Location - len);
re = 1;
}
else
{
re = 0;
}
}
else if (strstr(buf, "QENG: "))
{
//+QENG: 0,2506,,176,"0BF576D1",-59,-6,31,21,5,3095,0,-17,3
char *Location, *Locationl, choutdou = 1;
int len = strlen("QENG: 0,"), ti = 0, tj = 0;
Location = strstr(buf, "QENG: 0,");
IOTDAT(MODULE).rsrp = 0;
IOTDAT(MODULE).cellid = 0;
IOTDAT(MODULE).EARFCN = 0;
IOTDAT(MODULE).PCI = 0;
IOTDAT(MODULE).ECL = 0;
IOTDAT(MODULE).SNR = 0;
for (;;)
{
Locationl = strstr(&Location[len], ",");
if ((Locationl != NULL) && (Locationl >= (Location + len)))
{
if (choutdou == 1) //小区号
{
for (ti = 0; ti < Locationl - Location - len; ti++)
{
IOTDAT(MODULE).EARFCN = (IOTDAT(MODULE).EARFCN * 10) + (Location[len + ti] - 0x30);
}
}
else if (choutdou == 3) //PCI
{
for (ti = 0; ti < Locationl - Location - len; ti++)
{
IOTDAT(MODULE).PCI = (IOTDAT(MODULE).PCI * 10) + (Location[len + ti] - 0x30);
}
}
else if (choutdou == 4) //cellid
{
for (ti = 0; ti < 8; ti++)
{
if (Location[len] == '\"')
{
IOTDAT(MODULE).cellid = (IOTDAT(MODULE).cellid << 4) + CharToHex(Location[len + ti + 1]);
}
}
}
else if (choutdou == 5) //rsrp
{
if (Location[len] == '-') //一定是个负数
{
ti = Locationl - Location - len - 1;
for (tj = 0; tj < ti; tj++)
{
IOTDAT(MODULE).rsrp = IOTDAT(MODULE).rsrp * 10 - (Location[len + tj + 1] - 0x30);
}
}
}
else if (choutdou == 8) //snr
{
if (Location[len] == '-')
{
ti = Locationl - Location - len - 1;
for (tj = 0; tj < ti; tj++)
{
IOTDAT(MODULE).SNR = IOTDAT(MODULE).SNR * 10 - (Location[len + tj + 1] - 0x30);
}
}
else
{
ti = Locationl - Location - len;
for (tj = 0; tj < ti; tj++)
{
IOTDAT(MODULE).SNR = IOTDAT(MODULE).SNR * 10 + (Location[len + tj] - 0x30);
}
}
}
else if (choutdou == 9) //band
{
IOTDAT(MODULE).Band = Location[len] - 0x30;
}
else if (choutdou == 11) //ecl
{
IOTDAT(MODULE).ECL = Location[len] - 0x30;
}
else if (choutdou > 11)
{
break;
}
}
else
{
break;
}
len = 0;
choutdou++;
Location = Locationl + 1;
}
re = 1;
}
else if (strstr(buf, "CSCON: 0"))
{
re = 1;
}
else if (strstr(buf, "CCLK: "))
{
#if NB_CLK > 0 && API_UseRTC > 0
//+CCLK: "2020/08/17,08:33:55+32"
Calendar_Type CLK;
char *Location;
int len = strlen("CCLK: ");
Location = strstr(buf, "CCLK: ");
CLK.time.second = (Location[24] - 0x30) * 10 + (Location[25] - 0x30);
CLK.time.minute = (Location[21] - 0x30) * 10 + (Location[22] - 0x30);
CLK.time.hour = (Location[18] - 0x30) * 10 + (Location[19] - 0x30) + (((Location[27] - 0x30) * 10 + (Location[28] - 0x30)) / 4);
CLK.date.day = (Location[15] - 0x30) * 10 + (Location[16] - 0x30);
CLK.date.month = (MONTH)((Location[12] - 0x30) * 10 + (Location[13] - 0x30));
CLK.date.year = (Location[9] - 0x30) * 10 + (Location[10] - 0x30) + 2000;
API_Calendar(&CLK);
API_Set_Time_HEX(&CLK);
#endif
re = 1;
}
else if (strstr(buf, "ENTER PSM")) //QNBIOTEVENT: "ENTER PSM"
{
re = 0;
}
return re;
}
static uint8_t bc260SendCoapIPort(iot_type *iot)
{
iotprintf("%s%15s%s%5s%s%s%s", "AT+QLACONFIG=0,\"", iot->net.Ip, "\",",
iot->net.Port, ",\"", IOTDAT(MODULE).CGSNNum, "\",300,3\r\n");
return 2; //发命令函数除非有额外需求否则一律返回2
}
static uint8_t bc260SendUdpTcpIpPort(iot_type *iot)
{
if (iot->foo.LinkMode != TCPNum)
{
iotprintf("%s%15s%s%5s%s", "AT+QIOPEN=0,0,\"UDP\",", iot->net.Ip, ",", iot->net.Port, "\r\n");
}
else
{
iotprintf("%s%15s%s%5s%s", "AT+QIOPEN=0,0,\"TCP\",", iot->net.Ip, ",", iot->net.Port, "\r\n");
}
return 2; //发命令函数除非有额外需求否则一律返回2
}
static uint8_t bc260OneNetojb1Rec(iot_type *iot)
{
iotprintf("%s%20s%s", "AT+MIPLOBSERVERSP=0,", IOTDAT(MODULE).msgid1, ",1\r\n");
return 2; //发命令函数除非有额外需求否则一律返回2
}
static uint8_t bc260OneNetojb2Rec(iot_type *iot)
{
iotprintf("%s%20s%s", "AT+MIPLDISCOVERRSP=0,", IOTDAT(MODULE).msgid2, ",1,4,\"5750\"\r\n");
return 2; //发命令函数除非有额外需求否则一律返回2
}
static uint8_t bc260OberveSend(iot_type *iot)
{
/*AT+QLAOBSRSP=60722,1,19,0,0,2,1,"FF",0*/
iotprintf("%s%6s%s", "AT+QLAOBSRSP=", IOTDAT(MODULE).oberve, ",1,19,0,0,2,1,\"FF\",0\r\n");
return 2; //发命令函数除非有额外需求否则一律返回2
}
static uint8_t FAILDO(MODULE)(char *name)
{
if (name == NULL)
return 0;
if (strcmp(name, "at") == 0)
{
/*at都不好使*/
return 1;
}
if (strcmp(name, "cfun") == 0)
{
/*没卡*/
return 2;
}
if (strcmp(name, "isyp") == 0)
{
/*没信号*/
return 3;
}
if ((strcmp(name, "coap4") == 0) || (strcmp(name, "coap5") == 0))
{
/*没注册到平台*/
return 4;
}
if (strcmp(name, "txdat") == 0)
{
/*发3次都没成功,超时了*/
return 5;
}
if (strcmp(name, "wait") == 0)
{
/*如果是接收来的实际是主动停止的*/
return 6;
}
return 0;
}
static iot_buf_type RXANALY(MODULE)(iot_type *iot)
{
uint8_t ta = 0;
iot_buf_type analy = {0, NULL};
char *buf = iot->core.rxbuf;
/*+QLAURC: "write",3735,19,1,0,2,50,"data",0*/
if (strstr(buf, "QLAURC: "))
{
char *Locationl = NULL, countdou = 0;
int len = strlen("QLAURC: \"write\",");
analy.loc = strstr(buf, "QLAURC: \"write\",");
for (;;)
{
Locationl = strstr(&analy.loc[len], ",");
if (Locationl != NULL)
{
analy.loc = Locationl + 1;
len = 0;
countdou++;
if (countdou == 5)
break;
}
else
{
break;
}
}
if (Locationl != NULL)
{
for (ta = 0; ta < 4; ta++)
{
if (analy.loc[ta] == ',')
{
break;
}
else
{
analy.len *= 10;
analy.len += (analy.loc[ta] - 0x30);
}
}
ta += 2; //+2是因为 rxlen之后还有 ," 两个字符
analy.loc = &analy.loc[ta];
}
}
/*+QIURC: "recv",0,4,"54657374"*/
else if (strstr(buf, "QIURC: "))
{
int len = strlen("QIURC: \"recv\",0,");
analy.loc = strstr(buf, "QIURC:");
for (ta = 0; ta < 4; ta++)
{
if (analy.loc[len + ta] == ',')
{
break;
}
else
{
analy.len *= 10;
analy.len += (analy.loc[len + ta] - 0x30);
}
}
ta += (len + 2); //+2是因为 rxlen之后还有 ," 两个字符
analy.loc = &analy.loc[ta];
}
else if (strstr(buf, "MIPLWRITE:"))
{
//+MIPLWRITE: 0,11535,3200,0,5750,2,8,3131323233333434,0,0
char *Locationl, countdou = 0;
int len = strlen("MIPLWRITE: 0,");
analy.loc = strstr(buf, "MIPLWRITE: 0,");
Locationl = strstr(&analy.loc[len], ",");
if ((Locationl != NULL) && (Locationl > (analy.loc + len)))
{
memset(IOTDAT(MODULE).msgid2, 0, 20);
memcpy(IOTDAT(MODULE).msgid2, &analy.loc[len], Locationl - analy.loc - len);
iotprintf("%s%20s%s", "AT+MIPLWRITERSP=0,", IOTDAT(MODULE).msgid2, ",2\r\n");
}
// 123456789
// +MIPLWRITE: 0,8506,3200,0,5750,2,9,313233343536373839,0,0
// AT+MIPLWRITERSP=0,8506,2
for (;;)
{
Locationl = strstr(&analy.loc[len], ",");
if (Locationl != NULL)
{
analy.loc = Locationl + 1;
len = 0;
countdou++;
if (countdou == 5)
break;
}
else
{
break;
}
}
if (Locationl != NULL)
{
for (ta = 0; ta < 4; ta++)
{
if (analy.loc[ta] == ',')
{
break;
}
else
{
analy.len *= 10;
analy.len += (analy.loc[ta] - 0x30);
}
}
ta += 1; //+1是因为 rxlen之后还有 , 1个字符
analy.loc = &analy.loc[ta];
AsciiToHex((uint8_t *)analy.loc, (uint8_t *)analy.loc, analy.len);
analy.len >>= 1;
}
}
return analy;
}
static void UDP_SEND(MODULE)(uint8_t *buf, uint16_t len)
{
//AT+QISEND=0,3,AA1133
iotprintf("%s%d%s%l%a%s", "AT+QISEND=0,", len, ",", len, buf, "\r\n");
}
static void TCP_SEND(MODULE)(uint8_t *buf, uint16_t len)
{
bc260udpsend(buf, len);
}
static void COAP_SEND(MODULE)(uint8_t *buf, uint16_t len)
{
/*AT+QLANOTIFY=19,0,0,2,75,"DATA",0,0*/
iotprintf("%s%d%s%l%a%s", "AT+QLANOTIFY=19,0,0,2,", len, ",\"", len, buf, "\",0,0\r\n");
}
static void ONET_SEND(MODULE)(uint8_t *buf, uint16_t len)
{
//AT+MIPLNOTIFY=0,9523,3200,0,5750,1,5,”hello”,0,0 //数据主动上报
iotprintf("%s%20s%s%d%s%l%a%s", "AT+MIPLNOTIFY=0,", IOTDAT(MODULE).msgid1, ",3200,0,5750,1,",
len * 2, ",\"", len, buf, "\",0,0\r\n");
}
getcmdinfo_type GETCMD(MODULE)(uint8_t linkmode)
{
getcmdinfo_type info;
if (linkmode == InitNum)
{
}
if (linkmode == CoapNum)
{
info.cmd = (cmd_type *)&DIC_COAP(MODULE);
info.len = ARRAY_SIZE(DIC_COAP(MODULE));
info.SendFun = COAP_SEND(MODULE);
}
else if (linkmode == OneNET)
{
info.cmd = (cmd_type *)&DIC_ONET(MODULE);
info.len = ARRAY_SIZE(DIC_ONET(MODULE));
info.SendFun = ONET_SEND(MODULE);
}
else if (linkmode == TCPNum)
{
info.cmd = (cmd_type *)&DIC_TCUDP(MODULE);
info.len = ARRAY_SIZE(DIC_TCUDP(MODULE));
info.SendFun = TCP_SEND(MODULE);
}
else
{
info.cmd = (cmd_type *)&DIC_TCUDP(MODULE);
info.len = ARRAY_SIZE(DIC_TCUDP(MODULE));
info.SendFun = UDP_SEND(MODULE);
}
info.RxFun = RXANALY(MODULE);
info.Faildo = FAILDO(MODULE);
return info;
}
|
66d6c5bb6e012b742eb573f7f070e4f3dc254bd2
|
034b5dea1e7d36f472acb0a4695ee8726925f6b1
|
/libssl/libssl/openssl/sslerr.h
|
e7066fd756aa8e43eae10e970e7e0b90b8f646e8
|
[] |
no_license
|
build2-packaging/openssl
|
78ee19d5939aa4db55c9677e8236a67bd1084aca
|
24d43fe451d3f4fa6b15665cfa3353f4c08a5f5d
|
refs/heads/master
| 2023-07-26T03:20:46.041661 | 2023-07-06T07:41:20 | 2023-07-06T07:41:20 | 201,514,824 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 42 |
h
|
sslerr.h
|
../../../upstream/include/openssl/sslerr.h
|
e69058fcbb42ba6b654b127349505c52b8315b56
|
40e87318b9c4c707e97c7d94dede55d67c11f495
|
/lib/string/memmove.c
|
c733ca02fc7abe98a1073ec9c6aef6eca4cdfe9d
|
[] |
no_license
|
mvanga/Bach-Operating-System
|
ea5a1ddba622be09b7905cb3ae4e379b3db63602
|
fb1e9bb16d710834d48871265b75cf5a2aabe5a8
|
refs/heads/master
| 2016-09-06T09:59:42.229556 | 2010-09-21T17:58:39 | 2010-09-21T17:58:39 | 919,299 | 9 | 2 | null | null | null | null |
UTF-8
|
C
| false | false | 287 |
c
|
memmove.c
|
#include <string.h>
#include <stddef.h>
void *memmove(void *s1, const void *s2, size_t n)
{
char *p1 = s1;
const char *p2 = s2;
if (p2 < p1 && p1 < p2 + n) {
p2 += n;
p1 += n;
while (n-- != 0)
*--p1 = *--p2;
} else {
while (n-- != 0)
*p1++ = *p2++;
}
return s1;
}
|
cb0aa13a3b4f02e5c7460e73ad4790265042c473
|
112cd4e31ed351d3c7bca7f227974f937cf3ba9e
|
/link.c
|
8d82f92c576f8a765b93a95ff38fde51fbf4affa
|
[] |
no_license
|
ThomasWilshaw/render
|
75b2afd9a0166780f62fc290a4080c779490c035
|
020d90d3dd8e9ca34df40955a2b3505caaf523c5
|
refs/heads/master
| 2021-01-10T15:15:18.799344 | 2015-11-16T21:20:27 | 2015-11-16T21:20:27 | 46,303,471 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 52 |
c
|
link.c
|
#inlcude "link.h"
void listInit(Item *header)
{
}
|
576ef2c29c0bc8e179636cee9118f261ae42bda8
|
b8998410c17aca1e5ffca1966a66d6e5b9bd276f
|
/test/hmm_example/hmm_matrices.h
|
4c9798fc5d52bed6c688ba019893b0779f543a92
|
[
"MIT"
] |
permissive
|
Nokturnal66/rtHMM
|
0fe51daf9d9c543dfe58f236e08bcc7a7022a228
|
0477d71c040232fbd2d1b712cc649707404782e2
|
refs/heads/master
| 2021-05-29T16:55:13.140581 | 2014-08-14T16:53:27 | 2014-08-14T16:53:27 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 400 |
h
|
hmm_matrices.h
|
#ifndef HMM_MATRICES_H
#define HMM_MATRICES_H
#define STATE_COUNT 3
#define ALPHABET_SIZE 3
#define ALPHABET { 0ul, 1ul, 2ul }
#define PRIOR 0.6, 0.2, 0.2
#define TRANSITION 0.7, 0.3, 0.0, \
0.1, 0.6, 0.3, \
0.0, 0.3, 0.7
#define OBSERVATION 0.7, 0.15, 0.15, \
0.3, 0.5, 0.2, \
0.2, 0.4, 0.4
#endif //HMM_MATRICES_H
|
8084b7041e80a65ebdd5698a44c50af516cdf221
|
d8e1a65a5863ea5a111c8304a040f1c797f8ebbf
|
/ mtktest --username qq413187589/N65/N65_V1/vendor/wap/obigo_Q03C/v1_official/modules/BRA/source/bra_sig.h
|
816757738aa586ac72b2e5ef998cca4b1f0cb280
|
[] |
no_license
|
manoj-gupta5/mtktest
|
a6b627cde8c9a543d473a99f778fd6f587a8d053
|
98370766a36fffb8b0dde1cc6dd144599ea184f6
|
refs/heads/master
| 2020-12-25T21:12:59.596045 | 2010-07-18T05:06:14 | 2010-07-18T05:06:14 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 6,341 |
h
|
bra_sig.h
|
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*
* Copyright (C) Teleca Mobile Technologies AB, 2002-2003.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and Teleca Mobile Technologies AB, and may be
* used and copied only in accordance with the terms of the
* said agreement.
*
* Teleca Mobile Technologies AB assumes no responsibility or
* liability for any errors or inaccuracies in this software,
* or any consequential, incidental or indirect damage arising
* out of the use of the software.
*
*/
/*
* bra_sig.h
*
* Created by Mats Tedenvall, Wed Jul 10 10:20 2002.
*
* Revision history:
*
*/
/************************************************************
*
* Sending and receiving signals in the protocol stack:
*
************************************************************/
#ifndef _bra_sig_h
#define _bra_sig_h
/*********************************************
* Signal destinations.
* The constants here are chosen to allow
* each destination a large enough interval
* in which to define its signal values.
*********************************************/
#define W_SIG_DST_BRA_MAIN 0x010
/**************************************************
* Macros
**************************************************/
#define BRA_SIGNAL_SENDTO(d, sig) \
bra_signal_sendto ((d), (sig), 0, 0, 0, NULL)
#define BRA_SIGNAL_SENDTO_I(d, sig, i) \
bra_signal_sendto ((d), (sig), i, 0, 0, NULL)
#define BRA_SIGNAL_SENDTO_U(d, sig, u) \
bra_signal_sendto ((d), (sig), 0, (u), 0, NULL)
#define BRA_SIGNAL_SENDTO_IU(d, sig, i, u) \
bra_signal_sendto ((d), (sig), (i), (u), 0, NULL)
#define BRA_SIGNAL_SENDTO_UU(d, sig, u1, u2) \
bra_signal_sendto ((d), (sig), 0, (u1), (u2), NULL)
#define BRA_SIGNAL_SENDTO_IUU(d, sig, i, u1, u2) \
bra_signal_sendto ((d), (sig), (i), (u1), (u2), NULL)
#define BRA_SIGNAL_SENDTO_P(d, sig, p) \
bra_signal_sendto ((d), (sig), 0, 0, 0, (p))
#define BRA_SIGNAL_SENDTO_IP(d, sig, i, p) \
bra_signal_sendto ((d), (sig), (i), 0, 0, (p))
#define BRA_SIGNAL_SENDTO_IUP(d, sig, i, u, p) \
bra_signal_sendto ((d), (sig), (i), (u), 0, (p))
#define BRA_SIGNAL_SENDTO_IUUP(d, sig, i, u1, u2, p) \
bra_signal_sendto ((d), (sig), (i), (u1), (u2), (p))
/****************************************
* Type definitions:
****************************************/
typedef struct bra_signal_st {
struct bra_signal_st *next;
int dst; /* The destination for this signal */
int type; /* Which signal it is */
long int i_param; /* Parameters: */
unsigned long int u_param1;
unsigned long int u_param2;
void *p_param;
} bra_signal_t;
/*
* This kind of function is called when a signal is delivered.
*/
typedef void bra_signal_function_t (bra_signal_t *);
/****************************************
* Exported functions:
****************************************/
/*
* Initialize the signal module.
*/
void
bra_signal_init (void);
/*
* Terminate the signal module.
*/
void
bra_signal_terminate (void);
/*
* Process the first signal in the signal queue.
*/
void
bra_signal_process (void);
/*
* Return TRUE if the global signal queue is empty,
* FALSE otherwise.
*/
int
bra_signal_queue_is_empty (void);
/*
* Delete a signal and its parameters.
*/
void
bra_signal_delete (bra_signal_t *sig);
/*
* Register the function "f" to be called when a signal
* is delivered to destination "dst".
*/
void
bra_signal_register_dst (int dst, bra_signal_function_t *f);
/*
* Remove the registrated function for destination "dst".
*/
void
bra_signal_deregister (int dst);
/*
* Add a new signal to the end of the global queue.
*/
void
bra_signal_sendto (int dst,
int sig,
long int i_param,
unsigned long int u_param1,
unsigned long int u_param2,
void *p_param);
/*
* Add an old signal to the beginning of the queue.
*/
void
bra_signal_prepend (bra_signal_t *sig);
#endif
|
c99b1fd09a2e172bbe90f2fd58bba2804b2b1b9c
|
62d3121bd681579c02ed95e424937b2dc6f4e8e5
|
/Prometheus Worlds/DrivingCode.c
|
55e9fd25b31d834e11bc1df9e45ec9d267b2fc41
|
[] |
no_license
|
BeckerJason/Star-Struck
|
e9ce844efb779d423d5e65bda47b2e99f2de84ab
|
0366e9f36ddadfedaf9ae779bb45d1a368716639
|
refs/heads/master
| 2022-04-30T17:48:40.602346 | 2022-04-16T01:49:41 | 2022-04-16T01:49:41 | 251,497,158 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 7,963 |
c
|
DrivingCode.c
|
void DrivingCode(int ArmValue)
{//writeDebugStreamLine("(%d);",SensorValue[Gyro]);
//writeDebugStreamLine("L (%d) R (%d);",SensorValue[LeftEnc],SensorValue[RightEnc]);
//writeDebugStreamLine("(%d);",SensorValue[RightEnc]);
int Time=300;
int EncoderI, EncoderF, EncoderValue, Direction, ArmI, ArmF;
float GyroI, GyroF, GyroValue;
if(vexRT[Btn7L]==1)
{SensorValue[Gyro]=0;
GyroI=GyroRecord();
while(vexRT[Btn7L]==1)
{
int speed=70; //SPEED HERE
motor[LM] = -speed;
motor[L1] = -speed;
motor[L2] = -speed;
motor[RM] = speed;
motor[R1] = speed;
motor[R2] = speed;
}
GyroF=GyroRecord();
GyroValue=DifferenceGyro(GyroI, GyroF);
TurnBreak(100,70);
writeDebugStreamLine("TurnDegree(%d, 70);", -GyroValue/8); //SET SPEED
writeDebugStreamLine("TurnBreak(100, %d);", 70);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn7R]==1)
{SensorValue[Gyro]=0;
GyroI=GyroRecord();
int speed=70;
while(vexRT[Btn7R]==1)
{
motor[LM] = speed;
motor[L1] = speed;
motor[L2] = speed;
motor[RM] = -speed;
motor[R1] = -speed;
motor[R2] = -speed;
}
GyroF=GyroRecord();
GyroValue=DifferenceGyro(GyroI, GyroF);
TurnBreak(100, -70);
writeDebugStreamLine("TurnDegree(%d, 70);", GyroValue/8); //SET SPEED
writeDebugStreamLine("TurnBreak(100,%d);", -70);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn7U]==1)
{
Direction=1; //Forward
EncoderI=DistRecord(,);
int speed=70; //SET SPEED
SensorValue[Gyro]=0;
while (vexRT[Btn7U]==1) //While the button is pressed
{if (SensorValue[Gyro]>0){
motor[LM] = speed;
motor[L1] = speed;
motor[L2] = speed;
motor[RM] = speed-15;
motor[R1] = speed-15;
motor[R2] = speed-15;}
else if (SensorValue[Gyro]<0){
motor[LM] = speed-15;
motor[L1] = speed-15;
motor[L2] = speed-15;
motor[RM] = speed;
motor[R1] = speed;
motor[R2] = speed;}
else{
motor[LM] = speed;
motor[L1] = speed;
motor[L2] = speed;
motor[RM] = speed;
motor[R1] = speed;
motor[R2] = speed;}
}
EncoderF=DistRecord();
EncoderValue=Difference(EncoderI, EncoderF);
Break(100,speed); //Stop the robot... thank you Norrin
writeDebugStreamLine("Dist( %d, %d, %d, 0);", EncoderValue, Direction, 70 /*,TimeOut*/); //SET SPEED
writeDebugStreamLine("Break(100,%d);", speed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn7D]==1)
{
Direction=0; //Backward
EncoderI=DistRecord(,);
int speed=70; //SET SPEED
SensorValue[Gyro]=0;
while (vexRT[Btn7D]==1) //While the button is pressed
{if (SensorValue[Gyro]>0){
motor[LM] = -speed;
motor[L1] = -speed;
motor[L2] =-speed;
motor[RM] = -speed-15;
motor[R1] = -speed-15;
motor[R2] = -speed-15;}
else if (SensorValue[Gyro]<0){
motor[LM] = -speed-15;
motor[L1] = -speed-15;
motor[L2] = -speed-15;
motor[RM] = -speed;
motor[R1] = -speed;
motor[R2] = -speed;}
else{
motor[LM] = -speed;
motor[L1] = -speed;
motor[L2] = -speed;
motor[RM] = -speed;
motor[R1] = -speed;
motor[R2] = -speed;}
}
EncoderF=DistRecord();
EncoderValue=Difference(EncoderI, EncoderF);
Break(100,-speed); //Stop the robot... thank you Norrin
writeDebugStreamLine("Dist( %d, %d, %d, %d);", EncoderValue, Direction, speed ,TimeOut); //SET SPEED
writeDebugStreamLine("Break(100,%d);", -speed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Ch3]>=10) //JOYSTICK DEADBAND
{
Direction=1; //Forward
EncoderI=DistRecord();
int speed=-70; //SET SPEED
SensorValue[Gyro]=0;
while(vexRT[Ch3]>=10)
{if (SensorValue[Gyro]>0){
motor[LM] = speed;
motor[L1] = speed;
motor[L2] = speed;
motor[RM] = speed-10;
motor[R1] = speed-10;
motor[R2] = speed-10;}
else if (SensorValue[Gyro]<0){
motor[LM] = speed-10;
motor[L1] = speed-10;
motor[L2] = speed-10;
motor[RM] = speed;
motor[R1] = speed;
motor[R2] = speed;}
else{
motor[LM] = speed;
motor[L1] = speed;
motor[L2] = speed;
motor[RM] = speed;
motor[R1] = speed;
motor[R2] = speed;}
} //Stop the robot... thank you Norrin
EncoderF=DistRecord();
EncoderValue=Difference(EncoderI, EncoderF);
Break(100,-speed);
writeDebugStreamLine("Dist( %d, %d, %d, 0);", EncoderValue, Direction, 70); //SET SPEED
writeDebugStreamLine("Break(100,%d);", -speed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn8L]==1)
{int turnspeed=70; //SET TURN SPEED
TurnDegree(-90, turnspeed, TimeOut);
TurnBreak(50,turnspeed);
writeDebugStreamLine("TurnDegree(-90, %d, %d);", turnspeed, TimeOut);
writeDebugStreamLine("TurnBreak(50, %d);", turnspeed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn8R]==1)
{int turnspeed=70; //SET TURN SPEED
TurnDegree(90, turnspeed, TimeOut);
TurnBreak(50,-turnspeed);
writeDebugStreamLine("TurnDegree(90, %d, %d);", turnspeed, TimeOut);
writeDebugStreamLine("TurnBreak(50, %d);", -turnspeed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn8U]==1)
{int turnspeed=70; //SET TURN SPEED
TurnDegree(-135, turnspeed, TimeOut);
TurnBreak(50,turnspeed);
writeDebugStreamLine("TurnDegree(-135, %d, %d);", turnspeed, TimeOut);
writeDebugStreamLine("TurnBreak(50, %d);", turnspeed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else if(vexRT[Btn8D]==1)
{int turnspeed=70; //SET TURN SPEED
TurnDegree(35, turnspeed, TimeOut);
TurnBreak(50,-turnspeed);
writeDebugStreamLine("TurnDegree(45, %d, %d);", turnspeed, TimeOut);
writeDebugStreamLine("TurnBreak(50, %d);", -turnspeed);
writeDebugStreamLine("wait1Msec(%d);",Time);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
}
else
{
motor[LM] = 0;
motor[L1] = 0;
motor[L2] = 0;
motor[RM] = 0;
motor[R1] = 0;
motor[R2] = 0;
}
int armspeed=-90;// ARM SPEED HERE
if(vexRT[Btn5U] == 1) //If button 5U is pressed...
{SensorValue[ArmEnc]=0;
ArmI=ArmRecord();
while(vexRT[Btn5U] == 1)
{
motor[leftArmM] = -armspeed;
motor[leftArmY] = -armspeed;
motor[rightArmM] = -armspeed;
motor[rightArmY] = -armspeed;
}
ArmF=ArmRecord();
EncoderValue=Difference(ArmI, ArmF);
writeDebugStreamLine("ArmPosition(%d, 1, %d, %d);",EncoderValue, 90,TimeOut);
writeDebugStreamLine("ArmRun(%d);",ArmValue);
writeDebugStreamLine("wait1Msec(%d);",Time);
}
else if(vexRT[Btn5D] == 1) //Else, if button 5D is pressed...
{SensorValue[ArmEnc]=0;
ArmI=ArmRecord();
while(vexRT[Btn5D] == 1)
{
motor[leftArmM] = armspeed/2;
motor[leftArmY] = armspeed/2;
motor[rightArmM] = armspeed/2;
motor[rightArmY] = armspeed/2;
}
ArmF=ArmRecord();
EncoderValue=Difference(ArmI, ArmF);
writeDebugStreamLine("ArmPosition(%d, 0, %d, 0);",EncoderValue, 45);
//writeDebugStreamLine("ArmRun(%d);",ArmValue);
writeDebugStreamLine("wait1Msec(%d);",Time);
}
else //Else (neither button is pressed)...
{
ArmRun(ArmValue); //...hold the arm.
}
///PUNCHER DEBUG//////////
//if(vexRT[Btn8D]==1){ SensorValue[puncher]=1;}
//else {SensorValue[puncher]=0;}
//////////////////////////////////////
//CLAW
// if(vexRT[Btn6U]==1){SensorValue[clawR]=1; SensorValue[clawL]=1;}
//else{SensorValue[clawR]=0; SensorValue[clawL]=0;}
///////////////
wait1Msec(20);
//writeDebugStream("wait1Msec(1000);
}
|
73d96b7035ec916ce89adc1c685a9cbe299612ea
|
88550128c8f680503e4d81c3c6e3cd833ef53c52
|
/PIC_18f4431/MOTEUR_P5_Metalhome/Backup/2_Fevrier_2018/variable_main.h
|
5bcedf899c83e8bdd9d57452f670ba7e6c46f7ea
|
[] |
no_license
|
sermap-miro/P5
|
9a0a1a06f69146a34699d3560c03553b84b5ac1f
|
32e73a66dfec56fe0185c80b5437ee8d5f9911ed
|
refs/heads/master
| 2020-11-24T20:49:43.497733 | 2019-12-16T08:53:38 | 2019-12-16T08:53:38 | 228,336,002 | 0 | 0 | null | null | null | null |
ISO-8859-1
|
C
| false | false | 10,097 |
h
|
variable_main.h
|
/*
* File: variable_main.h
* Author: sam
*
* Created on 17 janvier 2018, 16:59
*/
#ifndef VARIABLE_MAIN_H
#define VARIABLE_MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include "define.h"
//Variable de fonctionnement
//16 bit
//volatile unsigned char Image_Courant_Moteur_1;
//volatile bit Nouvelle_Valeur_ADC;
//volatile int erreur;
//volatile signed int erreur_accumulator;
//volatile int consigne;
//volatile int consigne_pwm;
//volatile int consigne_pwm_max;
unsigned char Version;
unsigned char Etat;
unsigned char Etat_Log[NB_ACTION_LOG];
unsigned char Alarme;
//unsigned char Action;
unsigned char Etat_Precedent_Index;
//
// Paramètres de déplacement
unsigned char nb_s_fonctionnement; //Sauvegarde le temps entre pions
unsigned char nb_s_patinage; //consigne de seconde qui défini le temps maximal avant de déclarer le mouvement en patinage
unsigned char nb_100ms_Timer_5;
unsigned char nb_100ms_pion; //
unsigned char nb_100ms_platine;
// unsigned char nb_100ms_platine_fin;
unsigned char nb_s_pelle;
unsigned char nb_s_bequille;
//Detection des pions
volatile bit Detecteur_Pion;
unsigned char nb_Pion; // Nombre de pion vu lors du deplacement
unsigned char Capteur_Capot_Nb_Evenement;
unsigned char Capteur_Capot_Nb_Evenement_Autoriser;
unsigned char Capteur_Capot_Compteur_Temps_S;
unsigned char Patinage_Nb_Essai;
unsigned char Patinage_Nb_Essai_Autoriser;
volatile int duty;
volatile int erreur; //volatile char erreur;
//8 bit
volatile unsigned char Image_Courant_Moteur_1;
volatile unsigned char Image_Courant_Moteur_2;
volatile bit Nouvelle_Valeur_ADC;
//volatile unsigned char erreur_accumulator;//8bit
//volatile unsigned int erreur_accumulator;//16bit
volatile int erreur_accumulator; //16 bit
//volatile unsigned int erreur_accumulator;//16 bit
volatile unsigned int PID_out;
volatile unsigned int erreur_accumulator_max; //16 bit
//volatile unsigned short long erreur_accumulator;//32 bit
//
//volatile unsigned short long erreur_accumulator;//24 bit
//volatile unsigned short long erreur_accumulator_max;//24 bit
volatile char moteur_indice;
unsigned char Consigne_en_A;
volatile char consigne;
char consigne_moteur_1;
char consigne_moteur_2;
char consigne_moteur_3;
volatile char direction;
volatile char consigne_pwm;
volatile char consigne_pwm_max;
unsigned char delay_s_counter;
bit TIMER0_Etat;
//
//
////8 bit
//volatile unsigned char Image_Courant_Moteur_1;
//volatile bit Nouvelle_Valeur_ADC;
//volatile char erreur;
////volatile unsigned char erreur_accumulator;//8bit
////volatile unsigned int erreur_accumulator;//16bit
//volatile unsigned int erreur_accumulator;//16 bit
//volatile unsigned int PID_out;
//volatile unsigned int erreur_accumulator_max;//16 bit
////volatile unsigned short long erreur_accumulator;//32 bit
////
////volatile unsigned short long erreur_accumulator;//24 bit
////volatile unsigned short long erreur_accumulator_max;//24 bit
//volatile char consigne;
//volatile char consigne_pwm;
//volatile char consigne_pwm_max;
volatile bit RX1_full;
#define EUSART1_TX_BUFFER_SIZE 96
#define EUSART1_RX_BUFFER_SIZE 96
extern unsigned char UART_TX_TEXT[EUSART1_TX_BUFFER_SIZE];
extern unsigned char UART_RX_TEXT[EUSART1_RX_BUFFER_SIZE];
//extern static unsigned char UART_TX_TEXT[EUSART1_TX_BUFFER_SIZE];
//extern static unsigned char UART_RX_TEXT[EUSART1_RX_BUFFER_SIZE];
//
//
//extern volatile unsigned char eusart1TxIndex; //index du buffer de transmission
//extern static unsigned char eusart1TxBuffer[EUSART1_TX_BUFFER_SIZE]; //Buffer de transmission
//
//extern volatile unsigned char eusart1RxIndex; //index du buffer de réception
//extern static unsigned char eusart1RxBuffer[EUSART1_RX_BUFFER_SIZE]; //Buffer d'émission
//
//
// unsigned char UART_TX_TEXT[EUSART1_TX_BUFFER_SIZE];
// unsigned char UART_RX_TEXT[EUSART1_RX_BUFFER_SIZE];
//
//
//volatile unsigned char eusart1TxIndex; //index du buffer de transmission
// unsigned char eusart1TxBuffer[EUSART1_TX_BUFFER_SIZE]; //Buffer de transmission
//
//volatile unsigned char eusart1RxIndex; //index du buffer de réception
// unsigned char eusart1RxBuffer[EUSART1_RX_BUFFER_SIZE]; //Buffer d'émission
//static unsigned char UART_TX_TEXT[EUSART1_TX_BUFFER_SIZE];
//static unsigned char UART_RX_TEXT[EUSART1_RX_BUFFER_SIZE];
//
//
//volatile unsigned char eusart1TxIndex; //index du buffer de transmission
//static unsigned char eusart1TxBuffer[EUSART1_TX_BUFFER_SIZE]; //Buffer de transmission
//
//volatile unsigned char eusart1RxIndex; //index du buffer de réception
//static unsigned char eusart1RxBuffer[EUSART1_RX_BUFFER_SIZE]; //Buffer d'émission
//volatile unsigned char UART_TX_TEXT[EUSART1_TX_BUFFER_SIZE];
//volatile unsigned char UART_RX_TEXT[EUSART1_RX_BUFFER_SIZE];
//
//
//volatile unsigned char eusart1TxIndex; //index du buffer de transmission
//volatile unsigned char eusart1TxBuffer[EUSART1_TX_BUFFER_SIZE]; //Buffer de transmission
//
//volatile unsigned char eusart1RxIndex; //index du buffer de réception
//volatile unsigned char eusart1RxBuffer[EUSART1_RX_BUFFER_SIZE]; //Buffer d'émission
#pragma warning disable 752
// CONFIG1H
#pragma config OSC = IRCIO // Oscillator Selection bits (Internal oscillator block, port function on RA6 and port function on RA7)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)
#pragma config IESO = ON // Internal External Oscillator Switchover bit (Internal External Switchover mode enabled)
// CONFIG2L
#pragma config PWRTEN = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bits (Brown-out Reset enabled)
#pragma config BORV = 27 // Brown Out Reset Voltage bits (VBOR set to 2.7V)
// CONFIG2H
#pragma config WDTEN = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
#pragma config WDPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
#pragma config WINEN = OFF // Watchdog Timer Window Enable bit (WDT window disabled)
// CONFIG3L
#pragma config PWMPIN = OFF // PWM output pins Reset state control (PWM outputs disabled upon Reset (default))
#pragma config LPOL = HIGH // Low-Side Transistors Polarity (PWM0, 2, 4 and 6 are active-high)
#pragma config HPOL = HIGH // High-Side Transistors Polarity (PWM1, 3, 5 and 7 are active-high)
#pragma config T1OSCMX = OFF // Timer1 Oscillator MUX (Standard (legacy) Timer1 oscillator operation)
// CONFIG3H
#pragma config FLTAMX = RC1 // FLTA MUX bit (FLTA input is multiplexed with RC1)
#pragma config SSPMX = RC7 // SSP I/O MUX bit (SCK/SCL clocks and SDA/SDI data are multiplexed with RC5 and RC4, respectively. SDO output is multiplexed with RC7.)
#pragma config PWM4MX = RB5 // PWM4 MUX bit (PWM4 output is multiplexed with RB5)
#pragma config EXCLKMX = RC3 // TMR0/T5CKI External clock MUX bit (TMR0/T5CKI external clock input is multiplexed with RC3)
#pragma config MCLRE = OFF // MCLR Pin Enable bit (Disabled)
// CONFIG4L
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF // Low-Voltage ICSP Enable bit (Low-voltage ICSP disabled)
// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000200-000FFFh) not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (001000-001FFF) not code-protected)
#pragma config CP2 = OFF // Code Protection bit (Block 2 (002000-002FFFh) not code-protected)
#pragma config CP3 = OFF // Code Protection bit (Block 3 (003000-003FFFh) not code-protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot Block (000000-0001FFh) not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000200-000FFFh) not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (001000-001FFF) not write-protected)
#pragma config WRT2 = OFF // Write Protection bit (Block 2 (002000-002FFFh) not write-protected)
#pragma config WRT3 = OFF // Write Protection bit (Block 3 (003000-003FFFh) not write-protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot Block (000000-0001FFh) not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000200-000FFFh) not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (001000-001FFF) not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (002000-002FFFh) not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (003000-003FFFh) not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot Block (000000-0001FFh) not protected from table reads executed in other blocks)
#ifdef __cplusplus
}
#endif
#endif /* VARIABLE_MAIN_H */
|
aeb204e361aea54a6618395e30365a9ed4218ec7
|
e13db8ab683b0117b547eef64ef5ed3d1b49b334
|
/irc_server/include/macro.h
|
1c296d02381e5441519d3ea7d3826484528dbff0
|
[] |
no_license
|
flavian11/IRCchat
|
1bff6e97810556b5d43ae28840ca1b6e74e5b331
|
969d59083214c8e21f48495b020c62e7417b2793
|
refs/heads/main
| 2023-04-26T15:55:05.375278 | 2018-05-27T19:11:47 | 2018-05-27T19:11:47 | 362,052,268 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 236 |
h
|
macro.h
|
/*
** EPITECH PROJECT, 2018
** irc
** File description:
** macro
*/
#pragma once
#define FD_FREE 0
#define FD_CLIENT 1
#define FD_SERVER 2
#define MAX_FD 255
#define MAX_CHAN 10
#define MAX_USERS 25
#define USAGE "USAGE: %s port"
|
f1156f0409f24479bd06c249a73590d4995e9892
|
6125bc063c483e11c8151430c1220f164f617453
|
/aula17/aula17-7.c
|
cc0150325209089a061682ec21a2a8bd03cbee9c
|
[] |
no_license
|
daniloabreu1/LP1-2019.2N
|
f723e3ab6ef9b339d2f4f08def5586ee63a33d6f
|
8927ab9a9d85058c9bef1f2dbc24b0004e74d8fc
|
refs/heads/master
| 2020-07-05T08:47:44.308484 | 2019-11-27T12:16:32 | 2019-11-27T12:16:32 | 202,594,665 | 0 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 177 |
c
|
aula17-7.c
|
#include <stdio.h>
void i(char *p){
puts(p);
}
void pre(char *p){
fgets(p,21,stdin);
p[2]='X';
}
main(){
char c[21]="bom dia";
i(c);
pre(c);
i(c);
}
|
f112e91fd300ca45108acbf7bebeec7550980acf
|
92093fe73428dd191b1e5d0b4d4f185a71c5f9ad
|
/ServerCommand.h
|
37e17215cca125dd07d0218a0dfad8f5fb48196c
|
[] |
no_license
|
hugo082/superchat
|
e38ee05146fe539323faca27f743897d09c287e3
|
3c75d86738f852166bfee00ef2cfe2b7d76793ba
|
refs/heads/master
| 2020-07-27T21:22:49.278260 | 2017-08-09T13:07:43 | 2017-08-09T13:07:43 | 73,425,017 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 407 |
h
|
ServerCommand.h
|
//
// ServerCommand.h
// superchat
//
// Created by Hugo on 11/11/2016.
// Copyright © 2016 hfqt. All rights reserved.
//
#ifndef ServerCommand_h
#define ServerCommand_h
#include "Server.h"
/*
Remove client with name
**/
void remove_client_with_name(Client *clients, char *name, int *actual);
/*
List all clients.
**/
void ls_client(Client *clients, int *actual);
#endif /* ServerCommand_h */
|
3b07e95d8e2829de2f4567701fc11a18c07ef5a8
|
2b3b3da229e9baaddffd9ca1168e9f74e1ed9808
|
/src/ft_get_index.c
|
ecf604bc03124430b228944e704eac9736f7cb9f
|
[] |
no_license
|
dutenrapha/push_swap
|
1752f42cea67ba12ed02e9ba250faf6001a49fba
|
61248aba697060d771619adaad6e1b5c25e2f68d
|
refs/heads/master
| 2023-06-19T00:02:52.210996 | 2021-07-19T20:14:10 | 2021-07-19T20:14:10 | 372,046,104 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,146 |
c
|
ft_get_index.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_index.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rdutenke <rdutenke@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/20 01:39:55 by rdutenke #+# #+# */
/* Updated: 2021/07/09 00:06:01 by rdutenke ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/push_swap.h"
int ft_get_index(t_stack *s, int value)
{
int position;
int i;
i = 0;
position = -1;
while (s != NULL)
{
if (s->data == value)
{
position = i;
break ;
}
i++;
s = s->next;
}
return (position);
}
|
7d58fed67d8719a6bfbf01530f70e717d5f901c7
|
e25f0244060d0473c18199bdcbbcfbf21f746f76
|
/dk51/DSorokin/SorokinLaba2/FunctionList.c
|
0a811f0c0705c92a91fca68b5d8b728fceaa83d2
|
[] |
no_license
|
oxyyyyy/2016
|
9f45060be062ac78fd9b32e411df76b39ca45665
|
f789aae25e141e079d2bb62f4183c62af24db44b
|
refs/heads/master
| 2020-12-11T03:45:23.717798 | 2016-03-24T06:09:02 | 2016-03-24T06:09:02 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,504 |
c
|
FunctionList.c
|
#include <stdio.h>
#include <stdlib.h>
#include "Function.h"
#include "FunctionList.h"
IntList *CreateList()
{
IntList *theList = (IntList *)malloc(sizeof(IntList));
theList->head = NULL; //<!- not head
theList->tail = NULL; //<!- not tail
theList->count = 0; //<!- initial value of count is zero - no elements in the list
return theList;
}
void FreeList(IntList *aList)
{
if (NULL == aList)
{
return;
}
IntNode *theNode = aList->head;
while (NULL != theNode)
{
IntNode *theNodeToBeFree = theNode;
theNode = theNode->nextNode;
free(theNodeToBeFree);
}
free(aList);
}
IntNode *AddNode(IntList *aList, IntNode *aNewNode)
{
if (NULL == aList || NULL == aNewNode)
{
return NULL;
}
if (NULL == aList->head && NULL == aList->tail)
{
aList->head = aList->tail = aNewNode;
}
else
{
IntNode *theTail = aList->tail;
aList->tail = aNewNode;
if (NULL != theTail)
{
theTail->nextNode = aList->tail;
}
}
aList->count += 1;
return aNewNode;
}
IntNode *NodeAtIndex(const IntList *aList, int anIndex)
{
IntNode *theResult = NULL;
if (NULL != aList && anIndex < aList->count)
{
int i = 0;
IntNode *theNode = aList->head;
do
{
if (i == anIndex) //<!- index was found
{
theResult = theNode; //<! - our node
break;
}
i++; // increase index
theNode = theNode->nextNode; //<! - go to next node
} while (NULL != theNode);
}
return theResult;
}
|
937fbc3a2a46a62b82e96b81b43a453357307509
|
4d9c741a31edae00908e781b3cd9f033037a38a2
|
/codechef/Practice/MARCHA1.c
|
2e7eeeba0917a7a927622eab3c7a350ce5b64606
|
[] |
no_license
|
LavishKothari/MyAllCodes---Lavish
|
eebff25b762748e715122b383630b456f41bd17c
|
73786bb44531b06c63a94048f4c0f9c8982dc36e
|
refs/heads/master
| 2020-04-06T10:01:37.207045 | 2019-04-15T18:50:27 | 2019-04-15T18:50:27 | 20,599,188 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 474 |
c
|
MARCHA1.c
|
#include<stdio.h>
int arr[21],n,m;
void dp()
{
int i,j;
int T[n+1][m+1];
for(j=0;j<=m;j++)
T[0][j]=0;
for(i=0;i<=n;i++)
T[i][0]=1;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
T[i][j]=T[i-1][j];
if(j-arr[i-1] >=0)
T[i][j]=(T[i][j] | T[i-1][j-arr[i-1]]);
}
if(T[n][m])
printf("Yes\n");
else printf("No\n");
}
int main()
{
int t,i;scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
dp();
}
return 0;
}
|
49b17fbf17b2681fe6b3be87e9f1081dbe393285
|
f5cb745a0646632070184fe02b55a6f2be95590c
|
/paragraph.c
|
0931912cea5ec8ddbbdd9c325eba9615680d5994
|
[] |
no_license
|
manimaran63/Manimaran
|
dd53c37c2acb9d8628e2d97f960fe55e320286a9
|
8c5733a3da34442171d9d61a9d4419f647c3f30d
|
refs/heads/master
| 2021-05-11T01:05:26.587052 | 2018-03-20T11:24:13 | 2018-03-20T11:24:13 | 118,320,061 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 254 |
c
|
paragraph.c
|
#include <stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[50];
int i,count=1;
clrscr();
printf("Enter the string");
scanf("%s",&s[i]);
for(i=0;s[i]!='\0';i++)
{
if(s[i] == '.')
count++;
}
printf("%d",count);
getch();
}
|
360cee357efd9bf896554f2b41bb4209f055e2cf
|
3a56b1155d39c8e4dfaff52f0ec2e43b64304c28
|
/frames/04092.c
|
85dc7bba19dbd9dbcd4f5654661bbc761b6890de
|
[] |
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 | 6,958 |
c
|
04092.c
|
//{{BLOCK(_4092)
//======================================================================
//
// _4092, 40x40@8,
// + palette 256 entries, not compressed
// + 25 tiles lz77 compressed
// Total size: 512 + 1572 = 2084
//
// Time-stamp: 2014-11-28, 05:20:06
// Exported by Cearn's GBA Image Transmogrifier, v0.8.12
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
const unsigned int _4092Tiles[393] __attribute__((aligned(4))) __attribute__((visibility("hidden")))=
{
0x00064010,0xBD6C6600,0x060606BD,0x0700D606,0x30B20610,0x0740B20F,0xE9660F00,0x07100620,
0x10D01710,0x00BDBD07,0x0F008016,0xD3B2B2B2,0x001E1E39,0x6CEC031E,0x1E66B2C8,0x75EC5B00,
0x66B26203,0xECB5005B,0xB262DBEC,0x30801E1E,0xB566B207,0x42DB20DD,0x5BD1B200,0xDB75753D,
0x260081B8,0xEC20D63D,0x07101E73,0x44EC7500,0x16D5C0BE,0x5A3800EB,0x0EC4BEA0,0x2300A6BE,
0x38FB093A,0x00A6D533,0xFB193319,0x3F19A6A0,0xA0AFD500,0xEB330909,0xAFEB000E,0x3F2DA8D5,
0xD500A672,0xD8A3D50E,0x0016FB34,0xA338C04C,0xC0C051C5,0xF84C5100,0xA5D8C433,0x4A9C000C,
0x07C02D63,0x63004863,0xA02D989C,0x003A2D53,0x09489CEA,0x6BAAC036,0xEA0CC300,0xA5531F76,
0x488200A4,0x2DFB3345,0xA5086776,0x00764548,0xCBEEA407,0xFB76A900,0xEE67A6FF,0x48A90067,
0x0CC34644,0x4A00829C,0xAA4AD863,0x00641798,0x0C075395,0xBC64B94A,0x879C0500,0xBCB9BC0C,
0x3A2C00BC,0x2C829807,0x050064BC,0xBC480776,0x00B9B90C,0x45B7A946,0x46464A82,0x36A90C00,
0x2CDA3AAD,0x661A046B,0x01BD3939,0x1A66B22E,0x1039B239,0xB2180106,0x23D1FB00,0x07001E1E,
0x10D1D1D1,0x800F3006,0xD11E1010,0xD2D2D2D6,0x5B5B00B5,0xED8C945B,0x0110010D,0x07110101,
0x244F2020,0x004501C0,0x1E6EEC07,0x00DD3DB5,0x0D78DDB6,0xD23DB5B5,0x4FDDD600,0xD2B55B01,
0xB6B600DD,0xD23DC678,0x00805CDD,0x3D5B5C07,0x200A0A4F,0x8C202000,0x8E018C8C,0x2727008E,
0x43344C83,0x38004CC4,0x2D7FCCC4,0x0038AAC4,0xC1E4CC23,0xB37FB3F8,0x7CC48300,0xE0BFC501,
0x4C9400BF,0xD9BB5C0D,0x4400F02E,0xD60ABB94,0x00C9F0BB,0x200AC92A,0x0AFEC6EC,0xFE0A7500,
0x2727200A,0x200A009E,0x5AEA3422,0xA401A9A4,0xAAC0A845,0x07009A5A,0x63C02300,0x6BAA4623,
0xB834004A,0xB787C034,0x2E00B787,0x1A94F3F0,0x00F61AF6,0x94F62A54,0x1A871A96,0x6D0A7500,
0xF0BB016D,0x270A002E,0x5C5CC627,0xAD002A5C,0x53A5AD36,0x007EF1A9,0xA9ADB7F1,0xF1F1172C,
0x0C6A5300,0xDA4A46EA,0x6AB70246,0x0787B707,0x00073800,0x962E1A1A,0xC92EF6C7,0xD996D910,
0xEC540700,0xC9002E73,0x75D9D9BB,0x08752AEC,0x54545CDD,0x0D049F00,0x94940040,0x0401D201,
0xC5107C96,0x0F0001F3,0x407B6E6E,0x8EBBED00,0x40BF248E,0xF0F000C5,0x6ED70A27,0x0D00FA5F,
0x3B0241D9,0x0061617B,0x928A10F4,0xFD89E5FC,0x8A4BF400,0xFD864DA7,0xE96E00FD,0x41411DE9,
0x4100E9E9,0xAE414141,0x0041E9AE,0x6F6F6FA2,0x6FA2D4D4,0x615F6104,0x0800D4D4,0x5900A780,
0xCF808080,0x009928E3,0x9D50509F,0x2F2F80CF,0x37372F00,0x2F8BCDCD,0x88F2002F,0x88373737,
0x9E006DAE,0x9E24E7A2,0x0086AED7,0x1DAE6F27,0x6DA261E7,0x42007A40,0xA26F8A5F,0xE5003BA2,
0xAC5F6F3B,0x002884E3,0x25502870,0x59656580,0xAC80F700,0x13138B25,0x8B30008B,0x3088608B,
0x15002F37,0xE730CD2F,0x006EA26F,0xBFC5E96E,0x6FE91D5F,0xE9830080,0xE7E76F69,0x96004040,
0x7BDF5F73,0x00BFBF7B,0x3B2873BF,0x243B3BDF,0xE36DB800,0xF4116571,0x69260077,0x595984DC,
0x11006565,0x132F2F65,0x009F9F30,0x4FFE505F,0xF0FEF0FE,0xF08CC900,0x40E9BB0A,0x047C087C,
0xF600FEF0,0x00C524BF,0x73F0FEFE,0x408E73BF,0x736D6D00,0x6D6DBFBF,0x1DC5006E,0x6DBF6E40,
0x92004024,0xB3C4CC22,0x002292B3,0xB3C49231,0x92F4E0F3,0x10B3A300,0xDE3B5077,0xB3A3002F,
0x28F7774B,0xCF00CD37,0xEFACE350,0x0021E1E6,0xA19F99CF,0xAB353E49,0x144E5800,0x0B5EABFC,
0xE54D0057,0x1BAB894E,0xCF00CECE,0xEFFA3B50,0x00F51BC2,0x71D786D7,0x5E5EEF3C,0x08080800,
0x37B4B4B4,0x68F500E2,0xB4E29B18,0x5500F2B4,0x3E55551C,0x00218D55,0xE11C1C55,0x9BF59BF5,
0x3535E100,0x3EF59393,0x930B008D,0x218FCE93,0x0B003E3E,0x9B8F0B0B,0x003E9B0B,0x0B57CE93,
0xB1B15557,0x8BE2F200,0x88891588,0x372F0488,0x01158888,0x00E2CD5C,0x4D15A18B,0x1368B028,
0x4E8BE600,0xF9E50F4D,0x13F700F9,0x7A3B2BE5,0x49002960,0x61FC2B8B,0x0097F961,0xA1FCCD84,
0x97975F10,0x32708400,0xDE5F85AC,0xDCDC000F,0x99B030CD,0xDC008BDE,0x99CDCD30,0x0071E550,
0x704D7012,0x80E5AC8A,0x4DE33C00,0x7BACAC8B,0x12110026,0x8AAC2525,0x12008A1D,0xCF6565A7,
0x00851D10,0xA7A71181,0x101D7180,0x12818100,0x10508011,0xEA4700F8,0xAEC5E083,0xAA00CC4B,
0x6D9447AA,0x01477F27,0x070C9567,0x00C4B87B,0xE8530007,0xAA7FFE40,0x9A0056CB,0xD8C9076B,
0x0095CB63,0xEAAA5656,0xB9C3118A,0x45679A00,0xB931FAA5,0x675600B9,0x7B7BBC3A,0xBA004B7B,
0x9E08E222,0x00776D86,0xE2185252,0x387D240A,0x3EA82300,0x4383E721,0xA8BE0338,0x0000218D,
0x059001F0,0x91070180,0x5D5D1C55,0x90005535,0x8D1C741C,0x00741C3E,0x91907474,0x9090E19B,
0x93919003,0xF0B12179,0x0003B031,0x70E36097,0xAE857199,0x84E66000,0x85FA9970,0x8D292169,
0x618A0F10,0x0F008D97,0xA25F5018,0x03B031F0,0x00A310AE,0x50777777,0xA31069FC,0x85268100,
0x69AE0F28,0x26A300A3,0x41B03269,0xA306CC85,0xFC588526,0x03B031F0,0x2B2B00FD,0xA5A37FA1,
0x32004D82,0x83C15832,0x0032A545,0xA1C2C2CA,0x894848FA,0xC218C201,0x98C30285,0xB08031F0,
0x009C6001,
};
const unsigned short _4092Pal[256] __attribute__((aligned(4))) __attribute__((visibility("hidden")))=
{
0x0000,0x214D,0x4256,0x0C88,0x31D1,0x5AF9,0x0444,0x39D1,
0x1952,0x5257,0x14EB,0x21D6,0x4A55,0x298F,0x6AFD,0x2993,
0x39F5,0x52BB,0x4659,0x31F6,0x10ED,0x1D51,0x41F5,0x6F7D,
0x25D5,0x5A58,0x318F,0x1D94,0x325B,0x31B2,0x0886,0x41D3,
0x10CA,0x2E18,0x5EFC,0x5ABA,0x254F,0x3A17,0x4657,0x1D0D,
0x31D4,0x3E5A,0x1D0B,0x2591,0x5AB8,0x5278,0x254D,0x2172,
0x2994,0x4E99,0x29D3,0x733F,0x3DD3,0x25F7,0x3990,0x2594,
0x4A36,0x0465,0x779F,0x2550,0x5B3F,0x0CA8,0x3219,0x6ADC,
0x2D90,0x31D2,0x210D,0x3191,0x294E,0x6B3D,0x4212,0x4E77,
0x631B,0x3A58,0x5297,0x4236,0x35B2,0x2592,0x192F,0x0CA9,
0x3A16,0x3171,0x5ADD,0x4E56,0x18EA,0x2E39,0x5A97,0x25F8,
0x2DD4,0x4EBC,0x66FC,0x0887,0x190B,0x429D,0x21B4,0x35F4,
0x3A39,0x31D3,0x20EC,0x5298,0x6F9E,0x52BC,0x0866,0x5EB9,
0x2DF7,0x39F4,0x358F,0x4A34,0x0846,0x212E,0x2990,0x2DB2,
0x2DB4,0x4258,0x5E9A,0x254E,0x367C,0x14CA,0x6F3E,0x4A58,
0x0CC9,0x1DB7,0x214F,0x2970,0x2DB0,0x294F,0x5275,0x4635,
0x4A9B,0x4E79,0x77BF,0x4656,0x3A37,0x3E15,0x1D2E,0x2D6E,
0x2593,0x2192,0x3E16,0x2DD5,0x1D2C,0x3639,0x214E,0x21B6,
0x2E3A,0x25F9,0x56DB,0x1D95,0x3190,0x5697,0x2D8F,0x3E7A,
0x5EFA,0x35F5,0x5677,0x25D6,0x673C,0x4238,0x18EC,0x35F6,
0x4E36,0x31F4,0x2991,0x4E78,0x5A98,0x737E,0x6F1E,0x4E9A,
0x5EBB,0x6F3D,0x5698,0x2A17,0x3E37,0x671B,0x35D3,0x775F,
0x2DB3,0x365B,0x0865,0x3DF4,0x1D73,0x0C87,0x10EA,0x39B1,
0x252E,0x4E76,0x673F,0x256E,0x739F,0x0845,0x5679,0x296F,
0x39B2,0x35F2,0x29F4,0x5AD9,0x4615,0x31B1,0x190C,0x35D0,
0x1CEC,0x212C,0x2E15,0x62D9,0x4A57,0x29B4,0x1DB5,0x4A79,
0x0C65,0x0C86,0x0CC8,0x0C66,0x31B3,0x5A79,0x14EA,0x18ED,
0x3DF3,0x296E,0x4613,0x1068,0x2DB5,0x10C9,0x1930,0x2971,
0x2D6F,0x2A18,0x25B5,0x3E38,0x3E35,0x2150,0x3217,0x2D91,
0x3DD2,0x2DB1,0x5277,0x62BB,0x10A9,0x256D,0x7B7F,0x429A,
0x212D,0x62F9,0x2193,0x35B1,0x4A78,0x29F7,0x35B0,0x4259,
0x4636,0x3A59,0x4257,0x41F4,0x29B2,0x1D71,0x1D0C,0x5A99,
};
//}}BLOCK(_4092)
|
e039d80d3e65c35956cf0de260aa663e3a77f076
|
d02da3ca64d5be81e251d8a224bb1b1f56e46912
|
/ARChemistre_build/Classes/Native/mscorlib_System_IO_DirectoryInfoMethodDeclarations.h
|
8a0f15cbe47715237e0b5c54f58ea905159fff2c
|
[] |
no_license
|
Dotby/ARChemistre
|
ae0dadc598142bb8545ccf3170ed2e4d8fd4e779
|
d3904072305237fbb926dcf095aca5263ae7b138
|
refs/heads/master
| 2020-12-26T19:38:31.255015 | 2015-07-14T16:27:50 | 2015-07-14T16:27:50 | 38,375,255 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,046 |
h
|
mscorlib_System_IO_DirectoryInfoMethodDeclarations.h
|
#pragma once
#include <stdint.h>
#include <assert.h>
#include <exception>
#include "codegen/il2cpp-codegen.h"
// System.IO.DirectoryInfo
struct DirectoryInfo_t1953;
// System.String
struct String_t;
// System.Runtime.Serialization.SerializationInfo
struct SerializationInfo_t1123;
// System.Runtime.Serialization.StreamingContext
#include "mscorlib_System_Runtime_Serialization_StreamingContext.h"
// System.Void System.IO.DirectoryInfo::.ctor(System.String)
extern "C" void DirectoryInfo__ctor_m11326 (DirectoryInfo_t1953 * __this, String_t* ___path, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.IO.DirectoryInfo::.ctor(System.String,System.Boolean)
extern "C" void DirectoryInfo__ctor_m11327 (DirectoryInfo_t1953 * __this, String_t* ___path, bool ___simpleOriginalPath, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.IO.DirectoryInfo::.ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
extern "C" void DirectoryInfo__ctor_m11328 (DirectoryInfo_t1953 * __this, SerializationInfo_t1123 * ___info, StreamingContext_t1124 ___context, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.IO.DirectoryInfo::Initialize()
extern "C" void DirectoryInfo_Initialize_m11329 (DirectoryInfo_t1953 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean System.IO.DirectoryInfo::get_Exists()
extern "C" bool DirectoryInfo_get_Exists_m11330 (DirectoryInfo_t1953 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.IO.DirectoryInfo System.IO.DirectoryInfo::get_Parent()
extern "C" DirectoryInfo_t1953 * DirectoryInfo_get_Parent_m11331 (DirectoryInfo_t1953 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.IO.DirectoryInfo::Create()
extern "C" void DirectoryInfo_Create_m11332 (DirectoryInfo_t1953 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.IO.DirectoryInfo::ToString()
extern "C" String_t* DirectoryInfo_ToString_m11333 (DirectoryInfo_t1953 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR;
|
784638bcef9746572a997d736f9c363a4a970676
|
5ef731925af65b37f6a2aa308e9c1e1aa3ffd872
|
/main.c
|
d560ef9176fb4fb9e1ec9d49beaf17e662be7ed9
|
[] |
no_license
|
JustineDeSousa/arbres-couvrants
|
2aac228e6188278645ca659ba2d4764437356c1b
|
14ecf3766a66ee242e28d1aacee34906e3fac236
|
refs/heads/main
| 2023-05-05T09:23:18.890813 | 2021-05-21T18:45:30 | 2021-05-21T18:45:30 | 358,538,913 | 0 | 1 | null | 2021-05-19T07:20:09 | 2021-04-16T09:02:23 |
C
|
UTF-8
|
C
| false | false | 11,681 |
c
|
main.c
|
// Compilation:
// icc -std=c99 -mkl -qopenmp main.c citiesReader.c
// icc -std=c99 -mkl -qopenmp -qopt-report=1 -qopt-report-annotate=html main.c citiesReader.c
// Execution:
// ./a.out
#include "citiesReader.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <float.h>
#include <math.h>
#include <mkl.h>
#define R 6378
#define pi 3.14
#define conversion pi/180
inline float poids(ListOfCities* cities, int a, int b){
if(a==b)return 0;
return R*acos( sin(cities->lat[a] * conversion)*sin(cities->lat[b]*conversion) + cos((cities->lon[a] - cities->lon[b])*conversion)*cos(cities->lat[a]*conversion)*cos(cities->lat[b]*conversion) );
}
int main() {
bool version;
printf("Classic or Variant?"); //0 for classic version, 1 for variant version
scanf("%i",&version);
//Version classique
if (version == 0){
int popMin;
printf("Minimal population? ");
scanf("%i", &popMin);
ListOfCities* cities;
float taille_reseau = 0.0;
int nb_villes = 0;
double duration = 0;
cities = citiesReader_classic(popMin);
nb_villes += cities->number;
//-----------------------------------------------------------------
//--- COMPUTING graph
//-----------------------------------------------------------------
//TEMPS DE CALCUL: entrée dans l'algo
unsigned MKL_INT64 t0;
mkl_get_cpu_clocks(&t0);
// allocation des variables
bool* dansS = malloc(cities->number*sizeof(bool));
int* voisin = malloc(cities->number*sizeof(int));
float* dist = malloc(cities->number*sizeof(float));
//Initialisation
dansS[0] = true; //On démarre du sommet 0
dist[0] = 0; //dist(0,0)=0
for(int i = 1; i < cities->number; i++){
dansS[i] = false;
dist[i] = poids(cities,0,i);
voisin[i] = 0;
}
//Itérations
int k = 0;
while(k < cities->number - 2){
//Trouver i tels que (dansS[i]=false) et (dist[i] est minimal)
float minDist = FLT_MAX;
int i = 0;
for(int j = 1; j < cities->number; j++){
if( dansS[j] == false && dist[j] < minDist){
minDist = dist[j];
i = j;
}
}//minDist,min_i OK
dansS[i] = true;
#pragma omp parallel for
for(int j = 0; j < cities->number; j++){
if( dansS[j] == false && dist[j] > poids(cities,i,j)){
dist[j] = poids(cities,i,j);
voisin[j] = i;
}
}
k ++;
}
//TEMPS DE CALCUL: sortie de l'algo
unsigned MKL_INT64 t1;
mkl_get_cpu_clocks(&t1);
// Écriture du graphe (chaque ligne correspond à une arête)
FILE* fileOut = NULL;
fileOut = fopen("resuGraph.dat", "w");
for(int i=0; i<cities->number; i++){
for(int j=0; j<i; j++){
fprintf(fileOut, "%i %i\n", i, voisin[i]);
}
}
fclose(fileOut);
for(int i = 0; i < cities->number; i++){
taille_reseau += poids(cities,i,voisin[i]);
if(i==-1) printf("taille reseau = %f",taille_reseau);
}
//-----------------------------------------------------------------
//--- DEALLOCATE arrays
//-----------------------------------------------------------------
free(dansS);
free(voisin);
free(dist);
free(cities->name);
free(cities->pop);
free(cities->lon);
free(cities->lat);
free(cities);
duration = (double)(t1 - t0)/mkl_get_clocks_frequency()/1e9;
printf("\t%i cities: \n", nb_villes);
printf("Taille du reseau: %1.0f km\n",taille_reseau);
printf("Time is %fs\n ",duration);
return 0;
}
//Version variante
if (version == 1){
int popMin;
printf("Minimal population? ");
scanf("%i", &popMin);
// allocation des variables
ListOfCities* cities;
float taille_reseau = 0;
int nb_villes = 0;
double time = 0;
bool* dansS = malloc(1024*sizeof(bool));
int* voisin = malloc(1024*sizeof(int));
float* dist = malloc(1024*sizeof(float));
for(int dpt = 1; dpt<96; dpt++){
//-----------------------------------------------------------------
//--- READING cities from departement = dpt
//-----------------------------------------------------------------
char outputFile[50];
sprintf(outputFile,"resuCities_%d.dat",dpt);
cities = citiesReader(popMin,dpt,outputFile);
nb_villes += cities->number;
//TEMPS DE CALCUL: entrée dans l'algo
unsigned MKL_INT64 t0;
mkl_get_cpu_clocks(&t0);
//-----------------------------------------------------------------
//--- COMPUTING graph
//-----------------------------------------------------------------
//Initialisation
dansS[0] = true; //On démarre du sommet 0
dist[0] = 0; //dist(0,0) = 0
for(int i = 0; i < cities->number; i++){
dansS[i] = false;
dist[i] = poids(cities,0,i);
voisin[i] = 0;
}
//Itérations
int k = 0;
while(k < cities->number - 2){
//Trouver i tels que (dansS[i]=false) et (dist[i] est minimal)
float minDist = FLT_MAX;
int i = 0;
for(int j = 1; j < cities->number; j++){
if( dansS[j] == false && dist[j] < minDist){
minDist = dist[j];
i = j;
}
}
dansS[i] = true;
#pragma omp parallel for
for(int j = 0; j < cities->number; j++){
if( dansS[j] == false && dist[j] > poids(cities,i,j)){
dist[j] = poids(cities,i,j);
voisin[j] = i;
}
}
k ++;
}
//-----------------------------------------------------------------
//--- GRAPH COMPUTED
//-----------------------------------------------------------------
//TEMPS DE CALCUL: sortie de l'algo
unsigned MKL_INT64 t1;
mkl_get_cpu_clocks(&t1);
time += (double)(t1-t0);
//-----------------------------------------------------------------
//--- WRITING GRAPH for cities from departement = dpt
//-----------------------------------------------------------------
char filename[50];
sprintf(filename,"resuGraph_%d.dat",dpt);
FILE* fileOut = fopen(filename, "w");
for(int i=0; i<cities->number; i++){
fprintf(fileOut, "%i %i\n", i, voisin[i]);
}
fclose(fileOut);
float taille_reseau_dpt = 0;
for(int i = 0; i < cities->number; i++){
taille_reseau_dpt += poids(cities,i,voisin[i]);
if(dpt==0 && i ==0) printf("taille reseau dpt %i ville %i= %f\n",dpt,i,taille_reseau_dpt);
}
taille_reseau += taille_reseau_dpt;
}
//-----------------------------------------------------------------
//--- READING bigger city from each departement
//-----------------------------------------------------------------
cities = bigcitiesReader();
//TEMPS DE CALCUL: entrée dans l'algo
unsigned MKL_INT64 t2;
mkl_get_cpu_clocks(&t2);
//-----------------------------------------------------------------
//--- COMPUTING graph
//-----------------------------------------------------------------
//Initialisation
dansS[0] = true; //On démarre du sommet 0
dist[0] = 0; //dist(0,0) = 0
for(int i = 0; i < cities->number; i++){
dansS[i] = false;
dist[i] = poids(cities,0,i);
voisin[i] = 0;
}
//Itérations
int k = 0;
while(k < cities->number - 2){
//Trouver i tels que (dansS[i]=false) et (dist[i] est minimal)
float minDist = FLT_MAX;
int i = 0;
for(int j = 1; j < cities->number; j++){
if( dansS[j] == false && dist[j] < minDist){
minDist = dist[j];
i = j;
}
}
dansS[i] = true;
#pragma omp parallel for
for(int j = 0; j < cities->number; j++){
if( dansS[j] == false && dist[j] > poids(cities,i,j)){
dist[j] = poids(cities,i,j);
voisin[j] = i;
}
}
k ++;
}
//-----------------------------------------------------------------
//--- GRAPH COMPUTED
//-----------------------------------------------------------------
//TEMPS DE CALCUL: sortie de l'algo
unsigned MKL_INT64 t3;
mkl_get_cpu_clocks(&t3);
//TEMPS DE CALCUL TOTAL
double duration = (double)(t3 - t2 + time)/mkl_get_clocks_frequency()/1e9;
//-----------------------------------------------------------------
//--- WRITING GRAPH for big cities
//-----------------------------------------------------------------
FILE* fileOut = fopen("resuGraph_bigcities.dat", "w");
for(int i = 0; i<cities->number; i++){
fprintf(fileOut, "%i %i\n", i, voisin[i]);
}
fclose(fileOut);
for(int i = 0; i < cities->number; i++){
taille_reseau += poids(cities,i,voisin[i]);
}
//-----------------------------------------------------------------
//--- DEALLOCATE arrays
//-----------------------------------------------------------------
free(dansS);
free(voisin);
free(dist);
free(cities->dpt);
free(cities->name);
free(cities->pop);
free(cities->lon);
free(cities->lat);
free(cities);
//---------------------------------------------------------------
//--- Réunion de tous les fichiers
//---------------------------------------------------------------
FILE* citiesOutputFile = NULL;
citiesOutputFile = fopen("resuCities.dat","w");
FILE* graphOutputFile = NULL;
graphOutputFile = fopen("resuGraph.dat","w");
if(citiesOutputFile != NULL && graphOutputFile != NULL){
int n = 0;
int nbVilles = 0;
for(int dpt = 1; dpt < 96; dpt ++){
char citiesFilename[64];
sprintf(citiesFilename,"resuCities_%d.dat",dpt);
char graphFilename[64];
sprintf(graphFilename,"resuGraph_%d.dat",dpt);
//printf("== Merging cities file with population >= %i and department = %i from %s ==\n", popMin, dpt, citiesFilename);
//printf("== Merging graph file with population >= %i and department = %i from %s ==\n", popMin, dpt, graphFilename);
FILE* citiesInputFile = NULL;
citiesInputFile = fopen(citiesFilename, "r");
FILE* graphInputFile = NULL;
graphInputFile = fopen(graphFilename, "r");
if(citiesInputFile != NULL && graphInputFile != NULL){
char line[512];
const char s[2] = " ";
char *token;
nbVilles = 0;
while(fgets(line, 512, citiesInputFile) != NULL){
token = strtok(line, s);
int myPop = atoi(token);
token = strtok(NULL, s);
float myLon = atof(token);
token = strtok(NULL, s);
float myLat = atof(token);
fprintf(citiesOutputFile, "%i %f %f\n", myPop, myLon, myLat);
nbVilles ++;
}
while(fgets(line, 512, graphInputFile) != NULL){
token = strtok(line, s);
int villeA = atoi(token);
token = strtok(NULL, s);
int villeB = atoi(token);
fprintf(graphOutputFile, "%i %i\n", villeA+n, villeB+n);
}
}
n += nbVilles;
if (remove(citiesFilename) != 0) {
printf("The file %s is not deleted.",citiesFilename);
}
if (remove(graphFilename) != 0) {
printf("The file %s is not deleted.",graphFilename);
}
}
}
//-----------------------------------------------------------------
//--- FICHIERS DPT REUNIS DANS resuGraph.dat et resuCities.dat
//-----------------------------------------------------------------
printf("\t%i cities: \n", nb_villes);
printf("Taille du reseau: %1.0f km\n",taille_reseau);
printf("Time is %fs\n ",duration);
return 0;
}
}
|
3bca1d87b602744b8a32ff09b24e6e782c45d2ee
|
369c38227a5fc3cc774f769c0a7c10f5154044f8
|
/src/camera.c
|
702e5015ca6aa1d602b19ace0086bedeb6882b49
|
[
"MIT"
] |
permissive
|
mearns/raytrace
|
8629476c86b060fc8d2b24d1715472cf524c1a63
|
b46696e6b960b6df2a5f03b733fe46c58ff2c3fc
|
refs/heads/master
| 2021-01-19T09:05:55.655107 | 2014-11-01T01:43:03 | 2014-11-01T01:43:03 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,796 |
c
|
camera.c
|
/**
* File: camera.c
*
*/
#include "camera.h"
#include "axes.h"
Camera_t * Camera_cfg(Camera_t *const pThis, double frame_dist)
{
Axes_cfg(&(pThis->axes));
pThis->frame_dist = frame_dist;
return pThis;
}
Camera_t * Camera_copy(Camera_t *const pThis, const Camera_t *const pRhs)
{
Axes_copy(&(pThis->axes), &(pRhs->axes));
pThis->frame_dist = pRhs->frame_dist;
return pThis;
}
Point_t * Camera_getEye(const Camera_t *const pThis, Point_t *opEye)
{
Point_copy(opEye, &(pThis->axes.origin));
return opEye;
}
Vect_t * Camera_getPov(const Camera_t *const pThis, Vect_t *opPov)
{
Vect_scale(opPov, &(pThis->axes.z), pThis->frame_dist);
return opPov;
}
Vect_t * Camera_getUp(const Camera_t *const pThis, Vect_t *opUp)
{
Vect_copy(opUp, &(pThis->axes.y));
return opUp;
}
Camera_t * Camera_scale(Camera_t *const pThis, const double scale)
{
Axes_scale(&(pThis->axes), scale);
return pThis;
}
Camera_t * Camera_yaw(Camera_t *const pThis, const double rads)
{
Axes_yaw(&(pThis->axes), rads);
return pThis;
}
Camera_t * Camera_pitch(Camera_t *const pThis, const double rads)
{
Axes_pitch(&(pThis->axes), rads);
return pThis;
}
Camera_t * Camera_roll(Camera_t *const pThis, const double rads)
{
Axes_roll(&(pThis->axes), rads);
return pThis;
}
Camera_t * Camera_march(Camera_t *const pThis, const double dist)
{
Axes_march(&(pThis->axes), dist);
return pThis;
}
Camera_t * Camera_strafe(Camera_t *const pThis, const double dist)
{
Axes_strafe(&(pThis->axes), dist);
return pThis;
}
Camera_t * Camera_climb(Camera_t *const pThis, const double dist)
{
Axes_climb(&(pThis->axes), dist);
return pThis;
}
|
6c2e1c025bf754f7a2cfc58380b5c4961521f96f
|
4f0b1c7da91d67e87879e8773ca5de155edcdcdc
|
/src/editor/renderer_util.c
|
907178e5a73d00e624ff8a02fd154ab0661e8492
|
[] |
no_license
|
Klemms/42.doom.nukem
|
542df213c957445694b1dd90944d664e18c5f9d5
|
1fbe4dd13df2d1422b129df4a802cc6d9d3982a0
|
refs/heads/master
| 2020-04-30T01:06:45.248798 | 2019-05-07T23:58:57 | 2019-05-07T23:58:57 | 176,520,199 | 4 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 910 |
c
|
renderer_util.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* renderer_util.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bsiche <bsiche@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/07 16:10:29 by cababou #+# #+# */
/* Updated: 2019/05/07 22:44:25 by bsiche ### ########.fr */
/* */
/* ************************************************************************** */
#include "doom.h"
|
2e949ca43a7e4e0f8316c694a460248940281f4c
|
92352d79f18d8167300ec5edbaf23f4780e2e047
|
/c-lang/Heap/main.c
|
ea96380f0e68d67c1041c6c6ecf9324ae2b3aa1f
|
[
"MIT"
] |
permissive
|
xxxcrel/algorithms
|
a3fff77ac92045fadd756a4a7ab19d13973db5ea
|
75b2b85ca7f6e0774bdbc632905a3f7532dfff07
|
refs/heads/master
| 2021-07-04T18:34:53.747845 | 2020-10-20T05:42:10 | 2020-10-20T05:42:10 | 190,575,563 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,469 |
c
|
main.c
|
#include"heap.h"
#include"heap.c"
#include<stdio.h>
#include<math.h>
void PrintHeap(PriorityQueue H);
int main()
{
int HeapSize;
ElementType HElement, MinElement;
PriorityQueue H;
printf("Please enter the heap size:\n");
scanf("%d", &HeapSize);
printf("Please enter the element and end of -1:\n");
H = Initialize(HeapSize);
scanf("%d", &HElement);
for(int i = 1; HElement != -1; i++)
{
H->Elements[i] = HElement;
H->Size++;
scanf("%d", &HElement);
}
BuildHeap(H);
PrintHeap(H);
MinElement = DeleteMin(H);
printf("DeleteMin = %d\n", MinElement);
MinElement = FindMin(H);
printf("FindMin = %d\n", MinElement);
printf("After DeleteMin:\n");
PrintHeap(H);
DecreaseKey(H, 3, 3);
printf("After DecreaseKey(H, 3, 3):\n");
PrintHeap(H);
IncreaseKey(H, 4, 4);
printf("After IncreaseKey(H, 4, 4):\n");
PrintHeap(H);
Destroy(H);
return 0;
}
void OutSpace(int SpaceOnFront)
{
for(int i = 0; i < pow(2, SpaceOnFront); i++)
printf(" ");
printf("\b");
}
void PrintHeap(PriorityQueue H)
{
int LineStart, LineEnd, Depth = 0;
for(int i = 1; i <= H->Size; i *= 2)
Depth++;
int SpaceOnFront = Depth - 1;
int Interal = Depth;
for(int Level = 0; Level < Depth; Level++)
{
OutSpace(SpaceOnFront);
LineStart = pow(2, Level);
LineEnd = LineStart * 2;
for(int i = LineStart; i < LineEnd; i++)
{
if(i <= H->Size)
{
printf("%d", H->Elements[i]);
OutSpace(Interal);
}
}
printf("\n");
SpaceOnFront--;
Interal--;
}
}
|
aafc76506d9afa20f4de36f4040e413253a7d0fb
|
cdaf20c92dec7d0304e91e5613dad4b5a28ea8d4
|
/source/port/PortWdt.h
|
9e31589f72b0bd7d8e72e8ca88db3d2dc246003a
|
[] |
no_license
|
DvdSpijker/PriorRTOS
|
ea16b0525f3ed542bdfbf139f601b4ed3725f92b
|
0be91376c68ba2db17ed4059afb017340bd6a5e7
|
refs/heads/master
| 2021-01-21T10:45:34.672196 | 2019-04-14T13:17:07 | 2019-04-14T13:25:41 | 101,984,289 | 4 | 0 | null | 2019-04-14T13:25:42 | 2017-08-31T09:31:11 |
C
|
UTF-8
|
C
| false | false | 510 |
h
|
PortWdt.h
|
/*
* PortWdt.h
*
* Created: 4-3-2018 1:00:01
* Author: Dorus
*/
#ifndef PORT_WDT_H_
#define PORT_WDT_H_
#define PORT_WDT_EXPIRE_15_MS 0
#define PORT_WDT_EXPIRE_30_MS 1
#define PORT_WDT_EXPIRE_60_MS 2
#define PORT_WDT_EXPIRE_120MS 3
#define PORT_WDT_EXPIRE_8_S 4
#include <OsTypes.h>
/* Watchdog Timer Port. */
void PortWdtInit(U8_t wdt_mode);
void PortWdtEnable(U32_t timeout_ms);
void PortWdtDisable(void);
void PortWdtKick(void);
extern void OsWdtIsr(void);
#endif /* PORT_WDT_H_ */
|
7460392f4ee8b03c31dec8ce2ff75423b075c67f
|
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
|
/cmake-build-debug/programs_tiling/function13882/function13882_schedule_21/function13882_schedule_21_wrapper.h
|
dc69081f78a38ef9437858d6839789fcf045c503
|
[] |
no_license
|
IsraMekki/tiramisu_code_generator
|
8b3f1d63cff62ba9f5242c019058d5a3119184a3
|
5a259d8e244af452e5301126683fa4320c2047a3
|
refs/heads/master
| 2020-04-29T17:27:57.987172 | 2019-04-23T16:50:32 | 2019-04-23T16:50:32 | 176,297,755 | 1 | 2 | null | null | null | null |
UTF-8
|
C
| false | false | 378 |
h
|
function13882_schedule_21_wrapper.h
|
#ifndef HALIDE__generated_function13882_schedule_21_h
#define HALIDE__generated_function13882_schedule_21_h
#include <tiramisu/utils.h>
#ifdef __cplusplus
extern "C" {
#endif
int function13882_schedule_21(halide_buffer_t *buf00, halide_buffer_t *buf01, halide_buffer_t *buf02, halide_buffer_t *buf03, halide_buffer_t *buf0);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
|
2b4715b61208c298ddab9882338a3430dc29cc74
|
af70f7612ab39bc5eec41d9874ad658b5a297679
|
/tests/c_cases.h
|
d67f025c292a2aca5a124934f33e19e3fcddfe64
|
[] |
no_license
|
stevenlsjr/dangerengine
|
ed283d17e814361f79961ee0680edbb159249b5f
|
31008b53b5fd202939a9d726d6ace963ece96f00
|
refs/heads/master
| 2021-09-14T03:23:29.725731 | 2016-09-12T19:53:23 | 2016-09-12T19:53:23 | 34,703,923 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 378 |
h
|
c_cases.h
|
//
// Created by Steven on 4/27/15.
//
#ifndef DANGERENGINE_C_CASES_H
#define DANGERENGINE_C_CASES_H
#ifdef __cplusplus
extern "C" {
#endif
struct MinunitCaseArray {
char **cases;
size_t n;
};
typedef char const *(*MinunitTestFn)();
char const *c_run_all_tests();
extern int tests_run;
#ifdef __cplusplus
};
#endif
#endif //DANGERENGINE_C_CASES_H
|
9d9fb4b907128d5fa0edcc905869c474f7f0b277
|
a6da7ea2464953cf3df36273c4ff3eef1a0f9f1c
|
/BStreeRec.c
|
4367c9fabc7003a7425d5d55674704168f65636d
|
[] |
no_license
|
raveenavenugopal/C-Programs
|
87a67f63982804baa75ed4f4cd553d2fd964631b
|
939ad5c76dc6ddd8203b7b7cc2d3a2c0e427fe81
|
refs/heads/master
| 2016-09-06T10:15:38.175734 | 2015-06-30T08:18:17 | 2015-06-30T08:18:17 | 38,296,171 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,140 |
c
|
BStreeRec.c
|
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *rchild;
struct node *lchild;
}*start=NULL,*root,*q,*new;
void build_tree(int,struct node *);
void inorder(struct node *);
void preorder(struct node *);
void postorder(struct node *);
main()
{
int choice,n,k,another=1;
do{
printf("\n1:Build A Binary Search Tree\n2:Traversal\n3:Exit\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
while(another!=2){
printf("Enter A Number\t");
scanf("%d",&n);
build_tree(n,start);
printf("Another nodes?\nEnter 1 for YES or 2 for NO :\t");
scanf("%d",&another);
}
printf("Enter a Number:\t");
scanf("%d",&n);
build_tree(n,start);
break;
case 2:
printf("\nINORDER TRAVERSAL IS\n");
inorder(start);
printf("\nPREORDER TRAVERSAL IS\n");
preorder(start);
printf("\nPOSTORDER TRAVERSAL IS\n");
postorder(start);
another=1;
break;
case 3:
printf("\t........PROGRAM IS EXITING..........\n\n");
exit(0);
break;
default:
printf("Wrong Entry\nTRY AGAIN...\n");
}
}while(choice!=3);
}
void build_tree(int k,struct node *p)
{
new=(struct node *)malloc(sizeof(struct node));
new->data=k;
new->lchild=NULL;
new->rchild=NULL;
if(start==NULL){
start=new;
}
else if(k<p->data){
if(p->lchild==NULL){
p->lchild=new;
}else{
build_tree(k,p->lchild);
}
}
else if(k>p->data){
if(p->rchild==NULL){
p->rchild=new;
}else{
build_tree(k,p->rchild);
}
}
else{
printf("Data Exists\n");
}
}
void inorder(struct node *p)
{
if(start==NULL){
printf("Tree Is Empty..\n");
}
else{
if(p!=NULL){
inorder(p->lchild);
printf("%d-->",p->data);
inorder(p->rchild);
}
}
}
void preorder(struct node *p)
{
if(start==NULL){
printf("Tree Is Empty..\n");
}
else{
if(p!=NULL){
printf("%d-->",p->data);
preorder(p->lchild);
preorder(p->rchild);
}
}
}
void postorder(struct node *p)
{
if(start==NULL){
printf("Tree Is Empty..\n");
}
else{
if(p!=NULL){
postorder(p->lchild);
postorder(p->rchild);
printf("%d-->",p->data);
}
}
}
|
eeb0e502d8ba9f8ee33eae53d906d6be08ef1d3f
|
1b00390cad4a487f6e9991d8f868c66f9370bc82
|
/soal1/client/client.c
|
769b4a152f61993bb4f21635ec331dec3dca0481
|
[] |
no_license
|
sisop-C02/soal-shift-sisop-modul-3-C02-2021
|
b7d63ac6dc4d11ba8ae79341a1fade1da67461be
|
b57a7d060c42e68dc9de3a2685902c42c72bf0f1
|
refs/heads/main
| 2023-05-03T21:01:18.071906 | 2021-05-23T13:41:16 | 2021-05-23T13:41:16 | 362,880,567 | 0 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 7,905 |
c
|
client.c
|
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdlib.h>
int connection_start();
bool check_empty();
int greetings();
void procedures(int);
int activities();
void split_activities(int);
// Global variable
int sock;
char credentials[101];
char curr_t[101] = {0};
const char * avail_activity[] = {
"add",
"download",
"delete",
"see",
"find"
};
int main(int argc , char *argv[])
{
// Connection attempt
if( connection_start() )
return 1;
// Availability check
bool isEmpty = check_empty();
while(true) {
// Initialize
int command = greetings();
// [3.] Exit
if (command == 3) {
puts("Terima kasih telah menggunakan aplikasi ini.\nSampai jumpa");
send(sock , "exit" , strlen("exit") , 0);
break;
}
// [1.] dan [2.]
else {
memset(credentials,0,sizeof(credentials));
procedures(command);
}
// Mengirim info user ke server
puts("Mengirim data ke server...");
send(sock , credentials , strlen(credentials) , 0);
// Menerima balasan server
char creds_check[1000] = {0};
recv(sock , creds_check , sizeof(creds_check) , 0);
// Handle balasan server
if (!strcmp(creds_check, "gagal"))
{
if (command == 1) {
puts("\nRegister gagal, username sudah tersedia.\nMengembalikan ke halaman awal...\n");
continue;
} else {
puts("\nLogin gagal, username atau password salah.\nMengembalikan ke halaman awal...\n");
continue;
}
} else {
if (command == 1) {
puts("\nRegister berhasil! Silahkan kembali login.\nMengembalikan ke halaman awal...");
continue;
}
else {
// Setelah login
puts("\nLogin sukses!");
// Username
char curr_uname[50] = {0}; memset(curr_uname,0,sizeof(curr_uname));
recv(sock , curr_uname , sizeof(curr_uname) , 0);
printf("Selamat datang, %s\n", curr_uname);
while(true)
{
// Opsi yang dimiliki pengguna
int chosen_activity = activities();
if (chosen_activity == 6) {
puts("Anda berhasil logout.\n");
send(sock , "logout" , strlen("logout") , 0);
break;
}
else {
printf("\nAnda telah memilih: %s\n", avail_activity[chosen_activity - 1]);
send(sock , avail_activity[chosen_activity - 1] , strlen(avail_activity[chosen_activity - 1]) , 0);
split_activities(chosen_activity - 1);
if (!strcmp("op_sukses", curr_t) || !strcmp("done", curr_t)) {
memset(curr_t,0,sizeof(curr_t));
puts("Perintah sukses dijalankan!\nMengembalikan ke halaman perintah...");
continue;
} else if (!strcmp("op_gagal", curr_t)){
puts("Perintah gagal dijalankan!\nSilahkan coba lagi.");
continue;
}
}
}
continue;
}
}
}
close(sock);
return 0;
}
bool check_empty() {
// Check availability
char empty[1000] = {0}, usrcreds[101] = {0};
recv(sock , empty , sizeof(empty) , 0);
while(strcmp(empty, "free")) {
memset(empty, 0, sizeof(empty));
recv(sock , empty , sizeof(empty) , 0);
}
memset(empty, 0, sizeof(empty));
return true;
}
int connection_start() {
//Create socket
struct sockaddr_in server;
sock = socket(AF_INET , SOCK_STREAM , 0);
if (sock == -1)
printf("Could not create socket");
server.sin_addr.s_addr = inet_addr("127.0.0.1");
server.sin_family = AF_INET;
server.sin_port = htons( 8888 );
//Connect to remote server
if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0) {
perror("Connection failed.");
return 1;
}
puts("[connected]");
puts("Anda terhubung, mohon tunggu sejenak.\n");
return 0;
}
int greetings() {
int userchoice;
printf("Selamat datang! Silahkan pilih salah satu dari opsi-opsi berikut\n");
printf("[1.] Register\n");
printf("[2.] Login\n");
printf("[3.] Keluar\n");
printf("Masukkan angka yang anda pilih: "); scanf("%d", &userchoice);
while (userchoice < 1 || userchoice > 3) {
printf("Angka pilihan tidak tersedia. Silahkan input ulang.\n");
printf("Masukkan angka yang anda pilih: "); scanf("%d", &userchoice);
}
return userchoice;
}
void procedures(int userchoice) {
// Menampilkan layar yang dipilih
if (userchoice == 1)
puts("\nREGISTER");
else
puts("\nLOGIN");
// Variables
char userid[50], password[50];
// Menerima input
printf("username: ");
scanf("%s", userid); strcat(userid,":");
printf("password: ");
scanf("%s", password); strcat(userid, password);
// Menggabungkan input
if (userchoice == 1) {
strcpy(credentials, "r");
strcat(credentials, userid);
} else {
strcpy(credentials, "l");
strcat(credentials, userid);
}
}
int activities() {
// Proses pemilihan opsi
puts("\nSilahkan pilih salah satu dari perintah berikut.");
printf("[1.] Add\n[2.] Download\n");
printf("[3.] Delete\n[4.] See\n");
printf("[5.] Find\n[6.] Logout\n");
int userchoice;
printf("Masukkan angka yang anda pilih: "); scanf("%d", &userchoice);
while (userchoice < 1 || userchoice > 6) {
printf("Angka pilihan tidak tersedia. Silahkan input ulang.\n");
printf("Masukkan angka yang anda pilih: "); scanf("%d", &userchoice);
}
return userchoice;
}
void split_activities(int chosen_activity) {
// Menerima perintah
char comm[10];
strcpy(comm, avail_activity[chosen_activity]);
// Perintah add
if (!strcmp(comm,"add")) {
char temp[50], add_tsv[200];
getchar();
printf("Publisher: "); scanf("%s", temp);
strcpy(add_tsv, temp); strcat(add_tsv, "\t");
getchar();
printf("Tahun publikasi: "); scanf("%s", temp);
strcat(add_tsv, temp); strcat(add_tsv, "\t");
getchar();
printf("Filepath: "); scanf("%s", temp);
strcat(add_tsv, temp);
strcat(add_tsv, "a");
//mengirim isi command
send(sock , add_tsv , strlen(add_tsv) , 0);
puts("\nMengirimkan file ke server...");
//Menerima balasan server
char activ_check[20] = {0}; memset(activ_check,0,sizeof(activ_check));
recv(sock , activ_check , sizeof(activ_check) , 0);
strcpy(curr_t, activ_check);
}
// Perintah download
else if (!strcmp(comm,"download")) {
// char temp_down[10]; scanf("%s", temp_down);
char down_tsv[50];
scanf("%s", down_tsv);
strcat(down_tsv, "d");
//mengirim isi command
send(sock , down_tsv , strlen(down_tsv) , 0);
puts("\nMenerima file dari server...");
//Menerima balasan server
char activ_check[20] = {0}; memset(activ_check,0,sizeof(activ_check));
recv(sock , activ_check , sizeof(activ_check) , 0);
strcpy(curr_t, activ_check);
}
// Perintah delete
else if (!strcmp(comm,"delete")) {
char del_tsv[50];
scanf("%s", del_tsv);
strcat(del_tsv, "e");
//mengirim isi command
send(sock , del_tsv , strlen(del_tsv) , 0);
puts("\nMenunggu proses delete file...");
//Menerima balasan server
char activ_check[20] = {0}; memset(activ_check,0,sizeof(activ_check));
recv(sock , activ_check , sizeof(activ_check) , 0);
strcpy(curr_t, activ_check);
}
// Perintah see
else if (!strcmp(comm,"see")) {
//mengirim isi command
send(sock , "sees" , strlen("sees") , 0);
puts("Menunggu respon...\n");
// Menerima dari server
char see_reply[1000] = {0};
memset(see_reply,0,1000);
recv(sock , see_reply , sizeof(see_reply) , 0);
while(strcmp(see_reply, "done") != 0) {
printf("\n%s", see_reply);
memset(see_reply,0,1000);
recv(sock , see_reply , sizeof(see_reply) , 0);
}
strcpy(curr_t, see_reply);
return;
}
// Perintah find
else if (!strcmp(comm,"find")) {
char find_tsv[50];
scanf("%s", find_tsv);
strcat(find_tsv, "f");
//mengirim isi command
send(sock , find_tsv , strlen(find_tsv) , 0);
// Menerima dari server
char see_reply[1000] = {0}; memset(see_reply,0,1000);
recv(sock , see_reply , sizeof(see_reply) , 0);
while(strcmp(see_reply, "done") != 0) {
printf("\n%s", see_reply);
memset(see_reply,0,1000);
recv(sock , see_reply , sizeof(see_reply) , 0);
}
strcpy(curr_t, see_reply);
return;
}
}
|
eff65e1012d844b274bad3560d940a41c52860b5
|
8500cf3ebb275f73bd17f82dc013361d279cafdb
|
/Simulation on Airport Queuing/control.h
|
c5c3bee1e838cc69032210220d65c24236aefcec
|
[] |
no_license
|
liuzhonghao1998/code
|
d5d7470513330807b8bf490098e736cc96fad46b
|
1d5e1bd03b7440d8576cf7db3b2ee5d810edfc68
|
refs/heads/master
| 2023-08-31T16:19:51.212819 | 2023-08-22T08:55:16 | 2023-08-22T08:55:16 | 202,261,716 | 0 | 0 | null | 2022-11-16T11:55:57 | 2019-08-14T02:48:41 |
JavaScript
|
UTF-8
|
C
| false | false | 42 |
h
|
control.h
|
extern int state_change;
void control();
|
d9cdd00326baa6841c0fc05e08b749afa1799b27
|
6253b43898cdc086fa23403b3e9ad6a93f088743
|
/src/svd/tutorials/cnetwork/network.h
|
76115fb3fd652ed518d94c1f36dc8bb5c199908b
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
firedrakeproject/slepc
|
352635175760e9d637c75d2e2f1d6e64f17230b6
|
e438e49934b4d8ac38d5c001ee2b7d8e98360e4b
|
refs/heads/firedrake
| 2023-08-04T01:54:15.051720 | 2023-04-02T10:53:55 | 2023-04-02T10:53:55 | 104,322,294 | 2 | 4 |
BSD-2-Clause
| 2023-07-20T10:14:07 | 2017-09-21T08:32:24 |
C
|
UTF-8
|
C
| false | false | 1,600 |
h
|
network.h
|
/*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SLEPc - Scalable Library for Eigenvalue Problem Computations
Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
This file is part of SLEPc.
SLEPc is distributed under a 2-clause BSD license (see LICENSE).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
/*
Utilities for loading a complex network file and represent it as a graph
*/
#if !defined(NETWORK_H)
#define NETWORK_H
#include <slepcsys.h>
typedef enum { GRAPH_UNDIRECTED,
GRAPH_DIRECTED,
GRAPH_BIPARTITE } GraphType;
SLEPC_EXTERN const char *GraphTypes[];
typedef enum { GRAPH_WEIGHT_UNWEIGHTED,
GRAPH_WEIGHT_POSITIVE,
GRAPH_WEIGHT_POSWEIGHTED,
GRAPH_WEIGHT_SIGNED,
GRAPH_WEIGHT_MULTISIGNED,
GRAPH_WEIGHT_WEIGHTED,
GRAPH_WEIGHT_MULTIWEIGHTED,
GRAPH_WEIGHT_DYNAMIC,
GRAPH_WEIGHT_MULTIPOSWEIGHTED } GraphWeight;
SLEPC_EXTERN const char *GraphWeights[];
struct _n_Graph {
MPI_Comm comm;
GraphType type;
GraphWeight weight;
PetscInt nvertices;
PetscInt nedges;
Mat adjacency;
};
typedef struct _n_Graph* Graph;
SLEPC_EXTERN PetscErrorCode GraphCreate(MPI_Comm,Graph*);
SLEPC_EXTERN PetscErrorCode GraphDestroy(Graph*);
SLEPC_EXTERN PetscErrorCode GraphPreload(Graph,char*);
SLEPC_EXTERN PetscErrorCode GraphPreallocate(Graph,char*);
SLEPC_EXTERN PetscErrorCode GraphLoadUnweighted(Graph,char*);
#endif
|
8c7ed4dd0f8b9e7498780703822637bc7da4365b
|
c319b8b958e8ebb79497969c737f927156d21d1b
|
/app/src/main/jni/base/macros.h
|
993d4aaea2963e0bee5c6188d95cf1932ffe4554
|
[] |
no_license
|
kaitian521/weixingif
|
3291faaa0303e4d117315a8ebffc28000ab33046
|
799bfe68ec687d0e38b9f8c69b626d1d779eebb9
|
refs/heads/master
| 2021-01-10T09:37:49.684880 | 2015-11-30T02:50:19 | 2015-11-30T02:50:19 | 36,643,878 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 541 |
h
|
macros.h
|
#ifndef BASE_MACROS_H_
#define BASE_MACROS_H_
// A macro to forbid the compiler to generate copy constrcutor
// and assign function which usually are error-prone.
//
// We will always encounter compile-time errors if we use them unknowingly.
#define DISABLE_COPY_AND_ASSIGN(name) \
name(const name&) = delete; \
name& operator=(const name&) = delete
// Get the resource content defined by blade resource_library rule.
#define STATIC_RESOURCE(resource) \
StringPiece(RESOURCE_##resource, sizeof(RESOURCE_##resource) / sizeof(char))
#endif
|
8a7ca8b6dc3410d1eb455dbf599287715dcf65d3
|
5b29f854b4da4234fc97c8b9c54c747864ceb59f
|
/GenericFunc.h
|
e3af1c6e18f99b7de57ac154636678ab63113b77
|
[] |
no_license
|
Nikita-str/SolveQuadratic
|
80a3dac07e2dde5162562fc11579eb37ceb15cc1
|
41aa16157aa2797a9a6f55b62f6c7da11da89980
|
refs/heads/master
| 2022-12-20T12:56:51.728443 | 2020-10-02T18:42:47 | 2020-10-02T18:42:47 | 293,535,473 | 0 | 0 | null | null | null | null |
WINDOWS-1251
|
C
| false | false | 1,715 |
h
|
GenericFunc.h
|
#pragma once
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
extern const double GENERIC_EPS;
/**
* @brief проверяет равны ли два числа типа double друг другу с точностью до GENERIC_EPS
*/
extern bool DoubleEqualDouble(double d1, double d2);
/**
* @brief проверяет равно ли число типа double нулю с точностью до GENERIC_EPS
*/
extern bool DoubleEqualZero(double d);
/**
* @brief возвращает ~случайное число от 0 до 1
*/
extern double d_rand_0to1();
/**
* @brief возвращает ~случайное 32х битное число
*/
extern int32_t i32_rand();
/**
* @brief возвращает ~случайное 64х битное число
*/
extern int64_t i64_rand();
/**
* @brief возвращает случайный bool
*/
extern bool bool_rand();
/**
* @brief возвращает случайный знак числа (1 или -1)
*/
extern int sign_rand();
/**
* @brief возвращает ~случайное 32х битное целое число в указанных пределах
*/
extern int32_t i32_rand_range(int32_t min, int32_t max);
/**
* @brief возвращает ~случайное 64х битное целое число в указанных пределах
*/
extern int64_t i64_rand_range(int64_t min, int64_t max);
/**
* @brief возвращает ~случайное 64х битное число с плавающей запятой в указанных пределах
*/
extern double d_rand_range(int64_t min, int64_t max);
|
ed1bcd9905c479aaadbc4745c89315912269514b
|
6cd59917cc7057b97b7ede46cd1ab80daac5ad73
|
/src/data/setup.c
|
5d96a325662e6faf80c92010e2da151c7d0cfaa2
|
[] |
no_license
|
infinitis/workouts
|
6a5185086eda442e1bf78c86f688bc2438988d7f
|
f6f6b01e6d4604791fa670bdf025474c82dbe492
|
refs/heads/master
| 2023-01-20T00:47:28.223693 | 2020-10-27T04:52:08 | 2020-12-18T22:37:07 | 145,338,550 | 0 | 0 | null | 2023-01-06T13:13:35 | 2018-08-19T21:23:55 |
JavaScript
|
UTF-8
|
C
| false | false | 413 |
c
|
setup.c
|
#include<data.h>
int setup() {
sqlite3 *db_p = NULL;
if(sqlite3_open_v2(global_opts.db_location,&db_p,SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,NULL)!=SQLITE_OK) { goto cleanup; }
if(sqlite3_exec(db_p,CREATE_SCHEMA_SQL,NULL,NULL,NULL)!=SQLITE_OK) { goto cleanup; }
if(sqlite3_close_v2(db_p)!=SQLITE_OK) { goto cleanup; }
return 1;
cleanup:
if(db_p!=NULL) { sqlite3_close_v2(db_p); }
return -1;
}
|
20a151014bb2bdcbd9908bfcad59acb9d1898ae4
|
9dc65d0c66d8a8eeb404a2ee969ce8fda9558bdd
|
/src/SOSSE/log.c
|
5483b75d874a5168551ba165a0fdd6b669c222bb
|
[
"GPL-2.0-only",
"GPL-3.0-only",
"BSD-3-Clause"
] |
permissive
|
h2lab/smartleia-target-funcard
|
45db267b6b1f004094098eeb13f44a29c759cd3d
|
49f103c03b5232010b0d900e7d865fd35c66efed
|
refs/heads/master
| 2023-04-04T04:41:02.147800 | 2021-04-13T16:43:06 | 2021-04-13T16:43:06 | 351,911,913 | 0 | 1 |
BSD-3-Clause
| 2021-04-21T15:17:07 | 2021-03-26T21:05:42 |
C
|
UTF-8
|
C
| false | false | 1,503 |
c
|
log.c
|
/*
Simple Operating System for Smartcard Education
Copyright (C) 2002 Matthias Bruestle <m@mbsks.franken.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*! @file
\brief Logging functions.
$Id: log.c,v 1.6 2002/12/22 15:42:55 m Exp $
*/
#include <config.h>
#include <hal.h>
#include <log.h>
#include <types.h>
#if CONF_WITH_LOGGING==1
iu16 dst=LOG_START+2;
bool log_enable;
void log_init( void )
{
dst=LOG_START+2;
hal_eeprom_write( LOG_START, (iu8 *) &dst, 2 );
log_enable=FALSE;
}
void log_add( iu8 tag, iu8 *data, iu8 len )
{
bool save=log_enable;
if( !log_enable || dst<LOG_START ) return;
log_enable=FALSE;
hal_eeprom_write( dst++, &tag, 1 );
hal_eeprom_write( dst++, &len, 1 );
hal_eeprom_write( dst, data, len );
dst+=len;
hal_eeprom_write( LOG_START, (iu8 *) &dst, 2 );
log_enable=save;
}
#endif /* CONF_WITH_LGGING==1 */
|
1c37e531dba76338519053338171e4a35b29ed20
|
2c14b705476b6a9dad9c5441fa78cf2a29fec1df
|
/src/tests/ship-and-bug/main.c
|
0af181cea2f1d95b5dedf7cf9131b95c00a256ca
|
[
"MIT"
] |
permissive
|
dalacorte/game-boy
|
453dc371ae2194520d6640d50067d138dd67d68f
|
acf826aad787efd1f51021ec5027546ea8580620
|
refs/heads/main
| 2023-06-14T05:05:20.102112 | 2021-07-08T01:25:33 | 2021-07-08T01:25:33 | 374,149,014 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,298 |
c
|
main.c
|
#include <gb/gb.h>
#include <stdio.h>
#include "main-character.c"
#include "test-sprites.c"
struct mainCharacter ship;
struct mainCharacter bug;
UBYTE spriteSize = 8;
void performantDelay(UINT8 numloops)
{
UINT8 i;
for (i = 0; i < numloops; i++)
{
wait_vbl_done();
}
}
UBYTE checkCollisions(struct mainCharacter *one, struct mainCharacter *two)
{
return (one->x >= two->x && one->x <= two->x + two->width) && (one->y >= two->y && one->y <= two->y + two->height) || (two->x >= one->x && two->x <= one->x + one->width) && (two->y >= one->y && two->y <= one->y + one->height);
}
void moveGameCharacter(struct mainCharacter *character, UINT8 x, UINT8 y)
{
move_sprite(character->spriteIds[0], x, y);
move_sprite(character->spriteIds[1], x + spriteSize, y);
move_sprite(character->spriteIds[2], x, y + spriteSize);
move_sprite(character->spriteIds[3], x + spriteSize, y + spriteSize);
}
void setShip()
{
ship.x = 80;
ship.y = 130;
ship.width = 16;
ship.height = 16;
set_sprite_tile(0, 0);
ship.spriteIds[0] = 0;
set_sprite_tile(1, 1);
ship.spriteIds[1] = 1;
set_sprite_tile(2, 2);
ship.spriteIds[2] = 2;
set_sprite_tile(3, 3);
ship.spriteIds[3] = 3;
moveGameCharacter(&ship, ship.x, ship.y);
}
void setBug()
{
bug.x = 30;
bug.y = 0;
bug.width = 16;
bug.height = 16;
set_sprite_tile(4, 4);
bug.spriteIds[0] = 4;
set_sprite_tile(5, 5);
bug.spriteIds[1] = 5;
set_sprite_tile(6, 6);
bug.spriteIds[2] = 6;
set_sprite_tile(7, 7);
bug.spriteIds[3] = 7;
moveGameCharacter(&bug, bug.x, bug.y);
}
void main()
{
set_sprite_data(0, 8, TestSprites);
setShip();
setBug();
SHOW_SPRITES;
DISPLAY_ON;
while (!checkCollisions(&ship, &bug))
{
if (joypad() & J_LEFT)
{
ship.x -= 2;
moveGameCharacter(&ship, ship.x, ship.y);
}
if (joypad() & J_RIGHT)
{
ship.x += 2;
moveGameCharacter(&ship, ship.x, ship.y);
}
bug.y += 5;
if (bug.y >= 144)
{
bug.y = 0;
bug.x = ship.x;
}
moveGameCharacter(&bug, bug.x, bug.y);
performantDelay(5);
}
printf("GAME OVER");
}
|
684e0dc711f9c23bc7c0c91d7ae5c76161352fa6
|
42b210f95c0a4d9e395dd9f62b7c40c73edc0b4c
|
/Single_Channel_ADC.c
|
accf78e47bc2741f47ec856ca1724ae7ffc619c7
|
[] |
no_license
|
Sghoshxperia/Atmega16
|
44025177a29b199c1c66b4b5d19ec0c83eece223
|
6b2ea3f4240a1fe5f6de13e2f1a1a836b8a521cf
|
refs/heads/master
| 2021-05-17T21:14:40.634783 | 2020-03-29T06:31:15 | 2020-03-29T06:31:15 | 250,955,939 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 976 |
c
|
Single_Channel_ADC.c
|
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
unsigned int ADC_read(unsigned char chnl)
{
chnl= chnl & 0b00000111; //select adc channel between 0 to 7
ADMUX|=chnl; //channel A0 selected
ADCSRA|=(1<<ADSC); // start conversion
while(!(ADCSRA & (1<<ADIF))); // wait for ADIF conversion complete return
ADCSRA|=(1<<ADIF);
uint8_t val = ADCL;
uint16_t value=(ADCH<<8)|val ;
return (value); //return calculated ADC value
}
void PWM_init()
{
TCCR0 = (1<<WGM00) | (1<<WGM01) | (1<<COM01) | (1<<CS00);
DDRB|=(1<<PINB3);
}
int main(void)
{
DDRA = 0b00000000;
PWM_init();
ADMUX=(1<<REFS0); // Selecting internal reference voltage
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1); // Enable ADC also set Prescaler as 64
ADMUX&=~(1<<ADLAR);
int i = 0; // define an integer to save adc read value
while (1)
{
i = ADC_read(0);
OCR0 = i/4;
//_delay_ms(15);
}
}
|
10cdfc5a998fa88cddcda946548dafd663e3eb16
|
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
|
/source/freebsd/usr.sbin/ppp/extr_timer.c_StopTimerNoBlock.c
|
0008572b48ae4e56210998e8d65f31bbba19a658
|
[] |
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,425 |
c
|
extr_timer.c_StopTimerNoBlock.c
|
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct pppTimer {scalar_t__ state; scalar_t__ rest; struct pppTimer* enext; struct pppTimer* next; int /*<<< orphan*/ name; } ;
struct itimerval {int dummy; } ;
/* Variables and functions */
struct pppTimer* ExpiredList ;
int /*<<< orphan*/ ITIMER_REAL ;
int /*<<< orphan*/ LogERROR ;
scalar_t__ RESTVAL (struct itimerval) ;
scalar_t__ TIMER_RUNNING ;
scalar_t__ TIMER_STOPPED ;
struct pppTimer* TimerList ;
scalar_t__ getitimer (int /*<<< orphan*/ ,struct itimerval*) ;
int /*<<< orphan*/ log_Printf (int /*<<< orphan*/ ,char*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ timer_InitService (int) ;
int /*<<< orphan*/ timer_TermService () ;
__attribute__((used)) static void
StopTimerNoBlock(struct pppTimer *tp)
{
struct itimerval itimer;
struct pppTimer *t, *pt;
/*
* A RUNNING timer must be removed from TimerList (->next list).
* A STOPPED timer isn't in any list, but may have a bogus [e]next field.
* An EXPIRED timer is in the ->enext list.
*/
if (tp->state == TIMER_STOPPED)
return;
pt = NULL;
for (t = TimerList; t != tp && t != NULL; t = t->next)
pt = t;
if (t) {
if (pt)
pt->next = t->next;
else {
TimerList = t->next;
if (TimerList == NULL) /* Last one ? */
timer_TermService(); /* Terminate Timer Service */
}
if (t->next) {
if (!pt && getitimer(ITIMER_REAL, &itimer) == 0)
t->next->rest += RESTVAL(itimer); /* t (tp) was the first in the list */
else
t->next->rest += t->rest;
if (!pt && t->next->rest > 0) /* t->next is now the first in the list */
timer_InitService(1);
}
} else {
/* Search for any pending expired timers */
pt = NULL;
for (t = ExpiredList; t != tp && t != NULL; t = t->enext)
pt = t;
if (t) {
if (pt)
pt->enext = t->enext;
else
ExpiredList = t->enext;
} else if (tp->state == TIMER_RUNNING)
log_Printf(LogERROR, "Oops, %s timer not found!!\n", tp->name);
}
tp->next = tp->enext = NULL;
tp->state = TIMER_STOPPED;
}
|
99bdaac9638642fb74357af8d1d559df5f140c54
|
6c196a2ef220256fe82c2dc74c2d2cfbfe0cf553
|
/P2.3/ej6.c
|
1e0748c6b9926b82585c5c935d501f8db3e1a23c
|
[] |
no_license
|
CarlosMGS/ASOR
|
a8afdb9128f9d543877f2763bf5607bd80c0b4a1
|
caa586c19a1b71fed8b5ce654f6393a9140e0825
|
refs/heads/master
| 2020-09-25T18:32:42.631463 | 2020-01-07T15:34:51 | 2020-01-07T15:34:51 | 226,064,087 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 845 |
c
|
ej6.c
|
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/resource.h>
int main(int argc, char **argv) {
pid_t pid;
pid_t ppid;
pid_t gid;
pid_t sid;
pid_t cur = fork();
if(cur==0){
pid = getpid();
ppid = getppid();
gid = getpgid(pid);
sid = getsid(pid);
printf("Soy el hijo.El pid es %d, el ppid %d, el gid es %d, el sid es %d \n", pid, ppid, gid, sid);
}else if(cur>0){
sleep(50);
pid = getpid();
ppid = getppid();
gid = getpgid(pid);
sid = getsid(pid);
printf("Soy el padre.El pid es %d, el ppid %d, el gid es %d, el sid es %d \n", pid, ppid, gid, sid);
}else{
printf("Ha habido un error!!");
return -1;
}
return 0;
}
|
cbf1603f566099cbf977cbbc0a757b2f3a7ba6f2
|
c428b5b80d6207fc5a5d7aa729591624d702a188
|
/lib/config.c
|
1224842d6465054c42723bd3945bc01f9ee09a8f
|
[
"BSD-2-Clause"
] |
permissive
|
bensimner/system-litmus-harness
|
eac3ab49753e4c01c6b6288a57b59de963a360e3
|
10c296bf89570553df1d087edad6f33da8050613
|
refs/heads/master
| 2023-04-12T04:34:46.128302 | 2021-02-26T09:45:34 | 2021-02-26T09:45:34 | 366,327,441 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 13,257 |
c
|
config.c
|
#include <stdint.h>
#include "lib.h"
#include "argdef.h"
/* global configuration options + default values */
uint64_t NUMBER_OF_RUNS = 10000UL;
uint64_t RUNS_IN_BATCH = 1;
uint8_t ENABLE_PGTABLE = 1; /* start enabled */
uint8_t ENABLE_PERF_COUNTS = 0;
uint8_t RUN_FOREVER = 0;
uint8_t ENABLE_RESULTS_HIST = 1;
uint8_t ENABLE_RESULTS_OUTREG_PRINT = 1;
uint8_t ENABLE_RESULTS_MISSING_SC_WARNING = 1;
uint8_t VERBOSE = 1; /* start verbose */
uint8_t TRACE = 0;
uint8_t DEBUG = 0;
uint8_t ONLY_SHOW_MATCHES = 0;
char* collected_tests[100] = { NULL };
uint64_t collected_tests_count = 0;
sync_type_t LITMUS_SYNC_TYPE = SYNC_ASID;
aff_type_t LITMUS_AFF_TYPE = AFF_RAND;
shuffle_type_t LITMUS_SHUFFLE_TYPE = SHUF_RAND;
concretize_type_t LITMUS_CONCRETIZATION_TYPE = CONCRETE_RANDOM;
char LITMUS_CONCRETIZATION_CFG[1024] = { '\0' };
litmus_runner_type_t LITMUS_RUNNER_TYPE = RUNNER_EPHEMERAL;
char* sync_type_to_str(sync_type_t ty) {
switch (ty) {
case SYNC_NONE:
return "none";
case SYNC_ALL:
return "all";
case SYNC_ASID:
return "asid";
case SYNC_VA:
return "va";
default:
return "unknown";
}
}
char* aff_type_to_str(aff_type_t ty) {
switch (ty) {
case AFF_NONE:
return "none";
case AFF_RAND:
return "rand";
default:
return "unknown";
}
}
char* shuff_type_to_str(shuffle_type_t ty) {
switch (ty) {
case SHUF_NONE:
return "none";
case SHUF_RAND:
return "rand";
default:
return "unknown";
}
}
char* concretize_type_to_str(concretize_type_t ty) {
switch (ty) {
case CONCRETE_LINEAR:
return "linear";
case CONCRETE_RANDOM:
return "random";
case CONCRETE_FIXED:
return "fixed";
default:
return "unknown";
}
}
char* runner_type_to_str(litmus_runner_type_t ty) {
switch (ty) {
case RUNNER_ARRAY:
return "array";
case RUNNER_SEMI_ARRAY:
return "semi";
case RUNNER_EPHEMERAL:
return "ephemeral";
default:
return "unknown";
}
}
static void help(char* opt) {
if (opt == NULL || *opt == '\0')
display_help_and_quit(&ARGS);
else
display_help_for_and_quit(&ARGS, opt);
}
static void version(char* opt) {
printf("%s\n", version_string());
abort();
}
static void __print_id_cpu(int cpu, void* arg) {
char** outs = arg;
int i = 0;
#define __IDREG(r) sprintf(outs[i++], #r ": %p", read_sysreg(r))
__IDREG(CCSIDR_EL1);
__IDREG(CLIDR_EL1);
__IDREG(CSSELR_EL1);
__IDREG(CTR_EL0);
__IDREG(DCZID_EL0);
//__IDREG(GMID_EL1);
__IDREG(ID_AA64AFR0_EL1);
__IDREG(ID_AA64AFR1_EL1);
__IDREG(ID_AA64DFR0_EL1);
__IDREG(ID_AA64DFR1_EL1);
__IDREG(ID_AA64ISAR0_EL1);
__IDREG(ID_AA64ISAR1_EL1);
__IDREG(ID_AA64MMFR0_EL1);
__IDREG(ID_AA64MMFR1_EL1);
//__IDREG(ID_AA64MMFR2_EL1);
__IDREG(ID_AA64PFR0_EL1);
__IDREG(ID_AA64PFR1_EL1);
__IDREG(ID_AFR0_EL1);
__IDREG(ID_DFR0_EL1);
//__IDREG(ID_DFR1_EL1);
__IDREG(ID_ISAR0_EL1);
__IDREG(ID_ISAR1_EL1);
__IDREG(ID_ISAR2_EL1);
__IDREG(ID_ISAR3_EL1);
__IDREG(ID_ISAR4_EL1);
__IDREG(ID_ISAR5_EL1);
//__IDREG(ID_ISAR6_EL1);
__IDREG(ID_MMFR0_EL1);
__IDREG(ID_MMFR1_EL1);
__IDREG(ID_MMFR2_EL1);
__IDREG(ID_MMFR3_EL1);
__IDREG(ID_MMFR4_EL1);
//__IDREG(ID_MMFR5_EL1);
__IDREG(ID_PFR0_EL1);
__IDREG(ID_PFR1_EL1);
//__IDREG(ID_PFR2_EL1);
__IDREG(MIDR_EL1);
__IDREG(MPIDR_EL1);
__IDREG(REVIDR_EL1);
}
static void device_ident_and_quit(char* opt) {
uint64_t midr = read_sysreg(midr_el1);
uint64_t rev = midr & BITMASK(1 + 3 - 0);
uint64_t partnum = (midr >> 4) & BITMASK(1 + 15 - 4);
uint64_t variant = (midr >> 20) & BITMASK(1 + 23 - 20);
uint64_t impl = (midr >> 24) & BITMASK(1 + 31 - 24);
const char* impl_names[0x100] = {
[0x00] = "Reserved for software use Ampere Computing",
[0xC0] = "Arm Limited",
[0x41] = "Broadcom Corporation Cavium Inc.",
[0x42] = "Digital Equipment Corporation",
[0x43] = "Fujitsu Ltd.",
[0x44] = "Infineon Technologies AG",
[0x46] = "Motorola or Freescale Semiconductor Inc.",
[0x49] = "NVIDIA Corporation",
[0x4D] = "Applied Micro Circuits Corporation",
[0x4E] = "Qualcomm Inc.",
[0x50] = "Marvell International Ltd.",
[0x51] = "Intel Corporation",
};
printf("Implementor: %s\n", impl_names[impl]);
printf("Variant: %p\n", variant);
printf("Revision: %p\n", rev);
printf("PartNum: %p\n", partnum);
char** cpu_outs[4];
for (int i = 0; i < 4; i++) {
cpu_outs[i] = ALLOC_MANY(char*, 100);
for (int j = 0; j < 100; j++) {
cpu_outs[i][j] = ALLOC_MANY(char, 1024);
cpu_outs[i][j][0] = '\0';
}
}
ENABLE_PGTABLE = 0; /* pgtable may not be setup yet, so dont try use it on the other booted CPUs */
ensure_cpus_on();
for (int cpu = 0; cpu < NO_CPUS; cpu++)
run_on_cpu(cpu, __print_id_cpu, &cpu_outs[cpu][0]);
/* each line from each CPU is of the form "ID_REG_NAME: 0x000ABC" */
/* first calculate the maximum length of the ID lines */
int maxlinelen = 0;
for (int i = 0; i < 100; i++) {
for (int cpu = 0; cpu < 4; cpu++) {
maxlinelen = MAX(maxlinelen, strlen(cpu_outs[cpu][i]));
}
}
/* we want to print a header
* so first we work out the length of the indent for the title
* indent
* vvvvvvvvvvvvvvvvvvvv
* ID REGISTERS PER CPU <- title
* CPU0 CPU1 CPU2 CPU3 <- headers
*/
int indent_width = ((maxlinelen+2)*4 - 22) / 2;
for (int i = 0; i < indent_width; i++)
printf(" ");
printf(" ID REGISTERS PER CPU\n");
/* now the headers
* each right-aligned with the columns of the table
* CPU0 CPU1 ... <- headers
* ID0: 0x0 ID0: 0x2 ...
* ID1: 0x1 ID1: 0x3 ...
*/
for (int cpu = 0; cpu < 4; cpu++) {
for (int i = 0; i < 2+maxlinelen-4; i++)
printf(" ");
printf("CPU%d", cpu);
}
printf("\n");
/* and finally print each line, right-aligned in columns
* underneath each header
*/
for (int i = 0; i < 100; i++) {
for (int cpu = 0; cpu < 4; cpu++) {
char* line = cpu_outs[cpu][i];
/* empty string means we ran off the end
* and are at the end, so just abort
* no need to cleanup */
if (strcmp(line, ""))
abort();
int len = strlen(line);
for (int j = 0; j < 2+maxlinelen-len; j++)
printf(" ");
printf("%s", line);
}
printf("\n");
}
abort();
}
static void n(char* x) {
int Xn = atoi(x);
NUMBER_OF_RUNS = Xn;
}
static void b(char* x) {
int Xn = atoi(x);
RUNS_IN_BATCH = Xn;
}
static void s(char* x) {
int Xn = atoi(x);
INITIAL_SEED = Xn;
}
static void show(char* x) {
display_help_show_tests();
}
static void q(char* x) {
if (x != NULL && *x != '\0') {
fail("-q/--quiet did not expect an argument.\n");
}
VERBOSE = 0;
DEBUG = 0;
TRACE = 0;
}
static void conc_cfg(char* x) {
valloc_memcpy(LITMUS_CONCRETIZATION_CFG, x, strlen(x));
}
/* this init_cfg_state function gets called
* after reading the args to do any housekeeping and cleanup
*
* e.g. checking mutual exclusive options and the like
* that the argparser itself does not do
*/
void init_cfg_state(void) {
/* ensure we use the correct runner for the given concretization algorithm */
switch (LITMUS_CONCRETIZATION_TYPE) {
case CONCRETE_RANDOM:
LITMUS_RUNNER_TYPE = RUNNER_EPHEMERAL;
break;
case CONCRETE_LINEAR:
LITMUS_RUNNER_TYPE = RUNNER_SEMI_ARRAY;
break;
case CONCRETE_FIXED:
LITMUS_RUNNER_TYPE = RUNNER_EPHEMERAL;
break;
}
}
argdef_t ARGS = (argdef_t){
.args=(const argdef_arg_t*[]){
OPT(
"-h",
"--help",
help,
"display this help text and quit\n"
"\n"
"displays help text.\n"
"--help=foo will display detailed help for foo.",
.show_help_both=1
),
OPT(
"-V",
"--version",
version,
"display version information and quit\n"
"\n"
"displays full version info\n"
),
OPT(
NULL,
"--id",
device_ident_and_quit,
"display device identification information and quit\n"
"\n"
"shows the information for the current device, and all ID registers."
),
OPT(
NULL,
"--show",
show,
"show list of tests and quit\n"
"\n"
"displays the complete list of the compiled tests and their groups, then quits.",
.only_action=1
),
FLAG(
NULL,
"--run-forever",
RUN_FOREVER,
"repeat test runs indefinitely\n"
),
OPT(
"-n",
NULL,
n,
"number of runs per test\n"
"\n"
"sets the number of runs per test\n"
"X must be an integer (default: 10k).\n"
"Examples: \n"
" ./litmus.exe -n300\n"
" ./litmus.exe -n10k\n"
" ./litmus.exe -n1M\n"
"\n"
"Note that currently 1M is likely to fail due to over-allocation of results.\n"
),
OPT(
"-b",
"--batch-size",
b,
"number of runs per batch\n"
"\n"
"sets the number of runs per batch\n"
"X must be an integer (default: 1).\n"
"up to maximum number of ASIDs (e.g. 2^8).\n"
"If not using --tlbsync=ASID then this must be 1\n"
),
FLAG(
"-p",
"--pgtable",
ENABLE_PGTABLE,
"enable/disable pagetable tests\n"
),
FLAG(
NULL,
"--perf",
ENABLE_PERF_COUNTS,
"enable/disable performance tests\n"
),
FLAG(
"-t",
"--trace",
TRACE,
"enable/disable tracing\n"
),
FLAG(
"-d",
"--debug",
DEBUG,
"enable/disable debugging\n"
),
FLAG(
NULL,
"--verbose",
VERBOSE,
"enable/disable verbose output\n"
),
OPT(
"-q",
"--quiet",
q,
"quiet mode\n"
"\n"
"disables verbose/trace and debug output.\n",
.only_action=1
),
FLAG(
NULL,
"--hist",
ENABLE_RESULTS_HIST,
"enable/disable results histogram collection\n"
),
FLAG(
NULL,
"--print-outcome-breakdown",
ENABLE_RESULTS_OUTREG_PRINT,
"prints the breakdown of observed outcomes (default: on)\n"
),
FLAG(
NULL,
"--print-missing-warning",
ENABLE_RESULTS_MISSING_SC_WARNING,
"prints a warning if an expected outcome is not observed (default: on)\n"
),
OPT(
"-s",
"--seed",
s,
"initial seed\n"
"\n"
"at the beginning of each test, a random seed is selected.\n"
"this seed can be forced with --seed=12345 which ensures some level of determinism."
),
ENUMERATE(
"--tlbsync",
LITMUS_SYNC_TYPE,
sync_type_t,
4,
ARR((const char*[]){"none", "asid", "va", "all"}),
ARR((sync_type_t[]){SYNC_NONE, SYNC_ASID, SYNC_VA, SYNC_ALL}),
"type of tlb synchronization\n"
"\n"
"none: no synchronization of the TLB (incompatible with --pgtable).\n"
"all: always flush the entire TLB in-between tests.\n"
"va: (EXPERIMENTAL) only flush test data VAs\n"
"asid: assign each test run an ASID and run in batches \n"
),
ENUMERATE(
"--aff",
LITMUS_AFF_TYPE,
aff_type_t,
2,
ARR((const char*[]){"none", "rand"}),
ARR((aff_type_t[]){AFF_NONE, AFF_RAND}),
"type of affinity control\n"
"\n"
"none: Thread 0 is pinned to CPU0, Thread 1 to CPU1 etc.\n"
"rand: Thread 0 is pinned to vCPU0, etc. vCPUs may migrate between CPUs"
" in-between tests.\n"
),
ENUMERATE(
"--shuffle",
LITMUS_SHUFFLE_TYPE,
shuffle_type_t,
2,
ARR((const char*[]){"none", "rand"}),
ARR((shuffle_type_t[]){SHUF_NONE, SHUF_RAND}),
"type of shuffle control\n"
"\n"
"controls the order of access to allocated pages\n"
"shuffling the indexes more should lead to more interesting caching results.\n"
"\n"
"none: access pages in-order\n"
"rand: access pages in random order\n"
),
ENUMERATE(
"--concretize",
LITMUS_CONCRETIZATION_TYPE,
concretize_type_t,
3,
ARR((const char*[]){"linear", "random", "fixed"}),
ARR((concretize_type_t[]){CONCRETE_LINEAR, CONCRETE_RANDOM, CONCRETE_FIXED}),
"test concretization algorithml\n"
"\n"
"controls the memory layout of generated concrete tests\n"
"\n"
"linear: allocate each var as a fixed shape and walk linearly over memory\n"
"random: allocate randomly\n"
"fixed: always use the same address, random or can be manually picked via --config-concretize\n"
),
OPT(
NULL,
"--config-concretize",
conc_cfg,
"concretization-specific configuration\n"
"\n"
"the format differs depending on the value of --concretize:\n"
"for random, linear: do nothing.\n"
"for fixed:\n"
"format: [<var>=<value]*\n"
"example: \n"
" --config-concretize=\"x=0x1234,y=0x5678,c=0x9abc\"\n"
" places x at 0x1234, y at 0x5678 and z at 0x9abc.\n"
),
NULL
}
};
void read_args(int argc, char** argv) {
argparse_read_args(&ARGS, argc, argv);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.